background image

Package ‘ggpicrust2’

March 28, 2023

Type Package

Title Make 'PICRUSt2' Output Analysis and Visualization Easier

Version 1.4.9

Description Provides a convenient way to analyze and visualize 'PICRUSt2' output with pre-

defined plots and functions. Allows for generating statistical plots about microbiome func-
tional predictions and offers customization options. Features a one-click option for creating pub-
lication-level plots, saving time and effort in producing professional-grade figures. Stream-
lines the 'PICRUSt2' analysis and visualization process. For more de-
tails, see Yang et al. (2023) <

arXiv:2303.10388

>.

BugReports

https://github.com/cafferychen777/ggpicrust2/pulls

URL

https://github.com/cafferychen777/ggpicrust2

License MIT + file LICENSE

Encoding UTF-8

RoxygenNote 7.2.3

Imports ALDEx2, aplot, DESeq2, dplyr, edgeR, funrar, GGally, ggplot2,

grid, lefser, limma, Maaslin2, metagenomeSeq, MicrobiomeStat,
readr, stats, SummarizedExperiment, tibble, tidyr, ggprism

Depends R (>= 3.5.0)

Suggests covr, testthat (>= 3.0.0), cowplot, Biobase, devtools,

KEGGREST, ComplexHeatmap, ggforce, patchwork, ggplotify,
BiocGenerics, BiocManager, magrittr, utils

Config/testthat/edition 3

NeedsCompilation no

Author Chen Yang [aut, cre],

Liangliang Zhang [aut]

Maintainer Chen Yang <cafferychen7850@gmail.com>

Repository CRAN

Date/Publication 2023-03-28 12:40:02 UTC

1


background image

2

ggpicrust2

R topics documented:

ggpicrust2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2

ko2kegg_abundance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

pathway_annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4

pathway_daa

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

pathway_errorbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6

pathway_heatmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7

pathway_pca

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

Index

10

ggpicrust2

This function integrates pathway name/description annotations, ten of
the most advanced differential abundance (DA) methods, and visual-
ization of DA results.

Description

This function integrates pathway name/description annotations, ten of the most advanced differen-
tial abundance (DA) methods, and visualization of DA results.

Usage

ggpicrust2(

file,
metadata,
group,
pathway,
daa_method = "ALDEx2",
ko_to_kegg = FALSE,
p.adjust = "BH",
order = "group",
p_values_bar = TRUE,
x_lab = "pathway_name",
select = NULL,
reference = NULL,
colors = NULL

)

Arguments

file

A character, the file path to store picrust2 export files

metadata

A tibble, consisting of sample information

group

A character, name of the group

pathway

A character, consisting of "EC", "KO", "MetaCyc"

daa_method

A character, the chosen differential abundance analysis (DA) method


background image

ko2kegg_abundance

3

ko_to_kegg

A character to control the conversion of KO abundance to KEGG abundance

p.adjust

A character, the method to adjust p-values

order

A character to control the order of the main plot rows

p_values_bar

A character to control if the main plot has the p_values bar

x_lab

A character to control the x-axis label name

select

A vector consisting of pathway names to be selected

reference

A character, a reference group level for several DA methods

colors

A vector consisting of colors number

Value

daa.results.df, a dataframe of DA results

Examples

## Not run:
# Load necessary data: abundance data and metadata
abundance_file <- "path/to/your/abundance_file.tsv"
metadata <- read.csv("path/to/your/metadata.csv")

# Run ggpicrust2 with desired parameters
results <- ggpicrust2(file = abundance_file,

metadata = metadata,
group = "your_group_column",
pathway = "KO",
daa_method = "ALDEx2")

# Access the plot and results dataframe for the first DA method
example_plot <- results[[1]]$plot
example_results <- results[[1]]$results

## End(Not run)

ko2kegg_abundance

Convert KO abundance in picrust2 export files to KEGG pathway
abundance

Description

This function takes a file containing KO (KEGG Orthology) abundance data in picrust2 export
format and converts it to KEGG pathway abundance data. The input file should be in .tsv, .txt, or
.csv format.

Usage

ko2kegg_abundance(file)


background image

4

pathway_annotation

