Skip to contents

This function computes the average abundance of each cell type stratified by phenotype labels and visualizes the result using a line plot. Labels are based on prediction scores or user-provided values.

Usage

PhenoAbundancePlot(cell_type_distribution, pred_score)

Arguments

cell_type_distribution

A data.frame or matrix of cell type proportions per spot (rows = spots, columns = cell types).

pred_score

A data.frame with prediction scores. Must contain at least column "pred_score" and optional "label". Row names should match those of cell_type_distribution.

Value

A ggplot2 object showing average cell type abundance across phenotype groups.

Details

This plot is useful for interpreting how cell type composition differs across predicted phenotypic groups. Input data should contain cell type proportions and prediction scores with associated phenotype labels.

Author

Bin Duan

Examples

if (FALSE) { # \dontrun{
cell_type_distribution <- matrix(runif(300), nrow = 100,
  dimnames = list(paste0("spot", 1:100), paste0("cell", 1:3)))
pred_score <- data.frame(
  pred_score = rnorm(100),
  label = sample(c("phenotype+", "phenotype-", "background"), 100, replace = TRUE),
  row.names = paste0("spot", 1:100)
)
PhenoAbundancePlot(cell_type_distribution, pred_score)
} # }