MarioniLab / miloR

R package implementation of Milo for testing for differential abundance in KNN graphs
https://bioconductor.org/packages/release/bioc/html/miloR.html
GNU General Public License v3.0
316 stars 20 forks source link

Mixed effects models with contrasts #297

Closed HJ234 closed 7 months ago

HJ234 commented 7 months ago

Thank you for the new feature allowing a mixed effect model in milo. I have a dataset with samples collected at 3 timepoints from the same individuals ,and the mixed effect model seems to work nicely for this study design. I was just wondering if it's possible to use contrasts in the model to compare the timepoints. For instance, making a neighbourhood graph made with cells from all 3 timepoints, modelling the individual(donor) as the random effect variable (design = ~ timepoint + (1|individual)), and then comparing the first timepoint to the second timepoint (contrast = "timepoint1 - timepoint2").

Does the current mixed effect model allow the use of contrasts? if not, can this be an additional feature in the near future? Thanks!

MikeDMorgan commented 7 months ago

Hi @HJ234 - I haven't yet implemented contrasts for the GLMM, it's on my long to-do list. In the meantime, you can create a new variable to capture the relevant contrasts instead. For example, comparing timepoint1 and timepoint2, these contain 1 and -1, and timepoint3 would be 0 in this new variable. I hope that makes sense!

HJ234 commented 7 months ago

Great idea. That makes sense. I'll try that for my dataset. Thank you!