这是原帖http://www.bio-info-trainee.com/2218.html
http://www.bio-info-trainee.com/2218.html
准备工作:
安装WSL,并将源换成国内源;
在D盘建立文件夹bs用来放生信软件,文件夹data用来放下载的数据,data下建立文件夹fastq用来放测序数据,gtf用来放注释文件,hg19用来放index文件,map用来放比对排序等文件。
1、数据下载
数据在GEO地址是:https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE50177,可知RNA-Seq数据为:
Run Sample
SRR957680 siSUZ12_BiolRep2
SRR957679 siSUZ12_BiolRep1
SRR957678 siCtrl_BiolRep2
SRR957677 siCtrl_BiolRep1
for i in {77..80}; do wget ftp://ftp-trace.ncbi.nlm.nih.gov ... /SRR/SRR957/SRR9576${i}/SRR9576{i}.sra; done
2、数据处理
(1)安装软件
wget https://ftp-trace.ncbi.nlm.nih.g ... 2-1-ubuntu64.tar.gz
tar -zxvf sratoolkit.2.8.2-1-ubuntu64.tar.gz
echo ‘PATH =$PATH:/mnt/d/bs/sratoolkit.2.8.1-1/bin’ >> ~/.bashrc
source ~/.bashrc
(2)将sra文件转化为fastq格式
for i in {77..80};do fastq-dump --gzip --split-3 -O /mnt/d/data/fastq -A /mnt/d/data/SRR9576${i}.sra;done
(3)下载安装FastQC软件
sudo apt install fastqc
(4)对fastq文件进行质控
ls *.gz | while read id; do fastqc $id -o /mnt/d/data/fastqc -t 4; done
3、序列比对
(1)下载index文件:
wget -c ftp://ftp.ccb.jhu.edu/pub/infphilo/hisat2/data/hg19.tar.gz
tar zxvf hg19.tar.gz
(2)下载安装hisat2软件
sudo apt install hisat2
(3)正式比对
for i in {77..80};do hisat2 -t -x /mnt/d/data/hg19/genome -U /mnt/d/data/fastq/SRR9576{i}.sam;done
(4)下载安装SAMtools软件
sudo apt install samtools
(5)SAMtools转换为bam排序
for i in {77..80}; do samtools view -S SRR9576{i}.bam; samtools sort SRR9576{i}_sorted.bam; samtools index SRR9576${i}_sorted.bam; done
4、reads计数
(1)下载安装HTSeq-count软件
sudo apt-get install python-numpy python-matplotlib python-pysam python-htseq
(2)下载注释文件
wget ftp://ftp.sanger.ac.uk/pub/genco ... 7.annotation.gtf.gz
gzip -d gencode.v26lift37.annotation.gtf.gz
(3)htseq-count计数
for i in {77..80}; do htseq-count -s no -f bam /mnt/d/data/map/SRR9576{i}.count; done
(4)合成表达矩阵(在R中操作)
(i)分别读取count文件
options(stringsAsFactors = FALSE)
m_control_1<-read.table("d:/data/map/SRR957677.count",sep="\t",col.names=c("gene_id","m_control1"))
m_control_2<-read.table("d:/data/map/SRR957678.count",sep="\t",col.names=c("gene_id","m_control2"))
m_case_1<-read.table("d:/data/map/SRR957679.count",sep="\t",col.names=c("gene_id","m_suz1"))
m_case_2<-read.table("d:/data/map/SRR957680.count",sep="\t",col.names=c("gene_id","m_suz2"))
(ii)按照gene_id合并
m_raw_count<-merge(merge(m_control_1,m_control_2,by="gene_id"),merge(m_case_1,m_case_2,by="gene_id"))
write.csv(m_raw_count,file="d:/data/map/m_raw_count.txt",quote=FALSE,row.names=FALSE) #见附件
(iii)简单分析
summary(m_raw_count)
5、差异表达分析(在R中进行操作)
(1)安装DESeq2
install.packages("BiocManager")
BiocManager::install("DESeq2")
BiocManager::install("GenomeInfoDbData")
library(DESeq2)
(2)差异表达分析
database<-read.table(file="d:/data/map/m_raw_count.txt",sep=",",header=T,row.names=1)
database<-round(as.matrix(database))
condition<-factor(c(rep("control",2),rep("suz",2)),levels=c("control","suz"))
coldata<-data.frame(row.names=colnames(database),condition)
dds<-DESeqDataSetFromMatrix(countData=database,colData=coldata,design=~condition)
dds <- dds[rowSums(counts(dds))>1,]
dds <- DESeq(dds)
res <- results(dds)
(3)提取差异分析结果
res <- res[order(res$padj),]
diff_gene <- subset(res,padj<0.05 & (log2FoldChange>1 | log2FoldChange < -1))
diff_gene <- row.names(diff_gene)
resdata <- merge(as.data.frame(res),as.data.frame(counts(dds,normalized=TRUE)),by="row.names",sort=FALSE)
write.csv(resdata,file="d:/data/map/control_vs_suz.csv",row.names=F) #得到csv格式的差异表达分析结果
到此运行正常,但后续用clusterProfiler做富集分析时出错,出错提示见附图。请教一下是哪一步有错误?