applyNFsGRanges {BRGenomics} | R Documentation

## Apply normalization factors to GRanges object

### Description

Convenience function for multiplying signal counts in one or more GRanges object by their normalization factors.

### Usage

    applyNFsGRanges(
      dataset.gr,
      NF,
      field = "score",
      ncores = getOption("mc.cores", 2L)
    )

### Arguments

`dataset.gr` | A GRanges object with signal data in one or more metadata fields, or a list of such GRanges objects.
`NF` | One or more normalization factors to apply by multiplication. The number of normalization factors should match the number of datasets in `dataset.gr`.
`field` | The metadata field(s) in `dataset.gr` that contain signal to be normalized.
`ncores` | The number of cores to use for computations. Multicore only used if there are multiple datasets present.

### Value

A GRanges object, or a list of GRanges objects.

### Author(s)

Mike DeBerardine

### See Also

`getSpikeInNFs`

### Examples

    # Apply NFs to a single GRanges
    gr <- GRanges(seqnames = "chr1",
                  ranges = IRanges(1:3, 3:5),
                  strand = c("+", "+", "-"),
                  score = c(2, 3, 4))
    gr

    applyNFsGRanges(gr, NF = 0.5, ncores = 1)

    # Apply NFs to a list of GRanges
    gr2 <- gr
    ranges(gr2) <- IRanges(4:6, 5:7)
    grl <- list(gr, gr2)
    grl

    applyNFsGRanges(grl, NF = c(0.5, 0.75), ncores = 1)

    # Apply NFs to a multiplexed GRanges
    gr_multi <- gr
    names(mcols(gr_multi)) <- "gr1"
    gr_multi$gr2 <- c(3, 5, 7)
    gr_multi

    applyNFsGRanges(gr_multi, NF = c(2, 3), field = c("gr1", "gr2"),
                    ncores = 1)

[Package BRGenomics version 1.6.0 Index]