TestConvergenceScore: Test Convergence Score

View source: R/composite_score_function.R

TestConvergenceScoreR Documentation

Test Convergence Score

Description

Runs a statistical test between a numeric convergence score and another variable, automatically choosing the appropriate test (Spearman, Wilcoxon, or Kruskal-Wallis).

Usage

TestConvergenceScore(
  seurat_obj,
  score_var,
  test_var,
  level = c("cell", "patient"),
  patient_id_var = NULL
)

Arguments

seurat_obj

Seurat object whose meta.data holds score_var and test_var.

score_var

Character. Name of the meta.data column holding the numeric score.

test_var

Character. Name of the meta.data column to test the score against.

level

Character. Either "cell" (default) or "patient" (pseudobulk aggregation).

patient_id_var

Character. Name of the meta.data column identifying patients (required if level = "patient").

Value

The underlying htest object (invisibly). A message is printed summarizing the results.

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$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"
)

TestConvergenceScore(
  seurat_obj = seu,
  score_var = "Converged_Immune",
  test_var = "age",
  level = "patient",
  patient_id_var = "SS"
)

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