Question: Factoring analysis and better design
0
gravatar for arabella23
2.8 years ago by
arabella230
arabella230 wrote:

Hi Michael and other DESeq2 users,

My dilemma is setting the best analysis for this design. 

I have been trying the following code:

dds <-DESeqDataSetFromMatrix(countData=counttable, colData=colData, design= ~group)

dds <- DESeq (dds)

This works but I want to take account the patient so making a paired design. 

So I did this:

design(dds) <- ~ group + patient

then rerun DESeq again,

I got the model matrix not full rank error. I would like to do a paired analysis where I have to compare CondA_7 of a specific subject to CondA_0 of the same patient, CondA_63 of the same patient vs CondA_0 of the same patient then compare them as a group afterwards versus other groups, taking account the time and the condition for each.So I tried this:

mm1 <- model.matrix(~ group + group:patient, colData)

mm1
idx <- which(colSums(mm1 == 0) == nrow(mm1))
mm1 <- mm1[,-idx]
mm1
mm0 <- model.matrix(~ group, colData)
colnames(mm1)

dds <- estimateSizeFactors(dds)
dds <- estimateDispersionsGeneEst(dds, modelMatrix=mm1)

error: inv(): matrix seems singular
Error: inv(): matrix seems singular

dds <- estimateDispersionsFit(dds)

found already estimated fitted dispersions, removing these

dds <- estimateDispersionsMAP(dds, modelMatrix=mm1)

found already estimated dispersions, removing these
using supplied model matrix
dds <- nbinomLRT(dds, full=mm1, reduced=mm0)

using supplied model matrix
found results columns, replacing these
3 rows did not converge in beta, labelled in mcols(object)$fullBetaConv. Use larger maxit argument with nbinomLRT

Did I run it correctly? What am I missing? I have search on most paired analysis and tried most of them but I think I am missing a great point to make this work. Im currently using DESeq2 v. 1.12.3.

 

Here is the colData:

colData

        sampleName patient condition time group
A16_6_12_12 A16 CondA Day0 CondADay0
A16_6_19_12 A16 CondA Day7 CondADay7
A16_8_14_12 A16 CondA Day63 CondADay63
A77_3_25_13 A77 CondA Day0 CondADay0
A77_4_1_13 A77 CondA Day7 CondADay7
A77_5_28_13 A77 CondA Day63 CondADay63
A25_4_17_13 A25 CondA Day0 CondADay0
A25_4_24_13 A25 CondA Day7 CondADay7
A25_6_19_13 A25 CondA Day63 CondADay63
A74_6_3_13 A74 CondA Day0 CondADay0
A74_6_10_13 A74 CondA Day7 CondADay7
A\74_8_5_13 A74 CondA Day63 CondADay63
A29_7_31_13 A29 CondA Day0 CondADay0
A29_8_7_13 A29 CondA Day7 CondADay7
A29_10_2_13 A29 CondA Day63 CondADay63
A85_6_6_12 A85 CondB Day0 CondBDay0
A85_6_13_12 A85 CondB Day7 CondBDay7
A85_8_8_12 A85 CondB Day63 CondBDay63
A23_7_9_12 A23 CondB Day0 CondBDay0
A23_7_18_12 A23 CondB Day7 CondBDay7
A23_9_10_12 A23 CondB Day63 CondBDay63
A84_3_26_13 A84 CondB Day0 CondBDay0
A84_4_2_13 A84 CondB Day7 CondBDay7
A84_5_28_13 A84 CondB Day63 CondBDay63
A79_5_21_13 A79 CondB Day0 CondBDay0
A79_5_28_13 A79 CondB Day7 CondBDay7
A79_7_23_13 A79 CondB Day63 CondBDay63
A34_6_17_13 A34 CondB Day0 CondBDay0
A34_6_24_13 A34 CondB Day7 CondBDay7
A34_8_19_13 A34 CondB Day63 CondBDay63
A87_6_6_12 A87 CondC Day0 CondCDay0
A87_6_13_12 A87 CondC Day7 CondCDay7
A87_8_8_12 A87 CondC Day63 CondCDay63
A54_8_27_12 A54 CondC Day0 CondCDay0
A54_9_4_12 A54 CondC Day7 CondCDay7
A54_10_29_12 A54 CondC Day63 CondCDay63
A87_4_15_13 A87 CondC Day0 CondCDay0
A87_4_22_13 A87 CondC Day7 CondCDay7
A87_6_17_13 A87 CondC Day63 CondCDay63
A32_5_29_13 A32 CondC Day0 CondCDay0
A32_6_5_13 A32 CondC Day7 CondCDay7
A32_7_31_13 A32 CondC Day63 CondCDay63
A26_7_29_13 A26 CondC Day0 CondCDay0
A26_8_5_13 A26 CondC Day7 CondCDay7
A26_9_30_13 A26 CondC Day63 CondCDay63
A86_6_6_12 A86 CondD Day0 CondDDay0
A86_6_13_12 A86 CondD Day7 CondDDay7
A86_8_8_12 A86 CondD Day63 CondDDay63
A01_7_31_12 A01 CondD Day0 CondDDay0
A01_8_7_12 A01 CondD Day7 CondDDay7
A01_10_2_12 A01 CondD Day63 CondDDay63
A86_4_15 A86 CondD Day0 CondDDay0
A86_4_22_13 A86 CondD Day7 CondDDay7
A86_6_17_13 A86 CondD Day63 CondDDay63
A15_5_28_13 A15 CondD Day0 CondDDay0
A15_6_4_13 A15 CondD Day7 CondDDay7
A15_7_30_13 A15 CondD Day63 CondDDay63
A46_6_24_13 A46 CondD Day0 CondDDay0
A46_7_1_13 A46 CondD Day7 CondDDay7
A46_8_26_13 A46 CondD Day63 CondDDay63

