Factor levels and Differential Expression analysis: Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels
1
0
Entering edit mode
bak16 • 0
@bak16-23268
Last seen 4.0 years ago

Hi,

I am a relatively novice bioinformatician and want to perform differential expression on my RNASeq data (12 treatment groups with 6 replicates of each). I have built a sample table:

Sample_Table <- data.frame(Sample = samples, 
                           FileName = files, 
                           Treatment = Treatment, 
                           Cell = Cell, 
                           Type = Type, 
                           Replicate = Replicate)

and then the DESeq dataset from my HTSeqcount outputs:

dds <- DESeqDataSetFromHTSeqCount(sampleTable = Sample_Table,
                                            directory = directory,
                                            design = ~Treatment)   

Then, I have tried to filter, subset my dataset and run differential expression on the subset:

dds_V <- dds[,dds$Treatment=="Vehicle"]
keep <- rowSums (counts (dds_V, normalized = TRUE)>=50) >=3
dds_V <- dds_V[keep,]
dds_V$Treatment <- droplevels(dds_V$Treatment)
dds_V$Cell <- relevel(dds_V$Cell,ref = "T") 
dds_V <- DESeq(dds_V)

Unfortunately this returns the message: 'Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels'.

I have also tried:

dds_V <- dds[,dds$Treatment=="Vehicle"]
keep <- rowSums (counts (dds_V, normalized = TRUE)>=50) >=3
dds_V <- dds_V[keep,]
dds_V$Cell <- factor(dds_V$Cell, levels = c("T","M"))
dds_V <- DESeq(dds_V)

which returns this: 'Error in designAndArgChecker(object, betaPrior) : full model matrix is less than full rank'.

I understand there seems to be a problem with recognising the 2 factors but I can't seem to find a way round it. I'd be really grateful if anyone has any suggestions on how to proceed.

Thank you

deseq2 • 2.6k views
ADD COMMENT
1
Entering edit mode
@mikelove
Last seen 3 hours ago
United States

DESeq2 is for differential analysis.

DE analysis can't be performed without a minimum of two groups as specified by the design.

This is the problematic line where you remove all samples except for vehicle.

dds_V <- dds[,dds$Treatment=="Vehicle"]

If you did this subsetting before DESeqDataSet, it would also tell you that you can't perform DE on samples without any difference among them, as specified by your design.

ADD COMMENT
0
Entering edit mode

Thanks so much for this, Michael.

The 'vehicle' samples actually comprise 2 different cell types, which are what I'd like to look at the differential expression of. I labelled my sample table as follows:

samples <- gsub("htseq_|.txt", "",files)
Treatment <- ifelse(grepl("DSSV",samples),"Vehicle", 
                    (ifelse(grepl("DSSE2",samples), "E2", 
                    (ifelse(grepl("VP",samples), "P",
                    (ifelse(grepl("VR",samples), "R",
                    (ifelse(grepl("EP",samples), "EP", "ER")))))))))
Cell <- ifelse(grepl("47",samples), "T", "M")                
Type <- ifelse(grepl("47",samples), "Wildtype", "Mutant")
Replicate <- str_sub(samples, -1, -1)

The output I get for:

dds_V <- dds[,dds$Treatment=="Vehicle"]

is:

class: DESeqDataSet 
dim: 6 12 
metadata(1): version
assays(1): counts
rownames(6): ENSG00000000003.15 ENSG00000000419.12 ... ENSG00000001036.14
  ENSG00000001084.13
rowData names(0):
colnames(12): T1 T2 ... M3 M4
colData names(5): Treatment Cell Type Replicate sizeFactor

So ddsV contains 12 samples, T1-6 and M1-6 (all vehicle-treated) as I'd expect. But how do I then perform DE on ddsV (i.e. between vehicle-treated samples T1-6 and M1-6)?

Thank you again

ADD REPLY
0
Entering edit mode

Hi,

I'd recommend working with a statistician on the design part. I can help with software usage questions but how to specify the correct design is beyond the level of support I can provide. I just don't have extra time in my schedule to work out statistical analysis plans.

You told DESeq2 the design is ~treatment but then you only give samples belonging to one level of treatment, so DESeq2 can't "see" the other aspects of the variables that are of interest for modeling differences.

ADD REPLY
0
Entering edit mode

Ok, thank you for your help

ADD REPLY

Login before adding your answer.

Traffic: 565 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6