applyToClosePairs: Apply a function to pairs of close genomic regions.

Description Usage Arguments Value Examples

View source: R/genomicPairAply.R

Description

This function returns a vector with the resulting functin call for each input pair.

Usage

1
applyToClosePairs(gp, rangesGR, datamat, fun = cor, maxDist = 10^6)

Arguments

gp

data.frame of pairs of genomic ranges. First two columns hold indices of the range in rangesGR. The rows has to be sorted according to the first two columns.

rangesGR

GenomicRanges object with all ranges used in gp. It shoul be annoated with seqinfo and seqnames.

datamat

a matrix of with data values associated to each rang in rangesGR. Assumes the ranges in rows while row.names(datamat) are the names(rangesGR).

fun

A function that takes two numeric vectors as imput to compute a summary statsitic. Default is cor().

maxDist

maximal distance of pairs in bp as numeric.

Value

A Numeric vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
rangesGR <- GRanges(
 rep(c("chr1", "chr2"), c(3,2)),
 IRanges(
      c(100, 200, 300, 100, 200),
      c(150, 250, 350, 150, 250)
   ))
gp <- data.frame(
 g1=c(1,4,2,1,4),
 g2=c(2,4,3,3,5)
)

datamat <- rbind(
    c(10, 20, 30),
    c(15, 26, 40),
    c(100, 2, 0),
    c(10, 20, 30),
    c(15, 26, 40)
  )
applyToClosePairs(gp, rangesGR, datamat)

ibn-salem/genepair documentation built on May 18, 2019, 1:30 a.m.