{"id":24555780,"url":"https://github.com/cafferychen777/ggpicrust2","last_synced_at":"2025-04-16T14:38:09.404Z","repository":{"id":146916320,"uuid":"579335152","full_name":"cafferychen777/ggpicrust2","owner":"cafferychen777","description":"Make Picrust2 Output Analysis and Visualization Easier","archived":false,"fork":false,"pushed_at":"2024-04-01T05:18:40.000Z","size":22228,"stargazers_count":101,"open_issues_count":50,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-18T19:54:17.747Z","etag":null,"topics":["16s-rrna","functional-data","metagenomic-analysis","metagenomics","microbiome","microbiota","picrust2","tax4fun2","visualization"],"latest_commit_sha":null,"homepage":"https://cafferychen777.github.io/ggpicrust2/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cafferychen777.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-17T10:55:29.000Z","updated_at":"2024-09-17T23:17:00.000Z","dependencies_parsed_at":"2024-03-12T09:28:34.129Z","dependency_job_id":"6ed8a5aa-8b6f-4135-a573-ded43aacd775","html_url":"https://github.com/cafferychen777/ggpicrust2","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafferychen777%2Fggpicrust2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafferychen777%2Fggpicrust2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafferychen777%2Fggpicrust2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafferychen777%2Fggpicrust2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cafferychen777","download_url":"https://codeload.github.com/cafferychen777/ggpicrust2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235224021,"owners_count":18955579,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["16s-rrna","functional-data","metagenomic-analysis","metagenomics","microbiome","microbiota","picrust2","tax4fun2","visualization"],"created_at":"2025-01-23T04:20:19.573Z","updated_at":"2025-04-16T14:38:09.390Z","avatar_url":"https://github.com/cafferychen777.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# ggpicrust2 vignettes\n\n🌟 **If you find `ggpicrust2` helpful, please consider giving us a star on GitHub!** Your support greatly motivates us to improve and maintain this project. 🌟\n\n*ggpicrust2* is a comprehensive package designed to provide a seamless and intuitive solution for analyzing and interpreting the results of PICRUSt2 functional prediction. It offers a wide range of features, including pathway name/description annotations, advanced differential abundance (DA) methods, and visualization of DA results.\n\nOne of the newest additions to *ggpicrust2* is the capability to compare the consistency and inconsistency across different DA methods applied to the same dataset. This feature allows users to assess the agreement and discrepancy between various methods when it comes to predicting and sequencing the metagenome of a particular sample. It provides valuable insights into the consistency of results obtained from different approaches and helps users evaluate the robustness of their findings.\n\nBy leveraging this functionality, researchers, data scientists, and bioinformaticians can gain a deeper understanding of the underlying biological processes and mechanisms present in their PICRUSt2 output data. This comparison of different methods enables them to make informed decisions and draw reliable conclusions based on the consistency evaluation of macrogenomic predictions or sequencing results for the same sample.\n\nIf you are interested in exploring and analyzing your PICRUSt2 output data, *ggpicrust2* is a powerful tool that provides a comprehensive set of features, including the ability to assess the consistency and evaluate the performance of different methods applied to the same dataset.\n\n[![CRAN version](https://www.r-pkg.org/badges/version/ggpicrust2)](https://CRAN.R-project.org/package=ggpicrust2) [![Downloads](https://cranlogs.r-pkg.org/badges/grand-total/ggpicrust2)](https://CRAN.R-project.org/package=ggpicrust2) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)\n\n## News\n\n🌟 **New Feature: Gene Set Enrichment Analysis (GSEA) for PICRUSt2 Data**\n\nWe're excited to announce the addition of GSEA functionality to the ggpicrust2 package! This powerful new feature allows researchers to perform Gene Set Enrichment Analysis on PICRUSt2 predicted functional profiles, offering a more nuanced understanding of functional differences between conditions.\n\nThe new GSEA module includes:\n\n- `pathway_gsea()`: Performs GSEA analysis on PICRUSt2 data\n- `visualize_gsea()`: Creates various visualizations including enrichment plots, dot plots, network plots, and heatmaps\n- `compare_gsea_daa()`: Compares GSEA and differential abundance analysis results\n- `gsea_pathway_annotation()`: Annotates GSEA results with pathway information\n\nThese new functions complement our existing differential abundance analysis tools, providing researchers with multiple approaches to analyze functional profiles.\n\n🌟 **Also Check Out: `MicrobiomeStat`**\n\nWe're pleased to introduce `MicrobiomeStat`, our latest R package tailored for **longitudinal microbiome data** analysis. Designed to work efficiently with 16s rRNA microbiome data, `MicrobiomeStat` integrates comprehensive statistical tests and clear visualizations, offering a practical solution for microbiome researchers.\n\n`MicrobiomeStat` aims to simplify the complexities of microbiome data analysis. It's well-suited for various research needs, whether you're dealing with multi-omics data or cross-sectional studies. The package is designed to be user-friendly, accommodating both new and experienced researchers in the field.\n\nFor those engaged in microbiome research, `MicrobiomeStat` provides a straightforward approach to data analysis. Discover its full capabilities and learn more about how it can enhance your research at the [MicrobiomeStat Wiki](https://www.microbiomestat.wiki/). You can also access the tool directly on GitHub: [MicrobiomeStat GitHub Repository](https://github.com/cafferychen777/MicrobiomeStat).\n\nWe appreciate your support and interest in our tools and look forward to seeing the contributions our packages can make to your research endeavors.\n\n## Table of Contents\n\n-   [Citation](#citation)\n-   [Installation](#installation)\n-   [Stay Updated](#stay-updated)\n-   [Workflow](#workflow)\n-   [Output](#output)\n-   [Function Details](#function-details)\n    -   [ko2kegg_abundance()](#ko2kegg_abundance)\n    -   [pathway_daa()](#pathway_daa)\n    -   [compare_daa_results()](#compare_daa_results)\n    -   [pathway_annotation()](#pathway_annotation)\n    -   [pathway_errorbar()](#pathway_errorbar)\n    -   [pathway_heatmap()](#pathway_heatmap)\n    -   [pathway_pca()](#pathway_pca)\n    -   [compare_metagenome_results()](#compare_metagenome_results)\n    -   [pathway_gsea()](#pathway_gsea)\n    -   [visualize_gsea()](#visualize_gsea)\n    -   [compare_gsea_daa()](#compare_gsea_daa)\n    -   [gsea_pathway_annotation()](#gsea_pathway_annotation)\n-   [FAQ](#faq)\n-   [Author's Other Projects](#authors-other-projects)\n\n## Citation {#citation}\n\nIf you use *ggpicrust2* in your research, please cite the following paper:\n\nChen Yang and others. (2023). ggpicrust2: an R package for PICRUSt2 predicted functional profile analysis and visualization. *Bioinformatics*, btad470. [DOI link](https://doi.org/10.1093/bioinformatics/btad470)\n\nBibTeX entry: [Download here](https://academic.oup.com/Citation/Download?resourceId=7234609\u0026resourceType=3\u0026citationFormat=2)\n\nResearchGate link: [Click here](https://www.researchgate.net/publication/372829051_ggpicrust2_an_R_package_for_PICRUSt2_predicted_functional_profile_analysis_and_visualization)\n\nBioinformatics link: [Click here](https://academic.oup.com/bioinformatics/article/39/8/btad470/7234609?login=false\u0026utm_source=advanceaccess\u0026utm_campaign=bioinformatics\u0026utm_medium=email)\n\n## Installation {#installation}\n\nYou can install the development version of *ggpicrust2* from GitHub with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"cafferychen777/ggpicrust2\")\n```\n\n## Dependent CRAN Packages\n\n| Package        | Description                                                                                                                       |\n|----------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| aplot          | Create interactive plots                                                                                                          |\n| dplyr          | A fast consistent tool for working with data frame like objects both in memory and out of memory                                  |\n| ggplot2        | An implementation of the Grammar of Graphics in R                                                                                 |\n| grid           | A rewrite of the graphics layout capabilities of R                                                                                |\n| MicrobiomeStat | Statistical analysis of microbiome data                                                                                           |\n| readr          | Read rectangular data (csv tsv fwf) into R                                                                                        |\n| stats          | The R Stats Package                                                                                                               |\n| tibble         | Simple Data Frames                                                                                                                |\n| tidyr          | Easily tidy data with spread() and gather() functions                                                                             |\n| ggprism        | Interactive 3D plots with 'prism' graphics                                                                                        |\n| cowplot        | Streamlined Plot Theme and Plot Annotations for 'ggplot2'                                                                         |\n| ggforce        | Easily add secondary axes, zooms, and image overlays to 'ggplot2'                                                                 |\n| ggplotify      | Convert complex plots into 'grob' or 'ggplot' objects                                                                             |\n| magrittr       | A Forward-Pipe Operator for R                                                                                                     |\n| utils          | The R Utils Package                                                                                                               |\n\n## Dependent Bioconductor Packages\n\n| Package              | Description                                                           |\n|----------------------|-----------------------------------------------------------------------|\n| phyloseq             | Handling and analysis of high-throughput microbiome census data       |\n| ALDEx2               | Differential abundance analysis of taxonomic and functional features  |\n| SummarizedExperiment | SummarizedExperiment container for storing data and metadata together |\n| Biobase              | Base functions for Bioconductor                                       |\n| devtools             | Tools to make developing R packages easier                            |\n| ComplexHeatmap       | Making Complex Heatmaps in R                                          |\n| BiocGenerics         | S4 generic functions for Bioconductor                                 |\n| BiocManager          | Access the Bioconductor Project Package Repositories                  |\n| metagenomeSeq        | Statistical analysis for sparse high-throughput sequencing            |\n| Maaslin2             | Tools for microbiome analysis                                         |\n| edgeR                | Empirical Analysis of Digital Gene Expression Data in R               |\n| lefser               | R implementation of the LEfSE method for microbiome biomarker discovery |\n| limma                | Linear Models for Microarray and RNA-Seq Data                         |\n| KEGGREST             | R Interface to KEGG REST API                                          |\n| DESeq2               | Differential gene expression analysis using RNA-seq data              |\n\n\n``` r\nif (!requireNamespace(\"BiocManager\", quietly = TRUE))\n    install.packages(\"BiocManager\")\n\npkgs \u003c- c(\"phyloseq\", \"ALDEx2\", \"SummarizedExperiment\", \"Biobase\", \"devtools\",\n          \"ComplexHeatmap\", \"BiocGenerics\", \"BiocManager\", \"metagenomeSeq\",\n          \"Maaslin2\", \"edgeR\", \"lefser\", \"limma\", \"KEGGREST\", \"DESeq2\")\n\nfor (pkg in pkgs) {\n  if (!requireNamespace(pkg, quietly = TRUE))\n    BiocManager::install(pkg)\n}\n```\n\n## Stay Updated {#stay-updated}\n\nStay up to date with the latest *ggpicrust2* developments by following me on Twitter: [![](https://img.shields.io/twitter/follow/CafferyYang?style=social)](https://twitter.com/CafferyYang)\n\nOn my Twitter account, you'll find regular updates, announcements, and insights related to *ggpicrust2*. By following me, you'll ensure that you never miss any important information or new features.\n\nFeel free to join the conversation, ask questions, and engage with other users who are also interested in *ggpicrust2*. Twitter is a great platform to stay connected and be a part of the community.\n\nClick on the Twitter follow button above or visit [https://twitter.com/CafferyYang](https://twitter.com/CafferyYang) to follow me now!\n\nThank you for your interest in *ggpicrust2*, and I look forward to keeping you informed about all the exciting updates!\n\n## Workflow {#workflow}\n\nThe easiest way to analyze the PICRUSt2 output is using ggpicrust2() function. The main pipeline can be run with ggpicrust2() function.\n\nggpicrust2() integrates ko abundance to kegg pathway abundance conversion, annotation of pathway, differential abundance (DA) analysis, part of DA results visualization. When you have trouble running ggpicrust2(), you can debug it by running a separate function, which will greatly increase the speed of your analysis and visualization.\n\n![](https://raw.githubusercontent.com/cafferychen777/ggpicrust2_paper/main/paper_figure/Workflow.png)\n\n### ggpicrust2()\n\nYou can download the example dataset from the provided [Github link](https://github.com/cafferychen777/ggpicrust2_paper/tree/main/Dataset) and [Google Drive link](https://drive.google.com/drive/folders/1on4RKgm9NkaBCykMCCRvVJuEJeNVVqAF?usp=share_link) or use the dataset included in the package.\n\n```{r ggpicrust2(), eval = FALSE}\n# If you want to analyze the abundance of KEGG pathways instead of KO within the pathway, please set `ko_to_kegg` to TRUE.\n# KEGG pathways typically have more descriptive explanations.\n\nlibrary(readr)\nlibrary(ggpicrust2)\nlibrary(tibble)\nlibrary(tidyverse)\nlibrary(ggprism)\nlibrary(patchwork)\n\n# Load necessary data: abundance data and metadata\nabundance_file \u003c- \"path/to/your/abundance_file.tsv\"\nmetadata \u003c- read_delim(\n    \"path/to/your/metadata.txt\",\n    delim = \"\\t\",\n    escape_double = FALSE,\n    trim_ws = TRUE\n)\n\n# Run ggpicrust2 with input file path\nresults_file_input \u003c- ggpicrust2(file = abundance_file,\n                                 metadata = metadata,\n                                 group = \"your_group_column\", # For example dataset, group = \"Environment\"\n                                 pathway = \"KO\",\n                                 daa_method = \"LinDA\",\n                                 ko_to_kegg = TRUE,\n                                 order = \"pathway_class\",\n                                 p_values_bar = TRUE,\n                                 x_lab = \"pathway_name\")\n\n# Run ggpicrust2 with imported data.frame\nabundance_data \u003c- read_delim(abundance_file, delim = \"\\t\", col_names = TRUE, trim_ws = TRUE)\n\n# Run ggpicrust2 with input data\nresults_data_input \u003c- ggpicrust2(data = abundance_data,\n                                 metadata = metadata,\n                                 group = \"your_group_column\", # For example dataset, group = \"Environment\"\n                                 pathway = \"KO\",\n                                 daa_method = \"LinDA\",\n                                 ko_to_kegg = TRUE,\n                                 order = \"pathway_class\",\n                                 p_values_bar = TRUE,\n                                 x_lab = \"pathway_name\")\n\n# Access the plot and results dataframe for the first DA method\nexample_plot \u003c- results_file_input[[1]]$plot\nexample_results \u003c- results_file_input[[1]]$results\n\n# Use the example data in ggpicrust2 package\ndata(ko_abundance)\ndata(metadata)\nresults_file_input \u003c- ggpicrust2(data = ko_abundance,\n                                 metadata = metadata,\n                                 group = \"Environment\",\n                                 pathway = \"KO\",\n                                 daa_method = \"LinDA\",\n                                 ko_to_kegg = TRUE,\n                                 order = \"pathway_class\",\n                                 p_values_bar = TRUE,\n                                 x_lab = \"pathway_name\")\n\n# Analyze the EC or MetaCyc pathway\ndata(metacyc_abundance)\nresults_file_input \u003c- ggpicrust2(data = metacyc_abundance,\n                                 metadata = metadata,\n                                 group = \"Environment\",\n                                 pathway = \"MetaCyc\",\n                                 daa_method = \"LinDA\",\n                                 ko_to_kegg = FALSE,\n                                 order = \"group\",\n                                 p_values_bar = TRUE,\n                                 x_lab = \"description\")\nresults_file_input[[1]]$plot\nresults_file_input[[1]]$results\n```\n\n### If an error occurs with ggpicrust2, please use the following workflow.\n\n```{r alternative, eval = FALSE}\nlibrary(readr)\nlibrary(ggpicrust2)\nlibrary(tibble)\nlibrary(tidyverse)\nlibrary(ggprism)\nlibrary(patchwork)\n\n# If you want to analyze KEGG pathway abundance instead of KO within the pathway, turn ko_to_kegg to TRUE.\n# KEGG pathways typically have more explainable descriptions.\n\n# Load metadata as a tibble\n# data(metadata)\nmetadata \u003c- read_delim(\"path/to/your/metadata.txt\", delim = \"\\t\", escape_double = FALSE, trim_ws = TRUE)\n\n# Load KEGG pathway abundance\n# data(kegg_abundance)\nkegg_abundance \u003c- ko2kegg_abundance(\"path/to/your/pred_metagenome_unstrat.tsv\")\n\n# Perform pathway differential abundance analysis (DAA) using ALDEx2 method\n# Please change group to \"your_group_column\" if you are not using example dataset\ndaa_results_df \u003c- pathway_daa(abundance = kegg_abundance, metadata = metadata, group = \"Environment\", daa_method = \"ALDEx2\", select = NULL, reference = NULL)\n\n# Filter results for ALDEx2_Welch's t test method\n# Please check the unique(daa_results_df$method) and choose one\ndaa_sub_method_results_df \u003c- daa_results_df[daa_results_df$method == \"ALDEx2_Wilcoxon rank test\", ]\n\n# Annotate pathway results using KO to KEGG conversion\ndaa_annotated_sub_method_results_df \u003c- pathway_annotation(pathway = \"KO\", daa_results_df = daa_sub_method_results_df, ko_to_kegg = TRUE)\n\n# Generate pathway error bar plot\n# Please change Group to metadata$your_group_column if you are not using example dataset\np \u003c- pathway_errorbar(abundance = kegg_abundance, daa_results_df = daa_annotated_sub_method_results_df, Group = metadata$Environment, p_values_threshold = 0.05, order = \"pathway_class\", select = NULL, ko_to_kegg = TRUE, p_value_bar = TRUE, colors = NULL, x_lab = \"pathway_name\")\n\n# If you want to analyze EC, MetaCyc, and KO without conversions, turn ko_to_kegg to FALSE.\n\n# Load metadata as a tibble\n# data(metadata)\nmetadata \u003c- read_delim(\"path/to/your/metadata.txt\", delim = \"\\t\", escape_double = FALSE, trim_ws = TRUE)\n\n# Load KO abundance as a data.frame\n# data(ko_abundance)\nko_abundance \u003c- read.delim(\"path/to/your/pred_metagenome_unstrat.tsv\")\n\n# Perform pathway DAA using ALDEx2 method\n# Please change column_to_rownames() to the feature column if you are not using example dataset\n# Please change group to \"your_group_column\" if you are not using example dataset\ndaa_results_df \u003c- pathway_daa(abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"), metadata = metadata, group = \"Environment\", daa_method = \"ALDEx2\", select = NULL, reference = NULL)\n\n# Filter results for ALDEx2_Kruskal-Wallace test method\ndaa_sub_method_results_df \u003c- daa_results_df[daa_results_df$method == \"ALDEx2_Wilcoxon rank test\", ]\n\n# Annotate pathway results without KO to KEGG conversion\ndaa_annotated_sub_method_results_df \u003c- pathway_annotation(pathway = \"KO\", daa_results_df = daa_sub_method_results_df, ko_to_kegg = FALSE)\n\n# Generate pathway error bar plot\n# Please change column_to_rownames() to the feature column\n# Please change Group to metadata$your_group_column if you are not using example dataset\np \u003c- pathway_errorbar(abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"), daa_results_df = daa_annotated_sub_method_results_df, Group = metadata$Environment, p_values_threshold = 0.05, order = \"group\",\nselect = daa_annotated_sub_method_results_df %\u003e% arrange(p_adjust) %\u003e% slice(1:20) %\u003e% dplyr::select(feature) %\u003e% pull(),\nko_to_kegg = FALSE,\np_value_bar = TRUE,\ncolors = NULL,\nx_lab = \"description\")\n\n# Workflow for MetaCyc Pathway and EC\n\n# Load MetaCyc pathway abundance and metadata\ndata(\"metacyc_abundance\")\ndata(\"metadata\")\n\n# Perform pathway DAA using LinDA method\n# Please change column_to_rownames() to the feature column if you are not using example dataset\n# Please change group to \"your_group_column\" if you are not using example dataset\nmetacyc_daa_results_df \u003c- pathway_daa(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\", daa_method = \"LinDA\")\n\n# Annotate MetaCyc pathway results without KO to KEGG conversion\nmetacyc_daa_annotated_results_df \u003c- pathway_annotation(pathway = \"MetaCyc\", daa_results_df = metacyc_daa_results_df, ko_to_kegg = FALSE)\n\n# Generate pathway error bar plot\n# Please change column_to_rownames() to the feature column\n# Please change Group to metadata$your_group_column if you are not using example dataset\npathway_errorbar(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), daa_results_df = metacyc_daa_annotated_results_df, Group = metadata$Environment, ko_to_kegg = FALSE, p_values_threshold = 0.05, order = \"group\", select = NULL, p_value_bar = TRUE, colors = NULL, x_lab = \"description\")\n\n# Generate pathway heatmap\n# Please change column_to_rownames() to the feature column if you are not using example dataset\n# Please change group to \"your_group_column\" if you are not using example dataset\nfeature_with_p_0.05 \u003c- metacyc_daa_results_df %\u003e% filter(p_adjust \u003c 0.05)\npathway_heatmap(abundance = metacyc_abundance %\u003e% filter(pathway %in% feature_with_p_0.05$feature) %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\")\n\n# Generate pathway PCA plot\n# Please change column_to_rownames() to the feature column if you are not using example dataset\n# Please change group to \"your_group_column\" if you are not using example dataset\npathway_pca(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\")\n\n# Run pathway DAA for multiple methods\n# Please change column_to_rownames() to the feature column if you are not using example dataset\n# Please change group to \"your_group_column\" if you are not using example dataset\nmethods \u003c- c(\"ALDEx2\", \"DESeq2\", \"edgeR\")\ndaa_results_list \u003c- lapply(methods, function(method) {\n  pathway_daa(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\", daa_method = method)\n})\n\n# Compare results across different methods\ncomparison_results \u003c- compare_daa_results(daa_results_list = daa_results_list, method_names = c(\"ALDEx2_Welch's t test\", \"ALDEx2_Wilcoxon rank test\", \"DESeq2\", \"edgeR\"))\n\n```\n\n\n\n## Output {#output}\n\nThe typical output of the ggpicrust2 is like this.\n\n![](https://cdn.jsdelivr.net/gh/cafferychen777/ggpicrust2_paper@main/paper_figure/figure1.jpg)\n\n## function details {#function-details}\n\n### ko2kegg_abundance() {#ko2kegg_abundance}\n\nKEGG Orthology(KO) is a classification system developed by the Kyoto Encyclopedia of Genes and Genomes (KEGG) data-base(Kanehisa et al., 2022). It uses a hierarchical structure to classify enzymes based on the reactions they catalyze. To better understand pathways' role in different groups and classify the pathways, the KO abundance table needs to be converted to KEGG pathway abundance. But PICRUSt2 removes the function from PICRUSt. ko2kegg_abundance() can help convert the table.\n\n```{r ko2kegg_abundance sample,echo = TRUE,eval=FALSE}\n# Sample usage of the ko2kegg_abundance function\ndevtools::install_github('cafferychen777/ggpicrust2')\n\nlibrary(ggpicrust2)\n\n# Assume that the KO abundance table is stored in a file named \"ko_abundance.tsv\"\nko_abundance_file \u003c- \"ko_abundance.tsv\"\n\n# Convert KO abundance to KEGG pathway abundance\nkegg_abundance \u003c- ko2kegg_abundance(file = ko_abundance_file)\n\n# Alternatively, if the KO abundance data is already loaded as a data frame named \"ko_abundance\"\ndata(\"ko_abundance\")\nkegg_abundance \u003c- ko2kegg_abundance(data = ko_abundance)\n\n# The resulting kegg_abundance data frame can now be used for further analysis and visualization.\n\n```\n\n### pathway_daa() {#pathway_daa}\n\nDifferential abundance(DA) analysis plays a major role in PICRUSt2 downstream analysis. pathway_daa() integrates almost all DA methods applicable to the predicted functional profile which there excludes ANCOM and ANCOMBC. It includes [ALDEx2](https://www.bioconductor.org/packages/release/bioc/html/ALDEx2.html)(Fernandes et al., 2013), [DESeq2](https://bioconductor.org/packages/release/bioc/html/DESeq2.html)(Love et al., 2014), [Maaslin2](https://www.bioconductor.org/packages/release/bioc/html/Maaslin2.html)(Mallick et al., 2021), [LinDA](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-022-02655-5)(Zhou et al., 2022), [edgeR](https://bioconductor.org/packages/release/bioc/html/edgeR.html)(Robinson et al., 2010) , [limma voom](https://ucdavis-bioinformatics-training.github.io/2018-June-RNA-Seq-Workshop/thursday/DE.html)(Ritchie et al., 2015), [metagenomeSeq](https://www.bioconductor.org/packages/release/bioc/html/metagenomeSeq.html#:~:text=metagenomeSeq%20is%20designed%20to%20address,the%20testing%20of%20feature%20correlations.)(Paulson et al., 2013), [Lefser](https://bioconductor.org/packages/release/bioc/html/lefser.html)(Segata et al., 2011).\n\n```{r pathway_daa sample,echo = TRUE,eval=FALSE}\n# The abundance table is recommended to be a data.frame rather than a tibble.\n# The abundance table should have feature names or pathway names as row names, and sample names as column names.\n# You can use the output of ko2kegg_abundance\nko_abundance_file \u003c- \"path/to/your/pred_metagenome_unstrat.tsv\"\nkegg_abundance \u003c- ko2kegg_abundance(ko_abundance_file) # Or use data(kegg_abundance)\n\nmetadata \u003c- read_delim(\"path/to/your/metadata.txt\", delim = \"\\t\", escape_double = FALSE, trim_ws = TRUE)\n\n# The default DAA method is \"ALDEx2\"\n# Please change group to \"your_group_column\" if you are not using example dataset\ndaa_results_df \u003c- pathway_daa(abundance = kegg_abundance, metadata = metadata, group = \"Environment\", daa_method = \"linDA\", select = NULL, p.adjust = \"BH\", reference = NULL)\n\n# If you have more than 3 group levels and want to use the LinDA, limma voom, or Maaslin2 methods, you should provide a reference.\nmetadata \u003c- read_delim(\"path/to/your/metadata.txt\", delim = \"\\t\", escape_double = FALSE, trim_ws = TRUE)\n\n# Please change group to \"your_group_column\" if you are not using example dataset\ndaa_results_df \u003c- pathway_daa(abundance = kegg_abundance, metadata = metadata, group = \"Group\", daa_method = \"LinDA\", select = NULL, p.adjust = \"BH\", reference = \"Harvard BRI\")\n\n# Other example\ndata(\"metacyc_abundance\")\ndata(\"metadata\")\nmetacyc_daa_results_df \u003c- pathway_daa(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\", daa_method = \"LinDA\", select = NULL, p.adjust = \"BH\", reference = NULL)\n```\n\n### compare_daa_results() {#compare_daa_results}\n\n```{r compare_daa_results sample,echo = TRUE,eval=FALSE}\nlibrary(ggpicrust2)\nlibrary(tidyverse)\ndata(\"metacyc_abundance\")\ndata(\"metadata\")\n\n# Run pathway_daa function for multiple methods\n# Please change column_to_rownames() to the feature column if you are not using example dataset\n# Please change group to \"your_group_column\" if you are not using example dataset\nmethods \u003c- c(\"ALDEx2\", \"DESeq2\", \"edgeR\")\ndaa_results_list \u003c- lapply(methods, function(method) {\n  pathway_daa(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\", daa_method = method)\n})\n\nmethod_names \u003c- c(\"ALDEx2\",\"DESeq2\", \"edgeR\")\n# Compare results across different methods\ncomparison_results \u003c- compare_daa_results(daa_results_list = daa_results_list, method_names = method_names)\n```\n\n### pathway_annotation() {#pathway_annotation}\n\n**If you are in China and you are using kegg pathway annotation, Please make sure your internet can break through the firewall.**\n\n```{r pathway_annotation sample,echo = TRUE,eval=FALSE}\n\n# Make sure to check if the features in `daa_results_df` correspond to the selected pathway\n\n# Annotate KEGG Pathway\ndata(\"kegg_abundance\")\ndata(\"metadata\")\n# Please change group to \"your_group_column\" if you are not using example dataset\ndaa_results_df \u003c- pathway_daa(abundance = kegg_abundance, metadata = metadata, group = \"Environment\", daa_method = \"LinDA\")\ndaa_annotated_results_df \u003c- pathway_annotation(pathway = \"KO\", daa_results_df = daa_results_df, ko_to_kegg = TRUE)\n\n# Annotate KO\ndata(\"ko_abundance\")\ndata(\"metadata\")\n# Please change column_to_rownames() to the feature column if you are not using example dataset\n# Please change group to \"your_group_column\" if you are not using example dataset\ndaa_results_df \u003c- pathway_daa(abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"), metadata = metadata, group = \"Environment\", daa_method = \"LinDA\")\ndaa_annotated_results_df \u003c- pathway_annotation(pathway = \"KO\", daa_results_df = daa_results_df, ko_to_kegg = FALSE)\n\n# Annotate KEGG\n# daa_annotated_results_df \u003c- pathway_annotation(pathway = \"EC\", daa_results_df = daa_results_df, ko_to_kegg = FALSE)\n\n# Annotate MetaCyc Pathway\ndata(\"metacyc_abundance\")\ndata(\"metadata\")\n# Please change column_to_rownames() to the feature column if you are not using example dataset\n# Please change group to \"your_group_column\" if you are not using example dataset\nmetacyc_daa_results_df \u003c- pathway_daa(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\", daa_method = \"LinDA\")\nmetacyc_daa_annotated_results_df \u003c- pathway_annotation(pathway = \"MetaCyc\", daa_results_df = metacyc_daa_results_df, ko_to_kegg = FALSE)\n```\n\n### pathway_errorbar() {#pathway_errorbar}\n\n```{r pathway_errorbar sample,echo = TRUE,eval=FALSE}\ndata(\"ko_abundance\")\ndata(\"metadata\")\nkegg_abundance \u003c- ko2kegg_abundance(data = ko_abundance) # Or use data(kegg_abundance)\n# Please change group to \"your_group_column\" if you are not using example dataset\ndaa_results_df \u003c- pathway_daa(kegg_abundance, metadata = metadata, group = \"Environment\", daa_method = \"LinDA\")\ndaa_annotated_results_df \u003c- pathway_annotation(pathway = \"KO\", daa_results_df = daa_results_df, ko_to_kegg = TRUE)\n# Please change Group to metadata$your_group_column if you are not using example dataset\np \u003c- pathway_errorbar(abundance = kegg_abundance,\n           daa_results_df = daa_annotated_results_df,\n           Group = metadata$Environment,\n           ko_to_kegg = TRUE,\n           p_values_threshold = 0.05,\n           order = \"pathway_class\",\n           select = NULL,\n           p_value_bar = TRUE,\n           colors = NULL,\n           x_lab = \"pathway_name\")\n\n# If you want to analysis the EC. MetaCyc. KO without conversions.\ndata(\"metacyc_abundance\")\ndata(\"metadata\")\nmetacyc_daa_results_df \u003c- pathway_daa(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\", daa_method = \"LinDA\")\nmetacyc_daa_annotated_results_df \u003c- pathway_annotation(pathway = \"MetaCyc\", daa_results_df = metacyc_daa_results_df, ko_to_kegg = FALSE)\np \u003c- pathway_errorbar(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"),\n           daa_results_df = metacyc_daa_annotated_results_df,\n           Group = metadata$Environment,\n           ko_to_kegg = FALSE,\n           p_values_threshold = 0.05,\n           order = \"group\",\n           select = NULL,\n           p_value_bar = TRUE,\n           colors = NULL,\n           x_lab = \"description\")\n```\n\n### pathway_heatmap() {#pathway_heatmap}\n\nIn this section, we will demonstrate how to create a pathway heatmap using the `pathway_heatmap` function in the ggpicrust2 package. This function visualizes the relative abundance of pathways in different samples.\n\nUse the fake dataset\n\n```{r  ,echo = TRUE,eval=FALSE}\n# Create example functional pathway abundance data\nabundance_example \u003c- matrix(rnorm(30), nrow = 3, ncol = 10)\ncolnames(abundance_example) \u003c- paste0(\"Sample\", 1:10)\nrownames(abundance_example) \u003c- c(\"PathwayA\", \"PathwayB\", \"PathwayC\")\n\n# Create example metadata\n# Please change your sample id's column name to sample_name\nmetadata_example \u003c- data.frame(sample_name = colnames(abundance_example),\n                               group = factor(rep(c(\"Control\", \"Treatment\"), each = 5)))\n\n# Create a heatmap\npathway_heatmap(abundance_example, metadata_example, \"group\")\n```\n\nUse the real dataset\n```{r  ,echo = TRUE,eval=FALSE}\nlibrary(tidyverse)\nlibrary(ggh4x)\nlibrary(ggpicrust2)\n# Load the data\ndata(\"metacyc_abundance\")\n\n# Load the metadata\ndata(\"metadata\")\n\n# Perform differential abundance analysis\nmetacyc_daa_results_df \u003c- pathway_daa(\n  abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"),\n  metadata = metadata,\n  group = \"Environment\",\n  daa_method = \"LinDA\"\n)\n\n# Annotate the results\nannotated_metacyc_daa_results_df \u003c- pathway_annotation(\n  pathway = \"MetaCyc\",\n  daa_results_df = metacyc_daa_results_df,\n  ko_to_kegg = FALSE\n)\n\n# Filter features with p \u003c 0.05\nfeature_with_p_0.05 \u003c- metacyc_daa_results_df %\u003e%\n  filter(p_adjust \u003c 0.05)\n\n# Create the heatmap\npathway_heatmap(\n  abundance = metacyc_abundance %\u003e%\n    right_join(\n      annotated_metacyc_daa_results_df %\u003e% select(all_of(c(\"feature\",\"description\"))),\n      by = c(\"pathway\" = \"feature\")\n    ) %\u003e%\n    filter(pathway %in% feature_with_p_0.05$feature) %\u003e%\n    select(-\"pathway\") %\u003e%\n    column_to_rownames(\"description\"),\n  metadata = metadata,\n  group = \"Environment\"\n)\n```\n### pathway_pca() {#pathway_pca}\n\nIn this section, we will demonstrate how to perform Principal Component Analysis (PCA) on functional pathway abundance data and create visualizations of the PCA results using the `pathway_pca` function in the ggpicrust2 package.\n\nUse the fake dataset\n\n```{r ,echo = TRUE,eval=FALSE}\n# Create example functional pathway abundance data\nabundance_example \u003c- matrix(rnorm(30), nrow = 3, ncol = 10)\ncolnames(kegg_abundance_example) \u003c- paste0(\"Sample\", 1:10)\nrownames(kegg_abundance_example) \u003c- c(\"PathwayA\", \"PathwayB\", \"PathwayC\")\n\n# Create example metadata\nmetadata_example \u003c- data.frame(sample_name = colnames(kegg_abundance_example),\n                                group = factor(rep(c(\"Control\", \"Treatment\"), each = 5)))\n# Perform PCA and create visualizations\npathway_pca(abundance = abundance_example, metadata = metadata_example, \"group\")\n```\n\nUse the real dataset\n```{r ,echo = TRUE,eval=FALSE}\n# Create example functional pathway abundance data\ndata(\"metacyc_abundance\")\ndata(\"metadata\")\n\npathway_pca(abundance = metacyc_abundance %\u003e% column_to_rownames(\"pathway\"), metadata = metadata, group = \"Environment\")\n```\n\n### compare_metagenome_results() {#compare_metagenome_results}\n\n```{r compare_metagenome_results sample,echo = TRUE,eval=FALSE}\nlibrary(ComplexHeatmap)\nset.seed(123)\n# First metagenome\nmetagenome1 \u003c- abs(matrix(rnorm(1000), nrow = 100, ncol = 10))\nrownames(metagenome1) \u003c- paste0(\"KO\", 1:100)\ncolnames(metagenome1) \u003c- paste0(\"sample\", 1:10)\n# Second metagenome\nmetagenome2 \u003c- abs(matrix(rnorm(1000), nrow = 100, ncol = 10))\nrownames(metagenome2) \u003c- paste0(\"KO\", 1:100)\ncolnames(metagenome2) \u003c- paste0(\"sample\", 1:10)\n# Put the metagenomes into a list\nmetagenomes \u003c- list(metagenome1, metagenome2)\n# Define names\nnames \u003c- c(\"metagenome1\", \"metagenome2\")\n# Call the function\nresults \u003c- compare_metagenome_results(metagenomes, names)\n# Print the correlation matrix\nprint(results$correlation$cor_matrix)\n# Print the p-value matrix\nprint(results$correlation$p_matrix)\n```\n\n### pathway_gsea() {#pathway_gsea}\n\nThe `pathway_gsea()` function performs Gene Set Enrichment Analysis (GSEA) on PICRUSt2 predicted functional profiles. GSEA is a powerful method for identifying enriched pathways between different conditions, offering a more nuanced understanding of functional differences compared to traditional differential abundance analysis.\n\n```{r pathway_gsea sample, echo = TRUE, eval=FALSE}\nlibrary(ggpicrust2)\nlibrary(tidyverse)\n\n# Load example data\ndata(\"ko_abundance\")\ndata(\"metadata\")\n\n# Perform GSEA analysis\ngsea_results \u003c- pathway_gsea(\n  abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"),\n  metadata = metadata,\n  group = \"Environment\",\n  method = \"fgsea\",    # Can be \"fgsea\" or \"GSEA\"\n  rank_method = \"log2_ratio\",  # Method to calculate ranking metric\n  organism = \"ko\",    # KEGG organism code\n  minSize = 10,       # Minimum gene set size\n  maxSize = 500,      # Maximum gene set size\n  nperm = 1000        # Number of permutations\n)\n\n# View the results\nhead(gsea_results)\n```\n\n### visualize_gsea() {#visualize_gsea}\n\nThe `visualize_gsea()` function creates various visualizations for GSEA results, including enrichment plots, dot plots, network plots, and heatmaps.\n\n```{r visualize_gsea sample, echo = TRUE, eval=FALSE}\nlibrary(ggpicrust2)\nlibrary(tidyverse)\n\n# Load example data and perform GSEA\ndata(\"ko_abundance\")\ndata(\"metadata\")\n\ngsea_results \u003c- pathway_gsea(\n  abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"),\n  metadata = metadata,\n  group = \"Environment\"\n)\n\n# Create an enrichment plot for a specific pathway\nenrichment_plot \u003c- visualize_gsea(\n  gsea_results = gsea_results,\n  plot_type = \"enrichment\",\n  pathway_id = gsea_results$pathway_id[1]  # Select the first pathway\n)\n\n# Create a dot plot showing top enriched pathways\ndot_plot \u003c- visualize_gsea(\n  gsea_results = gsea_results,\n  plot_type = \"dot\",\n  n_pathways = 20,  # Show top 20 pathways\n  sort_by = \"NES\"   # Sort by Normalized Enrichment Score\n)\n\n# Create a network plot showing pathway relationships\nnetwork_plot \u003c- visualize_gsea(\n  gsea_results = gsea_results,\n  plot_type = \"network\",\n  n_pathways = 15,\n  network_params = list(\n    similarity_measure = \"jaccard\",\n    similarity_cutoff = 0.2,\n    layout = \"fruchterman\",\n    node_color_by = \"NES\"\n  )\n)\n\n# Create a heatmap showing pathway gene expression\nheatmap_plot \u003c- visualize_gsea(\n  gsea_results = gsea_results,\n  plot_type = \"heatmap\",\n  abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"),\n  metadata = metadata,\n  group = \"Environment\",\n  n_pathways = 10,\n  heatmap_params = list(\n    cluster_rows = TRUE,\n    cluster_columns = TRUE,\n    show_column_names = TRUE,\n    show_row_names = FALSE\n  )\n)\n```\n\n### compare_gsea_daa() {#compare_gsea_daa}\n\nThe `compare_gsea_daa()` function compares results from GSEA and differential abundance analysis (DAA) to identify pathways that are consistently identified by both methods or uniquely identified by each method.\n\n```{r compare_gsea_daa sample, echo = TRUE, eval=FALSE}\nlibrary(ggpicrust2)\nlibrary(tidyverse)\n\n# Load example data\ndata(\"ko_abundance\")\ndata(\"metadata\")\n\n# Perform GSEA analysis\ngsea_results \u003c- pathway_gsea(\n  abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"),\n  metadata = metadata,\n  group = \"Environment\"\n)\n\n# Perform DAA analysis\ndaa_results \u003c- pathway_daa(\n  abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"),\n  metadata = metadata,\n  group = \"Environment\",\n  daa_method = \"ALDEx2\"\n)\n\n# Compare GSEA and DAA results\ncomparison \u003c- compare_gsea_daa(\n  gsea_results = gsea_results,\n  daa_results_df = daa_results,\n  gsea_pvalue_cutoff = 0.05,\n  daa_pvalue_cutoff = 0.05,\n  plot_type = \"venn\"  # Can be \"venn\", \"upset\", or \"both\"\n)\n\n# View the comparison plot\ncomparison$plot\n\n# View the overlapping pathways\nhead(comparison$overlap)\n```\n\n### gsea_pathway_annotation() {#gsea_pathway_annotation}\n\nThe `gsea_pathway_annotation()` function annotates GSEA results with pathway information, including pathway names, descriptions, and classifications.\n\n```{r gsea_pathway_annotation sample, echo = TRUE, eval=FALSE}\nlibrary(ggpicrust2)\nlibrary(tidyverse)\n\n# Load example data and perform GSEA\ndata(\"ko_abundance\")\ndata(\"metadata\")\n\ngsea_results \u003c- pathway_gsea(\n  abundance = ko_abundance %\u003e% column_to_rownames(\"#NAME\"),\n  metadata = metadata,\n  group = \"Environment\"\n)\n\n# Annotate GSEA results\nannotated_results \u003c- gsea_pathway_annotation(\n  gsea_results = gsea_results,\n  pathway = \"KO\"\n)\n\n# View the annotated results\nhead(annotated_results)\n```\n\n## Share\n\n[![Twitter](https://img.shields.io/twitter/url?url=https%3A%2F%2Fgithub.com%2Fcafferychen777%2Fggpicrust2\u0026style=social)](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fcafferychen777%2Fggpicrust2\u0026text=Check%20out%20this%20awesome%20package%20on%20GitHub%21)\n\n[![Facebook](https://img.shields.io/badge/Share_on-Facebook-1877F2?logo=facebook\u0026style=social)](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fgithub.com%2Fcafferychen777%2Fggpicrust2\u0026quote=Check%20out%20this%20awesome%20package%20on%20GitHub%21)\n\n[![LinkedIn](https://img.shields.io/badge/Share_on-LinkedIn-0077B5?logo=linkedin\u0026style=social)](https://www.linkedin.com/shareArticle?mini=true\u0026url=https%3A%2F%2Fgithub.com%2Fcafferychen777%2Fggpicrust2\u0026title=Check%20out%20this%20awesome%20package%20on%20GitHub%21)\n\n\n\n## FAQ {#faq}\n\n### Issue 1: pathway_errorbar error\n\nWhen using `pathway_errorbar` with the following parameters:\n\n``` r\npathway_errorbar(abundance = abundance,\n                 daa_results_df = daa_results_df,\n                 Group = metadata$Environment,\n                 ko_to_kegg = TRUE,\n                 p_values_threshold = 0.05,\n                 order = \"pathway_class\",\n                 select = NULL,\n                 p_value_bar = TRUE,\n                 colors = NULL,\n                 x_lab = \"pathway_name\")\n```\n\nYou may encounter an error:\n\n```\nError in `ggplot_add()`:\n! Can't add `e2` to a \u003cggplot\u003e object.\nRun `rlang::last_trace()` to see where the error occurred.\n```\n\nMake sure you have the `patchwork` package loaded:\n\n``` r\nlibrary(patchwork)\n```\n\n### Issue 2: guide_train.prism_offset_minor error\n\nYou may encounter an error with `guide_train.prism_offset_minor`:\n\n```\nError in guide_train.prism_offset_minor(guide, panel_params[[aesthetic]]) :\n  No minor breaks exist, guide_prism_offset_minor needs minor breaks to work\n```\n\n```\nError in get(as.character(FUN)，mode = \"function\"object envir = envir)\nguide_prism_offset_minor' of mode'function' was not found\n```\n\nEnsure that the `ggprism` package is loaded:\n\n``` r\nlibrary(ggprism)\n```\n\n### Issue 3: SSL certificate problem\n\nWhen encountering the following error:\n\n```\nSSL peer certificate or SSH remote key was not OK: [rest.kegg.jp] SSL certificate problem: certificate has expired\n```\n\nIf you are in China, make sure your computer network can bypass the firewall.\n\n### Issue 4: Bad Request (HTTP 400)\n\nWhen encountering the following error:\n\n```\nError in .getUrl(url, .flatFileParser) : Bad Request (HTTP 400).\n```\n\nPlease restart R session.\n\n### Issue 5: Error in grid.Call(C_textBounds, as.graphicsAnnot(xlabel),x$x, x$y, :\n\nWhen encountering the following error:\n\n```\nError in grid.Call(C_textBounds, as.graphicsAnnot(xlabel),x$x, x$y, :\n```\n\nPlease having some required fonts installed. You can refer to this [thread](https://stackoverflow.com/questions/71362738/r-error-in-grid-callc-textbounds-as-graphicsannotxlabel-xx-xy-polygo).\n\n### Issue 6: Visualization becomes cluttered when there are more than 30 features of statistical significance.\n\nWhen faced with this issue, consider the following solutions:\n\n**Solution 1: Utilize the 'select' parameter**\n\nThe 'select' parameter allows you to specify which features you wish to visualize. Here's an example of how you can apply this in your code:\n\n```\nggpicrust2::pathway_errorbar(\n  abundance = kegg_abundance,\n  daa_results_df = daa_results_df_annotated,\n  Group = metadata$Day,\n  p_values_threshold = 0.05,\n  order = \"pathway_class\",\n  select = c(\"ko05340\", \"ko00564\", \"ko00680\", \"ko00562\", \"ko03030\", \"ko00561\", \"ko00440\", \"ko00250\", \"ko00740\", \"ko04940\", \"ko00010\", \"ko00195\", \"ko00760\", \"ko00920\", \"ko00311\", \"ko00310\", \"ko04146\", \"ko00600\", \"ko04141\", \"ko04142\", \"ko00604\", \"ko04260\", \"ko00909\", \"ko04973\", \"ko00510\", \"ko04974\"),\n  ko_to_kegg = TRUE,\n  p_value_bar = FALSE,\n  colors = NULL,\n  x_lab = \"pathway_name\"\n)\n```\n\n**Solution 2: Limit to the Top 20 features**\n\nIf there are too many significant features to visualize effectively, you might consider limiting your visualization to the top 20 features with the smallest adjusted p-values:\n\n```\ndaa_results_df_annotated \u003c- daa_results_df_annotated[!is.na(daa_results_df_annotated$pathway_name),]\n\ndaa_results_df_annotated$p_adjust \u003c- round(daa_results_df_annotated$p_adjust,5)\n\nlow_p_feature \u003c- daa_results_df_annotated[order(daa_results_df_annotated$p_adjust), ]$feature[1:20]\n\n\np \u003c- ggpicrust2::pathway_errorbar(\n  abundance = kegg_abundance,\n  daa_results_df = daa_results_df_annotated,\n  Group = metadata$Day,\n  p_values_threshold = 0.05,\n  order = \"pathway_class\",\n  select = low_p_feature,\n  ko_to_kegg = TRUE,\n  p_value_bar = FALSE,\n  colors = NULL,\n  x_lab = \"pathway_name\")\n```\n\n### Issue 7: There are no statistically significant biomarkers\n\nIf you are not finding any statistically significant biomarkers in your analysis, there could be several reasons for this:\n\n1.  **The true difference between your groups is small or non-existent.** If the microbial communities or pathways you're comparing are truly similar, then it's correct and expected that you won't find significant differences.\n\n2.  **Your sample size might be too small to detect the differences.** Statistical power, the ability to detect differences if they exist, increases with sample size.\n\n3.  **The variation within your groups might be too large.** If there's a lot of variation in microbial communities within a single group, it can be hard to detect differences between groups.\n\nHere are a few suggestions:\n\n1.  **Increase your sample size**: If possible, adding more samples to your analysis can increase your statistical power, making it easier to detect significant differences.\n\n2.  **Decrease intra-group variation**: If there's a lot of variation within your groups, consider whether there are outliers or subgroups that are driving this variation. You might need to clean your data, or to stratify your analysis to account for these subgroups.\n\n3.  **Change your statistical method or adjust parameters**: Depending on the nature of your data and your specific question, different statistical methods might be more or less powerful. If you're currently using a parametric test, consider using a non-parametric test, or vice versa. Also, consider whether adjusting the parameters of your current test might help.\n\nRemember, not finding significant results is also a result and can be informative, as it might indicate that there are no substantial differences between the groups you're studying. It's important to interpret your results in the context of your specific study and not to force statistical significance where there isn't any.\n\nWith these strategies, you should be able to create a more readable and informative visualization, even when dealing with a large number of significant features.\n\n\n\n## Author's Other Projects {#authors-other-projects}\n\n1. [MicrobiomeStat](https://www.microbiomestat.wiki/): The MicrobiomeStat package is a dedicated R tool for exploring longitudinal microbiome data. It also accommodates multi-omics data and cross-sectional studies, valuing the collective efforts within the community. This tool aims to support researchers through their extensive biological inquiries over time, with a spirit of gratitude towards the community’s existing resources and a collaborative ethos for furthering microbiome research.\n\nIf you're interested in helping to test and develop MicrobiomeStat, please contact cafferychen7850@gmail.com.\n\n2. [MicrobiomeGallery](https://cafferyyang.shinyapps.io/MicrobiomeGallery/): This is a web-based platform currently under development, which aims to provide a space for sharing microbiome data visualization code and datasets.\n\n![](https://raw.githubusercontent.com/cafferychen777/ggpicrust2_paper/main/paper_figure/MicrobiomeGallery_preview.jpg)\n\nWe look forward to sharing more updates as these projects progress.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafferychen777%2Fggpicrust2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcafferychen777%2Fggpicrust2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafferychen777%2Fggpicrust2/lists"}