ssvFetchSignal {seqsetvis}R Documentation

signal loading framework

Description

Does nothing unless load_signal is overridden to carry out reading data from file_paths (likely via the appropriate ssvFetch* function, ie. ssvFetchBigwig or ssvFetchBam

Usage

ssvFetchSignal(file_paths, qgr, unique_names = NULL,
  names_variable = "sample", win_size = 50, win_method = c("sample",
  "summary")[1], return_data.table = FALSE, load_signal = function(f,
  nam, qgr) {     warning("nothing happened, ", "supply a function to",
  "load_signal parameter.") }, n_cores = getOption("mc.cores", 1))

Arguments

file_paths

character vector of file_paths to load from. Alternatively, file_paths can be a data.frame or data.table whose first column is a character vector of paths and additial columns will be used as metadata.

qgr

GRanges of intervals to return from each file

unique_names

unique file ids for each file in file_paths. Default is names of file_paths vector

names_variable

character, variable name for column containing unique_names entries. Default is "sample"

win_size

numeric/integer window size resolution to load signal at. Default is 50.

win_method

character. one of c("sample", "summary"). Determines if viewGRangesWinSample_dt or viewGRangesWinSummary_dt is used to represent each region in qgr.

return_data.table

logical. If TRUE data.table is returned instead of GRanges, the default.

load_signal

function taking f, nam, and qgr arguments. f is from file_paths, nam is from unique_names, and qgr is qgr. See details.

n_cores

integer number of cores to use. Uses mc.cores option if not supplied.

Details

load_signal is passed f, nam, and qgr and is executed in the environment where load_signal is defined. See ssvFetchBigwig and ssvFetchBam for examples.

Value

A GRanges with values read from file_paths at intervals of win_size. Originating file is coded by unique_names and assigned to column of name names_variable. Output is data.table is return_data.table is TRUE.

Examples

library(GenomicRanges)
bam_f = system.file("extdata/test.bam",
    package = "seqsetvis", mustWork = TRUE)
bam_files = c("a" = bam_f, "b" = bam_f)
qgr = CTCF_in_10a_overlaps_gr[1:2]
qgr = resize(qgr, 500, "center")
load_bam = function(f, nam, qgr) {
    message("loading ", f, " ...")
    dt = seqsetvis:::ssvFetchBam.single(bam_f = f,
                      qgr = qgr,
                      win_size = 50,
                      fragLen = NULL,
                      target_strand = "*",
                      return_data.table = TRUE)
    dt[["sample"]] = nam
    message("finished loading ", nam, ".")
    dt
}
ssvFetchSignal(bam_files, qgr, load_signal = load_bam)

[Package seqsetvis version 1.4.0 Index]