View source: R/pathway_errorbar_table.R
pathway_errorbar_table | R Documentation |
This function generates a table containing mean relative abundance, standard deviation, and log2 fold change statistics for pathways, similar to the data used in pathway_errorbar plots but returned as a data frame instead of a plot.
pathway_errorbar_table(
abundance,
daa_results_df,
Group,
ko_to_kegg = FALSE,
p_values_threshold = 0.05,
select = NULL,
max_features = 30,
metadata = NULL,
sample_col = "sample_name"
)
abundance |
A data frame or matrix containing predicted functional pathway abundance, with pathways/features as rows and samples as columns. The column names should match the sample names in metadata. |
daa_results_df |
A data frame containing differential abundance analysis results from pathway_daa function. Must contain columns: feature, group1, group2, p_adjust. |
Group |
A vector containing group assignments for each sample in the same order as the columns in abundance matrix. Alternatively, if metadata is provided, this should match the order of samples in metadata. |
ko_to_kegg |
Logical value indicating whether to use KO to KEGG conversion. Default is FALSE. |
p_values_threshold |
Numeric value for p-value threshold to filter significant features. Default is 0.05. |
select |
Character vector of specific features to include. If NULL, all significant features are included. |
max_features |
Maximum number of features to include in the table. Default is 30. |
metadata |
Optional data frame containing sample metadata. If provided, the Group vector will be reordered to match the abundance column order. |
sample_col |
Character string specifying the column name in metadata that contains sample identifiers. Default is "sample_name". |
A data frame containing the following columns:
feature
: Feature/pathway identifier
group1
: Reference group name
group2
: Comparison group name
mean_rel_abundance_group1
: Mean relative abundance for group1
sd_rel_abundance_group1
: Standard deviation of relative
abundance for group1
mean_rel_abundance_group2
: Mean relative abundance for group2
sd_rel_abundance_group2
: Standard deviation of relative
abundance for group2
log2_fold_change
: Log2 fold change (group2/group1)
p_adjust
: Adjusted p-value from differential analysis
Additional annotation columns (e.g., description
,
pathway_name
, pathway_class
) if present in the input
daa_results_df
## Not run:
# Load example data
data("ko_abundance")
data("metadata")
# Convert KO abundance to KEGG pathways
kegg_abundance <- ko2kegg_abundance(data = ko_abundance)
# Perform differential abundance analysis
daa_results_df <- pathway_daa(
abundance = kegg_abundance,
metadata = metadata,
group = "Environment",
daa_method = "ALDEx2"
)
# Filter for specific method
daa_sub_method_results_df <- daa_results_df[
daa_results_df$method == "ALDEx2_Welch's t test",
]
# Annotate results
daa_annotated_sub_method_results_df <- pathway_annotation(
pathway = "KO",
daa_results_df = daa_sub_method_results_df,
ko_to_kegg = TRUE
)
# Generate abundance statistics table
abundance_stats_table <- pathway_errorbar_table(
abundance = kegg_abundance,
daa_results_df = daa_annotated_sub_method_results_df,
Group = metadata$Environment,
ko_to_kegg = TRUE,
p_values_threshold = 0.05
)
# View the results
head(abundance_stats_table)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.