Maaslin2() reference error

An error occurred during analysis using Maaslin2(). The following is the code I ran and the error that occurred.

fit_data2 <- Maaslin2(input_data = maaslin2_taxo,
                      input_metadata = maaslin2_metadata,
                      min_prevalence = 0, normalization = "NONE",
                      output = "MaAsLin2 Output (Taxo_IBD)",
                      fixed_effects = c("Case_status", "IBD"),
                      reference = c("Case_status, Patient", "IBD, Y"))
[1] "Warning: Deleting existing log file: MaAsLin2 Output (Taxo_IBD)/maaslin2.log"
2024-07-17 13:20:46.875378 INFO::Writing function arguments to log file
2024-07-17 13:20:46.893984 INFO::Verifying options selected are valid
2024-07-17 13:20:46.896145 INFO::Determining format of input files
2024-07-17 13:20:46.898438 INFO::Input format is data samples as rows and metadata samples as rows
2024-07-17 13:20:46.930703 INFO::Formula for fixed effects: expr ~  Case_status + IBD
The following error occurred in relevel.factor(metadata[, i], ref = ref):
 'ref' must be an existing level

Referring to the error message, I checked the level of the variable entered in the reference option.

> levels(maaslin2_metadata$Case_status)
[1] "Control" "Patient"     
> levels(maaslin2_metadata$IBD)
[1] "N" "Y" ""

Why does an error occur? I don’t think my code is wrong. If there is something wrong or you know how to fix it, please let me know.

Thank you for help!

I solved it! The problem was the spacing in the reference option!

2 Likes