參考文獻:
Pertea M, Kim D,Pertea G M, et al. Transcript-level expression analysis of RNA-seq experimentswith HISAT, StringTie and Ballgown.[J]. Nature Protocols, 2016, 11(9):1650.
1.clean reads質量檢驗:
用fastqc檢驗clean reads質量,代碼如下:
fastqc -o 【待測序列所在目錄】--extract -f fastq *.fq.gz(序列名稱)
質檢結果:
所有序列的Kmer Content均爲FAIL,Per Base Sequence Content、Per Tile sequence quality、sequence duplication levels至少有一個WARN。
Per Base Sequence Content圖中四條線交織,表明存在overrepresented sequence:
猜測:轉錄組中,表達量高的reads被識別爲overrepresented sequence,屬於正常現象。
參考:http://www.cnblogs.com/longjianggu/p/5078782.html
2.製作索引(indexes):
在GENOSCOPE下載油菜基因組序列文件(.fa.gz)和基因組註釋文件(.gff3.gz):http://www.genoscope.cns.fr/brassicanapus/data/
hisat2-build /genome/GCF_000686985.1_Brassica_napus_assembly_v1.0_genomic.fna(基因組序列文件目錄) brassica_tran(索引名稱及輸出目錄)
3.序列比對(alignment):
原始代碼:
hisat2 -p(線程數) 16 --dta -x indexes/brassica_tran(索引文件目錄) -1 /data/CleanData/$reads1(reads1目錄) -2 /data/CleanData/$reads2(reads2目錄) -S /hisat2_results/$【sample name】.sam(輸出文件名稱及目錄)
每個樣本都需通過上述代碼進行比對,封裝成BASH腳本運行:
vi alignment(新建空白文檔alignment,以下代碼在vi中輸入)
#! /bin/bash
# run some hisat2 alignments
while read line
do
reads1=${line}_1.fq.gz
reads2=${line}_2.fq.gz
hisat2 -p 16 --dta -x /indexes/brassica_tran -1/data/CleanData/$reads1 -2 /data/CleanData/$reads2 -S/hisat2_results/${line}.sam
done </files/samples.txt(將樣本名稱按行寫在位於/files目錄下的samples.txt文件中)
<Esc>:wq保存退出
chmod +x alignment(賦予可執行權限)
nohup ./alignment & 後臺運行腳本,輸出結果將儲存在生成的nohup.log文件中
4.samtools排序及格式轉換
原始代碼:
samtools sort -@ 16 -o /data/bamfiles/【sample name】.bam(bam文件名稱及輸出目錄) /data/hisat2_results/【sample name】.sam(sam文件名稱及輸出目錄)
封裝成BASH腳本:
#! /bin/bash
# samtools sort
while read line
do
samtools sort -@ 16 -o/data/bamfiles/${line}.bam /data/hisat2_results/${line}.sam
done < /files/samples.txt
5.序列初組裝(assembly)
原始代碼:
stringtie -p 16 -G /genes/brassica.gff(基因組註釋文件) -o /data/transcripts/【sample name】.gtf(輸出,比對結果,gtf文件) -l 【sample name】(命名規則) /data/bamfiles/【sample name】.bam(輸入,bam文件所在目錄)
封裝成BASH腳本:
#! /bin/bash
# stringtie 1st step
while read line
do
stringtie -p 16 -G/genes/brassica.gff -o /data/transcripts/${line}.gtf -l ${line}/data/bamfiles/${line}.bam
done < /files/samples.txt
6.Merge
stringtie --merge -p 16 -G /genes/brassica.gff -o stringtie_merged.gtf/data/transcripts/mergelist.txt
gffcompare檢測組裝結果:
gffcompare -r /genes/brassica.gff -G -o merged stringtie_merged.gtf
7.計算表達量並輸出成ballgown格式
原始代碼:
stringtie -e -B -p 16 -G /data/transcripts/stringtie_merged.gtf(用merge生成的gtf文件代替基因組註釋) -o /data/ballgown/$【sample name】/$【sample name】.gtf(輸出爲ballgown所需的輸入格式) /data/bamfiles/【sample name】.bam(輸入,bam文件)
封裝成BASH腳本:
#! /bin/bash
# stringtie 3rd step
while read line
do
stringtie -e -B -p 16 -G/data/transcripts/stringtie_merged.gtf -o /data/ballgown/${line}/${line}.gtf/data/bamfiles/${line}.bam
done < /files/samples.txt
8.ballgown分析差異表達基因(在R中進行)
>install.packages(‘devtools’)
>source('http://www.bioconductor.org/biocLite.R')
>biocLite(c(’ballgown’, 'genefilter’,'dplyr’,'devtools’))
>library(ballgown)
>library(genefilter)
>library(dplyr)
>library(devtools)
>file <- ballgown(dataDir='/data/ballgown',samplePattern=【sample名前綴】)輸入基因表達數據
>samplesNames(file)查看ballgown文件中各樣本的排列順序
>pData(file) <- read.csv(‘/data/geuvadis_phenodata.csv’)(導入自制的表型數據)
>filefilt <-subset(file,'rowVars(texpr(file))>1',genomesubset=TRUE)(過濾掉表達差異較小的基因)
>diff_genes <- stattest(filefilt,feature='gene',covariate=【自變量】,adjustvars=【無關變量】,meas='FPKM')(統計差異表達的基因)
將差異表達基因按pval從小到大排序,並寫入csv文件:
>diff_genes <- arrange(diff_genes,pval)
>write.csv(diff_genes,'/data/diff_genes',row.names=FALSE)