Skip to contents

Generates a UMAP plot highlighting the neighborhood of a given sample, showing its nearest neighbors and their group assignments.

Usage

make_neighborhood_plot(
  single_sample_prediction_output,
  this_sample_id,
  prediction_in_title = TRUE,
  add_circle = TRUE,
  label_column = "DLBCLone_wo",
  point_size = 0.5,
  point_alpha = 0.9,
  line_alpha = 0.9
)

Arguments

single_sample_prediction_output

A list containing prediction results and annotation data frames. Must include elements prediction (data frame with prediction results) and anno_df (data frame with UMAP coordinates and annotations).

this_sample_id

Character. The sample ID for which the neighborhood plot will be generated.

prediction_in_title

Logical. If TRUE, includes the predicted label in the plot title.

add_circle

Plot will include a circle surrounding the set of neighbors. Set to FALSE to disable.

label_column

Specify the column that contains the DLBCLone prediction you want to show. Default: the optimized Other-balanced "DLBCLone_wo".

point_size

Numeric. The size of the points in the plot. Default: 0.5.

point_alpha

Numeric. The transparency level of the points in the plot. Default: 0.9.

line_alpha

Numeric. The transparency level of the lines connecting the sample to its neighbors. Default: 0.9.

Value

A ggplot2 object representing the UMAP plot with the selected sample and its neighbors highlighted.

Details

The function extracts the nearest neighbors of the specified sample, draws segments connecting the sample to its neighbors, and colors points by group (e.g., lymphgen subtype). The plot title can optionally include the predicted label.

Examples


# Assuming 'pred_output' is the result of DLBCLone_predict_single_sample
# on sample_id "DLBCL10951T". 
if (FALSE) { # \dontrun{
 make_neighborhood_plot(pred_output, "DLBCL10951T")
} # }