Learn R Programming

derfinder (version 1.6.4)

findRegions: Find non-zero regions in a Rle

Description

Find genomic regions for which a numeric vector is above (or below) predefined thresholds. In other words, this function finds the candidate Differentially Expressed Regions (candidate DERs). This is similar to regionFinder and is a helper function for calculatePvalues.

Usage

findRegions(position = NULL, fstats, chr, oneTable = TRUE,
  maxClusterGap = 300L, cutoff = quantile(fstats, 0.99, na.rm = TRUE),
  segmentIR = NULL, smooth = FALSE, weights = NULL,
  smoothFunction = bumphunter::locfitByCluster, ...)

Arguments

position
A logical Rle of genomic positions. This is generated in loadCoverage. Note that it gets updated in preprocessCoverage if colsubset is not NULL.
fstats
A numeric Rle with the F-statistics. Usually obtained using calculateStats.
chr
A single element character vector specifying the chromosome name.
oneTable
If TRUE only one GRanges is returned. Otherwise, a GRangesList with two components is returned: one for the regions with positive values and one for the negative values.
maxClusterGap
This determines the maximum gap between candidate DERs. It should be greater than maxRegionGap (0 by default).
cutoff
Threshold applied to the fstats used to determine the #' regions.
segmentIR
An IRanges object with the genomic positions that are potentials DERs. This is used in calculatePvalues to speed up permutation calculations.
smooth
Whether to smooth the F-statistics (fstats) or not. This is by default FALSE. For RNA-seq data we recommend using FALSE.
weights
Weights used by the smoother as described in smoother.
smoothFunction
A function to be used for smoothing the F-statistics. Two functions are provided by the bumphunter package: loessByCluster and runmedByCluster. If you are using your own custom function, it has to return a named list with an element called $fitted that contains the smoothed F-statistics and an element claled $smoothed that is a logical vector indicating whether the F-statistics were smoothed or not. If they are not smoothed, the original values will be used.
...
Arguments passed to other methods and/or advanced arguments.

Value

  • Either a GRanges or a GRangesList as determined by oneTable. Each of them has the following metadata variables. [object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Details

regionFinder adapted to Rle world.

References

Rafael A. Irizarry, Martin Aryee, Hector Corrada Bravo, Kasper D. Hansen and Harris A. Jaffee. bumphunter: Bump Hunter. R package version 1.1.10.

See Also

calculatePvalues

Examples

Run this code
## Preprocess the data
prep <- preprocessCoverage(genomeData, cutoff=0, scalefac=32, chunksize=1e3, 
    colsubset=NULL)

## Get the F statistics
fstats <- genomeFstats

## Find the regions
regs <- findRegions(prep$position, fstats, 'chr21', verbose=TRUE)
regs

## Once you have the regions you can proceed to annotate them
library('bumphunter')
genes <- annotateTranscripts(TxDb.Hsapiens.UCSC.hg19.knownGene::TxDb.Hsapiens.UCSC.hg19.knownGene)
annotation <- matchGenes(regs, genes)
annotation

# Find regions with smoothing the F-statistics by bumphunter::runmedByCluster
regs_smooth <- findRegions(prep$position, fstats, 'chr21', verbose = TRUE,
    smoothFunction = bumphunter::runmedByCluster)
## Compare against the object regs obtained earlier
regs_smooth

Run the code above in your browser using DataLab