macでインフォマティクス

macでインフォマティクス

HTS (NGS) 関連のインフォマティクス情報についてまとめています。

大規模RNA-seqから差次的オルタナティブスプライシングを検出する rMATS-turbo

2026/10/06 追記

 

pre-mRNAの選択的スプライシング(alternative splicing)は、真核生物のトランスクリプトームおよびプロテオームの多様性を生み出す主要な機構である。制御された選択的スプライシングは、多くの生物学的プロセスに関与しており、その制御異常は多くのヒト疾患にみられる特徴である。現在、ショートリードRNAシーケンシング(RNA-seq)は、トランスクリプトーム全体を対象とした選択的スプライシング解析の標準的な手法となっている。2011年以来、本著者らの研究室では、RNA-seqデータから選択的スプライシングイベントを検出し、定量化するための計算ツールであるReplicate Multivariate Analysis of Transcript Splicing(rMATS)を開発・維持してきた。

本稿では、現在のrMATSであるrMATS-turboの使用プロトコルを提供する。rMATS-turboは、従来のrMATSソフトウェアの統計的枠組みとユーザーインターフェースを維持しながら、高速かつ大規模解析に対応できるよう再実装されたものであり、計算ワークフローを刷新することで、処理速度とデータ保存効率を大幅に向上させている。rMATS-turboは、数万サンプルを含む非常に大規模なRNA-seqデータセットにも対応可能である。rMATS-turboの有用性を示すため、本稿では2つの代表的な利用例について説明する。第一に、2つのサンプル群の間で差のある選択的スプライシングイベントを同定する、幅広く応用可能な2群比較解析について説明する。この解析では、既知のアノテーション済み選択的スプライシングイベントだけでなく、新規の選択的スプライシングイベントも対象とする。第二に、約1,000サンプルからなる大規模RNA-seqデータセットにおける選択的スプライシングの定量解析について説明する。この解析には、異なる細胞状態と関連する選択的スプライシングイベントの発見も含まれる。さらに、大規模RNA-seqデータセットを計算クラスター上で効率よく並列処理・解析するための、rMATS-turboのワークフローおよび各種機能について詳しく説明する。本プロトコルによって、幅広いrMATS-turboユーザーが本ソフトウェアを最大限に活用し、多様な生物学的システムにおける選択的スプライシング研究に役立てられることを期待している。

 

インストール

mambaで環境を作ってテストした。

Github

mamba create -n rmats-turbo -c conda-forge -c bioconda rmats samtools
conda activate rmats-turbo

> rmats.py -h

usage: rmats.py [options]

 

options:

  -h, --help            show this help message and exit

  --version             show program's version number and exit

  --gtf GTF             An annotation of genes and transcripts in GTF format

  --b1 B1               A text file containing a comma separated list of the BAM files for sample_1. (Only if using BAM)

  --b2 B2               A text file containing a comma separated list of the BAM files for sample_2. (Only if using BAM)

  --s1 S1               A text file containing a comma separated list of the FASTQ files for sample_1. If using paired reads the format is ":" to separate pairs and "," to separate replicates. (Only if using fastq)

  --s2 S2               A text file containing a comma separated list of the FASTQ files for sample_2. If using paired reads the format is ":" to separate pairs and "," to separate replicates. (Only if using fastq)

  --od OD               The directory for final output from the post step

  --tmp TMP             The directory for intermediate output such as ".rmats" files from the prep step

  -t {paired,single}    Type of read used in the analysis: either "paired" for paired-end data or "single" for single-end data. Default: paired

  --libType {fr-unstranded,fr-firststrand,fr-secondstrand}

                        Library type. Use fr-firststrand or fr-secondstrand for strand-specific data. Only relevant to the prep step, not the post step. Default: fr-unstranded

  --readLength READLENGTH

                        The length of each read. Required parameter, with the value set according to the RNA-seq read length

  --variable-read-length

                        Allow reads with lengths that differ from --readLength to be processed. --readLength will still be used to determine IncFormLen and SkipFormLen

  --anchorLength ANCHORLENGTH

                        The "anchor length" or "overhang length" used when counting the number of reads spanning splice junctions. A minimum number of "anchor length" nucleotides must be mapped to each end of a given splice junction. The minimum value is 1 and the default value is set

                        to 1 to make use of all possible splice junction reads.

  --tophatAnchor TOPHATANCHOR

                        The "anchor length" or "overhang length" used in the aligner. At least "anchor length" nucleotides must be mapped to each end of a given splice junction. The default is 1. (Only if using fastq)

  --bi BINDEX           The directory name of the STAR binary indices (name of the directory that contains the suffix array file). (Only if using fastq)

  --nthread NTHREAD     The number of threads. The optimal number of threads should be equal to the number of CPU cores. Default: 1

  --tstat TSTAT         The number of threads for the statistical model. If not set then the value of --nthread is used

  --cstat CSTAT         The cutoff splicing difference. The cutoff used in the null hypothesis test for differential alternative splicing. The default is 0.0001 for 0.01% difference. Valid: 0 <= cutoff < 1. Does not apply to the paired stats model

  --task {prep,post,both,inte,stat}

                        Specify which step(s) of rMATS-turbo to run. Default: both. prep: preprocess BAM files and generate .rmats files. post: load .rmats files into memory, detect and count alternative splicing events, and calculate P value (if not --statoff). both: prep + post.

                        inte (integrity): check that the BAM filenames recorded by the prep task(s) match the BAM filenames for the current command line. stat: run statistical test on existing output files

  --statoff             Skip the statistical analysis

  --paired-stats        Use the paired stats model

  --darts-model         Use the DARTS statistical model

  --darts-cutoff DARTS_CUTOFF

                        The cutoff of delta-PSI in the DARTS model. The output posterior probability is P(abs(delta_psi) > cutoff). The default is 0.05

  --novelSS             Enable detection of novel splice sites (unannotated splice sites). Default is no detection of novel splice sites

  --mil MIL             Minimum Intron Length. Only impacts --novelSS behavior. Default: 50

  --mel MEL             Maximum Exon Length. Only impacts --novelSS behavior. Default: 500

  --allow-clipping      Allow alignments with soft or hard clipping to be used

  --fixed-event-set FIXED_EVENT_SET

                        A directory containing fromGTF.[AS].txt files to be used instead of detecting a new set of events

  --individual-counts   Output individualCounts.[AS_Event].txt files and add the individual count columns to [AS_Event].MATS.JC.txt

 

