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.
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")Performs pseudobulk differential expression for every cluster using sample-level aggregation and DESeq2.
seurat: aSeuratobject.clus_ident: cluster identity column inseurat@meta.data.sample_ident: sample identifier column used for pseudobulking.- optional
batch_var,covariates, or customdesign_formula. - outputs CSV and PDF QC files into
out_dir. - optionally writes runtime messages and warnings to a log file via
log_file.
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
log2FCmeans higher expression inconditions[1]. - supports
batch_var,covariates, and customdesign_formula. - use
test_type = "LRT"for likelihood ratio tests ortest_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. - LRT output uses the raw DESeq2
log2FCas the mainlog2FoldChangecolumn, does not add a separatelog2FoldChange_rawcolumn, and adds onelog2FoldChange_<coef_name>column per condition coefficient.
Compares two groups of cells defined by a metadata identity.
group_1andgroup_2are values fromclus_ident.sample_identcontrols pseudobulk aggregation.- useful for pairwise cluster/group comparisons.
Creates refined violin plots for feature expression from a Seurat object.
- supports optional
condition_identto split by condition. - accepts
idents_to_plot,ncol,dot_size, andy_axis_title. - returns a
ggplot2object.
library(CVRCFunc)
# Bulk cluster DEbulk_res<- FindMarkersBulk(
seurat=seu,
clus_ident="seurat_clusters",
sample_ident="sample_id",
batch_var="batch",
covariates= c("age", "sex"),
out_dir="FindMarkersBulk_output",
log_file= file.path("FindMarkersBulk_output", "analysis.log")
)
# 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 designsfull_design<-~condition+batch+age+sexreduced_design<-~batch+age+sexcond_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 comparisonpair_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 plotp<- BetterVlnPlot(
seurat=seu,
clus_ident="seurat_clusters",
features= c("CD3D", "GNLY"),
assay="RNA",
condition_ident="treatment",
ncol=2,
dot_size=0.5
)
print(p)- Requires
Seurat,DESeq2,ggplot2,pheatmap,tidyr,ggbeeswarm, and related packages. - Functions create output directories automatically when needed.