Create an Alluvial Plot Comparing Original and Predicted Classifications
make_alluvial.RdThis function generates a detailed alluvial plot to visualize the concordance and discordance between original (e.g., Lymphgen) and predicted (e.g., DLBCLone) class assignments for samples. It supports annotation of concordance rates, per-group accuracy, unclassified rates, and flexible labeling and coloring options.
Usage
make_alluvial(
optimized,
count_excluded_as_other = FALSE,
title = "",
group_order = NULL,
add_accuracy_to_title = TRUE,
accuracy_per_group = TRUE,
accuracy_type = "sensitivity",
truth_column = "lymphgen",
pred_name = "DLBCLone",
truth_name = "Lymphgen",
pred_column = "predicted_label_optimized",
nudge = 0.03,
box_nudge = 0.15,
min_flip_n = 10,
add_percent = TRUE,
add_unclass_rate = TRUE,
denom = 20,
label_size = 3,
label_lock_y = TRUE,
label_line_flip_colour = TRUE,
label_box_flip_colour = TRUE,
concordant_label_relative_pos = 0.5,
verbose = FALSE,
custom_colours = NULL,
hide_legend = TRUE,
rotate = FALSE
)Arguments
- optimized
List containing prediction results and metadata, typically output from a DLBCLone optimization function.
- count_excluded_as_other
Logical; if TRUE, samples excluded due to missing features are counted as "Other" in the plot.
- title
Plot title (default: empty string).
- group_order
Character vector specifying the order of groups/classes for axes and coloring.
- add_accuracy_to_title
Logical; if TRUE, adds accuracy/concordance rate to the plot title.
- accuracy_per_group
Logical; if TRUE, computes and displays per-group accuracy.
- accuracy_type
Type of accuracy to report (default: "sensitivity").
- nudge
Amount to nudge labels horizontally (default: 0.03).
- box_nudge
Amount to nudge label boxes (default: 0.15).
- min_flip_n
Minimum number of samples for a flow to be labeled (default: 10).
- add_percent
Logical; if TRUE, adds percent concordance to labels.
- add_unclass_rate
Logical; if TRUE, adds unclassified rate annotation to the plot.
- denom
Denominator for stratum/flow width scaling (default: 20).
- label_size
Size of label text (default: 3).
- label_lock_y
Logical; if TRUE, locks label movement to the x-axis only.
- label_line_flip_colour
Logical; controls color assignment for label lines.
- label_box_flip_colour
Logical; controls color assignment for label boxes.
- concordant_label_relative_pos
Position for concordant labels: 0 (left), 0.5 (middle), or 1 (right).
- rotate
- pred
Name of the column in predictions to use for the predicted class (default: "predicted_label_optimized").
- original_name
Name for the original class column (default: "Lymphgen").
- new_name
Name for the predicted class column (default: "DLBCLone").