getNeighborhood: getNeighborhood

Usage Arguments Examples

View source: R/getNeighborhood.R

Usage

1
getNeighborhood(comp, side = 5, binWidth = 5000)

Arguments

comp
side
binWidth

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (comp, side = 5, binWidth = 5000) 
{
    tx_name <- names(comp)
    granges <- unlist(comp)
    tx <- granges[tx_name]
    strand <- as.character(as.data.frame(strand(tx))[[1]])
    chr <- as.character(as.data.frame(seqnames(tx))[[1]])
    if (side == 5) {
        checkpoints <- rep(1, length(tx))
        checkpoints_transcript <- GRanges(seqnames = chr, IRanges(start = checkpoints, 
            end = checkpoints, names = tx_name), strand = strand)
        checkPoints_genomic <- pmapFromTranscripts(checkpoints_transcript, 
            comp)
        checkRegion_genomic <- resize(x = checkPoints_genomic, 
            width = binWidth, fix = "end")
    }
    else if (side == 3) {
        checkpoints <- sum(width(comp))
        checkpoints_transcript <- GRanges(seqnames = chr, IRanges(start = checkpoints, 
            end = checkpoints, names = tx_name), strand = strand)
        checkPoints_genomic <- pmapFromTranscripts(checkpoints_transcript, 
            comp)
        checkRegion_genomic <- resize(x = checkPoints_genomic, 
            width = binWidth, fix = "start")
    }
    names(checkRegion_genomic) <- rep("", length(tx))
    sidelist <- split(checkRegion_genomic, tx_name, drop = TRUE)
    sidelist <- sidelist[tx_name]
    mapped_chr <- as.character(as.data.frame(seqnames(checkRegion_genomic))[[1]])
    mcols(sidelist) <- data.frame(mapped_chr)
    return(sidelist)
  }

lzcyzm/Travis_Dev documentation built on May 21, 2019, 9:16 a.m.