Arguments

file

A character string representing the file path of the input file containing KO abun-
dance data in picrust2 export format. The input file should have KO identifiers
in the first column and sample identifiers in the first row. The remaining cells
should contain the abundance values for each KO-sample pair.

Value

A data frame with KEGG pathway abundance values. Rows represent KEGG pathways, identified
by their KEGG pathway IDs. Columns represent samples, identified by their sample IDs from
the input file. Each cell contains the abundance of a specific KEGG pathway in a given sample,
calculated by summing the abundances of the corresponding KOs in the input file.

Examples

## Not run:
library(ggpicrust2)
# Prepare an example input file
input_file <- system.file("extdata", "example_ko_abundance.tsv", package = "ggpicrust2")

# Run ko2kegg_abundance function
kegg_abundance <- ko2kegg_abundance(file = input_file)

## End(Not run)

pathway_annotation

Pathway information annotation of "EC", "KO", "MetaCyc" pathway

Description

Pathway information annotation of "EC", "KO", "MetaCyc" pathway

Usage

pathway_annotation(

file = NULL,
pathway = NULL,
daa_results_df = NULL,
ko_to_kegg = FALSE

)

Arguments

file

A character, address to store picrust2 export files

pathway

A character, consisting of "EC", "KO", "MetaCyc"

daa_results_df

A data frame, output of pathway_daa

ko_to_kegg

A character, decide if convert ko abundance to kegg pathway abundance


background image

pathway_daa

5

Value

A data frame containing pathway annotation information. The data frame has the following columns:

• feature: The feature ID of the pathway (e.g., KO, EC, or MetaCyc ID).

• description: The description or name of the pathway.

• Other columns depending on the input parameters and type of pathway.

If ko_to_kegg is set to TRUE, the output data frame will also include the following columns:

• pathway_name: The name of the KEGG pathway.

• pathway_description: The description of the KEGG pathway.

• pathway_class: The class of the KEGG pathway.

• pathway_map: The KEGG pathway map ID.

Examples

## Not run:
# Prepare the required input files and data frames
# Then, you can use the pathway_annotation function as follows:

result <- pathway_annotation(file = "path/to/picrust2/export/file.txt",

pathway = "KO",
daa_results_df = NULL,
ko_to_kegg = FALSE)

## End(Not run)

pathway_daa

Predictional functional patwhay differential abundance (DA)

Description

Predictional functional patwhay differential abundance (DA)

Usage

pathway_daa(

abundance,
metadata,
group,
daa_method = "ALDEx2",
select = NULL,
p.adjust = "BH",
reference = NULL

)


background image

6

pathway_errorbar

Arguments

abundance

a data frame containing predicted functional pathway abundance

metadata

a tibble containing samples information

group

a character specifying the group name for differential abundance analysis

daa_method

a character specifying the method for differential abundance analysis, default is
"ALDEx2"

select

a vector containing pathway names for analysis, if NULL all pathways are in-
cluded, default is NULL

p.adjust

a character specifying the method for p-value adjustment, default is "BH"

reference

a character specifying the reference group level, required for several differential
abundance analysis methods such as LinDA, limme voom and Maaslin2, default
is NULL

Value

a data frame containing the differential abundance analysis results.

Examples

library(ggpicrust2)
library(MicrobiomeStat)
abundance <- data.frame(sample1 = c(10, 20, 30),
sample2 = c(20, 30, 40),
sample3 = c(30, 40, 50),
row.names = c("pathway1", "pathway2", "pathway3"))

metadata <- tibble::tibble(sample = paste0("sample", 1:3),
group = c("control", "control", "treatment"))

#Run pathway_daa function
result <- pathway_daa(abundance = abundance, metadata = metadata, group = "group",
daa_method = "LinDA")

pathway_errorbar

The function pathway_errorbar() is used to visualize the results of
functional pathway differential abundance analysis as error bar plots.

Description

The function pathway_errorbar() is used to visualize the results of functional pathway differential
abundance analysis as error bar plots.


background image

pathway_heatmap

7

Arguments

abundance

A data frame with row names representing pathways and column names repre-
senting samples. Each element represents the relative abundance of the corre-
sponding pathway in the corresponding sample.

