如何在DESeq2中索引设计公式元素?

问题描述 投票:0回答:2

这里是一个例子:

cts<-matrix(sample(1:1000, 600, replace = T), ncol=6)
rownames(cts)<-paste0("Gene", 1:100)
colnames(cts)<-paste0("sample", 1:6)

coldat<-data.frame(B=c(1,2,1,2,1,2),
                   C=c(1,1,1,2,2,2))
rownames(coldat)<-colnames(cts)

library(DESeq2)
batch="B"
condition="C"
dds <- DESeqDataSetFromMatrix(countData = cts,
                              colData = coldat,
                              design= ~ batch + condition)
dds <- DESeq(dds)
Error in DESeqDataSet(se, design = design, ignoreRank) : 
all variables in design formula must be columns in colData

我的问题是如何在batch="B"公式中为condition="C"design编制索引。

r
2个回答
0
投票

问题是batch中没有明确声明conditioncoldat。如果B=batchC=condition,则可以简单地~ B+C。否则,您将需要添加2列。

coldat$batch <- coldat$B
coldat$condition <- coldat$C

或者,如果不同的话

coldat$batch <- c(1,2,3,4,5,6)
coldat$condition <- c(1,1,1,2,2,2)

0
投票

刚想出:

dds <- DESeqDataSetFromMatrix(countData = cts,
                              colData = coldat,
                              design= as.formula(paste0("~", batch, "+", condition)))
© www.soinside.com 2019 - 2024. All rights reserved.