On this line, MaAsLin2 removes fixed effects that are also included as random effects. My understanding is that it is not uncommon to include a features as both a fixed effect and a random effect, as this remove the fixed intercept assumption when fitting the linear model. Granted, there seem to be plenty of definitions of fixed and random effects, so the most likely explanation is a disconnect on my end…
Why does MaAsLin2 not allow features to be both fixed and random effects? To get around this issue, I duplicated a column (
z) in my metadata, adding one as a fixed effect as a random effect and the other as a fixed effect. In both cases, the fit in the
ranef.rds was identical:
but in the case where it was included as a fixed effect, three genera (Escherichia, Enterococcus, and Ruminococcus) were shown to be deferentially abundant.
In the case where z was only included as a fixed effect, four genera (Gemmiger, Escherichia, Enterococcus, and Ruminococcus) were shown to be deferentially abundant.
So, the three scenarios (z as fixed, z as random, and z as both) all yield different results. In this case,
z is the institution samples were collected from: I want to account both systemic differences due to batch effects (as the fixed effect) as well as variability due to different treatment schemes between institute (eg patients may be given different drugs based to their disease progression according to institute policies).
Let me know if there is anything I can do to clarify things! And thanks for all your work!