pathway_pca {ggpicrust2}R Documentation

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.

Value

A ggplot object showing the PCA results.

Examples

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

# Create example metadata
# Please ensure the sample IDs in the metadata have the column name "sample_name"
metadata_example <- data.frame(sample_name = colnames(kegg_abundance_example),
                               group = factor(rep(c("Control", "Treatment"), each = 5)))

pca_plot <- pathway_pca(kegg_abundance_example, metadata_example, "group")
print(pca_plot)


data("metacyc_abundance")
data("metadata")
pathway_pca(metacyc_abundance %>% column_to_rownames("pathway"), metadata, "Environment")


[Package ggpicrust2 version 1.7.3 Index]