The bioBakery help forum

Maaslin2 handling of covariates


First, Maaslin2 is awesome. Thank you for this wonderful tool!

I am running an analysis with one predictor of interest and 3 categorical covariates. I’ve run maaslin2 (lm analysis method, min prevalence and abundance thresholds to filter out rare features), and the output shows pairwise comparisons for the covariates as well as the predictor of interest. Is there a way to make maaslin2 only perform comparisons for the predictor of interest and not the covariates (to reduce the number of comparisons performed) while still including covariates in the input so that they can be controlled for?

Thank you!

Hi @fquerdasi - one easy way to do that is as follows:

  1. Let’s say you have saved the MaAsLin 2 results in R as follows:
fit_data<-Maaslin2(input_data, input_metadata,...) # Your MaAsLin 2 run
maaslin2_all_results<-fit_data$results # Save results table
  1. Assuming that your primary predictor of interest is named MAIN, you can simply subset the results table as:
maaslin2_results<-maaslin2_all_results %>% filter(metadata == 'MAIN') # Discard covariate associations
  1. Once you have done that, you can simply re-calculate the q-values as follows:
maaslin2_results$qval<-p.adjust(maaslin2_results$pval, method = 'BH') # FDR correction using 'BH'

Hope this helps. Let me know if anything is unclear.

Hi @himel.mallick,

Thank you for the detailed explanation! This method works great.