R/calculateEnrichment.R
calculateGenomicCGDistribution.RdCompute genome-wide CpG metrics for a given BSgenome:
relH: relative CpG frequency (% of dinucleotides that are "CG").
GoGe: enrichment statistic \((nCG * genome_length) / (nC * nG)\).
calculateGenomicCGDistribution(BSgenome)A data.frame with two numeric columns:
genome.relH — percent of "CG" dinucleotides genome-wide.
genome.GoGe — GoGe enrichment statistic.
These values are used as denominators to normalise sample-level CpG enrichment.
Chromosomes with names containing "rand" or "chrUn" are excluded.
The BSgenome indicated by BSgenome is loaded dynamically.
Uses Biostrings and BSgenome utilities to count CpG, C, and G occurrences across the genome.
calculateCGEnrichment(), calculateCGEnrichmentGRanges(), BSgenome,
Biostrings
# Example: compute genome-wide CpG metrics for a S. cerevisae genome.
# It could be done for GRCh38 genome instead, but it will take more time to
# run (package must be installed)
if (requireNamespace("BSgenome.Scerevisiae.UCSC.sacCer3", quietly = TRUE)) {
calculateGenomicCGDistribution("BSgenome.Scerevisiae.UCSC.sacCer3")
}
#> genome.relH genome.GoGe
#> 1 2.922563 0.8033108