Thank you!

deseq deseq2 • 551 views
ADD COMMENTlink modified 2.8 years ago • written 2.8 years ago by arabella230
Answer: Factoring analysis and better design
2
gravatar for Michael Love
2.8 years ago by
Michael Love23k
United States
Michael Love23k wrote:

I'd first recommend that you have three separate variables for use in the design. You already have 'time' and 'patient' and likewise create 'condition' with levels A,B,C,D.

Secondly, you need to make sure all three of these are factor. Time should be a factor with three levels: 0, 7, 63.

Then you can follow the advice in the vignette in Section 3.12 “Model matrix not full rank"

It begins with: 

"Consider an experiment with grouped individuals, where we seek to test the group-specific effect of a treatment, while controlling for individual effects."

The vignette describes group, individual and condition. For your experiment, these are A,B,C,D (what you have called condition), patient, and time. You will have to create a nested variable for the patient variable as in the vignette example. Do you have equal number of patients in each condition?

ADD COMMENTlink written 2.8 years ago by Michael Love23k
Answer: Factoring analysis and better design
0
gravatar for arabella23
2.8 years ago by
arabella230
arabella230 wrote:

Hi Mike,

I checked all and they are factors. Yes they also do have equal number of patients in each condition which is 5 patients, 3 time points.

This is what I did:

condition=factor(colData$condition)

time=factor(colData$time)
patient=factor(colData$patient)

> class (time)
[1] "factor"
> class(condition)
[1] "factor"
> class(patient)
[1] "factor"

Then I ran them all again for DESeqDataSetFromMatrix with this design.

dds<-DESeqDataSetFromMatrix(countData=counttable,
                           colData=colData,
                           design=~time+condition+patient)

Still didn't work,

Then I tried similar to the vignette,

colData$ind.n<-factor(rep(rep(1:2,each=3),10))
model.matrix(~group+group:ind.n+group:condition, colData)

dds<-DESeqDataSetFromMatrix(countData=counttable,
                            colData=colData,
                            design=~group+group:ind.n+group:condition)

 

Same problem, what am I missing out?

Thanks.

 

      
   
ADD COMMENTlink modified 2.8 years ago • written 2.8 years ago by arabella230
Answer: Factoring analysis and better design
0
gravatar for arabella23
2.8 years ago by
arabella230
arabella230 wrote:

I think I figured out, I will just make a nested design at the end. Thanks.

