Hi I'm having some trouble figuring out how to work with continuous covariate.
The manual states that continuous covariates should be treads in a same manner as factorial covariates, but R seems to not like my code.
I have 3 patients, 2 replicates, total of 6 samples.
This is how my sampleTable looks like:
sample | fileName | patient | condition | nested | treatment_time |
A_untreated | A_untreated | A | untreated | 1 | 30 |
A_treated | A_treated | A | treated | 1 | 30 |
B_untreated | B_untreated | B | untreated | 2 | 45 |
B_treated | B_treated | B | treated | 2 | 45 |
C_untreated | C_untreated | C | untreated | 3 | 41 |
D_treated | D_treated | C | treated | 3 | 41 |
My goal is to perform a paired analysis, comparing between two condition of the same individual patient, including treatment time as continuous covariate.
Below is my code:
sampleTable <- data.frame(sample=samples$Sample, fileName=samples$Sample, patient = samples$Patient, condition=samples$Condition, nested=samples$Nested,treatment_time=samples$treatment_Time)
sampleTable$patient <- relevel(sampleTable$patient, ref="A")
sampleTable$condition <- relevel(sampleTable$condition, ref="untreated")
directory = "PATH"
dds <- DESeqDataSetFromHTSeqCount(sampleTable=sampleTable, directory=directory, design= ~1)
model = model.matrix(~nested:condition + ischemic_time:condition + condition, colData(dds))
I get an error as following:
Error in checkForExperimentalReplicates(object, modelMatrix) :
same number of samples and coefficients to fit with supplied model matrix
I have a couple of questions:
1) I don't understand why my model is making an error.
2) For the DE results, what resultsNames should I compare to accomplish the goal?
Thank you very much in advance.
Yes, and to follow up, you should just use a design of
~patient + condition
, if you are just interested in testing the effect of condition.As a 'nuisance parameter'
patient
here controls for both patient effect and difference due to treatment time, because they are confounded.