Skip to content

Instantly share code, notes, and snippets.

@ipurusho
Last active July 12, 2023 06:59
Show Gist options
  • Save ipurusho/26d0fe830a61b2a7c0c9caafcec56d92 to your computer and use it in GitHub Desktop.
Save ipurusho/26d0fe830a61b2a7c0c9caafcec56d92 to your computer and use it in GitHub Desktop.
Brief tutorial for using rMATS to conduct a pairwise differential splicing analysis

In order to perform a pairwise splicing analysis, sorted bam files per sample are needed as well as reference annotation in the form of a GTF file

###Download rMATS Download rMATS at http://rnaseq-mats.sourceforge.net/download.html

###Running rMATS Via python, you can run rMATs using the following example command:

python /path/to/rMATS/directory/RNASeq-MATS.py -b1 conditon1_replicate_1.bam,condition_1_replicate_2.bam -b2 condition_2_replicate_1.bam,condition_2_replicate_2.bam -gtf /path/to/gtf/file -o /path/to/results/directory -t single -len {read length}

Note:

  • -t should be changed to paired for paired-end reads
  • -b1 & -b2 are each a comma separated list of replicates per condition
  • Results will be in the directory specified by the -o flag in a subdirectory called MATS_output. Each splicing event p-values and inclusion difference can be found in files with the suffix .ReadsOnTargetAndJunctionCounts.txt. For example, SE.MATS.ReadsOnTargetAndJunctionCounts.txt is the skipped exon result

###Visualizing Results Installation Visualizations can be made in the form of Miso's Sashimi plots using a tool called rmats2sashimiplot. First, clone the git repository from https://github.com/Xinglab/rmats2sashimiplot.git, cd into the directory and perform python setup.py install

NOTE: Miso must be installed and in your path

Selecting Splice sites Since we are only visualizing a splicing event for a single gene, we need to run the command once per gene per splicing event. This requires greping the gene from the splicng event result file. For example, visualizing a gene's skipped exon events:

grep {gene name or ensembl id} SE.ReadsOnTargetAndJunctionCounts.txt > gene_SE.txt

Then:

/rmats/path/rmats2sashimiplot -b1 conditon1_replicate_1.bam,condition_1_replicate_2.bam -b2 condition_2_replicate_1.bam,condition_2_replicate_2.bam -e gene_SE.txt -t SE -l1 Condition_1_name -l2 Condition_2_name -o /path/to/output/directory

  • The -t flag is the splicing event you are investigating (SE, MXE, RI, etc...see rMATs documentation for an explanation of these)

  • The l1 and l2 flags are condition label names

  • The visualizations will be saved as PDFs

NOTE: unfortuantely rmats2sashimiplot requires the same number of replicates between condition 1 and condition 2. If you do not, have the same number of replicates, then it's imperative to merge all replicates to one bam file and perform the visualization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment