Skip to contents

Creates a Sankey diagram to visualize the correspondence between original and projected cell type labels, typically used to show scRNA-seq cell type annotation results.

Usage

sankey_plot(predict_result, sample_information_reference, plot = FALSE)

Arguments

predict_result

A data frame with 3 columns:

  • Column 1: Original labels

  • Column 2: Projected labels

  • Column 3: Sample names

sample_information_reference

Named vector of reference cell type annotations

plot

Whether to display the Sankey diagram (default: FALSE)

Value

The augmented prediction data frame including all reference cell types. If plot=TRUE, also displays the Sankey diagram.

Details

This function:

  • Processes prediction results to include all reference cell types

  • Generates a Sankey diagram showing label transitions

  • Handles cases where some reference cell types are not predicted

The visualization helps evaluate how cell types are mapped between reference and query datasets.

See also

getSankey for the underlying Sankey diagram implementation

Author

Bin Duan (binduan\@sjtu.edu.cn)

Examples

if (FALSE) { # \dontrun{
# Mock prediction results
predict_df <- data.frame(
  orign_label = c("Tcell", "Bcell", "Tcell", "Macrophage"),
  projection_label = c("CD4+", "CD19+", "CD8+", "Mono"),
  sample_name = rep("sample1", 4)
)

# Reference cell types
ref_labels <- c("Tcell", "Bcell", "Macrophage", "Neutrophil")

# Generate plot
sankey_plot(
  predict_result = predict_df,
  sample_information_reference = ref_labels,
  plot = TRUE
)

# Get augmented results without plotting
augmented_results <- sankey_plot(
  predict_result = predict_df,
  sample_information_reference = ref_labels
)
} # }