Using MAJIQ HET (ENCODE RBP knockdowns)

We have created a small example dataset from a few select genes/samples from ENCODE in order to demonstrate how to use MAJIQ. First, download the example dataset files:

[1]:
# create temporary working directory for this notebook
from tempfile import TemporaryDirectory
tempdir = TemporaryDirectory()
%cd $tempdir.name
# download archive with example data
!curl -LO http://majiq.biociphers.org/data/majiq_het_vignette.zip
# unzip and show what files are in the archive
!unzip -qn majiq_het_vignette.zip
/tmp/tmpqxkg15zs
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   326    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 52.6M  100 52.6M    0     0  46.5M      0  0:00:01  0:00:01 --:--:-- 59.7M
[2]:
ls
bam/            gff3/    majiq_het_vignette.zip  settings.ini
build-info.tsv  images/  output/                 vignette.ipynb

What are our inputs?

We selected RNA-seq experiments corresponding to SRSF4 knockdown (by CRISPR) vs no-target controls in K562 and HepG2 cells from ENCODE:

cell_line

knockdown

encode_accession

prefix

HepG2

SRSF4

ENCSR471INA

ENCSR471INA.rep1

HepG2

SRSF4

ENCSR471INA

ENCSR471INA.rep2

HepG2

SRSF4

ENCSR929JKA

ENCSR929JKA.rep1

HepG2

SRSF4

ENCSR929JKA

ENCSR929JKA.rep2

HepG2

notarget

ENCSR105NML

ENCSR105NML.rep1

HepG2

notarget

ENCSR194SPW

ENCSR194SPW.rep2

HepG2

notarget

ENCSR805TIZ

ENCSR805TIZ.rep1

HepG2

notarget

ENCSR805TIZ

ENCSR805TIZ.rep2

HepG2

notarget

ENCSR853AOV

ENCSR853AOV.rep1

HepG2

notarget

ENCSR853AOV

ENCSR853AOV.rep2

K562

SRSF4

ENCSR905NIK

ENCSR905NIK.rep1

K562

SRSF4

ENCSR905NIK

ENCSR905NIK.rep2

K562

SRSF4

ENCSR939BTN

ENCSR939BTN.rep1

K562

SRSF4

ENCSR939BTN

ENCSR939BTN.rep2

K562

notarget

ENCSR005JBU

ENCSR005JBU.rep2

K562

notarget

ENCSR015KGT

ENCSR015KGT.rep1

K562

notarget

ENCSR163JUC

ENCSR163JUC.rep2

K562

notarget

ENCSR772DUM

ENCSR772DUM.rep1

K562

notarget

ENCSR772DUM

ENCSR772DUM.rep2

We downloaded fastqs for these samples, aligned them to GRCh38, and took the subset of aligned reads corresponding to the following genes/genomic regions:

seqid

start

end

gene_name

gene_id

0

1

29147743

29181987

SRSF4

gene:ENSG00000116350

1

1

32179686

32198285

TXLNA

gene:ENSG00000084652

2

17

43170481

43211689

NBR1

gene:ENSG00000188554

3

19

5158495

5340803

PTPRS

gene:ENSG00000105426

4

21

42879644

42913304

NDUFV3

gene:ENSG00000160194

5

3

152243828

152465780

MBNL1

gene:ENSG00000152601

6

7

43608456

43729717

COA1

gene:ENSG00000106603

7

8

101177878

101206193

ZNF706

gene:ENSG00000120963

The resulting BAMs are located in the folder bam/:

