Hi everyone,
I'm fairly new to coding and I've recently run into some trouble with my for loop for DESeq2 in R. Apologies if this is a dumb question!
To give some background, I have many different columns in my colData that I want to loop through one at a time for DESeq2 design, however, whenever I try to, it gives me an error "Error in validObject(object) : invalid class “DESeqDataSet” object: all variables in design formula must be columns in colData"
I would appreciate any insight if possible. Thank you so much. Not the best coder in the world.. (but I'm enjoying learning :) )
edit: colnames is this, where X1, X2, X3..n are different columns in the colData:
colnames
1 x1
2 x2
3 x3
For loop:
test <- for (i in colnames$colnames) {
variable <- i
dds_del <- DESeqDataSet(del, design = ~ variable) #also tried [i] but it doesn't work
design(dds_del) = ~ print(variable) #also tried this but doesn't work
dds_del <- estimateSizeFactors(dds_del)
dssvaLRT = DESeq(ddssva)
shuffledres = list(results(ddssvaLRT_dup))
}
what is the solution?