Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Quantifying isoform usage with Torino

Learns coverage components of each gene from RNA-seq read depth across samples with Torino, without transcript annotations, and writes their per-sample usage as a phenotype table for QTL mapping.

Overview

This module turns aligned RNA-seq into isoform-level phenotypes without relying on a transcript annotation. Junction-based methods such as LeafCutter2 (splicing_calling_leafcutter2) quantify only the splice junctions a read crosses, so they miss intron retention and alternative polyadenylation, which change how much of a region is covered rather than which junctions are used. Annotation-based methods such as RSEM (RNA_calling) quantify only the isoforms the reference already lists, and references are biased towards transcripts expressed in healthy, easily accessible tissues.

Torino models the read depth along a gene directly. For one gene, the depth of NN samples over MM bases forms a count matrix XX, which Torino factorizes by empirical Bayes Poisson non-negative matrix factorization into KK coverage components and their usage in each sample, Xnm∼Poisson(∑kLnkFmk)X_{nm} \sim \text{Poisson}\big(\sum_k L_{nk} F_{mk}\big). Constitutive exons and introns vary little between samples, so the components that the factorization needs to explain the variation capture alternative RNA processing: cassette exons, retained introns, alternative first and last exons, and alternative polyadenylation sites. Priors on FF encourage biologically plausible profiles of exonic and intronic coverage while allowing for technical noise, so many components resemble isoform structures (Buen Abad Najar et al., 2026). The usage LnkL_{nk} of each component is the molecular phenotype carried forward.

Torino at the SRSF3 gene: read coverage across GTEx samples, the coverage components Torino finds, and how much each sample uses each component.

Torino at the SRSF3 gene. (a) Read coverage across 2,016 GTEx samples. (b) Torino splits the coverage into components, many of which look like isoform structures. (c) How much each sample uses each component; these usage values are the molecular phenotype for QTL mapping. This module estimates the components and their usage; matching components to known transcripts, shown in the paper’s panel d, was done in the study and is not part of this module. Panels a–c adapted (cropped) from Buen Abad Najar et al., 2026, Figure 1, under CC BY 4.0.

Matrix dimensions:

  • XX: N×MN \times M, read depth of each sample at each base of the gene window

  • FF: M×KM \times K, the coverage components, written EF_smooth in the factorization output

  • LL: N×KN \times K, the usage of each component in each sample, written EL

The module has one workflow, torino, whose four steps chain: read coverage from each BAM, a depth matrix per gene, a factorization per gene, and the cohort usage tables. torino_preprocessing runs the first two steps only.

The Torino paper goes further and merges components that share an exon chain into coverage patterns and classifies each against the annotation; that interpretation step is not part of this module. Its Alzheimer’s disease analysis tested component usage directly, as this module does.

When to run it. After alignment with RNA_calling, alongside or instead of splicing_calling_leafcutter2. The normalized usage table and its phenotype-group file go to phenotype_formatting and then to the association scan, where TensorQTL’s grouped permutation tests all components of one gene together.

Input

  • --samples tests/fixtures/splicing_calling/torino/protocol_example.sample_list.txt (the sample manifest, tab delimited with a header. coord_bam_list gives each coordinate-sorted, indexed BAM relative to --data-dir, and strand is rf, fr or strand_missing; the regtools codes RF, FR and XS are accepted for the same three, so a splicing_calling_leafcutter2 manifest can be reused. sample_id names every per-sample file and every column of the output tables. Output files take their prefix from this filename with all extensions stripped, so this manifest produces protocol_example.*; override it with --output-prefix.)

sample_id	strand	coord_bam_list
SAMPLE_001	strand_missing	bam/SAMPLE_001.bam
SAMPLE_002	strand_missing	bam/SAMPLE_002.bam

