Comments (8)
I just did it! And it is beautiful! Wait for the paper! :D
from ggpicrust2.
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.
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.
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.
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.
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.
@all-contributors please add @otaviolovison for Code
from ggpicrust2.
I've put up a pull request to add @otaviolovison! 🎉
from ggpicrust2.
Related Issues (20)
- error with MicrobiomeStat HOT 5
- Error in `guide_transform()`: ! <Guide> classes have been rewritten as <ggproto> classes. HOT 3
- undefined columns selected and ‘round’ not meaningful for factors HOT 3
- How to obtain log-fold change values? HOT 3
- curl_fetch_memory HOT 4
- The 'method' column in the 'daa_results_df' data frame contains more than one method. HOT 2
- All my pathway results are NA
- Help needed using sample dada Math.factor ‘round’ not meaningful for factors HOT 2
- pathway_pca HOT 4
- pathway_errorbar no longer working to graph data HOT 1
- Is this package compatible with other ggplot functions? HOT 1
- Error pathway_errorbar "`$<-.data.frame`(`*tmp*`, "group", value = c(2L, 2L, 2L, 2L, : replacement has 20 rows, data has 1" HOT 2
- Error in switch(file_format, .txt = abundance <- readr::read_delim(file, : EXPR must be a length 1 vector** HOT 2
- pathway_annotation error "An error occurred. Retrying......" HOT 3
- # Perform pathway DAA using ALDEx2 method not working with example dataset HOT 1
- add a title to errorbar and heatmap HOT 9
- Installation issues with Rfast HOT 2
- Issue with pathway_errorbar : "The `legend.text.align` theme element is not defined in the element hierarchy." HOT 6
- Error in ggpicrust2 (There are no statistically significant biomarkers in the dataset) HOT 4
- Error in `plot_theme()`: ! The `legend.text.align` theme element is not defined in the element hierarchy. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggpicrust2.