When a visualization becomes cluttered due to having more than 30 statistically significant features, use one of the following strategies:
Solution 1: Use the select parameter
Specify exactly which features (e.g., KO IDs) you want to visualize using the select argument in pathway_errorbar.
Solution 2: Limit to the Top 20 features
Filter your results to only include the top 20 features with the smallest adjusted p-values.
# Solution 1: Explicit selection
ggpicrust2::pathway_errorbar(
abundance = kegg_abundance,
daa_results_df = daa_results_df_annotated,
Group = metadata$Day,
p_values_threshold = 0.05,
order = "pathway_class",
select = c("ko05340", "ko00564", "ko00680"), # Add specific IDs here
ko_to_kegg = TRUE,
p_value_bar = FALSE,
colors = NULL,
x_lab = "pathway_name"
)
# Solution 2: Top 20 by p-value
daa_results_df_annotated <- daa_results_df_annotated[!is.na(daa_results_df_annotated$pathway_name),]
daa_results_df_annotated$p_adjust <- round(daa_results_df_annotated$p_adjust, 5)
low_p_feature <- daa_results_df_annotated[order(daa_results_df_annotated$p_adjust), ]$feature[1:20]
p <- ggpicrust2::pathway_errorbar(
abundance = kegg_abundance,
daa_results_df = daa_results_df_annotated,
Group = metadata$Day,
p_values_threshold = 0.05,
order = "pathway_class",
select = low_p_feature,
ko_to_kegg = TRUE,
p_value_bar = FALSE,
colors = NULL,
x_lab = "pathway_name"
)