哈,三月是適合寫簡(jiǎn)書的月份~
這只是一篇短的心得,記錄自己剛剛遇到的問(wèn)題,供大家參考。
背景:
- 在用DESeq2做轉(zhuǎn)錄組差異基因,有幾個(gè)關(guān)注的marker基因想要畫圖展示;
- 這種情況可以用DESeq2包自帶的plotcounts功能,這里我利用這個(gè)功能輸出數(shù)據(jù),后面接ggplot2作圖;
- 想要把關(guān)注的3個(gè)基因的表達(dá)情況展示在一張圖上,嘗試了layout( )不成功;
- 找教程,安裝了Rmisc包,利用multiplot功能,但是操作時(shí)遇到了問(wèn)題。
詳細(xì)情況:
setwd('')
colData <- read.table('', sep="\t", header=TRUE, row.names=1)
readscount <- read.table('', sep="\t", header=TRUE, row.names=1)
condition <- factor(c( ))
batch <- factor(c())
library(DESeq2)
dds <- DESeqDataSetFromMatrix(readscount, colData, design =~ batch + condition)
dds <- DESeq(dds) #完成dds構(gòu)建和數(shù)據(jù)標(biāo)準(zhǔn)化
library(ggplot2)
library(Rmisc)
p1 <- plotCounts(dds,gene="ENSSSCG001",returnData=TRUE) #基因id不便透露,returndata是只返回?cái)?shù)據(jù)不作圖,將數(shù)據(jù)存儲(chǔ)于p1
pp1 <- ggplot(p1,aes(x=condition,y=count))+ #這里不可直接輸出ggplot圖形,而是要存儲(chǔ)于另一個(gè)變量,最后再用multiplot輸出,否則就會(huì)出錯(cuò)!
geom_boxplot(notch=F,aes(color=condition)) +
scale_y_log10() + ggtitle("GENE1") + xlab("") + ylab("") +
theme(plot.title=element_text(face="italic"),legend.position="none")+
theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank())+
theme(panel.background=element_blank()) +
theme(axis.line=element_line(color = "black"))
p2 <- plotCounts(dds,gene="ENSSSCG002",returnData=TRUE) #這里只用兩個(gè)基因舉例
pp2 <- ggplot(p2,aes(x=condition,y=count))+
geom_boxplot(notch=F,aes(color=condition)) +
scale_y_log10() + ggtitle("GENE2") + xlab("") + ylab("") +
theme(plot.title=element_text(face="italic"),legend.position="none")+
theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank())+
theme(panel.background=element_blank()) +
theme(axis.line=element_line(color = "black"))
multiplot(pp1,pp2,cols = 2) #輸出兩個(gè)圖形在一個(gè)頁(yè)面上,左右而不是上下形式。
所以最后我想說(shuō),一定要把ggplot圖形存起來(lái)最后輸出,否則會(huì)出錯(cuò)。
這是一個(gè)小白問(wèn)題,但是本著“一定不止我一個(gè)人遇到這歌問(wèn)題”的原則,寫出來(lái)分享給大家,小白可參考,同時(shí)期待大佬的指點(diǎn)。
一個(gè)問(wèn)題:這里用的dds按道理是標(biāo)準(zhǔn)化了的,但是實(shí)際看來(lái)并非如此。為什么?