viewGRangesWinSummary_dt: Summarizes signal in bins. The same number of bins per...

Description Usage Arguments Details Value Examples

View source: R/functions_fetch_signal.R

Description

This function is most appropriate where features are expected to vary greatly in size and feature boundaries are important, ie. gene bodies, enhancers or TADs.

Usage

1
2
3
viewGRangesWinSummary_dt(score_gr, qgr, n_tiles = 100,
  anchor = c("center", "center_unstranded", "left",
  "left_unstranded")[3], summary_FUN = stats::weighted.mean)

Arguments

score_gr

GRanges with a "score" metadata column.

qgr

regions to view by window.

n_tiles

numeric >= 1, the number of tiles to use for every region in qgr.

anchor

character. controls how x value is derived from position for each region in qgr. 0 may be the left side or center. If not unstranded, x coordinates are flipped for (-) strand. One of c("center", "center_unstranded", "left", "left_unstranded"). Default is "left".

summary_FUN

function. used to aggregate score by tile. must accept x=score and w=width numeric vectors as only arguments. default is weighted.mean. limma::weighted.median is a good alternative.

Details

Columns in output data.table are: standard GRanges columns: seqnames, start, end, width, strand id - matched to names(score_gr). if names(score_gr) is missing, added as 1:length(score_gr) y - value of score from score_gr x - relative bp position

Value

data.table that is GRanges compatible

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
bam_file = system.file("extdata/test.bam",
    package = "seqsetvis")
qgr = CTCF_in_10a_overlaps_gr[1:5]
# unlike viewGRangesWinSample_dt, width is not fixed
# qgr = GenomicRanges::resize(qgr, width = 500, fix = "center")
bam_gr = fetchBam(bam_file, qgr)
bam_dt = viewGRangesWinSummary_dt(bam_gr, qgr, 50)

if(Sys.info()['sysname'] != "Windows"){
    bw_file = system.file("extdata/MCF10A_CTCF_FE_random100.bw",
        package = "seqsetvis")
    bw_gr = rtracklayer::import.bw(bw_file, which = qgr)
    bw_dt = viewGRangesWinSummary_dt(bw_gr, qgr, 50)
}

jrboyd/seqsetvis documentation built on Oct. 28, 2018, 3:16 a.m.