getDistanceToPeak: Calculate distance between peak and feature

Description Usage Arguments Value Examples

View source: R/peakMapping.R

Description

Given a peak and a feature, returns the position and distance of the peak relative to the feature. If currentFeature and currentPeak overlap, the distance between them is 0. Otherwise, the distance between them gives how many bases away an endpoint of currentFeature is from an endpoint of currentPeak, using the endpoints closest to each other. Position of the peak relative to the feature is some combination of upstream, downstream, and overlapping. Peaks and features without strand information are assumed to be on the forward strand. Note that this is a helper function intended for use by the mapPeaks function; the user should NOT call this function themselves.

Usage

1
getDistanceToPeak(currentFeature, currentPeak)

Arguments

currentFeature

A single feature, given as the following 6 fields: chromosome, start position, end position, name, score, and strand (i.e. a single row from a dataframe returned by importBED)

currentPeak

A single peak, given as the following 6 fields: chromosome, start position, end position, name, score, and strand (i.e. a single row from a dataframe returned by importBED)

Value

A vector containing 2 items. The first item describes the position of the peak relative to the feature. This is one of:

The second item in the vector gives the distance between the peak and the feature. If the two overlap, this distance is 0. Otherwise, this distance gives how many bases away an endpoint of currentPeak is from an endpoint of currentFeature, using the endpoints that are closest together.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
  pathToPeaks <- system.file("extdata",
     "H3K27me3Peaks.bed", package = "PeakMapper")
  pathToGenes <- system.file("extdata",
     "WS263Genes.bed", package = "PeakMapper")
  H3K27me3Peaks <- importBED(pathToPeaks)
  WS263Genes <- importBED(pathToGenes)
  singlePeak <- H3K27me3Peaks[1, ]
  singleGene <- WS263Genes[1, ]
  positionAndDistance <- getDistanceToPeak(singleGene, singlePeak)
  position <- positionAndDistance[1]
  distance <- positionAndDistance[2]

## End(Not run)

fuscada2/PeakMapper documentation built on Dec. 8, 2019, 12:35 p.m.