我的矩阵mat
有C
和D
两组,每组4个样本,如列名所示。我想执行差分表达式分析。
首先,在分配groups
和design
之前,我缩放了数据。
library(limma)
mat <- apply(mat, 2, (x) {
x <- as.numeric(x)
(x - min(x)) / diff(range(x))
})
group <- factor(as.factor(gsub("_.*", "", colnames(mat))), levels=c("C", "D"))
design <- model.matrix(~group)
colnames(design) <- c("C","CvsD")
第二步:归一化和滤波
dge <- DGEList(counts=mat, group=group)
keep <- filterByExpr(dge, design)
dge <- calcNormFactors(dge[keep,,keep.lib.sizes=FALSE])
第三步:微分表达式
v <- voom(keep, design, plot=TRUE, normalize="quantile")
回溯:
Error in voom(dge, design, plot = TRUE, normalize = "quantile") :
Need at least two genes to fit a mean-variance trend
fit <- eBayes(lmFit(v, design))
fit <- treat(fit, lfc=log2(1.2))
topTreat(fit, coef=ncol(design))
dt <- decideTests(tfit)
summary(dt)
> summary(dt)
C - D
Down 0
NotSig 0
Up 1725
数据:
> dput(mat[1:10,])
structure(c(1.0275, 1.05, 0.55875, 0.78375, 0.7175, 0.76875,
0.70875, 0.63, 0.73125, 0.76875, 0.8675, 0.74, 0.54875, 0.71375,
0.6775, 0.64875, 0.61875, 0.63, 0.63125, 0.91875, 0.6775, 0.9,
0.64875, 0.70375, 0.6975, 0.69875, 0.64875, 0.76, 0.65125, 0.82875,
1.3075, 1.03, 0.81875, 1.06375, 0.8375, 0.91875, 0.99875, 1.03,
0.98125, 1.05875, 0.7225, 0.89, 0.59125, 0.70625, 0.6925, 0.64125,
0.63125, 0.64, 0.62875, 0.89125, 0.9625, 0.8, 0.60125, 0.77625,
0.7325, 0.72125, 0.76125, 0.8, 0.75875, 0.78125, 1.2925, 1.05,
0.75125, 0.91625, 0.8425, 0.86125, 0.86125, 0.83, 0.87875, 1.02125,
0.9025, 0.98, 0.63125, 0.86625, 0.6625, 0.81125, 0.72125, 0.78,
0.72875, 0.88125), dim = c(10L, 8L), dimnames = list(c("AAAS",
"AAK1", "AAMDC", "AARS", "AASDHPPT", "ABCD3", "ABCE1", "ABCF1",
"ABHD10", "ABI1"), c("C_1", "C_2", "C_3", "C_4", "D_5", "D_6",
"D_7", "D_8")))
缩放您的数据会删除有关计数大小及其均值-方差关系的任何信息,并使filterByExpr和整个测试过程无效。省略该步骤,并按照limma用户指南中的内容进行操作。缩放不是它的一部分,在这种情况下,它对计数数据没有意义。使用手册中描述的原始空间计数。你还应该确保化验确实产生了voom期望的数字计数,而不是其他任何东西。
一个提示:是在继续之前将filterByExpr
输出表化。在你提供的数据中,这删除了你所有的矩阵。
table(keep)
keep
FALSE
10
第二提示:是检查是否有计数数据