View source: R/composite_score_function.R
| TestMultivariateConvergence | R Documentation |
Fits a multivariate linear model (lm) to test a numeric convergence score against multiple covariates simultaneously, correcting for confounding factors.
TestMultivariateConvergence(
seurat_obj,
score_var,
test_vars,
level = c("cell", "patient"),
patient_id_var = NULL
)
seurat_obj |
Seurat object whose meta.data holds the variables. |
score_var |
Character. Name of the meta.data column holding the numeric score. |
test_vars |
Character vector. Names of the meta.data columns to include in the model. |
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"). |
The summary.lm() object (invisibly). A detailed message is printed summarizing the model.
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$tumor_status <- sample(c("Primary", "Metastatic"), ncol(seu), replace = TRUE)
seu$treatment <- sample(c("Treated", "Untreated"), 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"
)
TestMultivariateConvergence(
seurat_obj = seu,
score_var = "Converged_Immune",
test_vars = c("age", "tumor_status", "treatment"),
level = "patient",
patient_id_var = "SS"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.