ADD COMMENTlink modified 2.8 years ago • written 2.8 years ago by arabella230
Answer: Factoring analysis and better design
0
gravatar for arabella23
2.8 years ago by
arabella230
arabella230 wrote:

Another question:

Am I correct that log2Foldchange >1 means that the output given by DESeq2 is a fold change of 2. 

 

Is there also a way of getting a ratio of fold change in DESeq wherein after doing the contrast of a group you like, I can also compare the ratio of two fold changes among each other and get DEgenes?

CondADay7vsCondADay0<-results(dds, contrast=c('group','CondADay7', 'CondADay0'))

CondDDay7vsCondDDay0<-results(dds, contrast=c('group','CondDDay7', 'CondDDay0'))

then

CondADay7 vs CondDay0 / CondDDay7 vs CondDDay0

ADD COMMENTlink written 2.8 years ago by arabella230

A note on the support site: you are posting "Answers" to the original question (your first post) when what you want to do is post comments to my answer, if you want to receive follow up information.

I can help a bit with how to use the software, but in the end, to interpret the results you may need to work with a statistician who can help to interpret linear model coefficients. The coefficients from the design I recommended in my answer allow you to test for different day effects across condition A-D and also to contrast the day comparisons across condition. Can you post the code you are using and the resultsNames(dds) that you get when you follow the recommendation in my original answer?

ADD REPLYlink modified 2.8 years ago • written 2.8 years ago by Michael Love23k
Answer: Factoring analysis and better design
0
gravatar for arabella23
2.8 years ago by
arabella230
arabella230 wrote:

A colleague of mine suggested to add another column called nested.patient then the design will be nested.patient+group, is this correct?Can you explain why not design= ~group+nested.patient?

 sampleName patient condition time group nested.patient
A16_6_12_12 A16 CondA Day0 CondADay0 A
A16_6_19_12 A16 CondA Day7 CondADay7 A
A16_8_14_12 A16 CondA Day63 CondADay63 A
A77_3_25_13 A77 CondA Day0 CondADay0 B
A77_4_1_13 A77 CondA Day7 CondADay7 B
A77_5_28_13 A77 CondA Day63 CondADay63 B
A25_4_17_13 A25 CondA Day0 CondADay0 C
A25_4_24_13 A25 CondA Day7 CondADay7 C
A25_6_19_13 A25 CondA Day63 CondADay63 C
A74_6_3_13 A74 CondA Day0 CondADay0 D
A74_6_10_13 A74 CondA Day7 CondADay7 D
A\74_8_5_13 A74 CondA Day63 CondADay63 D
A29_7_31_13 A29 CondA Day0 CondADay0 E
A29_8_7_13 A29 CondA Day7 CondADay7 E
A29_10_2_13 A29 CondA Day63 CondADay63 E
A85_6_6_12 A85 CondB Day0 CondBDay0 A
A85_6_13_12 A85 CondB Day7 CondBDay7 A
A85_8_8_12 A85 CondB Day63 CondBDay63 A
A23_7_9_12 A23 CondB Day0 CondBDay0 B
A23_7_18_12 A23 CondB Day7 CondBDay7 B
A23_9_10_12 A23 CondB Day63 CondBDay63 B
A84_3_26_13 A84 CondB Day0 CondBDay0 C
A84_4_2_13 A84 CondB Day7 CondBDay7 C
A84_5_28_13 A84 CondB Day63 CondBDay63 C
A79_5_21_13 A79 CondB Day0 CondBDay0 D
           
....          

 

ADD COMMENTlink written 2.8 years ago by arabella230

hi,

You are still posting *Answers* to your own original question. It makes it hard to follow the conversation. Try comments instead in the future.

You are talking about using a different design than the one that's in the vignette. Why use the one in the vignette rather than ~nested.patient + group? Because you said you wanted to "compare them as a group afterwards versus other groups, taking account the time and the condition for each". It's easy to accomplish this using the design I recommended, which would have an interaction between time and condition.

ADD REPLYlink modified 2.8 years ago • written 2.8 years ago by Michael Love23k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 198 users visited in the last hour