一個完整的RNA-seq分析pipeline之HISAT2+ StrintTie+ Ballgown以及StringTie和Kallisto的比較(包括得到FPKM、TPM、readscounts)...
最重要的參考連結
- https://pmbio.org/course/#module-06-rnaseq
- github連結:https://github.com/griffithlab/rnaseq_tutorial
- 由於可能國內進不去,我這裡將關鍵程式碼儲存下來。
目錄截圖
- 得到FPKM、TPM、Readscounts
cd /workspace/rnaseq/ref-only-expression
wget https://raw.githubusercontent.com/griffithlab/rnaseq_tutorial/master/scripts/stringtie_expression_matrix.pl
chmod +x stringtie_expression_matrix.pl
./stringtie_expression_matrix.pl --expression_metric=TPM --result_dirs='RNAseq_Norm_Lane1,RNAseq_Norm_Lane2,RNAseq_Tumor_Lane1,RNAseq_Tumor_Lane2' --transcript_matrix_file=transcript_tpm_all_samples.tsv --gene_matrix_file=gene_tpm_all_samples.tsv
./stringtie_expression_matrix.pl --expression_metric=FPKM --result_dirs='RNAseq_Norm_Lane1,RNAseq_Norm_Lane2,RNAseq_Tumor_Lane1,RNAseq_Tumor_Lane2' --transcript_matrix_file=transcript_fpkm_all_samples.tsv --gene_matrix_file=gene_fpkm_all_samples.tsv
./stringtie_expression_matrix.pl --expression_metric=Coverage --result_dirs='RNAseq_Norm_Lane1,RNAseq_Norm_Lane2,RNAseq_Tumor_Lane1,RNAseq_Tumor_Lane2' --transcript_matrix_file=transcript_coverage_all_samples.tsv --gene_matrix_file=gene_coverage_all_samples.tsv
head transcript_tpm_all_samples.tsv gene_tpm_all_samples.tsv
- Ballgown差異分析程式碼
# change working directory
cd /workspace/rnaseq/
# start R
R
# In R, run the following commands
library(ballgown)
library(genefilter)
library(dplyr)
library(devtools)
# create the phenotype data for each sample
#pheno_data = read.csv("RNA_data.csv")
pheno_data <- data.frame(ids=c("RNAseq_Norm", "RNAseq_Norm_Lane1", "RNAseq_Norm_Lane2", "RNAseq_Tumor", "RNAseq_Tumor_Lane1", "RNAseq_Tumor_Lane2"), type=c("normal", "normal", "normal", "tumor", "tumor", "tumor"))
# Load ballgown data structures for each sample
bg = ballgown(dataDir = "ballgown", samplePattern = "RNAseq", pData=pheno_data)
# Filter low-abundance genes
bg_filt = subset (bg,"rowVars(texpr(bg)) > 1", genomesubset=TRUE)
# Identify signficant differently expressed Transcripts
results_transcripts = stattest(bg_filt, feature="transcript", covariate="type", getFC=TRUE, meas="FPKM")
# Identify significant differently expressed Genes
results_genes = stattest(bg_filt, feature="gene", covariate="type", getFC=TRUE, meas="FPKM")
# Add transcript/gene names and transcript/gene IDs to the results_transcripts data frame
results_transcripts = data.frame(transcriptNames=ballgown::transcriptNames(bg_filt),transcriptIDs=ballgown::transcriptIDs(bg_filt),geneNames=ballgown::geneNames(bg_filt),geneIDs=ballgown::geneIDs(bg_filt),results_transcripts)
# Add common gene names on
tmp <- unique(results_transcripts[,c("geneNames", "geneIDs")])
results_genes <- merge(results_genes, tmp, by.x=c("id"), by.y=c("geneIDs"), all.x=TRUE)
# Sort from the smallest P value to largest
results_transcripts = arrange(results_transcripts,pval)
results_genes = arrange(results_genes,pval)
# Output as CSV
write.csv(results_transcripts,"RNAseq_transcript_results.csv",row.names=FALSE)
write.csv(results_genes,"RNAseq_genes_results.csv",row.names=FALSE)
# Output as TSV
write.table(results_transcripts,"RNAseq_transcript_results.tsv",sep="\t", quote=FALSE, row.names=FALSE)
write.table(results_genes,"RNAseq_gene_results.tsv",sep="\t", quote=FALSE, row.names=FALSE)
# Identify genes with p value < 0.05
subset(results_transcripts,results_transcripts$pval<0.05)
subset(results_genes,results_genes$pval<0.05)
# quit R
q()
- 差異分析視覺化
# start R
R
# set the working directory
setwd("~/workspace/rnaseq")
# load libraries
library(ggplot2)
library(viridis)
# load in the ballgown DE data
de_genes <- read.delim("RNAseq_gene_results.tsv")
# load in the FPKM values from stringtie
expr_tumor <- read.delim("~/workspace/rnaseq/ballgown/RNAseq_Tumor_gene_abundance.out")
# merge the expression and DE results
merged_results <- merge(de_genes, expr_tumor, by.x=c("id"), by.y=c("Gene.ID"), all.x=TRUE)
# log2 the fold change
merged_results$log2_fc <- log2(as.numeric(merged_results$fc))
# remove entries with an FPKM of 0
merged_results <- merged_results[merged_results$FPKM > 1,]
# create an MA plot for both genes and transcripts
pdf(file="ma_plot.pdf", height=5, width=10)
ggplot(data=merged_results) + geom_point(aes(y=log2_fc, x=FPKM, color=qval)) + ylim(c(-10, 10)) + xlim(c(0, 1000)) + scale_colour_viridis(direction=-1, trans='sqrt') + theme_bw() + xlab("FPKM") + ylab("log2 Fold Change")
dev.off()
相關文章
- 一個完整的RNA-seq分析pipeline
- flutter仿boss直聘,一個比較完整的例子(一)Flutter
- 一個比較完整的Inno Setup 安裝指令碼指令碼
- 索引的分析和比較索引
- 幾個分析函式的比較函式
- 一個字串比較的題字串
- Go和Python比較的話,哪個比較好?GoPython
- 幾個比較火的BI分析工具
- Java物件之間的比較之equals和==Java物件
- MVC、MVP和MVVM以及MVA比較MVCMVPMVVM
- 給大家分享一個案例分析-比較偏僻
- java 中日期比較以及日期的增加和減少Java
- 一個不錯的關於mysql和posgresql比較的帖子MySql
- 一個較完整的RMAN增量備份指令碼指令碼
- 學習asp.net比較完整的流程ASP.NET
- Mysql 一個比較好用的函式MySql函式
- 一個比較好的shell指令碼指令碼
- 一個比較好的oracle blogOracle
- 一個比較麻煩的限流需求
- Lock的獨佔鎖和共享鎖的比較分析
- Java,Go和Rust之間的比較 - DexterJavaGoRust
- js中各個型別之間的比較JS型別
- 一個比較float是否相等的工具類
- tar 命令一個比較有用的引數
- Jetty 的工作原理以及與 Tomcat 的比較JettyTomcat
- 【原創】InnoDB 和TokuDB的讀寫分析與比較
- ejb 和 javabean的比較JavaBean
- ImageMagic 和 GraphicsMagick 的比較
- netty原始碼分析之pipeline(一)Netty原始碼
- 探討一個比較複雜的查詢
- 一個比較好用的分頁控制元件控制元件
- Tweetolife:Twitter上的性別和時間比較分析
- Memcached 及 Redis 架構分析和比較Redis架構
- js 深比較和淺比較JS
- awk的一個比較不錯的總結網頁網頁
- TreeMap和HashMap的元素比較HashMap
- JPA和mybatis的CRUD比較MyBatis
- Wordpress 和 Movable Type 的比較