5.1.1 edgeR

樣本無重復(fù)與DESeq2的對(duì)比如下參考文章:

http://www.itdecent.cn/p/517167c50a5f

參考文章:

http://www.itdecent.cn/p/4863beb3abf9
https://blog.csdn.net/u012110870/article/details/102804557

安裝R包

if (!requireNamespace("edgeR", quietly = TRUE))
    BiocManager::install("edgeR")

構(gòu)建DGEList,前期需準(zhǔn)備count矩陣,未經(jīng)過標(biāo)準(zhǔn)化的原始讀數(shù)

setwd("D:/")
expr_matrix <- read.csv("CK_count_matrix.csv")
head(expr_matrix)
counts <- expr_matrix[,2:3]
group <- 1:2
y <- DGEList(counts=counts, group = group)
y
##An object of class "DGEList"
$counts
  CK18 CK69
1 1214  724
2 1458 1317
3 2801  502
4  792 1168
5  486 1492
30451 more rows ...

$samples
     group lib.size norm.factors
CK18     1 89473310            1
CK69     2 70278971            1

過濾

keep <- rowSums(cpm(y)>1) >= 1
y <- y[keep, , keep.lib.sizes=FALSE]
y
#An object of class "DGEList"
#$counts
#  CK18 CK69
#1 1214  724
#2 1458 1317
#3 2801  502
#4  792 1168
#5  486 1492
#27624 more rows ...

$samples
     group lib.size norm.factors
CK18     1 89403338            1
CK69     2 70219884            1
#標(biāo)準(zhǔn)化
> y <- calcNormFactors(y)

差異表達(dá)分析

bcv <- 0.1
et <- exactTest(y_bcv, dispersion = bcv ^ 2)
gene1 <- decideTestsDGE(et, p.value = 0.05, lfc = 0)
summary(gene1)
#         2-1
#Down    6462
#NotSig 15076
#Up      6091

有重復(fù)分析

library(edgeR)
setwd("D:/")
expr_matrix <- read.csv("transcript_count_matrix.csv")
head(expr_matrix)
counts <- expr_matrix[,2:5]
group <- c("CK", "CK", "T", "T")
transcript <- expr_matrix[,1]
y <- DGEList(counts=counts, genes =transcript, group = group)
y

keep <- rowSums(cpm(y)>1) >= 1
y <- y[keep, , keep.lib.sizes=FALSE]
y

designMat <- model.matrix(~0+group);designMat
plotMDS(y, col=as.numeric(y$samples$group))
legend("bottomleft",as.character(unique(y$samples$group)), col=1:3, pch=20)

y <- estimateGLMCommonDisp(y,design=designMat)
y <- estimateGLMTrendedDisp(y, design=designMat)
y <- estimateGLMTagwiseDisp(y, design=designMat)
plotBCV(y)
fit <- glmFit(y, designMat)
lrt.1vs2 <- glmLRT(fit, contrast = c(1,0))
degs.res.1vs2 <- topTags(lrt.1vs2, n = Inf, adjust.method = 'BH', sort.by = 'PValue')
degs.res.1vs2[1:5, ]

deGenes.1vs2 <- decideTestsDGE(lrt.1vs2, p=0.05, lfc = 1)
summary(deGenes.1vs2)

detag <- rownames(lrt.1vs2)[as.logical(deGenes.1vs2)]
plotSmear(lrt.1vs2, de.tags=detag)
abline(h=c(-1, 1), col='blue')

countsPerMillion <- cpm(y)
countCheck <- countsPerMillion > 1
keep <- which(rowSums(countCheck) >= 2)
y.keep <- y[keep,]
dim(y.keep)

y.norm <- calcNormFactors(y.keep, method = 'TMM')
plotMDS(y.norm, col=as.numeric(y.normsamplesgroup))
legend("bottomleft",as.character(unique(y.normsamplesgroup)), col=1:3, pch=20)

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

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容