DESeq2差異分析

need:表達矩陣 分組矩陣,值要是整數(shù)



DESeq2和EdgeR都可用于做基因差異表達分析,主要也是用于RNA-Seq數(shù)據(jù),同樣也可以處理類似的ChIP-Seq,shRNA以及質譜數(shù)據(jù)。

這兩個都屬于R包,其相同點在于都是對count data數(shù)據(jù)進行處理,都是基于負二項分布模型。因此會發(fā)現(xiàn),用兩者處理同一組數(shù)據(jù),最后在相同閾值下篩選出的大部分基因都是一樣的,但是有一部分不同應該是由于其估計離散度的不同方法所導致的。



library(DESeq2)

library(limma)

library(pasilla)#示例數(shù)據(jù)包

data(pasillaGenes)

exprSet=counts(pasillaGenes)? ##做好表達矩陣


group_list=pasillaGenes$condition##做好分組因子即可


(colData <- data.frame(row.names=colnames(exprSet), group_list=group_list))


dds <- DESeqDataSetFromMatrix(countData = exprSet,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? colData = colData,#Rows of colData correspond to columns of countData

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? design = ~ group_list)


##上面是第一步第一步,構建dds這個對象,需要一個表達矩陣分組矩陣?。?!

dds2 <- DESeq(dds)? ##第二步,直接用DESeq函數(shù)即可

resultsNames(dds2)#results extracts a result table from a DESeq analysis giving base means across samples,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? log2 fold changes, standard errors, test statistics, p-values and adjusted p-values;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? resultsNames returns the names of the estimated effects (coefficents) of the model;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? removeResults returns a DESeqDataSet object with results columns removed.

res <-? results(dds2, contrast=c("group_list","treated","untreated"))#this argument specifies what comparison to extract from the object to build a results table

## 提取你想要的差異分析結果,我們這里是treated組對untreated組進行比較


resOrdered <- res[order(res$padj),]#padj排序


resOrdered=as.data.frame(resOrdered)


可以看到程序非常好用!

它只對RNA-seq的基因的reads的counts數(shù)進行分析,請不要用RPKM等經過了normlization的表達矩陣來分析。

值得一提的是DESeq2軟件獨有的normlization方法!

rld <- rlogTransformation(dds2)? ## 得到經過DESeq2軟件normlization的表達矩陣!

exprSet_new=assay(rld)


par(cex = 0.7)#指定符號的大小

n.sample=ncol(exprSet)#樣本數(shù)

if(n.sample>40) par(cex = 0.5)

cols <- rainbow(n.sample*1.2)

par(mfrow=c(2,2))

boxplot(exprSet, col = cols,main="expression value",las=2)

boxplot(exprSet_new, col = cols,main="expression value",las=2)

hist(exprSet)

hist(exprSet_new)


第一張圖也是箱型圖

看這個圖就知道了,它把本來應該是數(shù)據(jù)離散程度非常大的RNA-seq的基因的reads的counts矩陣經過normlization后變成了類似于芯片表達數(shù)據(jù)的表達矩陣,然后其實可以直接用T檢驗來找差異基因了!

但是,如果你的分組不只是兩個,就復雜了,你需要再仔細研讀說明書,甚至你可能需要咨詢實驗設計人員或者統(tǒng)計人員!

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容