Overview
This vignette describes how PRIME handles normalization across libraries and subsampling for saturation analyses in CTSS datasets.
The examples use a CTSS RangedSummarizedExperiment
object bundled with PRIME. See vignette("ctss-processing")
for how to build this object from BigWig files.
Setup
ctss <- readRDS(system.file("extdata", "ctss.rds", package = "PRIME"))Size factor normalization
PRIME provides two size-factor-based normalization functions:
# Compute size factors (e.g., from total tags or an external method)
size_factors <- colData(ctss)$totalTags
# Normalize raw counts by size factors
ctss_norm <- PRIME::normalizeBySizeFactors(
ctss,
sizeFactors = size_factors,
inputAssay = "counts",
outputAssay = "normalized"
)
# Normalize to TPM scaled by size factors
ctss_norm <- PRIME::TPMnormalizeBySizeFactors(
ctss,
sizeFactors = size_factors,
inputAssay = "counts",
outputAssay = "normalizedTPM"
)Subsampling
Subsampling is used to equalize library depth before comparative analyses and for sequencing saturation experiments.
Subsample to an absolute target depth
target_depth <- min(colData(ctss)$totalTags)
ctss_sub <- PRIME::subsampleTarget(ctss, target = target_depth)Subsample to a proportion of the library
ctss_prop <- PRIME::subsampleProportion(ctss, proportion = 0.5)Batch-aware workflows
The bundled example data do not contain batch labels, so batch
normalization is not run here. For multi-batch datasets, PRIME provides
PRIME::calcBatchSupport() to summarize support across
batches and PRIME::conditionalNormalize() to normalize
within batches. Use a batch vector with one entry per sample, for
example batch = colData(ctss)$Batch, when calling these
functions.
Export normalized BigWig files
After normalization, export per-sample BigWig files for visualization or downstream tools:
# Create the directory if it doesn't already exist
if (!dir.exists("bw_output")) {
dir.create("bw_output", recursive = TRUE)
}
PRIME::writeBw(
ctss,
replicates = "all",
dir = "bw_output/"
)See also
-
vignette("ctss-processing")- CTSS quantification and basic QC -
vignette("noise-estimation")- estimating genomic background noise -
vignette("end-to-end-workflow")- complete pipeline walkthrough - Paper analysis code