使用STAR构建参考基因组
之前我们使用了hisat2构建了参考基因组序列,现在主流的软件是hisat2和STAR
于是我又跟着潘师兄的教程,来走一遍转录组,这里使用的就是STAR
在这过程中我还是碰到了许多问题和要注意的点,来看一下吧
软件安装
还是老样子,使用conda安装SATR,但是我最开始不清楚conda能不能安装STAR,于是我先看一下conda里面有没有它
conda search star
Loading channels: done
# Name Version Build Channel
star 2.4.0j 0 anaconda/cloud/bioconda
star 2.4.0j 1 anaconda/cloud/bioconda
star 2.4.2a 0 anaconda/cloud/bioconda
star 2.5.0a 0 anaconda/cloud/bioconda
star 2.5.0b 0 anaconda/cloud/bioconda
star 2.5.0c 0 anaconda/cloud/bioconda
star 2.5.1b 0 anaconda/cloud/bioconda
star 2.5.2a 0 anaconda/cloud/bioconda
star 2.5.2b 0 anaconda/cloud/bioconda
star 2.5.3a 0 anaconda/cloud/bioconda
star 2.5.4a 0 anaconda/cloud/bioconda
star 2.6.0b 0 anaconda/cloud/bioconda
star 2.6.0c 0 anaconda/cloud/bioconda
star 2.6.0c 1 anaconda/cloud/bioconda
star 2.6.0c 2 anaconda/cloud/bioconda
star 2.6.1a 1 anaconda/cloud/bioconda
star 2.6.1b 0 anaconda/cloud/bioconda
star 2.6.1d 0 anaconda/cloud/bioconda
star 2.7.0b 0 anaconda/cloud/bioconda
star 2.7.0d 0 anaconda/cloud/bioconda
star 2.7.0e 0 anaconda/cloud/bioconda
star 2.7.0f 0 anaconda/cloud/bioconda
star 2.7.1a 0 anaconda/cloud/bioconda
star 2.7.2a 0 anaconda/cloud/bioconda
star 2.7.2b 0 anaconda/cloud/bioconda
star 2.7.2c 0 anaconda/cloud/bioconda
star 2.7.3a 0 anaconda/cloud/bioconda
我们就直接安装最新版本的就行了,下面我们用conda安装指定版本的STAR
用 = 指定version就i行了
conda install star=2.7.3a
构建参考基因组
数据准备
- 参考基因组序列
- 基因注释文件
这些文件我们在转录组数据准备里面已经说过了,这里就不赘述。
开始构建
STAR --runThreadN --runMode genomeGenerate \
--genomeDir \
--genomeFastaFiles \
--sjdbGTFfile \
–runThreadN 是指构建是使用的线程数,在没有其他数据在跑的情况下,可以满线程跑
–runMode genomeGenerate 让STAR执行基因组索引的生成工作
–genomeDir 构建好的参考基因组存放的位置,最好是单独建立的一个文件夹
–genomeFastaFiles 参考基因组序列文件
–sjdbGTFfile 基因注释文件
然后我们照着这个走一次
STAR --runThreadN 20 --runMode genomeGenerate \
--genomeDir /home/lyc/workspace4.21.20/data/ref \
--genomeFastaFiles /home/lyc/workspace4.21.20/data/ref/Homo_sapiens.GRCh38.dna.primary_assembly.fa \
--sjdbGTFfile /home/lyc/workspace4.21.20/data/ref/Homo_sapiens.GRCh38.99.gtf \
#打开htop监控
htop
#发现才挂上去的脚本,一下就结束了
cat Log.txt
#打开日志文件,得到如下报错
step1.biud_index.sh: line 4: --sjdbGTFfile: command not found
Apr 23 11:24:00 ..... started STAR run
Apr 23 11:24:00 ... starting to generate Genome files
EXITING because of INPUT ERROR: could not open genomeFastaFile:
Apr 23 11:24:31 ...... FATAL ERROR, exiting
这就很奇怪了,我明明是按照帮助文档来的啊
后来我发现,是因为在语句
--genomeFastaFiles /home/lyc/workspace4.21.20/data/ref/Homo_sapiens.GRCh38.dna.primary_assembly.fa \
后面多了一个空格,导致STAR能正常运行,所以敲代码的时候,一定要注意规范,这种小错误往往最致命且不容易被发现。
我在上面的脚本中已经删掉了这个空格,你可以直接复制粘贴使用了。
比对
我们来看一下比对的代码
STAR
--runThreadN 20 \
--genomeDir /home/lyc/workspace4.21.20/data/ref \
--readFilesCommand gunzip -c \
--readFilesIn /home/lyc/workspace4.21.20/data/cleandata/N052611_Alb_1.fastq.gz /home/lyc/workspace4.21.20/data/cleandata/N052611_Alb_2.fastq.gz \
--outSAMtype BAM SortedByCoordinate \
--outFileNamePrefix N052611_Alb \
–runThreadN 运行的线程数,根据自己的服务器合理选择
–genomeDir 构建的参考基因组位置
–readFilesCommand 对于gz压缩的文件,我们可以在后面添加 gunzip -c
–readFilesIn 输入文件的位置,对于双末端测序文件,用空格分隔开就行了
–outSAMtype 默认输出的是sam文件,我们这里的BAM SortedByCoordinate是让他输出为ban文件,并排序
–outFileNamePrefix 表示的是输出文件的位置和前缀
然后就是输出文件的问题,输出的文件不止一个,包含了比对过程中的一些信息
- Aligned.out.sam或者Aligned.out.bam
它指的就是我们的比对结果 - Log.progress.out
它是每分钟记录一次的对比情况 - Log.out
它记录了STAR程序在运行中的各种情况,当我们的结果出现异常时,我们可以查看具体的运行情况,来查找错误 - Log.final.out
它包含的是对比完以后的对比统计信息 - SJ.out.tab
它包含了剪切的信息