Giter Club home page Giter Club logo

Comments (8)

otaviolovison avatar otaviolovison commented on September 17, 2024 1

I just did it! And it is beautiful! Wait for the paper! :D

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

Hello @otaviolovison ,

Thank you for reaching out with your issue while using the ggpicrust2 function. I understand that you've encountered an error related to the pathway_errorbar function, specifically when dealing with the 'group1' and 'group2' columns in the 'daa_results_df' data frame.

Based on your description, it seems that the error might be stemming from having more than two categories in your target variable. You mentioned that you have four categories and used Group 1 as the reference for LinDA. The code snippet you provided checks for the number of levels in the 'group1' and 'group2' columns, and if there's more than one group, it throws an error.

To address this, you can indeed filter the data to only include the two levels you want to compare. You can do this by filtering both the 'abundance' data and the 'daa_results_df' data frame to retain only the samples and results corresponding to the levels you're interested in. For instance, you can keep only the samples belonging to level 1 and level 2 in the 'abundance' data, and similarly, retain only the results related to these levels in the 'daa_results_df'.

This way, you'll be comparing only the relevant categories, and the pathway_errorbar function should work as expected. If you're looking for more detailed guidance on how to perform this analysis with four categories in your target attribute, I recommend checking the documentation or tutorials provided with the ggpicrust2 package, as they might offer specific insights into handling such scenarios.

Thank you for your kind words about the package! If you have any further questions or need additional assistance, please don't hesitate to ask.

Best regards,
Chen YANG

from ggpicrust2.

otaviolovison avatar otaviolovison commented on September 17, 2024

Thanks for the quick response!

I have looked the tutorials and documentation and didn't find any guidance for my case. Sorry! Could you, please, give me some orientation on where can I find these specific insights?

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

You can use the code similar to the followings

sub_metadata_sample_names <- metadata %>% filter(group %in% c("level1","levle2")) %>% select(sample_name) %>% pull()
sub_abundance  <- abundance[,sub_metadata_sample_names]
sub_daa_results_df <- daa_results_df %>% filter(group2 %in% "level2")
pathway_errorbar()

Best regards,

from ggpicrust2.

otaviolovison avatar otaviolovison commented on September 17, 2024

Thanks!

Let me put my code here... maybe it will help someone else.

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

abundance_file <- "path_to_your_abundance_file"
metadata <- read_delim(
"path_to_your_metadata.txt",
delim = "\t",
escape_double = FALSE,
trim_ws = TRUE
)

metacyc_abundance <- read_delim(abundance_file, delim = "\t", col_names = TRUE, trim_ws = TRUE)

Differential Abundance using LinDA (linear models for differential abundance analysis of microbiome compositional data) - must set a reference group for multiclass

#Group 1
metacyc_daa_results_df1 <- pathway_daa(abundance = metacyc_abundance %>% column_to_rownames("pathway"), metadata = metadata, group = "COVID19", daa_method = "LinDA", reference = "Group 1")
#Group 2
metacyc_daa_results_df2 <- pathway_daa(abundance = metacyc_abundance %>% column_to_rownames("pathway"), metadata = metadata, group = "COVID19", daa_method = "LinDA", reference = "Group 2")
#Group 3
metacyc_daa_results_df3 <- pathway_daa(abundance = metacyc_abundance %>% column_to_rownames("pathway"), metadata = metadata, group = "COVID19", daa_method = "LinDA", reference = "Group 3")

Annotating MetaCyc pathway

metacyc_daa_annotated_results_df1 <- pathway_annotation(pathway = "MetaCyc", daa_results_df = metacyc_daa_results_df1, ko_to_kegg = FALSE)
metacyc_daa_annotated_results_df2 <- pathway_annotation(pathway = "MetaCyc", daa_results_df = metacyc_daa_results_df2, ko_to_kegg = FALSE)
metacyc_daa_annotated_results_df3 <- pathway_annotation(pathway = "MetaCyc", daa_results_df = metacyc_daa_results_df3, ko_to_kegg = FALSE)

#Filtering replicates
filtered_df2 <- metacyc_daa_annotated_results_df2 %>%
filter(group1 != "Group 1")

filtered_df3 <- metacyc_daa_annotated_results_df3 %>%
filter(group1 != "Group 1" & group1 != "Group 2")

#Concatenating dfs
metacyc_daa_all_results_df <- rbind(metacyc_daa_annotated_results_df1, filtered_df2, filtered_df3)

Thank you so much!

Now I will have to discover how to plot! hahahaha

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

Hello @otaviolovison ,

Thank you so much for sharing your code and for your contribution to the ggpicrust2 community! Your thoughtful implementation in performing differential abundance analysis, especially in the context of COVID-19 research, is both innovative and incredibly useful. It's community members like you who help make ggpicrust2 a more robust and versatile tool for everyone. Your work has not only enriched the package but has also set a great example for others on how to contribute. Looking forward to seeing what you'll work on next—perhaps in the realm of plotting! 😄

Best regards,

from ggpicrust2.

cafferychen777 avatar cafferychen777 commented on September 17, 2024

@all-contributors please add @otaviolovison for Code

from ggpicrust2.

allcontributors avatar allcontributors commented on September 17, 2024

@cafferychen777

I've put up a pull request to add @otaviolovison! 🎉

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.