Open DeniRibicic opened 2 months ago
Dear DeniRibicic,
Thank you for reaching out and for your interest in the ggpicrust2 tool. I appreciate your feedback and am glad to hear that you find it useful for analyzing PICRUSt2 output.
I've reviewed the error message you're encountering with the pathway_errorbar
function. The error suggests a mismatch between the number of rows in your data and the replacement values, which is unexpected given the steps you've taken. Theoretically, the process you've described should work correctly.
To better understand and resolve this issue, it would be helpful if you could send your data to cafferychen777@tamu.edu. This will allow me to examine the specific structure and content of your datasets, which might reveal the source of the problem.
When sending the data, please include:
With these, I should be able to reproduce the issue and provide a more targeted solution.
In the meantime, could you also confirm:
Thank you for your patience as we work to resolve this. I look forward to receiving your data and helping you get the pathway_errorbar
function working correctly.
Best regards, Chen Yang
Hi @cafferychen777 and thank you for prompt reply.
As you mentioned dimensions here, I checked it and that was the problem!
Basically, my metadata file contains some additional samples that were not part of picrust2 analysis. Usually having listed more samples in metadata/mapping file doesn't cause errors with other microbiome packages that I use (it is rather the opposite- missing sample). However, with ggpicrust2
this is the case.
Quick subsetting solves the issue:
samples <- colnames(ko_abundance)[-1]
metadata_filtered <- metadata %>% filter(sampleid %in% abundance)
Dear @DeniRibicic,
Thank you for the update on your issue with the pathway_errorbar
function. I'm glad to hear that you were able to identify and resolve the problem.
It's great that you discovered the mismatch between your metadata file and the PICRUSt2 analysis samples. You're right that having additional samples in the metadata file can sometimes cause issues, even if it doesn't with other microbiome packages. Your solution of subsetting the metadata to match the samples in the abundance data is perfect:
samples <- colnames(ko_abundance)[-1]
metadata_filtered <- metadata %>% filter(`#SampleID` %in% samples)
This approach ensures that your metadata and abundance data are properly aligned, which is crucial for the correct functioning of ggpicrust2
.
Thank you for sharing this solution. It will be helpful for other users who might encounter similar issues in the future. If you have any more questions or run into any other problems, please don't hesitate to ask.
Best regards, Chen Yang
Hi again,
Running the same function on MetaCyc dataset, but getting the following error:
Error in pathway_errorbar(abundance = metacyc_abundance %>% column_to_rownames("#OTUID"), :
Visualization with 'pathway_errorbar' cannot be performed because there are no features with statistical significance. For possible solutions, please check the FAQ section of the tutorial.
2. stop("Visualization with 'pathway_errorbar' cannot be performed because there are no features with statistical significance. ",
"For possible solutions, please check the FAQ section of the tutorial.")
1. pathway_errorbar(abundance = metacyc_abundance %>% column_to_rownames("#OTUID"),
daa_results_df = metacyc_daa_annotated_results_df, Group = metadata_filtered$exposure,
ko_to_kegg = FALSE, p_values_threshold = 0.05, order = "group",
select = daa_annotated_results_df %>% arrange(p_adjust) %>% ...
Full command to create inputs:
metacyc_daa_results_df <- pathway_daa(abundance = metacyc_abundance %>% column_to_rownames("#OTUID"), metadata = metadata_filtered, group = "exposure", daa_method = "LinDA")
metacyc_daa_annotated_results_df <- pathway_annotation(pathway = "MetaCyc", daa_results_df = metacyc_daa_results_df, ko_to_kegg = FALSE)
p <- pathway_errorbar(abundance = metacyc_abundance %>% column_to_rownames("#OTUID"),
daa_results_df = metacyc_daa_annotated_results_df,
Group = metadata_filtered$exposure,
ko_to_kegg = FALSE,
p_values_threshold = 0.05,
order = "group",
select = daa_annotated_results_df %>%
arrange(p_adjust) %>%
dplyr::slice(1:30) %>%
select("feature") %>%
pull(),
p_value_bar = TRUE,
colors = NULL,
x_lab = "description")
No errors when creating these two input dfs.
p_adjust
is numeric and there are bunch of significant features.
Any idea from top of your head why is it complaining there are no significant features?
Dear DeniRibicic,
Thank you for your detailed follow-up on the issue. Theoretically, this problem should not occur given the information you've provided. To help diagnose the issue, it would be very helpful if you could send me the relevant R data objects (such as metacyc_abundance
, metacyc_daa_annotated_results_df
, and metadata_filtered
) as an RData file. This will allow me to reproduce the problem and investigate further.
In the meantime, you might want to try a few troubleshooting steps:
Restart your R session. Sometimes, unexplained errors can be resolved by simply restarting the R environment.
Make sure all your packages, including ggpicrust2, are up to date.
Double-check that the p_adjust
column in your metacyc_daa_annotated_results_df
contains numeric values and that there are indeed statistically significant features (p_adjust < 0.05).
Verify that the dimensions and sample names in your abundance data, metadata, and results dataframe all match correctly.
If the issue persists after trying these steps, please send me the RData file, and I'll be happy to take a closer look.
Best regards, Chen Yang
Hi DeniRibicic,
Thank you for sharing the details of the error. After reviewing the code, I found the issue.
In the command:
select = daa_annotated_results_df %>%
arrange(p_adjust) %>%
slice(1:30) %>%
select("feature") %>%
pull()
You are using daa_annotated_results_df
, but since you're working with the MetaCyc dataset, you need to update this to metacyc_daa_annotated_results_df
. Once you make this change, the function should run successfully.
Let me know if you encounter any further issues!
Best regards,
Caffery Yang
@cafferychen777 such a rookie mistake! Thanks, this works!
Hi,
First of all, thanks for creating this tool. It seems very neat for crunching down picrust2 output.
I am trying to run
pathway_errorbar
function but getting the following error:I have used following commands:
All the outputs are generated as they supposed to, it is only the last part that is throwing the error. When I run the exact same commands on your data (except the sub setting), everything works fine.
Any idea what could be wrong here? I can share my data if needed.