Looking at the interaction of time and treatment

Hi everyone,

I am looking to look at the interaction between time and treatment in my dataset. Here is a snippet of what my metadata looks like:

treatment only has two levels, bleached and unbleached.

From reading a previous response, to create an interaction variable, I need to do something like this:
data ← model.matrix(~treatment*time, data = df_input_data)

but then when I tack that onto my metadata
df_metadata_with_design_matrix ← cbind(df_input_metadata, data)

I get the following columns:
(Intercept) treatmentunbleached timefour timeone timeseven timesix timethree timetwo treatmentunbleached:timefour treatmentunbleached:timeone treatmentunbleached:timeseven treatmentunbleached:timesix treatmentunbleached:timethree treatmentunbleached:timetwo

which do I use as fixed effects? How can I interpret the results to only see main effects? (as in, I only care to see for each pathway I am looking at, if treatment, time, and/or treatment x time are significant)

Currently without interactions my code looks like this:
fit_data_ixn = Maaslin2(input_data = df_input_data,
input_metadata = df_input_metadata,
min_prevalence = 0,
normalization = “NONE”,
transform = "LOG”,
output = “output_interaction”,
fixed_effects = c(“treatment”, “time”),
reference = c("time,one”),
random_effects = c(“pond”))

Any help is greatly appreciated! Thanks.

Hi there,

This really depends on how you want to treat your time variable. If the time variable is on a continuous scale you might want to recode your variable into a numeric are re-create the model.matrix…

If time should be a categorical variable then you would include all of the columns with the interaction you’re interested in as a fixed effect. (i.e. all the columns with the treatment:time effect).

Hope that helps.
Jacob