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 alternative splicing from RNA-seq data

Quantifies alternative splicing from aligned RNA-seq with LeafCutter, producing the intron-usage tables that become splicing phenotypes.

Overview

This module turns aligned RNA-seq into splicing phenotypes. It expects BAM files already mapped with STAR using the WASP option, following the GTEx/TOPMed RNA-seq pipeline; the choice of modules is supported by internal, unpublished benchmarks from the GTEx group.

Splicing is quantified as alternatively excised intron usage, in the sense described by Wang et al. (2008) and Park et al. (2018).

  • leafcutter quantifies the usage of alternatively excised introns. Junctions are extracted from each BAM with regtools, then clustered across samples: introns sharing a splice site are grouped, and each intron is reported as a fraction of the reads in its cluster. That single measure collectively captures skipped exons, alternative 5-prime and 3-prime splice site usage, and more complex events, without needing to name the event type Li et al. (2018). The clustering defaults, --min-clu-ratio 0.001 --max-intron-len 500000 --min-clu-reads 30, are those of the GTEx sQTL discovery pipeline, section 3.4.3. This is the approach previously applied to ROSMAP data for Brain xQTL version 2.0.

  • leafcutter_preprocessing is not a separate method but the first half of leafcutter. The two share one section, declared as [leafcutter_1, leafcutter_preprocessing_1], and this workflow stops once the list of per-sample .junc files is written, which is exactly the file leafcutter would go on to cluster. Run it only when the clustering is done elsewhere.

When to run it. After STAR alignment, and before splicing_normalization, which turns the intron-usage tables produced here into the splicing phenotype matrices used for sQTL association.

Input

  • --samples -- the sample manifest, white-space delimited with a header and four columns: sample ID, RNA strandness, the BAM path used by leafcutter, and the SJ.out.tab path. Strandness is rf, fr, or strand_missing:

    sample_id strand bam_list SJ_list
    sample_1 rf sample_1.Aligned.sortedByCoord.out.bam sample_1.SJ.out.tab
    sample_2 fr sample_2.Aligned.sortedByCoord.out.bam sample_2.SJ.out.tab
    sample_3 strand_missing sample_3.Aligned.sortedByCoord.out.bam sample_3.SJ.out.tab
  • --data-dir -- directory holding the files named in the manifest; defaults to the directory containing --samples. Every file listed must be found there. If .bam.bai indexes already sit beside the BAMs, LeafCutter reuses them rather than re-indexing.

  • --cwd -- output directory, default output.

  • --container -- the tool image, oras://ghcr.io/statfungen/leafcutter_apptainer:latest.

Junction extraction (leafcutter, leafcutter_preprocessing):

  • --anchor-len -- minimum anchor length on each side of a junction, default 8.

  • --min-intron-len -- shortest intron considered, default 50.

  • --max-intron-len -- longest intron considered, default 500000.

Intron clustering (leafcutter):

  • --min-clu-reads -- minimum reads in a cluster, default 30.

  • --min-clu-ratio -- minimum fraction of cluster reads supporting a junction, default 0.001.

Reference data and example input for this module are not in the repository. The reference data is built by reference_data_preparation, and the example inputs, a manifest and a LeafCutter blacklist-chromosome file, are on Google Drive.

Runtime:

  • --numThreads, --job-size, --walltime, --mem -- threads (default 8) and cluster resources.

  • --modular-script-dir -- location of the shell and R drivers, default code/script.

Output

  • <sample>.junc -- per-sample junction files extracted from the BAMs by regtools, written by both LeafCutter workflows.

  • <samples>_intron_usage_perind.counts.gz -- the LeafCutter splicing phenotype: one row per intron, keyed chrom:start:end:clu_N, giving the fraction of that cluster reads supporting the intron in each sample.

  • <samples>_intron_usage_perind_numers.counts.gz -- the same rows as raw supporting-read counts rather than ratios.

  • <samples>_pooled and <samples>_refined -- intermediate cluster definitions written during clustering.

  • <samples>_intron_usage_perind.junc -- the list of per-sample .junc files. It is the final output of leafcutter_preprocessing, and leafcutter writes the same file on its way to clustering, although it declares only the counts file as its output, so SoS does not track this one.

Each step also writes .stdout and .stderr beside its output. There is no example output for this module in the repository, because its inputs are aligned BAM files that are not distributed here.

The intron-usage table feeds splicing_normalization, which builds the final splicing phenotype matrices.

Minimal Working Example

LeafCutter intron usage

Extract junctions from every BAM and cluster them into intron-excision ratios. Around 30 minutes on a full sample set.

Timing: TBD (on toy dataset)

LeafCutter junction extraction only

The first half of the leafcutter command above, stopping once the list of .junc files is written. leafcutter writes that same list itself, so this workflow is worth running on its own only when the clustering happens elsewhere.

Timing: TBD (on toy dataset)

Command Interface

usage: sos run pipeline/splicing_calling.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:
  leafcutter
  leafcutter_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 meta data list
  --data-dir  path(f"{samples:d}")

                        Raw data directory, default to the same directory as
                        sample list
  --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 8 (as int)
                        Number of threads
  --container ''
                        Software container option

Sections
  leafcutter_1, leafcutter_preprocessing_1:
    Workflow Options:
      --anchor-len 8 (as int)
                        anchor length (default 8)
      --min-intron-len 50 (as int)
                        minimum intron length to be analyzed (default 50)
      --max-intron-len 500000 (as int)
                        maximum intron length to be analyzed (default 500000)
  leafcutter_2:
    Workflow Options:
      --min-clu-reads 30 (as int)
                        minimum reads in a cluster (default 50 reads)
      --max-intron-len 500000 (as int)
                        maximum intron length to be analyzed (default 500000)
      --min-clu-ratio 0.001 (as float)
                        minimum fraction of reads in a cluster that support a
                        junction (default 0.001)
  leafcutter_preprocessing_2:

Workflow implementation

LeafCutter: junction extraction and clustering

Documentation: LeafCutter; the regtools parameter choices are discussed here. leafcutter_1 extracts junctions from each BAM, leafcutter_2 clusters them into intron-usage ratios, and leafcutter_preprocessing_2 writes the junction list instead of clustering. The underlying clustering script has further options this module does not expose, among them reusing an existing cluster file, skipping the chromosome-name check, and including constitutive introns.

References
  1. Wang, E. T., Sandberg, R., Luo, S., Khrebtukova, I., Zhang, L., Mayr, C., Kingsmore, S. F., Schroth, G. P., & Burge, C. B. (2008). Alternative isoform regulation in human tissue transcriptomes. Nature, 456(7221), 470–476. 10.1038/nature07509
  2. Park, E., Pan, Z., Zhang, Z., Lin, L., & Xing, Y. (2018). The Expanding Landscape of Alternative Splicing Variation in Human Populations. The American Journal of Human Genetics, 102(1), 11–26. 10.1016/j.ajhg.2017.11.002
  3. Li, Y. I., Knowles, D. A., Humphrey, J., Barbeira, A. N., Dickinson, S. P., Im, H. K., & Pritchard, J. K. (2017). Annotation-free quantification of RNA splicing using LeafCutter. Nature Genetics, 50(1), 151–158. 10.1038/s41588-017-0004-9