cpgDensityCalc {Repitools} | R Documentation

## Calculate CpG Density in a Window

### Description

Function to calculate CpG density around a position.

### Usage

      ## S4 method for signature 'data.frame,BSgenome'
    cpgDensityCalc(x, organism, ...)
      ## S4 method for signature 'GRangesList,BSgenome'
    cpgDensityCalc(x, organism, verbose = TRUE, ...)
      ## S4 method for signature 'GRanges,BSgenome'
    cpgDensityCalc(x, organism, seq.len = NULL, window = NULL,
                                              w.function = c("none", "linear", "exp", "log"),
                                              verbose = TRUE)

### Arguments

`x` | A `data.frame`, with columns `chr` and `position`, or columns `chr`, `start`, `end`, and `strand`. Also may be a `GRangesList` object, or `GRanges`.
`window` | Bases around the locations that are in the window. Calculation will consider `window/2 - 1` bases upstream, and `window/2` bases downstream.
`w.function` | Weighting function to use. Can be `"none"`, `"linear"`, `"log"`, or `"exp"`
`organism` | The `BSgenome` object to calculate CpG density upon.
`seq.len` | The fragment size of the sequence reads in `x`. Default: No extension.
`verbose` | Print details of processing.
`...` | Arguments passed into the `data.frame` or `GRangesList` method, but not used until the `GRanges` method.

### Details

If the version of the data frame with the start, end, and strand columns is given, the window will be created around the TSS.

For weighting scheme `"none"`, this is equivalent to the number of CG matches in the region. For `"linear"` weighting, each match is given a score `1/x` where `x` is the number of bases from the postition that the match occurred, and the scores are summed. For exponential weighting and logarithmic weighting, the idea is similar, but the scores decay exponentially (`exp^-5x/window`) and logarithmically (`log2(2 - (distancesForRegion / window))`).

### Value

A `numeric` vector of CpG densities for each region.

### Author(s)

Dario Strbenac

### Examples

      if(require(BSgenome.Hsapiens.UCSC.hg18))
      {
        TSSTable <- data.frame(chr = c("chr1", "chr2"), position = c(100000, 200000))
        cpgDensityCalc(TSSTable, organism = Hsapiens, window = 600)
      }

[Package Repitools version 1.28.0 Index]