RGLab / MAST

Tools and methods for analysis of single cell assay data in R
224 stars 57 forks source link

Multiple variables, single coefficient #163

Closed kanefos closed 3 years ago

kanefos commented 3 years ago

Hi there authors, Firstly big fan of MAST, really nice tool.

I am working with 3 categorical time point (TP) conditions: TP1, TP2 and TP3. I am looking for changes in expression across all three timepoints. Namely, H0: the 3 timepoints are identical vs. H1: there is a difference between them. I am essentially trying to replicate what is described here.

Having fit the model zlmCond using zlm() with TP1 as the reference variable, I then try to extract data thusly:

How do I extract a single coefficient for TP2 and TP3 versus TP1 to match the P-value?

I think this is mostly a question about how to extract from the LMlike class so I haven't included more code but I can if needed.

Many thanks, Kane

amcdavid commented 3 years ago
  1. I would do a 2-degree of freedom test, lrTest(zlmCond, 'condition') to test your null hypothesis. This drops the entire time point term from the model. The test you specified would test if (TP3 + TP2 - 2*TP1) = 0, which is equivalent to testing of (TP2-TP1)/2 + (TP3-TP1)/2 = 0, ie, the average change is zero. This is different from testing if any timepoint is different.

  2. You can extract the specific coefficients with coef(zlmCond, 'C') and/or coef(zlmCond, 'D'). If you need to extract other contrasts at the moment you'll have to do the algebra yourself.

On Jul 20, 2021, at 8:55 AM, Kane @.***> wrote:

Hi there authors, Firstly big fan of MAST, really nice tool.

I am working with 3 categorical time point (TP) conditions: TP1, TP2 and TP3. I am looking for changes in expression across all three timepoints. Namely, H0: the 3 timepoints are identical vs. H1: there is a difference between them. I am essentially trying to replicate what is described here https://github.com/HelenaLC/muscat/issues/34.

Having fit the model zlmCond using zlm() with TP1 as the reference variable, I then try to extract data thusly:

lrTest(zlmCond, Hypothesis("conditionTP2+conditionTP3")) yields the hurdle P-value summary(zlmCond, logLik=Hypothesis("conditionTP2+conditionTP3"))$datatable yields the coefficients for conditions TP2 and TP3. How do I extract a single coefficient for TP2 and TP3 versus TP1 to match the P-value?

I think this is mostly a question about how to extract from the LMlike class so I haven't included more code but I can if needed.

Many thanks, Kane

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RGLab/MAST/issues/163, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLAHQGKQ52WOO2JHXDAZ3TYVW3XANCNFSM5AVX2PMQ.

kanefos commented 3 years ago

Hi Andrew - that's perfect, thank you. I feel like I have a basic understand of models now but getting it into R is still tricky. Thanks again