Stringtie 自带一个脚本prepDE.py
用于计算转录组的 Raw Counts,用法如下:
Usage: prepDE.py [options]
Generates two CSV files containing the count matrices for genes and
transcripts, using the coverage values found in the output of `stringtie -e`
Options:
-h, --help show this help message and exit
-i INPUT, --input=INPUT, --in=INPUT
a folder containing all sample sub-directories, or a
text file with sample ID and path to its GTF file on
each line [default: ./]
-g G where to output the gene count matrix [default:
gene_count_matrix.csv
-t T where to output the transcript count matrix [default:
transcript_count_matrix.csv]
-l LENGTH, --length=LENGTH
the average read length [default: 75]
-p PATTERN, --pattern=PATTERN
a regular expression that selects the sample
subdirectories
-c, --cluster whether to cluster genes that overlap with different
gene IDs, ignoring ones with geneID pattern (see
below)
-s STRING, --string=STRING
if a different prefix is used for geneIDs assigned by
StringTie [default: MSTRG]
-k KEY, --key=KEY if clustering, what prefix to use for geneIDs assigned
by this script [default: prepG]
-v enable verbose processing
--legend=LEGEND if clustering, where to output the legend file mapping
transcripts to assigned geneIDs [default: legend.csv]
需要准备一个 2 列的文本文件,例如命名为all_gtf
,以Tab
键分隔,如:
sample1 sample1.gtf
sample2 sample2.gtf
...
第 1 列,样本名称
第 2 列,Stringtie 生成的 GTF 文件,要求运行 stringtie 的时候加
-e
参数
准备好后,运行:
$ prepDE.py -i all_gtf -v
不料却报以下错误:
Traceback (most recent call last):
File "/ifs/miniconda3/bin/prepDE.py", line 284, in <module>
geneDict.setdefault(geneIDs[i],{}) #gene_id
KeyError: 'ENST00000496112'
检查prepDE.py
的源代码无果,正一筹莫展时,突然想到输入prepDE.py
按Tab
键代码补全时,还显示有一个prepDE.py3
文件的存在,于是抱着试试看的心态,运行:
$ prepDE.py3 -i all_gtf -v
没报错。。。焦急等待中。。。最后输出如下结果:
..writing transcript_count_matrix.csv
..writing gene_count_matrix.csv
All done.
transcript_count_matrix.csv,转录本水平定量结果;
gene_count_matrix.csv,基因水平定量结果。
今天遇到这个坑是由于程序的版本造成的,换 Python3 版本的程序prepDE.py3
就好了。