PlotConvergenceCrossedProportion: Plot Convergence Crossed Proportion

View source: R/composite_score_function.R

PlotConvergenceCrossedProportionR Documentation

Plot Convergence Crossed Proportion

Description

Draws a 100%-stacked barplot of cell proportions across categories of x_var, colored by a convergence-direction column, and separated (faceted) by a secondary categorical variable (facet_var).

Usage

PlotConvergenceCrossedProportion(
  seurat_obj,
  x_var,
  fill_var,
  facet_var,
  color_var = NULL,
  title = NULL,
  x_label = NULL
)

Arguments

seurat_obj

Seurat object whose meta.data holds x_var, fill_var, facet_var, and the color column.

x_var

Character. Name of the meta.data column used on the x-axis.

fill_var

Character. Name of the meta.data column used to fill the bars.

facet_var

Character. Name of the meta.data column used to facet the plot (e.g., "tumor_status").

color_var

Character or NULL. Name of the meta.data column holding the hex color.

title

Character or NULL. Plot title.

x_label

Character or NULL. X-axis label.

Value

A ggplot object.

Examples

seu_path <- system.file("extdata", "pbmc3k_subset.rds", package = "ConvergeR")
seu <- readRDS(seu_path)
set.seed(42)
seu$SS <- paste0("Patient_", sample(1:5, ncol(seu), replace = TRUE))
seu$tumor_status <- sample(c("Primary", "Metastatic"), ncol(seu), replace = TRUE)
seu$Score_IFN <- rnorm(ncol(seu))
seu$Score_Inflam <- rnorm(ncol(seu))

seu <- CalculateConvergedScore(
  seurat_obj = seu,
  principal_score = "Score_IFN",
  other_scores = "Score_Inflam",
  output_colname = "Converged_Immune"
)

b_cross <- PlotConvergenceCrossedProportion(
  seurat_obj = seu,
  x_var = "SS",
  fill_var = "Converged_Immune_Direction",
  facet_var = "tumor_status",
  title = "Immune Convergence split by Tumor Status",
  x_label = "Patient ID"
)
print(b_cross)

ConvergeR documentation built on Oct. 10, 2026, 5:07 p.m.