I am quite new to RNA analysis and currently, trying to analyze my RNA-seq data with 19 samples using DESeq2 package. My coldata has three batches alongside my phenotype. I would like to assign all four columns into the design function.
dds <- DESeqDataSetFromMatrix(countData = X[,2:20],
colData = as.data.frame(coldat),
design = ~ Phenotype + Sequencer+ Bacth1+ Batch2)
Sample Phenotype Sequencer Batch1 Batch2 S1 S 1 in AS S2 C 1 in AM S3 C 1 in AM S4 C 1 in AM S5 C 1 in AM S6 C 1 in AM S7 C 1 in AM S8 C 1 in AM S9 S 1 in MP S10 C 1 in MA S11 C 1 in MA S12 C 1 in MA S13 C 1 in MA S14 C 1 in MA S15 S 2 out RS S16 S 2 out RH S17 S 2 out AS S18 S 2 out RH S19 S 2 out RH
However, as expected, it produces a matrix where some levels are "without samples". I have followed the instruction of “Model matrix not full rank” in the vignette(DESeq2) and produced a matrix and removed the all zero columns.
cd <- model.matrix(~ Phenotype*Sequencer*Batch1*Batch2, coldat) all.zero <- apply(cd, 2, function(x) all(x==0)) idx <- which(all.zero) cd <- cd[, -idx]
I try to integrate the produced matrix into "full" argument of DESeq like this:
dds <- DESeqDataSetFromMatrix(countData = X[,2:20], colData = as.data.frame(coldat), design = ~ Phenotype + Sequencer) dds <- DESeq(dds, test = "Wald", betaPrior = FALSE, full =design(cd), reduced = ~ Phenotype+Batch1+Batch2)
However, I am receiving this error
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘design’ for signature ‘"matrix"’
I am not sure how I have to proceed, so appreciate it if someone can help me in this regard.