Skip to contents

getInteractionMatrix construct interaction matrix between two Granges objects. Names of object a became row names and names of b column names.

Usage

getInteractionMatrix(a, b, ext = 500, count = FALSE)

Arguments

a

GRanges object.

b

GRanges object.

ext

Integer specifying number of base pairs the a coordinates should be extended in upstream and downstream directions.

count

Logical indicating if matrix should hold number of overlaps between a and b or if FALSE presence / absence indicators.

Value

Sparse matrix of class dgCMatrix, with rows corresponding to a and columns to b. Each cell holds a number indicating how many times a and b overlapped.

Examples

a <- GenomicRanges::GRanges(
  seqnames = c("chr20", "chr4"),
  ranges = IRanges::IRanges(
    start = c(62475984L, 173530220L),
    end = c(62476001L, 173530236L)),
  strand = c("-", "-"),
  name = c("hg19::chr20:61051039..61051057,-;hg_188273.1",
           "hg19::chr4:174451370..174451387,-;hg_54881.1"))
b <- GenomicRanges::GRanges(
  seqnames = c("chr4", "chr20"),
  ranges = IRanges::IRanges(
    start = c(173530229L, 63864270L),
    end = c(173530236L, 63864273L)),
  strand = c("-", "-"),
  name = c("HAND2", "GATA5"))
getInteractionMatrix(a, b)
#> 2 x 2 sparse Matrix of class "dgCMatrix"
#>                                              HAND2 GATA5
#> hg19::chr20:61051039..61051057,-;hg_188273.1     .     .
#> hg19::chr4:174451370..174451387,-;hg_54881.1     1     .