Multiple variables used as the references

Hi,

I am running an analysis with one predictor of interest and several categorical covariates. As the tutorial said, for the reference parameter, “semi-colon delimited for multiple variables”.

My current code goes like this:
Maaslin2(input_data, input_metadata,‘demo_output’, transform = “AST”,
max_significance = 0.1,
fixed_effects = c(“sex”,“age_group”,“BMI_g”,“smoking”,
“alcohol”,“MET_g”,“red_meat”),
normalization = ‘NONE’,
reference = c(“age_group,50plus”,“BMI_g,24minus”,“smoking,non-smoker”,
“alcohol,no”,“MET_g,A”,“red_meat,1pw_minus”))

but it doesn’t work well for the covariates. So I wonder how to set the reference parameter for multiple variables.

Thank you!
Yuhan

HI Yuhan,
try doing the following for your references, rather than having them as a vector.

reference = “age_group,50plus;BMI_g,24minus;smoking,non-smoker;alcohol,no;MET_g,A;red_meat,1pw_minus”

Hi @ayuhhh,

Apologies for not being clearer in the tutorial! We should add an example where we set multiple references for different variables - I will add that to our improvements list.

I haven’t tried @nickp60 method, thank you for offering that one! Adding more parentheses should also work (e.g. -

reference = c((“age_group,50plus”),(“BMI_g,24minus”),(“smoking,non-smoker”),
(“alcohol,no”),(“MET_g,A”),(“red_meat,1pw_minus”)))

I hope this helps!
Best,
Kelsey

Hi Kelsey,

I tried doing that and keep getting the same error. What am I missing? Here’s my code:

metadat.sub$Treatmentmod= factor(metadat.sub$Treatment,
levels = c(“Bare”, “Mustard”, “Radish”))

fit_data = Maaslin2(
input_data = otus.r,
input_metadata = metadat.sub,
output = “16S_output.trt”,
fixed_effects = c(“Treatmentmod”),
reference = c(“Bare”,“Mustard”,“Radish”))

It keeps returning this error:

Error in Maaslin2(input_data = otus.r, input_metadata = metadat.sub, output = “16S_output.trt”, :
Please provide the reference for the variable ‘Treatmentmod’ which includes more than 2 levels: Bare, Radish, Mustard.

Wait! I got it, here’s the code that worked for me, for reference.

metadat.sub$Treatmentmod= factor(metadat.sub$Treatment,
levels = c(“Bare”, “Mustard”, “Radish”))
fit_data = Maaslin2(
input_data = otus.r,
input_metadata = metadat.sub,
output = “16S_output.trt”,
fixed_effects = c(“Treatmentmod”),
reference = c(“Treatmentmod,Bare”))

1 Like

Hi @Jennifer_Berkowitz,

Yup, that is exactly what is needed here. I’m glad you could find the answer! Let us know if you have any additional questions.

Best,
Kelsey