if (FALSE) {
library(ggpicrust2)
library(ggh4x)
library(dplyr)
library(tidyr)
library(tibble)
library(magrittr)
# 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
metadata_example <- data.frame(
sample_name = colnames(kegg_abundance_example),
group = factor(rep(c("Control", "Treatment"), each = 5))
)
# Custom colors for facet strips
custom_colors <- c("skyblue", "salmon")
# Create a heatmap using custom colors for facet strips
pathway_heatmap(kegg_abundance_example, metadata_example, "group", colors = custom_colors)
# Use real dataset
data("metacyc_abundance")
data("metadata")
metacyc_daa_results_df <- pathway_daa(
abundance = metacyc_abundance %>% column_to_rownames("pathway"),
metadata = metadata,
group = "Environment",
daa_method = "LinDA"
)
annotated_metacyc_daa_results_df <- pathway_annotation(
pathway = "MetaCyc",
daa_results_df = metacyc_daa_results_df,
ko_to_kegg = FALSE
)
feature_with_p_0.05 <- metacyc_daa_results_df %>% filter(p_adjust < 0.05)
pathway_heatmap(
abundance = metacyc_abundance %>%
right_join(
annotated_metacyc_daa_results_df %>%
select(all_of(c("feature","description"))),
by = c("pathway" = "feature")
) %>%
filter(pathway %in% feature_with_p_0.05$feature) %>%
select(-"pathway") %>%
column_to_rownames("description"),
metadata = metadata,
group = "Environment",
colors = custom_colors
)
}
Run the code above in your browser using DataLab