Skip to content

Latest commit

 

History

History
129 lines (108 loc) · 3.97 KB

File metadata and controls

129 lines (108 loc) · 3.97 KB

CVRCFunc

CVRCFunc is a lightweight R package for CVRC single-cell analysis helpers. It contains pseudobulk differential expression wrappers and plotting helpers built around Seurat, DESeq2, and ggplot2.

Installation

Install from GitHub:

if (!requireNamespace("devtools", quietly = TRUE)) install.packages("devtools")
devtools::install_github("mgildea87/CVRCFunc")

Install locally from source:

devtools::install_local("/path/to/CVRCFunc")

Main functions

FindMarkersBulk()

Performs pseudobulk differential expression for every cluster using sample-level aggregation and DESeq2.

  • seurat: a Seurat object.
  • clus_ident: cluster identity column in seurat@meta.data.
  • sample_ident: sample identifier column used for pseudobulking.
  • optional batch_var, covariates, or custom design_formula.
  • outputs CSV and PDF QC files into out_dir.

FindMarkersCondition()

Runs pseudobulk DE per cluster between two conditions.

  • condition_ident: metadata column defining condition labels.
  • conditions: a length-two vector of condition values, e.g. c("treated", "control").
  • positive log2FC means higher expression in conditions[1].
  • supports batch_var, covariates, and custom design_formula.
  • use test_type = "LRT" for likelihood ratio tests or test_type = "Wald" for Wald tests.
  • with test_type = "LRT", the function uses a reduced model automatically when no custom design is provided. The reduced design will be the full design without condition_ident. If conditions == NULL (default) test will be run including all levels of condition_ident. Otherwise data will be subset to the 2 specified levels of condition_ident.

FindMarkers()

Compares two groups of cells defined by a metadata identity.

  • group_1 and group_2 are values from clus_ident.
  • sample_ident controls pseudobulk aggregation.
  • useful for pairwise cluster/group comparisons.

BetterVlnPlot()

Creates refined violin plots for feature expression from a Seurat object.

  • supports optional condition_ident to split by condition.
  • accepts idents_to_plot, ncol, dot_size, and y_axis_title.
  • returns a ggplot2 object.

Example usage

library(CVRCFunc)

# Bulk cluster DE
bulk_res <- FindMarkersBulk(
	seurat = seu,
	clus_ident = "seurat_clusters",
	sample_ident = "sample_id",
	batch_var = "batch",
	covariates = c("age", "sex"),
	out_dir = "FindMarkersBulk_output"
)

# Condition DE within clusters (LRT)
cond_res <- FindMarkersCondition(
	seurat = seu,
	clus_ident = "seurat_clusters",
	sample_ident = "sample_id",
	condition_ident = "condition",
	conditions = c("treated", "control"),
	out_dir = "FindMarkersCondition_output",
	test_type = "LRT"
)

# Condition DE within clusters (Wald)
cond_res_wald <- FindMarkersCondition(
	seurat = seu,
	clus_ident = "seurat_clusters",
	sample_ident = "sample_id",
	condition_ident = "condition",
	conditions = c("treated", "control"),
	out_dir = "FindMarkersCondition_output_wald",
	test_type = "Wald"
)

# Condition DE with custom full and reduced designs
full_design <- ~ condition + batch + age + sex
reduced_design <- ~ batch + age + sex
cond_res_design <- FindMarkersCondition(
	seurat = seu,
	clus_ident = "seurat_clusters",
	sample_ident = "sample_id",
	condition_ident = "condition",
	conditions = c("treated", "control"),
	design_formula = full_design,
	out_dir = "FindMarkersCondition_output_design",
	test_type = "LRT"
)

# Pairwise group comparison
pair_res <- FindMarkers(
	seurat = seu,
	clus_ident = "seurat_clusters",
	group_1 = "0",
	group_2 = "1",
	sample_ident = "sample_id",
	batch_var = "batch",
	out_dir = "FindMarkers_output"
)

# Better violin plot
p <- BetterVlnPlot(
	seurat = seu,
	clus_ident = "seurat_clusters",
	features = c("CD3D", "GNLY"),
	assay = "RNA",
	condition_ident = "treatment",
	ncol = 2,
	dot_size = 0.5
)
print(p)

Notes

  • Requires Seurat, DESeq2, ggplot2, pheatmap, tidyr, ggbeeswarm, and related packages.
  • Functions create output directories automatically when needed.