I have paired samples from cancer patients who were obese or not obese (labelled 'healthy'). Using 3.5 in edgeR to compare within and between samples.
I am able to compare within a condition i.e. comparing tumour to control in healthy patients or comparing tumour to control in obese patients. I am running into an error where I can't compare between healthy and obese samples.
I am trying to find 3 things:
- DE genes in healthy individuals
- DE genes in obese individuals
- DE genes between healthy and obese individuals
Sample of my edgeR code, I reduced the number of samples for readability.
type <- as.factor(c('benign', 'tumour', 'benign', 'tumour','benign', 'tumour','benign', 'tumour'))
y$samples$type <- type
patient <- factor(c(1,1,2,2,3,3,4,4))
y$samples$patient <- patient
condition <- as.factor(c('healthy','healthy','healthy','healthy', 'obese', 'obese','obese', 'obese'))
y$samples$condition <- condition
design <- model.matrix(~0+patient)
rownames(design) <- colnames(y)
Healthy.Tumour <- condition=="healthy" & type=="tumour"
Obese.Tumour <- condition=="obese" & type=="tumour"
design <- cbind(design, Healthy.Tumour, Obese.Tumour)
keep <- filterByExpr(y, design)
y <- y[keep,]
table(keep)
y <- calcNormFactors(y, method = "TMM")
y <- estimateDisp(y,design)
fit <- glmQLFit(y,design)
qlf_H <- glmQLFTest(fit, coef="Healthy.Tumour")
qlf_O <- glmQLFTest(fit, coef="Obese.Tumour")
qlf_O_vs_L <- glmQLFit(fit, contrast=c(0,0,0,0,-1,1))
This is the error code I get when running qlf_O_vs_L <- glmQLFit(fit, contrast=c(0,0,0,0,-1,1))
.
Error in dimnames(x$coefficients) <- value :
attempt to set an attribute on NULL
I am following the vignette, and I can see that there is no x$coefficients and I don't know how to get that attribute. In the vignette it references a target
dataframe and this may be the issue.
There is a $coefficients
which sits in fit$coefficients
, however adding that (as with below) it doesn't work.
qlf_O_vs_L <- glmQLFit(fit$coefficients, contrast=c(0,0,0,0,-1,1))
I am not sure... you have 8 samples but only reference 6 via
c(0,0,0,0,-1,1)
?From what I understood in the vignette, in the examples they had 9 paired samples (9 patients) and 3 different conditions (healthy, disease1, disease2) so when doing
glmQLFTest
(as with below) I think the first nine 0's correspond to the nine patients and the last three values0,-1,1
correspond to healthy, disease1, disease2 respectively, so I copied what was done. So the below compares disease1 and disease2.All these are guesses from playing around with edgeR. I have no idea how to get a
target
dataframe which matches the files for the samples. So perhaps the error is there, and I can't find in the vignette how thetarget
dataframe is created. All my sample details sit iny$samples
.That is not how contrasting works. You need one value for every sample = column in design. Also don't add the coefficients as you did, the
fit
alone is sufficient. Also consider usingmakeContrasts
which automates the contrasting based on the group names (colnames) in design. With your current design you compare individual patient sames, and one patient is even unreplicated. Can you clearly state which comparisons you want to make? Not with code, with words, then we can put a design for this together.I should have written that and I'll add it to the original post. I am trying to find 3 things:
I have used
makeContrasts
and it works, however I didn't know how to account that the samples were paired and the section in edgeR to compare within and between samples looked appropriate for this experiment.I have also corrected the unreplicated sample.