daa_results_df

A data frame containing the results of the differential abundance analysis of the
pathways, generated by the pathway_daa function.

Group

A data frame or a vector that assigns each sample to a group. The groups are
used to color the samples in the figure.

ko_to_kegg

A logical parameter indicating whether to convert pathway IDs from KEGG
orthology (KO) to KEGG pathway IDs. If TRUE, the conversion will be per-
formed.

p_values_threshold

A numeric parameter specifying the threshold for statistical significance of dif-
ferential abundance. Pathways with p-values below this threshold will be con-
sidered significant.

order

A parameter controlling the ordering of the rows in the figure. The options are:
"p_values" (order by p-values), "name" (order by pathway name), "group" (or-
der by the group with the highest mean relative abundance), or "pathway_class"
(order by the pathway category).

select

A vector of pathway names to be included in the figure. This can be used to limit
the number of pathways displayed. If NULL, all pathways will be displayed.

p_value_bar

A logical parameter indicating whether to display a bar showing the p-value
threshold for significance. If TRUE, the bar will be displayed.

colors

A vector of colors to be used to represent the groups in the figure. Each color
corresponds to a group.

x_lab

A character string to be used as the x-axis label in the figure. The default value
is "description" for KO IDs and "pathway_name" for KEGG pathway IDs.

Value

A figure showing the error bar plot of the differential abundance analysis results for the functional
pathways.

pathway_heatmap

Create pathway heatmap

Description

This function creates a heatmap of the predicted functional pathway abundance data. The function
first makes the abundance data relative, then converts the abundance data to a long format and orders
the samples based on the environment information. The heatmap is then created using the ‘ggplot2‘
library. The color palette, appearance and the color bar of the heatmap can be customized using the
‘scale_fill_gradientn‘, ‘theme‘ and ‘guides‘ functions respectively.


background image

8

pathway_pca

Arguments

abundance

A matrix or data frame of pathway abundance data, where columns correspond
to samples and rows correspond to pathways.

metadata

A data frame of metadata, where each row corresponds to a sample and each
column corresponds to a metadata variable.

group

A character string specifying the column name in the metadata data frame that
contains the group variable.

Value

A ggplot heatmap object. The output is a ggplot object representing the heatmap of the predicted
functional pathway abundance data. The heatmap visualizes the relative abundance of pathways in
different samples.

Examples

# Create example functional pathway abundance data
abundance_example <- matrix(rnorm(30), nrow = 10, ncol = 3)
rownames(abundance_example) <- paste0("Sample", 1:10)
colnames(abundance_example) <- c("PathwayA", "PathwayB", "PathwayC")

# Create example metadata
metadata_example <- data.frame(sample_name = rownames(abundance_example),

group = factor(rep(c("Control", "Treatment"), each = 5)))

# Create a heatmap
heatmap_plot <- pathway_heatmap(t(abundance_example), metadata_example, "group")
print(heatmap_plot)

pathway_pca

Perform Principal Component Analysis (PCA) on functional pathway
abundance data and create visualizations of the PCA results.

Description

Perform Principal Component Analysis (PCA) on functional pathway abundance data and create
visualizations of the PCA results.

Usage

pathway_pca(abundance, metadata, group)

Arguments

abundance

A data frame, predicted functional pathway abundance.

metadata

A tibble, consisting of sample information.

group

A character, group name.


background image

pathway_pca

9

Value

A ggplot object showing the PCA results.

Examples

# Create example functional pathway abundance data
abundance_example <- data.frame(A = rnorm(10), B = rnorm(10), C = rnorm(10))

# Create example metadata
metadata_example <- tibble::tibble(sample_id = 1:10,

group = factor(rep(c("Control", "Treatment"), each = 5)))

# Perform PCA and create visualizations
pca_plot <- pathway_pca(t(abundance_example), metadata_example, "group")
print(pca_plot)


background image

Index

ggpicrust2

,

2

ko2kegg_abundance

,

3

pathway_annotation

,

4

pathway_daa

,

5

pathway_errorbar

,

6

pathway_heatmap

,

7

pathway_pca

,

8

10