実行方法

rMATS-turboは、RNA-seqデータから代替スプライシングイベントを検出し、2群間の差次的スプライシングを統計的に評価するツールである。入力には、splice-aware alignerで作成したBAMファイル、またはFASTQファイルとSTAR index、遺伝子アノテーションGTFを用いる。

 

2群それぞれのBAMファイルをカンマ区切りで書いたテキストファイルを用意する。

cat group1.txt
/path/to/group1_rep1.bam,/path/to/group1_rep2.bam 
cat group2.txt
/path/to/group2_rep1.bam,/path/to/group2_rep2.bam

FASTQから始める場合は、--s1、--s2にFASTQのリストを渡す。

 

テストラン

1遺伝子でエクソンが3つの小さな人工データを使う。

rmats.py --b1 generated_input/b1.txt --b2 generated_input/b2.txt --gtf generated_input/test.gtf -t paired --readLength 50 --libType fr-unstranded --nthread 4 --od rmats_out --tmp rmats_tmp
  • --gtf   An annotation of genes and transcripts in GTF format
  • --b1    A text file containing a comma separated list of the BAM files for sample_1. (Only if using BAM)
  • --b2    A text file containing a comma separated list of the BAM files for sample_2. (Only if using BAM)
  • --s1    A text file containing a comma separated list of the FASTQ files for sample_1. If using paired reads the format is ":" to separate pairs and "," to separate replicates. (Only if using fastq)
  • --s2    A text file containing a comma separated list of the FASTQ files for sample_2. If using paired reads the format is ":" to separate pairs and "," to separate replicates. (Only if using fastq)
  • --tmp   The directory for intermediate output such as ".rmats" files from the prep step
  • -t {paired,single}    Type of read used in the analysis: either "paired" for paired-end data or "single" for single-end data. Default: paired
  • --libType {fr-unstranded,fr-firststrand,fr-secondstrand}  Library type. Use fr-firststrand or fr-secondstrand for strand-specific data. Only relevant to the prep step, not the post step. Default: fr-unstranded

 

出力

出力として、skipped exon、alternative 5' splice site、alternative 3' splice site、mutually exclusive exon、retained intronの各イベントについて、junction count、junction + exon count、PSI、P値、FDRなどを含む表が得られる。

rmats_outが解析結果で、rmats_tmpは中間ファイル

rmats_out/

 

summary.txtがスプライシングの種類ごとの検出数や、有意差がある件数のまとめ

SE.MATS.JC.txtとSE.MATS.JCEC.txtにはエクソンスキッピングの比較結果がまとめられている。

 

SE.MATS.JC.txt

IncLevel1とIncLevel2は、それぞれ第1群と第2群の各サンプルにおける、比較対象のエクソンを含む割合を示す。今回の人工データには3つのエクソンがあり、2番目のエクソンが比較対象となる。各群に2サンプルあるため、カンマ区切りで2個並んでいる。IncLevel1: 1.0,1.0は第1群の両サンプルで包含率が100%、IncLevel2: 0.0,0.0は第2群の両サンプルで包含率が0%と推定されたことを意味する。包含率0%は、スプライシングが起きていないという意味ではなく、対象のエクソンが飛ばされていることを示す。

 

