PlotConvergenceDensity: Plot Convergence Density

View source: R/composite_score_function.R

PlotConvergenceDensityR Documentation

Plot Convergence Density

Description

Draws overlapping density curves of a continuous variable (x_var), split by a convergence-direction column (fill_var).

Usage

PlotConvergenceDensity(
  seurat_obj,
  x_var,
  fill_var,
  color_var = NULL,
  title = NULL,
  x_label = NULL,
  alpha = 0.6
)

Arguments

seurat_obj

Seurat object whose meta.data holds x_var, fill_var, and its matching color column.

x_var

Character. Name of the meta.data column holding the continuous variable (e.g. "age").

fill_var

Character. Name of the meta.data column used to fill the density curves.

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. Defaults to x_var.

alpha

Numeric. Transparency of the density fill, between 0 and 1 (default: 0.6).

Value

A ggplot object.

Examples

seu_path <- system.file("extdata", "pbmc3k_subset.rds", package = "ConvergeR")
seu <- readRDS(seu_path)
set.seed(42)
seu$age <- sample(20:70, 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"
)

PlotConvergenceDensity(
  seurat_obj = seu,
  x_var = "age",
  fill_var = "Converged_Immune_Direction",
  x_label = "Patient Age"
)

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