[3]:
ls bam/*.bam
bam/ENCSR005JBU.rep2.subset.bam  bam/ENCSR805TIZ.rep2.subset.bam
bam/ENCSR015KGT.rep1.subset.bam  bam/ENCSR853AOV.rep1.subset.bam
bam/ENCSR105NML.rep1.subset.bam  bam/ENCSR853AOV.rep2.subset.bam
bam/ENCSR163JUC.rep2.subset.bam  bam/ENCSR905NIK.rep1.subset.bam
bam/ENCSR194SPW.rep2.subset.bam  bam/ENCSR905NIK.rep2.subset.bam
bam/ENCSR471INA.rep1.subset.bam  bam/ENCSR929JKA.rep1.subset.bam
bam/ENCSR471INA.rep2.subset.bam  bam/ENCSR929JKA.rep2.subset.bam
bam/ENCSR772DUM.rep1.subset.bam  bam/ENCSR939BTN.rep1.subset.bam
bam/ENCSR772DUM.rep2.subset.bam  bam/ENCSR939BTN.rep2.subset.bam
bam/ENCSR805TIZ.rep1.subset.bam

Running the MAJIQ Builder

To analyze RNA splicing in these experiments we need to run the MAJIQ builder to:

  • define splicegraphs of annotated junctions and retained introns between gene exons,

  • obtain coverage over the splicegraph’s LSVs for each experiment.

The resulting coverage files can be used for quantification, and the splicegraph database can be used for downstream analysis and visualization.

In order for an LSV to have coverage generated for it in these output files, MAJIQ requires at least one of its junctions or retained introns to have sufficient evidence for it in its input experiments.

An individual experiment provides supporting evidence for a junction when it passes junction filters: --minpos and either --minreads (annotated junctions) or --min-denovo (de novo junctions). For retained introns, when it passes intron filters: --irnbins and --min-intronic-cov. See majiq build --help for details on these parameters.

Support for a junction or retained intron from an individual experiment by itself is not necessarily enough. MAJIQ partitions the set of input experiments into independent build groups. A junction or retained intron is passed (considered to have enough evidence) when at least --min-experiments experiments from the same build group pass per-experiment filters in at least one build group.

The MAJIQ builder uses a configuration file to specify where the input experiments are located and how they are partitioned into build groups. Global information about experiments are specified in an [info] section:

[info]
# species/reference name for UCSC links by VOILA
genome=GRCh38
# relative or absolute path to directories (comma-separated) with bam files
bamdirs=bam/
# these ENCODE experiments are all reverse stranded
strandness=reverse

The build groups and experiments which belong to them are specified in an [experiments] section. Build groups are keys with values listing experiment names (prefixes to BAM files excluding the .bam extension) separated by commas. If we wanted to focus only on junctions and retained introns found in all experiments for a single cell-type/knockdown, we could organize this section like (setting --min-experiments to reflect how many experiments are necessary to pass):

[experiments]
HepG2_NT=ENCSR805TIZ.rep1.subset,ENCSR805TIZ.rep2.subset,ENCSR853AOV.rep1.subset,ENCSR853AOV.rep2.subset,ENCSR105NML.rep1.subset,ENCSR194SPW.rep2.subset
HepG2_SRSF4=ENCSR929JKA.rep1.subset,ENCSR929JKA.rep2.subset,ENCSR471INA.rep1.subset,ENCSR471INA.rep2.subset
K562_NT=ENCSR005JBU.rep2.subset,ENCSR772DUM.rep1.subset,ENCSR772DUM.rep2.subset,ENCSR015KGT.rep1.subset,ENCSR163JUC.rep2.subset
K562_SRSF4=ENCSR939BTN.rep1.subset,ENCSR939BTN.rep2.subset,ENCSR905NIK.rep1.subset,ENCSR905NIK.rep2.subset

If any experiment is sufficient, we can instead have a build group for each experiment:

[experiments]
ENCSR805TIZ.rep1.subset=ENCSR805TIZ.rep1.subset
ENCSR805TIZ.rep2.subset=ENCSR805TIZ.rep2.subset
# {... all of the other experiments ...}
ENCSR905NIK.rep1.subset=ENCSR905NIK.rep1.subset
ENCSR905NIK.rep2.subset=ENCSR905NIK.rep2.subset

Equivalently, we could set --min-experiments to 1.

Another reasonable possibility would be to group by accessions, which would result in the configuration in settings.ini.

For this analysis, we are interested in considering heterogeneity between individual experiments, so we’ll use settings.ini, but with--min-experiments set to 1. We specify these flags to the builder using -c settings.ini --min-experiments 1.

In addition to these input experiments/configuration file, MAJIQ requires a GFF3 describing annotated transcripts. The subset of Ensembl GRCh38 v94 annotations corresponding to our selected genes can be found at gff3/ensembl.Homo_sapiens.GRCh38.94.subset.gff3.gz. This is passed to the builder directly as a positional argument.

Finally, we must specify the builder’s output directory using a required flag. To save its output to output/build, this would be -o output/build.

Put together, we run the builder as follows:

[4]:
%%bash
majiq build \
    -o output/build \
    -c settings.ini \
    gff3/ensembl.Homo_sapiens.GRCh38.94.subset.gff3.gz \
    --min-experiments 1 \
    2> /dev/null

This produces output files:

  • splicegraph.sql (splicegraph database for use with VOILA)

  • majiq.log (logging output from majiq build)

  • {experiment}.sj (intermediate files that can be used instead of bams for future runs of majiq build)

  • {experiment}.majiq (inputs for majiq quantifiers)

[5]:
ls output/build
ENCSR005JBU.rep2.subset.majiq  ENCSR805TIZ.rep2.subset.majiq
ENCSR005JBU.rep2.subset.sj     ENCSR805TIZ.rep2.subset.sj
ENCSR015KGT.rep1.subset.majiq  ENCSR853AOV.rep1.subset.majiq
ENCSR015KGT.rep1.subset.sj     ENCSR853AOV.rep1.subset.sj
ENCSR105NML.rep1.subset.majiq  ENCSR853AOV.rep2.subset.majiq
ENCSR105NML.rep1.subset.sj     ENCSR853AOV.rep2.subset.sj
ENCSR163JUC.rep2.subset.majiq  ENCSR905NIK.rep1.subset.majiq
ENCSR163JUC.rep2.subset.sj     ENCSR905NIK.rep1.subset.sj
ENCSR194SPW.rep2.subset.majiq  ENCSR905NIK.rep2.subset.majiq
ENCSR194SPW.rep2.subset.sj     ENCSR905NIK.rep2.subset.sj
ENCSR471INA.rep1.subset.majiq  ENCSR929JKA.rep1.subset.majiq
ENCSR471INA.rep1.subset.sj     ENCSR929JKA.rep1.subset.sj
ENCSR471INA.rep2.subset.majiq  ENCSR929JKA.rep2.subset.majiq
ENCSR471INA.rep2.subset.sj     ENCSR929JKA.rep2.subset.sj
ENCSR772DUM.rep1.subset.majiq  ENCSR939BTN.rep1.subset.majiq
ENCSR772DUM.rep1.subset.sj     ENCSR939BTN.rep1.subset.sj
ENCSR772DUM.rep2.subset.majiq  ENCSR939BTN.rep2.subset.majiq
ENCSR772DUM.rep2.subset.sj     ENCSR939BTN.rep2.subset.sj
ENCSR805TIZ.rep1.subset.majiq  majiq.log
ENCSR805TIZ.rep1.subset.sj     splicegraph.sql

Running the MAJIQ quantifiers

We quantify and test for differences in PSI between independent samples from the different cell lines/knockdowns using majiq heterogen.

[6]:
%%bash
majiq heterogen -o output/heterogen/ -n K562_SRSF4KD HepG2_SRSF4KD \
    -grp1 output/build/ENCSR{939BTN,905NIK}*.majiq \
    -grp2 output/build/ENCSR{929JKA,471INA}*.majiq \
    2> /dev/null
[7]:
%%bash
majiq heterogen -o output/heterogen/ -n K562_SRSF4KD K562_NT \
    -grp1 output/build/ENCSR{939BTN,905NIK}*.majiq \
    -grp2 output/build/ENCSR{005JBU,772DUM,015KGT,163JUC}*.majiq \
    2> /dev/null
[8]:
%%bash
majiq heterogen -o output/heterogen/ -n K562_SRSF4KD HepG2_NT \
    -grp1 output/build/ENCSR{939BTN,905NIK}*.majiq \
    -grp2 output/build/ENCSR{805TIZ,853AOV,105NML,194SPW}*.majiq \
    2> /dev/null
[9]:
%%bash
majiq heterogen -o output/heterogen/ -n HepG2_SRSF4KD K562_NT \
    -grp1 output/build/ENCSR{929JKA,471INA}*.majiq \
    -grp2 output/build/ENCSR{005JBU,772DUM,015KGT,163JUC}*.majiq \
    2> /dev/null
[10]:
%%bash
majiq heterogen -o output/heterogen/ -n HepG2_SRSF4KD HepG2_NT \
    -grp1 output/build/ENCSR{929JKA,471INA}*.majiq \
    -grp2 output/build/ENCSR{805TIZ,853AOV,105NML,194SPW}*.majiq \
    2> /dev/null
[11]:
%%bash
majiq heterogen -o output/heterogen/ -n K562_NT HepG2_NT \
    -grp1 output/build/ENCSR{005JBU,772DUM,015KGT,163JUC}*.majiq \
    -grp2 output/build/ENCSR{805TIZ,853AOV,105NML,194SPW}*.majiq \
    2> /dev/null

These commands produce output to the directory specified (-o output/heterogen):

[12]:
ls output/heterogen
HepG2_SRSF4KD-HepG2_NT.het.voila  K562_SRSF4KD-HepG2_SRSF4KD.het.voila
HepG2_SRSF4KD-K562_NT.het.voila   K562_SRSF4KD-K562_NT.het.voila
K562_NT-HepG2_NT.het.voila        het_majiq.log
K562_SRSF4KD-HepG2_NT.het.voila

These commands do the heavy lifting of inference, sampling, and testing. However, we need to use VOILA with the splicegraph database to generate human-readable outputs, as described in the next section.

Running VOILA

VOILA has three modes for looking at the output of our quantifiers:

  • voila tsv: generate TSVs with quantified LSVs and associated statistics

  • voila modulize: generate TSVs which differentiate each specific type of splicing variation

  • voila view: run web service for interactively visualizing quantifications, statistics and their relationship to genes’ splicegraphs.

Generating TSV output

We can generate a TSV combining the LSVs quantified in all 6 pairs of comparisons. We:

  • specify the splicegraph output/build/splicegraph.sql and voila files output/heterogen/*.het.voila as positional arguments,

  • specify the path for our output TSV by the argument -f output/voila_tsv/all-pairs-het.tsv,

  • have VOILA save all quantified LSVs, not only with those called as changing using --show-all (alternatively, run voila view --help to set thresholds for changing events).

This leads to the following command:

[13]:
ls output/heterogen/tmp5sw2q083/
ls: cannot access 'output/heterogen/tmp5sw2q083/': No such file or directory
[14]:
%%bash
voila tsv \
    output/build/splicegraph.sql output/heterogen/*.het.voila \
    --show-all \
    -f output/voila_tsv/all-pairs-het.tsv
2022-02-10 22:23:50,567 (PID:999) - INFO - Command: /usr/local/bin/voila tsv output/build/splicegraph.sql output/heterogen/HepG2_SRSF4KD-HepG2_NT.het.voila output/heterogen/HepG2_SRSF4KD-K562_NT.het.voila output/heterogen/K562_NT-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_SRSF4KD.het.voila output/heterogen/K562_SRSF4KD-K562_NT.het.voila --show-all -f output/voila_tsv/all-pairs-het.tsv
2022-02-10 22:23:50,568 (PID:999) - INFO - Voila v2.4.dev76+g37780c8
2022-02-10 22:23:50,568 (PID:999) - INFO - config file: /tmp/tmpeu2573pp
2022-02-10 22:23:50,575 (PID:999) - INFO - heterogen TSV
2022-02-10 22:23:50,581 (PID:999) - INFO - Showing all results and ignoring all filters.
2022-02-10 22:23:50,611 (PID:999) - INFO - Creating Tab-delimited output file
2022-02-10 22:23:57,792 (PID:999) - INFO - Delimited output file successfully created in: output/voila_tsv/all-pairs-het.tsv
2022-02-10 22:23:57,806 (PID:999) - INFO - Duration: 0:00:07.225270

Let’s look at what these outputs look like:

[15]:
# print commented-out header
with open("output/voila_tsv/all-pairs-het.tsv", "r") as handle:
    for line in handle:
        if not line.startswith("#"):
            break
        print(line, end="")
# {
#     "command": "/usr/local/bin/voila tsv output/build/splicegraph.sql output/heterogen/HepG2_SRSF4KD-HepG2_NT.het.voila output/heterogen/HepG2_SRSF4KD-K562_NT.het.voila output/heterogen/K562_NT-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_SRSF4KD.het.voila output/heterogen/K562_SRSF4KD-K562_NT.het.voila --show-all -f output/voila_tsv/all-pairs-het.tsv",
#     "group_sizes": {
#         "HepG2_NT": 6,
#         "HepG2_SRSF4KD": 4,
#         "K562_NT": 5,
#         "K562_SRSF4KD": 4
#     },
#     "psi_samples": "100",
#     "stat_names": [
#         "TNOM",
#         "TTEST",
#         "WILCOXON"
#     ],
#     "test_percentile": "0.95",
#     "voila_version": "2.4.dev76+g37780c8"
# }

First, there is a commented-out header with metadata (in JSON format, after excluding the comment characters at the start of each line):

  • command: the call to voila tsv that generated the TSV. This helps indicate which thresholds were set, etc.,

  • group_sizes: the unique group names compared in the input voila files and the number of experiments included in each group,

  • psi_samples, test_percentile: parameters used by majiq heterogen for computing test statistics not only on PSI posterior means but on repeated samples from PSI posterior distributions (more detailed explanation below when discussing column names),

  • stat_names: the different statistical tests used to evaluate significance of differences between observations from groups,

  • voila_version: the version of VOILA that was used.

The most important consideration here are the stat_names: TNOM, TTEST, WILCOXON. By default, MAJIQ performs these three statistical tests (all but INFOSCORE) on each junction/retained intron from each LSV. TTEST corresponds to a independent two-sample t-test with unequal variances (Welch’s t-test). WILCOXON corresponds to an independent two-sample Mann-Whitney U test. INFOSCORE and TNOM correspond to the test statistics as originally implemented in the ScoreGenes package. INFOSCORE is excluded from defaults because it runs slower than the other tests with larger number of experiments.

MAJIQ can be configured to run only a subset of these tests by setting the --stats argument to the desired subset of these test-statistics. See {ref}``what statistic should I use <statistics>`` for more opinionated guidance about picking which statistics to use.

[16]:
# print first uncommented line (column names)
with open("output/voila_tsv/all-pairs-het.tsv", "r") as handle:
    for line in handle:
        if line.startswith("#"):
            continue
        print(line, end="")
        break
gene_name       gene_id lsv_id  lsv_type        strand  seqid   HepG2_SRSF4KD_median_psi        HepG2_NT_median_psi     K562_NT_median_psi      K562_SRSF4KD_median_psi HepG2_SRSF4KD_percentile25_psi  HepG2_SRSF4KD_percentile75_psi  HepG2_NT_percentile25_psi       HepG2_NT_percentile75_psi       K562_NT_percentile25_psi        K562_NT_percentile75_psi        K562_SRSF4KD_percentile25_psi   K562_SRSF4KD_percentile75_psi   HepG2_SRSF4KD_num_quantified    HepG2_NT_num_quantified K562_NT_num_quantified  K562_SRSF4KD_num_quantified     HepG2_SRSF4KD-HepG2_NT TNOM     HepG2_SRSF4KD-HepG2_NT TTEST    HepG2_SRSF4KD-HepG2_NT WILCOXON HepG2_SRSF4KD-K562_NT TNOM      HepG2_SRSF4KD-K562_NT TTEST     HepG2_SRSF4KD-K562_NT WILCOXON  K562_NT-HepG2_NT TNOM   K562_NT-HepG2_NT TTEST  K562_NT-HepG2_NT WILCOXON       K562_SRSF4KD-HepG2_NT TNOM      K562_SRSF4KD-HepG2_NT TTEST     K562_SRSF4KD-HepG2_NT WILCOXON  K562_SRSF4KD-HepG2_SRSF4KD TNOM K562_SRSF4KD-HepG2_SRSF4KD TTEST        K562_SRSF4KD-HepG2_SRSF4KD WILCOXON     K562_SRSF4KD-K562_NT TNOM       K562_SRSF4KD-K562_NT TTEST      K562_SRSF4KD-K562_NT WILCOXON   HepG2_SRSF4KD-HepG2_NT TNOM_quantile    HepG2_SRSF4KD-HepG2_NT TTEST_quantile   HepG2_SRSF4KD-HepG2_NT WILCOXON_quantile        HepG2_SRSF4KD-K562_NT TNOM_quantile     HepG2_SRSF4KD-K562_NT TTEST_quantile    HepG2_SRSF4KD-K562_NT WILCOXON_quantile K562_NT-HepG2_NT TNOM_quantile  K562_NT-HepG2_NT TTEST_quantile K562_NT-HepG2_NT WILCOXON_quantile      K562_SRSF4KD-HepG2_NT TNOM_quantile     K562_SRSF4KD-HepG2_NT TTEST_quantile    K562_SRSF4KD-HepG2_NT WILCOXON_quantile K562_SRSF4KD-HepG2_SRSF4KD TNOM_quantile        K562_SRSF4KD-HepG2_SRSF4KD TTEST_quantile       K562_SRSF4KD-HepG2_SRSF4KD WILCOXON_quantile    K562_SRSF4KD-K562_NT TNOM_quantile      K562_SRSF4KD-K562_NT TTEST_quantile     K562_SRSF4KD-K562_NT WILCOXON_quantile  HepG2_SRSF4KD-HepG2_NT tnom_score       HepG2_SRSF4KD-K562_NT tnom_score        K562_NT-HepG2_NT tnom_score     K562_SRSF4KD-HepG2_NT tnom_score        K562_SRSF4KD-HepG2_SRSF4KD tnom_score   K562_SRSF4KD-K562_NT tnom_score HepG2_SRSF4KD-HepG2_NT changing HepG2_SRSF4KD-K562_NT changing  K562_NT-HepG2_NT changing       K562_SRSF4KD-HepG2_NT changing  K562_SRSF4KD-HepG2_SRSF4KD changing     K562_SRSF4KD-K562_NT changing   HepG2_SRSF4KD-HepG2_NT nonchanging      HepG2_SRSF4KD-K562_NT nonchanging       K562_NT-HepG2_NT nonchanging    K562_SRSF4KD-HepG2_NT nonchanging       K562_SRSF4KD-HepG2_SRSF4KD nonchanging  K562_SRSF4KD-K562_NT nonchanging        num_junctions   num_exons       de_novo_junctions       junctions_coords        exons_coords    ir_coords       ucsc_lsv_link

Second, our first uncommented line in the TSV file indicates the column names for the table. Of note:

The 25th, 50th, and 75th percentiles of PSI for each group are indicated by the columns {group_name}_{percentile25,median,percentile75}_psi

The results of the statistical tests between groups are indicated by columns {grp1}-{grp2} {test_name}{,_quantile}. When the groups compared are unambiguous (only one VOILA file as input), {grp1}_{grp2} is excluded from the column name. When the TNOM statistical test was run, we also report {grp1}_{grp2} tnom_score. The special case is tnom_score, which reports the raw test-statistic – the minimum total number of mistakes when picking a single threshold on PSI to classify the observations back into the two groups. Otherwise, the statistical tests correspond to p-values from each test. For each test, we report {test_name} and {test_name}_quantile. The columns {test_name} (no quantile) correspond to statistical tests on the posterior means of each sample. These p-values are calibrated on an individual basis. In some cases, we can benefit from considering the uncertainty encoded in the full posterior distributions by performing tests on samples from the posterior distribution. Then, we can consider a credible range of test statistics from each comparison that we might expect. By default, majiq heterogen takes 100 samples from each posterior distribution and reports the 95th percentile p-value from the tests comparing each of the posterior samples (change using --psi-samples and --test_percentile flags). The {test_name}_quantile column thus indicates the selected percentile of sampled p-values, which is generally more conservative and not calibrated as a p-value in its own right.

There are also columns with the format {grp1}-{grp2} ?(non)changing. These indicate whether each junction/retained intron in the LSV met VOILA’s thresholds for being changing or nonchanging. By default, VOILA calls a junction as changing between groups if:

  • all test statistics have nominal p-value less than 0.05 (change with --changing-pvalue-threshold flag)

  • difference in group median PSI of at least 20% (change with --changing-between-group-dpsi flag).

Similarly, by default, VOILA calls a junction as non-changing between groups if:

  • all test statistics have nominal p-value greater than 0.05 (change with --non-changing-pvalue-threshold flag)

  • within-group interquartile range of PSI less than 10% in both groups (change with --non-changing-within-group-IQR flag)

  • difference in group median PSI of at most 5% (change with --non-changing-between-group-dpsi flag).

In some cases, for a certain quantifier run, due to low coverage or thresholding, a certain junction may not be quantified in a certain experimental group. This possibility is indicated through the {grp} num_quantified columns. In the majority of cases, the number here will match the value of num_junctions, but when fewer junctions are quantified in that group, the value here will reflect a lower sum.

[17]:
# print first line of data
with open("output/voila_tsv/all-pairs-het.tsv", "r") as handle:
    for line in handle:
        if line.startswith("#"):
            continue
        break  # don't print first uncommented line (column names)
    # print the next line (first row of data)
    print(next(handle), end="")
SRSF4   gene:ENSG00000116350    gene:ENSG00000116350:t:29160375-29160795        t|1e3.1o1|2e1.1o1|2e2.1o1|i     -       1       0.0039;0.8151;0.0836;0.1051     0.0059;0.8950;0.0557;0.0463     0.0141;0.8405;0.0375;0.1082     0.0060;0.7801;0.1173;0.0900     2.492e-03;7.936e-01;4.593e-02;9.300e-02 6.221e-03;8.337e-01;1.204e-01;1.157e-01 5.194e-03;8.686e-01;3.206e-02;3.479e-02 7.732e-03;9.100e-01;7.952e-02;5.702e-02 1.278e-02;8.315e-01;3.746e-02;7.229e-02 2.268e-02;8.682e-01;7.237e-02;1.120e-01 4.470e-03;6.601e-01;5.070e-02;7.267e-02 8.936e-03;8.802e-01;2.055e-01;1.050e-01 4       6       5       4       9.238e-01;9.524e-02;4.238e-01;9.524e-03 3.445e-01;8.225e-03;3.890e-01;3.191e-03 4.762e-01;3.810e-02;2.571e-01;9.524e-03 1.429e-01;5.635e-01;5.635e-01;9.921e-01 5.948e-02;1.683e-01;2.146e-01;5.968e-01 1.111e-01;2.857e-01;1.905e-01;5.556e-01 2.381e-01;2.381e-01;6.883e-01;4.762e-02 1.665e-01;1.012e-01;5.163e-01;6.715e-03 1.775e-01;1.255e-01;6.623e-01;1.732e-02 9.238e-01;4.238e-01;4.238e-01;9.524e-02 9.018e-01;1.893e-01;2.767e-01;5.238e-02 9.143e-01;1.143e-01;4.762e-01;6.667e-02 7.714e-01;7.714e-01;7.714e-01;1.000e+00 4.126e-01;5.292e-01;4.317e-01;4.043e-01 4.857e-01;1.000e+00;6.857e-01;6.857e-01 5.635e-01;5.635e-01;5.635e-01;9.921e-01 1.450e-01;3.400e-01;2.241e-01;6.783e-01 4.127e-01;9.048e-01;4.127e-01;9.048e-01 1.000e+00;9.238e-01;9.238e-01;9.238e-01 9.153e-01;8.035e-01;9.329e-01;7.385e-01 1.000e+00;9.143e-01;1.000e+00;7.695e-01 9.921e-01;9.921e-01;9.921e-01;9.921e-01 7.651e-01;9.424e-01;9.008e-01;9.428e-01 9.048e-01;1.000e+00;1.000e+00;1.000e+00 9.978e-01;9.978e-01;9.978e-01;9.978e-01 9.001e-01;7.838e-01;9.422e-01;5.095e-01 1.000e+00;9.307e-01;1.000e+00;6.623e-01 1.000e+00;9.238e-01;9.238e-01;9.276e-01 9.094e-01;7.220e-01;8.096e-01;8.150e-01 1.000e+00;9.143e-01;1.000e+00;9.143e-01 1.000e+00;1.000e+00;1.000e+00;1.000e+00 8.979e-01;9.092e-01;9.525e-01;9.307e-01 1.000e+00;1.000e+00;1.000e+00;1.000e+00 9.921e-01;9.921e-01;9.921e-01;9.921e-01 8.765e-01;9.100e-01;6.459e-01;9.487e-01 9.048e-01;1.000e+00;1.000e+00;1.000e+00 3.000e+00;2.000e+00;2.000e+00;2.000e+00 1.000e+00;2.000e+00;2.000e+00;3.000e+00 3.000e+00;3.000e+00;3.000e+00;2.000e+00 3.000e+00;2.000e+00;2.000e+00;2.000e+00 2.000e+00;2.000e+00;2.000e+00;2.000e+00 2.000e+00;2.000e+00;2.000e+00;2.000e+00 False;False;False;False False;False;False;False False;False;False;False False;False;False;False False;False;False;False False;False;False;False True;False;True;False   True;True;True;True     True;False;True;False   True;False;False;True   True;False;False;True   True;False;False;True   4       4       1;0;0;1 29160795-29165207;29160517-29181646;29160517-29165890;29160796-29165206 29160375-29160795;29165207-29165357;29165890-29166064;29181646-29181987 29160796-29165206       http://genome.ucsc.edu/cgi-bin/hgTracks?db=GRCh38&position=1%3A29181987-29160375

Finally, the remaining lines in the TSV are for the data in the table. Each row corresponds to a quantified LSV. For the quantification, test, etc. columns, the values for each junction/retained intron in the LSV are delimited by semicolons. Note that if computation is desired on the individual values, it can be convenient to “explode” the data to rows per LSV connection. In pandas, this can be done by using pd.Series.str.split(";") on appropriate columns followed by pd.DataFrame.explode(). In R, this can be done by using tidyr::separate_rows().

Categorizing splicing events with voila modulizer

We can also generate summaries of categorizations of splicing events with voila modulize. The purpose of this tool is not only to summarize classical events, but also a variety of complex events as well as determine common combinations of two or more events.

voila-modulizer

You may run the modulizer in the following manner:

[18]:
%%bash
voila modulize output/build/splicegraph.sql output/heterogen/*.het.voila -d output/modulized --overwrite
2022-02-10 22:23:58,718 (PID:1072) - INFO - Command: /usr/local/bin/voila modulize output/build/splicegraph.sql output/heterogen/HepG2_SRSF4KD-HepG2_NT.het.voila output/heterogen/HepG2_SRSF4KD-K562_NT.het.voila output/heterogen/K562_NT-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_SRSF4KD.het.voila output/heterogen/K562_SRSF4KD-K562_NT.het.voila -d output/modulized --overwrite
2022-02-10 22:23:58,718 (PID:1072) - INFO - Voila v2.4.dev76+g37780c8
2022-02-10 22:23:58,718 (PID:1072) - INFO - config file: /tmp/tmpdxaht65o
2022-02-10 22:23:58,729 (PID:1072) - INFO - HETx6 MODULIZE
2022-02-10 22:23:58,739 (PID:1072) - INFO - Modulizing 8 gene(s)
2022-02-10 22:23:58,739 (PID:1072) - INFO - Quantifications based on 6 input file(s)
2022-02-10 22:23:58,739 (PID:1072) - INFO - ╔═══════════════════════════════════════════════════════════════╗
2022-02-10 22:23:58,739 (PID:1072) - INFO - ╠╡ Before Modulization:                                         ║
2022-02-10 22:23:58,739 (PID:1072) - INFO - ║     Dropping junctions with max(PSI) < 0.050                  ║
2022-02-10 22:23:58,739 (PID:1072) - INFO - ║     Dropping junctions with max(number_of_reads) < 1          ║
2022-02-10 22:23:58,739 (PID:1072) - INFO - ╠╡ After Modulization:                                          ║
2022-02-10 22:23:58,739 (PID:1072) - INFO - ║     Dropping modules if none(max(E(|dPSI|)) >= 0.200)         ║
2022-02-10 22:23:58,739 (PID:1072) - INFO - ║     Dropping modules if none(max(P(|dPSI|>=0.200)) >= 0.950)  ║
2022-02-10 22:23:58,739 (PID:1072) - INFO - ╚═══════════════════════════════════════════════════════════════╝
2022-02-10 22:23:58,739 (PID:1072) - INFO - Writing TSVs to /tmp/tmpqxkg15zs/output/modulized
2022-02-10 22:24:06,786 (PID:1072) - INFO - Concatenating Results
2022-02-10 22:24:06,906 (PID:1072) - INFO - Modulization Complete

Note that the modulizer can run with any combination of the standard .psi.voila or .deltapsi.voila files in addition to our het.voila files. Each additional piece of data for the same LSV/junction will be recorded in the output row in the modulized output.

The modulized output will be recorded in a number of files in .tsv format.

[19]:
ls output/modulized
alt3and5prime.tsv         heatmap.tsv              p_alt5prime.tsv
alt3prime.tsv             junctions.tsv            p_alternate_first_exon.tsv
alt5prime.tsv             multi_exon_spanning.tsv  p_alternate_last_exon.tsv
alternate_first_exon.tsv  mutually_exclusive.tsv   summary.tsv
alternate_last_exon.tsv   orphan_junction.tsv      tandem_cassette.tsv
alternative_intron.tsv    other.tsv
cassette.tsv              p_alt3prime.tsv

They are:

  • summary.tsv: Likely the most immediately useful for the majority of users. Each row corresponds to a splicing module, and lists the counts of each type of splicing event found inside the module.

  • heatmap.tsv: For each module, a junction of greatest biological importance is considered and quantified here, one row per module. The method/parameters for choosing which junction is selected can be changed, see voila modulize --help for details.

  • event tsv files, ex: cassette.tsv: Contains quantification information across all input files for each junction making up that specific splicing event.

  • other.tsv: for any junctions not assigned to ANY splicing event, they are dumped here.

  • junctions.tsv: A concatenation of all junction data from all event tsv files as well as other.tsv.

Please see VOILA modulizer documentation for more details on the modulizer.

Interactively visualizing results with voila view

We can also view results interactively in our web browser using voila view. We can start the web service by running

voila view output/build/splicegraph.sql output/heterogen/*.het.voila

By default, the web service is hosted on a random port for localhost (--host and -p flags can be used to specify directly). The console will print a URL that can be accessed from the same machine within a web browser. For example, when we run the above command, we see:

2021-09-01 01:08:53,380 (PID:5613) - INFO - Command: /{redacted}/bin/voila view output/build/splicegraph.sql output/heterogen/HepG2_SRSF4KD-HepG2_NT.het.voila output/heterogen/HepG2_SRSF4KD-K562_NT.het.voila output/heterogen/K562_NT-HepG2_NT.het.voila output/heteroge
n/K562_SRSF4KD-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_SRSF4KD.het.voila output/heterogen/K562_SRSF4KD-K562_NT.het.voila
2021-09-01 01:08:53,380 (PID:5613) - INFO - Voila v2.2.0
2021-09-01 01:08:53,380 (PID:5613) - INFO - config file: /tmp/tmpixnu75yk
2021-09-01 01:08:53,395 (PID:5613) - INFO - Creating index: /{redacted}/output/heterogen/HepG2_SRSF4KD-HepG2_NT.het.voila
Indexing LSV IDs: 0 / 94
2021-09-01 01:08:55,510 (PID:5613) - INFO - Writing index: /{redacted}/output/heterogen/HepG2_SRSF4KD-HepG2_NT.het.voila
Serving on http://localhost:45899

So we open up http://localhost:45899 in our web browser. VOILA view first opens up to an index over genes/LSVs:

voila index

We can browse through pages of genes/LSV diagrams as convenient, or we can also use the search bar in the top-right hand side to search for a particular gene (or LSV). Once we’ve found a gene of interest, we click the link in the “Gene Name” column to view details for that gene.

For example, clicking into NDUFV3 gives us a screen that looks like:

voila-ndufv3

The top portion of the screen corresponds to splicegraphs. These indicate exon numbers and annotated vs denovo exons, junctions, and retained introns, and observed raw read coverage for each intron or junction. Which experiments have coverage displayed can be modified by clicking on the “SpliceGraph” button, and adding or removing additional experiments to display. The magnification buttons next to the legend allow zooming in or out on the splicegraph, and the wand button changes whether intronic regions are squashed or displayed to scale.

The bottom portion of the screen corresponds to quantified LSVs. Each LSV has three columns:

  1. The first column indicates the genomic coordinates of the junction or retained intron.

  2. The second column shows violin plots of the averaged posterior distributions per group. Individual points show the posterior means for PSI for each experiment per group. Hovering over points displays a tooltip indicating the experiment name.

  3. The third column shows a heat map showing group-vs-group comparisons. Below the diagonal, the heatmap displays observed p-values for each comparison. The specific test displayed can be changed using the radio buttons in the top-right corner. Above the diagonal, the heatmap shows the difference in PSI between the medians of each group.

We can see the quantified values of PSI for each experiment per group in the violin plots.

voila view as a multi-user web server

voila view was also designed with sharing and collaboration in mind. So, in addition to being used locally, it is possible to set it up as its own web server host.

Note that accessibility of the service within local networks or the internet in general can be highly dependent on network settings and security practices (e.g. port forwarding, IP {white,black}lists, etc.) outside the scope of MAJIQ/VOILA itself; You can consult with your system administrator for advice if you want to make voila view available outside of the local machine / for multiple users.

  • voila view has a --host parameter, which works similarly to --host parameters in most other unix-like programs. That is, it sets the bind address. For the most common use case, to listen to all addresses, simply pass --host 0.0.0.0. (The default is --host 127.0.0.1, which listens only to your local machine)

  • for security against port-scanners, voila view provides a --enable-passcode switch. This generates a unique passcode in the link which is needed for users to successfully view the output. Recommended for use when hosting sensitive data with the tool.

  • voila view has three web server options to cover all needs. you can choose flask, waitress, or gunicorn for as a parameter to the --web-server switch. flask is insecure and slow, and should only be used if you are trying to resolve a bizarre error, as it generates more debugging information. waitress is the default. It is efficient, and suitable for most single-user use cases. However, it is single-threaded. gunicorn is a production-ready, performant web server used by many projects. It can serve many users/page requests concurrently. It may be helpful in some cases to speed up access even for a single user if loading very large numbers of LSVs in a gene at once. You can set the number of threads to host with the --num-web-workers argument. Safe to use with nginx proxy-pass as well.

Filtering results

The output files used by VOILA (splicegraph.sql, *.voila) can be very large for real analyses. voila filter allows filtering these files to reduce their filesize to facilitate sharing (or downloading from a cluster environment).

We:

  • specify the splicegraph output/build/splicegraph.sql and voila files output/heterogen/*.het.voila as positional arguments,

  • specify the output directory for the filtered files with the required argument --directory output/voila_filter

  • specify the set of genes or LSVs to keep after filtering either directly (--gene-ids, --lsv-ids) or by specifying a file with IDs to keep (--gene-ids-file, --lsv-ids-file): --gene-ids 'gene:ENSG00000106603'.

This leads to the command:

[20]:
%%bash
voila filter output/build/splicegraph.sql output/heterogen/*.het.voila \
    --directory output/voila_filter --gene-ids 'gene:ENSG00000106603' --overwrite
2022-02-10 22:24:08,046 (PID:1139) - INFO - Command: /usr/local/bin/voila filter output/build/splicegraph.sql output/heterogen/HepG2_SRSF4KD-HepG2_NT.het.voila output/heterogen/HepG2_SRSF4KD-K562_NT.het.voila output/heterogen/K562_NT-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_NT.het.voila output/heterogen/K562_SRSF4KD-HepG2_SRSF4KD.het.voila output/heterogen/K562_SRSF4KD-K562_NT.het.voila --directory output/voila_filter --gene-ids gene:ENSG00000106603 --overwrite
2022-02-10 22:24:08,046 (PID:1139) - INFO - Voila v2.4.dev76+g37780c8
2022-02-10 22:24:08,046 (PID:1139) - INFO - config file: /tmp/tmpudoryl8v
2022-02-10 22:24:08,056 (PID:1139) - INFO - HETx6 FILTER
2022-02-10 22:24:08,056 (PID:1139) - INFO - Filtering input to 1 gene(s)
2022-02-10 22:24:08,056 (PID:1139) - INFO - One splicegraph and 6 voila files
2022-02-10 22:24:08,056 (PID:1139) - INFO - Writing output files to /tmp/tmpqxkg15zs/output/voila_filter
2022-02-10 22:24:08,101 (PID:1161) - INFO - Started Filtering /tmp/tmpqxkg15zs/output/heterogen/HepG2_SRSF4KD-K562_NT.het.voila
2022-02-10 22:24:08,101 (PID:1160) - INFO - Started Filtering /tmp/tmpqxkg15zs/output/heterogen/HepG2_SRSF4KD-HepG2_NT.het.voila
2022-02-10 22:24:08,101 (PID:1163) - INFO - Started Filtering /tmp/tmpqxkg15zs/output/heterogen/K562_NT-HepG2_NT.het.voila
2022-02-10 22:24:08,105 (PID:1165) - INFO - Started Filtering /tmp/tmpqxkg15zs/output/heterogen/K562_SRSF4KD-HepG2_NT.het.voila
2022-02-10 22:24:08,118 (PID:1163) - INFO - Finished writing output/voila_filter/K562_NT-HepG2_NT.het.voila
2022-02-10 22:24:08,118 (PID:1165) - INFO - Finished writing output/voila_filter/K562_SRSF4KD-HepG2_NT.het.voila
2022-02-10 22:24:08,118 (PID:1161) - INFO - Finished writing output/voila_filter/HepG2_SRSF4KD-K562_NT.het.voila
2022-02-10 22:24:08,120 (PID:1160) - INFO - Finished writing output/voila_filter/HepG2_SRSF4KD-HepG2_NT.het.voila
2022-02-10 22:24:08,130 (PID:1165) - INFO - Started Filtering /tmp/tmpqxkg15zs/output/heterogen/K562_SRSF4KD-HepG2_SRSF4KD.het.voila
2022-02-10 22:24:08,130 (PID:1163) - INFO - Started Filtering /tmp/tmpqxkg15zs/output/heterogen/K562_SRSF4KD-K562_NT.het.voila
2022-02-10 22:24:08,134 (PID:1165) - INFO - Finished writing output/voila_filter/K562_SRSF4KD-HepG2_SRSF4KD.het.voila
2022-02-10 22:24:08,135 (PID:1163) - INFO - Finished writing output/voila_filter/K562_SRSF4KD-K562_NT.het.voila
2022-02-10 22:24:09,100 (PID:1161) - INFO - Filtering Splicegraph
2022-02-10 22:24:09,220 (PID:1161) - INFO - Finished Filtering Splicegraph
2022-02-10 22:24:10,099 (PID:1139) - INFO - Filtering Complete