这里是一个例子:
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
编制索引。
问题是batch
中没有明确声明condition
和coldat
。如果B=batch
和C=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)
刚想出:
dds <- DESeqDataSetFromMatrix(countData = cts,
colData = coldat,
design= as.formula(paste0("~", batch, "+", condition)))