cafferychen777 / ggpicrust2_paper

https://cafferychen777.github.io/ggpicrust2_paper/
3 stars 2 forks source link

Having issue in KO_abundance analysis with ggpicrust2 provided datasets #2

Open roopender-bioinfo opened 6 months ago

roopender-bioinfo commented 6 months ago

Error in ggplot_add(): ! Can't add e2 to a object. Run rlang::last_trace() to see where the error occurred.

rlang::last_trace() <error/rlang_error> Error in ggplot_add(): ! Can't add e2 to a object.

Backtrace: ▆

  1. └─ggpicrust2::ggpicrust2(...)
  2. └─ggpicrust2::pathway_errorbar(...)
  3. └─GGally:::+.gg(pathway_class_annotation, bar_errorbar)
  4. └─e1 %+% e2
  5. └─ggplot2:::add_ggplot(e1, e2, e2name)
  6. ├─ggplot2::ggplot_add(object, p, objectname)
  7. └─ggplot2:::ggplot_add.default(object, p, objectname) Run rlang::last_trace(drop = FALSE) to see 2 hidden frames.

I just used ggpicrust 2 datasets

results_file_input <- ggpicrust2(data = ko_abundance,

  • metadata = metadata,
  • group = "Environment",
  • pathway = "KO",
  • daa_method = "LinDA",
  • ko_to_kegg = TRUE,
  • order = "pathway_class",
  • p_values_bar = TRUE,
  • x_lab = "pathway_name") I don't know how can i resolve this I have ggplot2 installed
cafferychen777 commented 6 months ago

Hi roopender-bioinfo,

Thank you for reporting this issue with ggpicrust2. It seems like the error is occurring when trying to combine the pathway_class_annotation and bar_errorbar ggplot objects into a single plot using the + operator.

This type of error often occurs when the ggplot2 package is missing a needed extension package for combining plots. In this case, I believe the missing package is patchwork. Could you please try installing and loading the patchwork package before running your ggpicrust2 code? You can do this with:

install.packages("patchwork")
library(patchwork)

After loading patchwork, please re-run your ggpicrust2 command:

results_file_input <- ggpicrust2(data = ko_abundance,
                                 metadata = metadata, 
                                 group = "Environment",
                                 pathway = "KO",
                                 daa_method = "LinDA", 
                                 ko_to_kegg = TRUE,
                                 order = "pathway_class",  
                                 p_values_bar = TRUE,
                                 x_lab = "pathway_name")

Hopefully this resolves the issue. If you still encounter problems, please let me know and I'll be happy to investigate further.

Best regards, Caffery