--b1と--b2でbamを指定してランする例。8スレッド指定、--individual-countsを指定し、各反復で得られたリードカウントも保存。結果はresultsに保存。解析途中の中間ファイルはtmpへ出力。マッピング済みのBAMを入力として用いるので、STARの参照インデックスを指定する--biは指定しない。

rmats.py --b1 control.txt --b2 RBFOX2_KD.txt --gtf gencode.v19.annotation.gtf -t paired --readLength 100 --libType fr-firststrand --nthread 8 --od results_user --tmp tmp --individual-counts
  • --od      The directory for final output from the post step

  • --tmp    The directory for intermediate output such as ".rmats" files from the prep step

  • -t {paired,single}   Type of read used in the analysis: either "paired" for paired-end data or "single" for single-end data. Default: paired

  • --libType {fr-unstranded,fr-firststrand,fr-secondstrand}

    Library type. Use fr-firststrand or fr-secondstrand for strand-specific data. Only relevant to the prep step, not the post step. Default: fr-unstranded

  • --readLength    The length of each read. Required parameter, with the value set according to the RNA-seq read length

  • --individual-counts    Output individualCounts.[AS_Event].txt files and add the individual count columns to [AS_Event].MATS.JC.txt
  • --nthread    The number of threads. The optimal number of threads should be equal to the number of CPU cores. Default: 1

データとして、ENCODEが公開しているK562細胞のRNA-seqデータのbamをダウンロードして用いた。これはRBFOX2(RNAに結合してオルタナティブスプライシングを調節するRNA結合タンパク質)をshRNAでノックダウンした2反復と、非標的shRNAを導入したコントロールの2反復となる。

https://www.encodeproject.org/experiments/ENCSR336DFS/

 

出力例

results/

 

summary,txt

対照群とRBFOX2ノックダウン群で、そのスプライシングの起こる割合に統計的な差があるサイトの数はイベントごとに整理されて報告される。本データでは、エクソンを含めるか飛ばすかの割合が変化するスキップエクソン(SE)イベントが最も多かった。

  • SE:29,267候補中482件が有意。
  • A5SS:2,833候補中51件が有意。
  • A3SS:4,683候補中69件が有意。
  • MXE:2,633候補中131件が有意。
  • RI:3,638候補中150件が有意。

それぞれ、スキップエクソン(SE)、選択的5'スプライス部位(A5SS)、選択的3'スプライス部位(A3SS)、相互排他的エクソン(MXE)、イントロン保持(RI)という5つの基本的な選択的スプライシングパターンとして報告される(マニュアルより)。

READMEより。 支持リード数は、ジャンクションリードのみ(JC)を用いてカウントすることも、ジャンクションリードとエクソンリードの両方(JCEC)を用いてカウントすることも可能。異なるカウント方法による出力ファイルは、ファイル名によって区別される(マニュアルより)。

 

その他、READMEより

  • rMATS-turboは従来のrMATSの統計的枠組みとユーザーインターフェースを保ちながら、計算ワークフローを刷新した高速・省容量な実装として設計されており、数千から数万サンプル規模のRNA-seqにも対応できる。
  • rMATS-turboは、数万サンプルを含む大規模RNA-seqデータセットまでスケール可能である。
  • 大規模データでは、--task prepでBAMごとの前処理を分散実行し、生成された.rmatsファイルを集めて--task postを実行できる。

  • rMATS-turboは、rMATSをC/Cythonで実装したバージョンである。rMATS-turboとrMATSの主な違いは、計算速度と必要な保存容量にある。rMATS-turboはrMATSより約100倍高速で、出力ファイルのサイズは約1/1000である。
  • リードカウント部分では、C/Cython版はPython版と比較して、1スレッドで20〜100倍高速である。統計解析部分では、6スレッド使用時に約300倍高速である。

  • --taskオプションを用いることで、rMATSのprepステップを、異なるBAMファイル群について独立に実行できる。その後、個別に生成された.rmatsファイルを用いてpostステップを実行できる。これにより、大規模RNA-seqデータセットを計算クラスター上で効率的に並列処理・解析することを可能にする。

引用

rMATS-turbo: an efficient and flexible computational tool for alternative splicing analysis of large-scale RNA-seq data

Yuanyuan Wang, Zhijie Xie, Eric Kutschera, Jenea I. Adams, Kathryn E. Kadash-Edmondson & Yi Xing 

Nature Protocols volume 19, pages1083–1104 (2024)