前面的步骤是这样的:
library(limma)
#limma计算
## 1.创建设计矩阵和对比
group_list <- c(rep("Relaps",2),rep("Control",3))
table(group_list)
design <- model.matrix(~0+factor(group_list))
comp <- 'Relaps-Control'#第一个Relaps比第二个Control
cont.matrix <- makeContrasts(contrasts=c(comp),levels = design)
使用limma包进行分析的过程中,出现的问题:
Error in makeContrasts(contrasts = c(comp), levels = design) :
The levels must by syntactically valid names in R, see help(make.names). Non-valid names: factor(group_list)Control,factor(group_list)Relaps
原因是我没有对design这个列名进行命名,它和cont.matrix不一样
design 列名自动生成是这样的解决方法:design这个列名和cont.matrix 保持一致
colnames(design) <- c("Control","Relaps")
修改后的design
cont.matrix
再继续从这里开始
comp <- 'Relaps-Control'#第一个Relaps比第二个Control
cont.matrix <- makeContrasts(contrasts=c(comp),levels = design)
#filter_value
colnames(filter_value) <- c("Control_1","Control_2","Control_3","Relaps_1","Relaps_2")
## 2.构建edgeR的DGEList对象,并归一化,拟合模型
dge <- DGEList(counts=filter_value)
dge <- calcNormFactors(dge)
v <- voom(dge,design,plot=TRUE, normalize="quantile")
fit <- lmFit(v, design)
fit2 <- contrasts.fit(fit,cont.matrix)
fit2 <- eBayes(fit2)
fit2 <- eBayes(fit2)
tmp <- topTable(fit2, coef=comp, n=Inf,adjust.method="BH")
C123_R34_limma_voom <- na.omit(tmp)
网友评论