cafferychen777 / ggpicrust2

Make Picrust2 Output Analysis and Visualization Easier
https://cafferychen777.github.io/ggpicrust2/
MIT License
110 stars 13 forks source link

daa_method ="Maaslin2", is there more options adjusting models and other parameters other than the default setting? #121

Open shuqili opened 1 month ago

shuqili commented 1 month ago

Hello,

Thank you so much for your work on this fantastic package, it helped accelerated my work so much! The installation and test data ran smoothly and I just have an additional question based on my analysis--

I am more familiar with MaAsLin2 package and use it all the time with my microbiome taxa differential analyses. For some datasets, I have tailored the model to "CPLM" and adjusted transformation as "NONE" in maaslin, as well as put confounding factors such as age, sex, bmi as fix effects to control. In this case I'd prefer to use the same model setting to test the difference of my predicted pathways. I'm wondering is there an option in the ggpicrust2 package to achieve this?

Thank you so much.

SL

cafferychen777 commented 1 week ago

Hi @shuqili,

Thank you for your interest in ggpicrust2 and for your question about MaAsLin2 parameters. Looking at the current implementation in the perform_maaslin2_analysis function (lines 509-566), I can help explain the current options and suggest how to add more flexibility:

Currently, the function uses these default MaAsLin2 parameters:

Maaslin2::Maaslin2(
    input_data = abundance_mat_t,
    input_metadata = metadata,
    output = output_dir,
    transform = "AST",
    fixed_effects = group,
    reference = if (length_Level > 2) paste0(group, ",", reference) else NULL,
    normalization = "TSS",
    standardize = TRUE,
    min_prevalence = 0.1,
    cores = 1,
    plot_heatmap = FALSE,
    plot_scatter = FALSE
)

To accommodate your needs, I suggest two approaches:

  1. Immediate Workaround: You can use MaAsLin2 directly and then use ggpicrust2 for visualization:
    
    # Run MaAsLin2 with custom parameters
    maaslin_results <- Maaslin2::Maaslin2(
    input_data = your_abundance_data,
    input_metadata = your_metadata,
    output = "maaslin2_output",
    transform = "NONE",
    analysis_method = "CPLM",
    fixed_effects = c("group", "age", "sex", "bmi"),
    # Other custom parameters
    )

Convert results for ggpicrust2

formatted_results <- data.frame( feature = maaslin_results$results$feature, method = "Maaslin2", group1 = reference_group, group2 = comparison_group, p_values = maaslin_results$results$pval )

Use ggpicrust2 for visualization

pathway_errorbar( abundance = your_abundance_data, daa_results_df = formatted_results,

Other visualization parameters

)


2. **Future Enhancement:**
I will consider adding these parameters to the next version of ggpicrust2:
```R
pathway_daa(
    abundance = abundance,
    metadata = metadata,
    group = "group",
    daa_method = "Maaslin2",
    maaslin_params = list(
        transform = "NONE",
        analysis_method = "CPLM",
        fixed_effects = c("group", "age", "sex", "bmi"),
        random_effects = NULL,
        standardize = TRUE,
        min_prevalence = 0.1
    )
)

Would you be interested in contributing to this enhancement? If so, I'd be happy to guide you through the process of submitting a pull request.

Best regards, Chen Yang