qiime2 / q2-longitudinal

QIIME 2 plugin for paired sample comparisons
BSD 3-Clause "New" or "Revised" License
9 stars 18 forks source link

added LME formula parameter #125

Closed nbokulich closed 5 years ago

nbokulich commented 5 years ago

Description

R-like formulae can now be input, in place of using lists of group_columns. For example, these two commands are equal (this is confirmed by unit tests):

linear_mixed_effects(
    state_column='month',
    group_columns='delivery,diet,antiexposedall',
    individual_id_column='studyid',
    metric='observed_otus')

linear_mixed_effects(
    state_column='month',
    formula='observed_otus ~ month * delivery * diet * antiexposedall'    
    individual_id_column='studyid')

That's useful for folks more comfortable with R-style formulae. Great. But group_columns includes all interactions between variables as terms in our model! So formulae allow us to specify much more explicit and complex models, e.g.:

observed_otus ~ month * delivery * peanuts + diet + month:diet - month:delivery

Notes

I have added a bunch of unit tests to cover formula validation, etc. However, these formulae can get pretty complex and I don't have much experience with working with more complex formulae... so there is probably room for improvement. Let me know if you want to see more unit tests!

thermokarst commented 5 years ago

@nbokulich: can you fix the conflict?

nbokulich commented 5 years ago

@thermokarst conflict: resolved

nbokulich commented 5 years ago

okay @thermokarst formula parsing is modernized. I have tested this manually with all reasonable edge cases I can think of.

nbokulich commented 5 years ago

thanks @thermokarst ! The formula now appears in the summary