Create an alluvial plot via the full workflow wrapper
Source:R/alluvial_plot.r
create_alluvial_plot.RdRuns the alluvial workflow end-to-end:
prepare_alluvial_data: aggregate ASV-levelRAtotax_leveland compute group means,classify_taxa_patterns: assign abundance-pattern classes and createtax_color,generate_alluvial_palette: generate a palette fortax_color(skipped ifcustom_paletteis provided),plot_alluvial: draw the plot.
Arguments
- data
Raw long-format data with ASV-level
RAand taxonomy columns.- tax_level
Character string naming the taxonomy rank to plot (e.g.
"Class","Family").- group_col
Character string naming the grouping column used on the x-axis.
- SampleID_col
Character string naming the sample ID column (default:
"SampleID").- groups
Optional character vector restricting groups included. If
NULL, all groups are used.- low_abundance_threshold
Numeric threshold passed to
classify_taxa_patterns(default: 0.01).- palette_list
Optional vector of HCL palette names passed to
generate_alluvial_palette.- custom_palette
Optional named palette mapping
tax_colorkeys to colors. If provided, palette generation is skipped.- prepare_args
Named list of extra arguments passed to
prepare_alluvial_data.- classify_args
Named list of extra arguments passed to
classify_taxa_patterns.- palette_args
Named list of extra arguments passed to
generate_alluvial_palette(only used ifcustom_paletteisNULL).- plot_args
Named list of extra arguments passed to
plot_alluvial.- return_all
Logical; if
TRUE, returns a list with intermediate objects:data_prepared,data_classified,palette,plot.
Examples
if (FALSE) { # \dontrun{
library(dplyr)
toy <- tibble::tibble(
SampleID = c("S1","S1","S2","S2"),
Group = c("G1","G1","G1","G1"),
Class = c("A","B","A","C"),
RA = c(0.7, 0.3, 0.6, 0.4)
)
res <- create_alluvial_plot(
data = toy,
tax_level = "Class",
group_col = "Group",
prepare_args = list(complete_zero = TRUE, clean_taxonomy = FALSE),
classify_args = list(detect_mixed_abundance = TRUE),
plot_args = list(alpha = 0.7),
return_all = TRUE
)
res$plot
} # }