Giter Club home page Giter Club logo

Comments (12)

cafferychen777 avatar cafferychen777 commented on September 17, 2024

Hello,

Thank you for bringing this issue to my attention. In order to troubleshoot this problem effectively, I would need a bit more context. Could you possibly provide the dataset you are working with? This would allow me to replicate the issue on my end and hopefully identify a solution more swiftly.

Just to remind you, if your dataset contains sensitive or private information, please make sure to anonymize or de-identify it before sharing.

Thank you for your cooperation and patience while we work to resolve this issue.

Best regards.

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

Dear @Lacona ,

Thank you for reaching out regarding the error you encountered while creating pathway error bar plots using ggpicrust2.

I noticed that you're using the "LinDA" method in your code. When dealing with multiple groups in the metadata, I recommend switching to the "ALDEx2" method for creating pathway error bar plots. From my experience, LinDA can sometimes fail to produce accurate visualizations in cases of comparisons involving multiple groups.

Please try modifying your code as follows:

results_file <- ggpicrust2(file = abundance_file,
                           metadata = metadata,
                           group = "treatment", 
                           pathway = "KO",
                           daa_method = "ALDEx2",
                           ko_to_kegg = TRUE,
                           order = "pathway_class",
                           p_values_bar = TRUE,
                           x_lab = "pathway_name")

Please let me know if this resolves the issue or if you have any further questions.

Best regards,

Chen

from ggpicrust2.

Lacona avatar Lacona commented on September 17, 2024

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

@Lacona

Dear Andrea,

Thank you for reaching out and for your patience. I understand that you have been exploring the ALDEx2 method and are having trouble figuring out how to perform multiple group comparisons. Unfortunately, the $results output does not provide the desired information.

To address this issue, you can try the following code snippet:

library(readr)
library(ggpicrust2)
library(tibble)
library(tidyverse)
library(ggprism)
library(patchwork)

# Load metadata as a tibble
metadata <- read_delim("/Users/apple/Microbiome/ggpicrust2总/ggpicrust2测试/ggpicrust2_test/Lacona/Salmonella22_metadata_42R.tsv", delim = "\t", escape_double = FALSE, trim_ws = TRUE) 

# Load KEGG pathway abundance
kegg_abundance <- ko2kegg_abundance("/Users/apple/Microbiome/ggpicrust2总/ggpicrust2测试/ggpicrust2_test/Lacona/pred_metagenome_unstrat (2).tsv") 

# Perform pathway differential abundance analysis (DAA) using ALDEx2 method
daa_results_df <- pathway_daa(abundance = kegg_abundance, metadata = metadata, group = "treatment", daa_method = "ALDEx2", select = NULL, reference = NULL) 

# Filter results for ALDEx2_Welch's t-test method
daa_sub_method_results_df <- daa_results_df[daa_results_df$method == "ALDEx2_Kruskal-Wallace test", ]

# Annotate pathway results using KO to KEGG conversion
daa_annotated_sub_method_results_df <- pathway_annotation(pathway = "KO", daa_results_df = daa_sub_method_results_df, ko_to_kegg = TRUE)

# Generate pathway error bar plot
pathway_errorbar(abundance = kegg_abundance, daa_results_df = daa_annotated_sub_method_results_df %>%
                        filter(!is.na(pathway_class)), Group = metadata$treatment, p_values_threshold = 0.05, order = "pathway_class", select = c("ko00561", "ko00310", "ko00604", "ko04973", "ko01051", "ko00300", "ko00591", "ko00253", "ko00380", "ko00625", "ko00627", "ko00270", "ko00941", "ko04910", "ko00363", "ko02010", "ko00361", "ko00362", "ko01040", "ko04626", "ko05020", "ko05146", "ko00051"), ko_to_kegg = TRUE, p_value_bar = FALSE, colors = NULL, x_lab = "pathway_name")

# Perform pathway PCA
pathway_pca(abundance = kegg_abundance, metadata = metadata, group = "treatment")

# Filter features with p-value < 0.05
feature_with_p_0.05 <- daa_annotated_sub_method_results_df %>% filter(p_adjust < 0.05) %>% filter(!is.na(pathway_class))

# Generate pathway heatmap
pathway_heatmap(abundance = kegg_abundance %>% filter(rownames(.) %in% feature_with_p_0.05$feature) %>% rownames_to_column("feature") %>% left_join(daa_annotated_sub_method_results_df %>% select(all_of(c("feature","pathway_name"))), by

 = "feature") %>% column_to_rownames("pathway_name") %>% select(-"feature"), metadata = metadata, group = "treatment")

Please ensure that you modify the file paths in the code snippet to match your actual data file locations. This code will help you perform multiple group comparisons using the ALDEx2 method and generate pathway error bar plots, pathway PCA plots, and pathway heatmaps based on your metadata and KEGG abundance data.

If you have any further questions or need additional assistance, please don't hesitate to ask. I'm here to help.

Best regards,
Chen
Screenshot 2023-06-30 at 00 07 56
Screenshot 2023-06-30 at 00 08 16
Screenshot 2023-06-30 at 00 08 31

from ggpicrust2.

Lacona avatar Lacona commented on September 17, 2024

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

from ggpicrust2.

Lacona avatar Lacona commented on September 17, 2024

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

from ggpicrust2.

Lacona avatar Lacona commented on September 17, 2024

from ggpicrust2.

Lacona avatar Lacona commented on September 17, 2024

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

Subsetting the dataset is a very easy thing. Maybe you guys should exercise your R skills instead of keeping telling something that is not related to ggpicrust.

from ggpicrust2.

Lacona avatar Lacona commented on September 17, 2024

from ggpicrust2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.