The 24 BAMs it names are shipped under tests/fixtures/splicing_calling/torino/bam/. They hold single-end reads over AP000547.3 on chr22, simulated from three of its Ensembl transcripts (fully spliced, retaining the last intron, and ending in an alternative last exon) in proportions that differ between two groups of samples. build_fixture.R in the same directory regenerates them and writes the simulated proportions to simulated_isoform_proportions.tsv.

  • --genes tests/fixtures/splicing_calling/torino/protocol_example.genes.bed (the genes to model, one per row: chromosome, 0-based start, end, gene ID, gene name and strand. A # header line is skipped. The gene ID names the per-gene files and the output phenotypes. For unstranded data, genes that overlap a gene on the opposite strand mix the two genes’ reads; the Torino paper removes such regions for GTEx.)

#chr	start	end	gene_id	gene_name	strand
chr22	16592894	16600110	ENSG00000287285	AP000547.4	+
chr22	16601910	16615111	ENSG00000283633	AP000547.3	+

AP000547.4 carries no reads in the fixture, so it shows the coverage filter at work.

  • --K 3 (number of coverage components per gene. The Torino paper used 3 for its brain cohort, three regions of one tissue, and 10 across 18 GTEx tissues, where tissue differences dominate the variation.)

  • --min-counts 100 (summed depth over a gene, the sum over bases of per-base depth, below which a sample is dropped. Used by both the depth-matrix and factorization steps.)

  • --min-samples 10 (samples that must reach --min-counts for a gene to be modelled. The Torino paper required 100 of 2,016 GTEx samples.)

  • --flank 50 (bases added to each side of the gene.)

  • --gene-chunks 1 (number of jobs the gene list is split into for the depth matrices. Pass the same value to every step.)

  • --merge-n auto (bases summed per matrix column to bound memory; auto uses 1, 3, 9 or 30 by gene width.)

  • --max-missing 0.1 (largest fraction of samples a component may be missing and still enter the normalized table.)

  • --min-usage-q90 0.1 (smallest 90th-percentile usage a component may have and still enter the normalized table.)

  • --seed 1 (random seed for the factorization.)

  • --data-dir (directory the coord_bam_list paths are relative to; defaults to the directory holding --samples.)

  • --output-prefix (prefix for the cohort-level files; defaults to the --samples filename with all extensions stripped.)

  • --min-mapq 0 (keep only reads with at least this mapping quality; 255 keeps uniquely mapped STAR reads.)

Output

  • output/torino/coverage/SAMPLE_001.coverage.bedgraph.gz (torino_1, torino_preprocessing_1) (per-base read depth of one sample, bgzipped bedGraph with a tabix index beside it: chromosome, 0-based start, end, depth. Zero-depth runs are reported too. A stranded sample instead gets SAMPLE_001.plus.coverage.bedgraph.gz and SAMPLE_001.minus.coverage.bedgraph.gz.)

chr22	0	16601911	0
chr22	16601911	16601929	1
chr22	16601929	16601948	2
  • output/torino/count_matrix/ENSG00000283633.csv.gz (torino_2, torino_preprocessing_2) (the depth matrix of one gene, the input Torino factorizes: one row per sample in manifest order, one column per base of the gene window named <chrom>:<position> with 1-based positions. Shown here are the first five bases and three bases where the first reads start.)

Sample_ID,chr22:16601861,chr22:16601862,chr22:16601863,chr22:16601864,chr22:16601865,...,chr22:16601919,chr22:16601920,chr22:16601921
SAMPLE_001,0,0,0,0,0,...,1,1,1
SAMPLE_002,0,0,0,0,0,...,1,1,1
  • output/torino/count_matrix/protocol_example.chunk_1.list (torino_2, torino_preprocessing_2) (the depth matrices this chunk wrote, one path per line; torino_3 reads its gene list from these files)

output/torino/count_matrix/ENSG00000283633.csv.gz
  • output/torino/count_matrix/protocol_example.chunk_1.skipped.tsv (torino_2, torino_preprocessing_2) (the genes of this chunk that were not written, and why)

gene_id	gene_name	reason
ENSG00000287285	AP000547.4	0 sample(s) with depth >= 100, 10 needed
  • output/torino/factorization/ENSG00000283633.rds (torino_3) (the factorization of one gene, as torino::run_torino_gene writes it. $torino_K3 is named for --K and is NULL if the factorization failed. EF_smooth holds the coverage components, bases by components, and EL their usage, samples by components; both carry the two Poisson-noise padding columns Torino adds at the window edges, hence 13,303 bases against the 13,301 of the depth matrix. $coords_all is every base column before filtering and merging.)

List of 3
 $ gene      : chr "ENSG00000283633"
 $ torino_K3 :List of 6
  ..$ EF       : num [1:13303, 1:3] 1.77e-10 1.77e-10 ...
  ..$ EF_smooth: num [1:13303, 1:3] 1.76e-10 1.76e-10 ...
  ..$ EL       : num [1:24, 1:3] 0.856 0.31 ...
  ..$ elbo     : num 5.86e+11
  ..$ coords   : chr [1:13303] "rpois(nsamples, 0.2)" "chr22:16601861" ...
  ..$ samples  : chr [1:24] "SAMPLE_001" "SAMPLE_002" ...
 $ coords_all: chr [1:13301] "chr22:16601861" "chr22:16601862" ...

On the fixture, each component recovered one simulated transcript across the 24 samples: the usage of factor_1 correlated with the fully spliced transcript at 0.98, factor_2 with the alternative last exon at 0.99, and factor_3 with intron retention at 0.99.

  • output/torino/protocol_example.torino_usage.bed.gz (torino_4) (the usage of every component in every sample, one row per component keyed <gene_id>:factor_<k> at its gene’s coordinates, coordinate-sorted, bgzipped and tabix-indexed, with NA for samples Torino dropped below --min-counts. Values rounded here.)

#chr	start	end	ID	SAMPLE_001	SAMPLE_002
chr22	16601910	16615111	ENSG00000283633:factor_1	0.8555	0.3102
chr22	16601910	16615111	ENSG00000283633:factor_2	0.0626	0.2320
  • output/torino/protocol_example.torino_usage.qqnorm.bed.gz (torino_4) (the phenotype for QTL mapping: the components passing --max-missing and --min-usage-q90, missing values filled with the component mean, each component centred and scaled across samples and each sample then quantile-normalized across components, as QQNorm_factors.py does in the Torino paper’s pipeline. Each sample is normalized across every component of every gene in the table, which for this one gene is three values, hence the repeated magnitudes.)

#chr	start	end	ID	SAMPLE_001	SAMPLE_002
chr22	16601910	16615111	ENSG00000283633:factor_1	0.8694	-0.8694
chr22	16601910	16615111	ENSG00000283633:factor_2	-0.8694	0.0000
  • output/torino/protocol_example.torino_usage.phenotype_group.txt (torino_4) (component ID and gene ID for every row of the normalized table, tab delimited without a header: the grouping TensorQTL’s --phenotype-group reads)

ENSG00000283633:factor_1	ENSG00000283633
ENSG00000283633:factor_2	ENSG00000283633
ENSG00000283633:factor_3	ENSG00000283633

Minimal Working Example

torino is the entry point and runs all four steps; torino_preprocessing stops after the per-gene depth matrices.

Coverage components and their usage from BAMs

torino reads coverage from the 24 fixture BAMs, builds the depth matrix of each gene that passes the coverage filter, factorizes it into three components and writes the cohort usage tables. The factorization step needs the torino R package. The 24 fixture samples meet the default --min-samples 10; a cohort far larger than this one should raise it.

Timing: ~1 min (on toy dataset)

Depth matrices only

torino_preprocessing stops once the per-gene depth matrices are written, for cohorts whose factorization runs elsewhere or to check the gene filter before committing to the factorization jobs.

Timing: ~7 s (on toy dataset)

Command Interface

usage: sos run pipeline/isoform_calling_torino.ipynb
               [workflow_name | -t targets] [options] [workflow_options]
  workflow_name:        Single or combined workflows defined in this script
  targets:              One or more targets to generate
  options:              Single-hyphen sos parameters (see "sos run -h" for details)
  workflow_options:     Double-hyphen workflow-specific parameters

Workflows:
  torino
  torino_preprocessing

Global Workflow Options:
  --modular-script-dir code/script (as path)
  --cwd output (as path)
                        The output directory for generated files.
  --samples VAL (as path, required)
                        Sample manifest: tab delimited with a header, columns
                        sample_id, strand and coord_bam_list
  --data-dir  path(f"{samples:d}")

                        Directory the coord_bam_list paths are relative to,
                        default to the same directory as the manifest
  --output-prefix  f'{samples:bnn}'

                        Prefix for every cohort-level output file; defaults to
                        the manifest name with all extensions stripped
  --job-size 1 (as int)
                        For cluster jobs, number commands to run per job
  --walltime 5h
                        Wall clock time expected
  --mem 16G
                        Memory expected
  --numThreads 1 (as int)
                        Number of threads
  --container ''
                        Software container option

Sections
  torino_1, torino_preprocessing_1:
    Workflow Options:
      --min-mapq 0 (as int)
                        keep only reads with at least this mapping quality
                        (default 0, off; 255 keeps uniquely mapped reads for
                        STAR alignments)
  torino_2, torino_preprocessing_2:
    Workflow Options:
      --genes VAL (as path, required)
                        gene BED: chrom, 0-based start, end, gene_id, gene_name,
                        strand (a #-prefixed header is skipped)
      --flank 50 (as int)
                        bases added on each side of the gene (default 50, the
                        Torino paper's value for human genes)
      --min-counts 100 (as int)
                        summed depth over the gene a sample needs to count
                        towards --min-samples (default 100)
      --min-samples 10 (as int)
                        samples that must reach --min-counts for the gene to be
                        written (default 10)
      --gene-chunks 1 (as int)
                        number of jobs the gene list is split into (default 1)
  torino_3:
    Workflow Options:
      --K 3 (as int)
                        number of coverage components per gene (default 3, the
                        Torino paper's value for its three-region brain cohort;
                        it used 10 across 18 GTEx tissues)
      --min-counts 100 (as int)
                        summed depth below which a sample is dropped before
                        factorization (default 100)
      --merge-n auto
                        bases summed per matrix column, or auto (default) to
                        choose from the gene's width
      --seed 1 (as int)
                        random seed for the factorization (default 1)
      --gene-chunks 1 (as int)
                        must match the value given to torino_2
  torino_4:
    Workflow Options:
      --genes VAL (as path, required)
                        gene BED given to torino_2
      --max-missing 0.1 (as float)
                        largest fraction of samples a kept component may be
                        missing (default 0.1)
      --min-usage-q90 0.1 (as float)
                        smallest 90th-percentile usage a kept component may have
                        (default 0.1)

Workflow implementation

Read coverage

torino_1 writes each BAM’s per-base read depth as a bgzipped, tabix-indexed bedGraph with torino_coverage.sh. Spliced reads add depth to the exons they cover and none to the intron they skip. An unstranded library gives one file per sample; a stranded one gives a plus-strand and a minus-strand file, so genes that overlap on opposite strands are kept apart.

Per-gene depth matrices

torino_2 cuts every gene in --genes, with --flank bases on either side, out of the coverage files with torino_count_matrix.R, and writes one samples-by-bases CSV per gene. A gene is written only when at least --min-samples samples have a summed depth of --min-counts over it; the rest are listed, with the reason, in the chunk’s .skipped.tsv. --gene-chunks splits the gene list into that many jobs.

Factorization

torino_3 factorizes each gene’s matrix into --K coverage components with torino_factorize.R, one job per gene. Samples below --min-counts are dropped, and --merge-n auto sums consecutive bases in groups of 3, 9 or 30 above 15 kb, 60 kb and 1 Mb to bound memory. The gene list is read from the chunk lists torino_2 wrote, so the two steps must use the same --output-prefix and --gene-chunks.

Usage tables

torino_4 collects every gene’s component usages into a cohort phenotype table with torino_usage.R, and writes a normalized copy restricted to components with at most --max-missing missing samples and a 90th-percentile usage of at least --min-usage-q90, together with the component-to-gene grouping.

References
  1. Buen Abad Najar, C. F., Xie, D., Feng, R., Carbonetto, P., Cao, X., Li, H., Fang, L., Wang, G., Stephens, M., & Li, Y. I. (2026). Reference-free isoform discovery links unannotated RNA processing to disease risk. openRxiv. 10.64898/2026.10.21.760529