make_centered_query_gr: make_centered_query_gr

View source: R/functions_make.R

make_centered_query_grR Documentation

make_centered_query_gr

Description

Returns version of query_gr GRanges centered on the maximum signal in bams/bigwigs supplied by query_dt.

Usage

make_centered_query_gr(
  query_dt,
  query_gr,
  view_size = NULL,
  fetch_fun = NULL,
  n_cores = getOption("mc.cores", 1),
  ...
)

Arguments

query_dt

data.table with query information. Only really needs file as first column.

query_gr

GRanges to be centered.

view_size

Size of final regions.

n_cores

Number of cores to use. Defaults to mc.cores if set or 1.

...

passed on the ssvFechBam or ssvFetchBigwig. Do not use, n_cores, win_size, win_method, return_data.table or n_region_splits.

Value

GRanges centered on the maximum signal

Examples

library(seqsetvis)
#bigwig example with 3 bigwigs
bw_files = dir(system.file("extdata", package = "seqqc"),
  pattern = "bw$", full.names = TRUE)
query_dt = make_dt(bw_files)
query_dt[, sample := sub("_FE_random100.A", "", name)]

peak_files = dir(system.file("extdata", package = "seqqc"),
  pattern = "Peak$", full.names = TRUE)
peak_grs = easyLoad_narrowPeak(peak_files)
query_gr = resize(ssvOverlapIntervalSets(peak_grs), 700, fix = "center")



#heatmap before centering
set.seed(0)
ssvSignalHeatmap(ssvFetchBigwig(query_dt, query_gr), nclust = 4) +
  labs(title = "Before centering")

query_gr.centered = make_centered_query_gr(query_dt, query_gr)
set.seed(0)
ssvSignalHeatmap(ssvFetchBigwig(query_dt, query_gr.centered), nclust = 4)+
  labs(title = "After centering")

#bam example with 1 bam, query_dt can just be file paths
peak_file = dir(system.file("extdata", package = "seqqc"),
  pattern = "test_peaks.bed$", full.names = TRUE)
bam_file = dir(system.file("extdata", package = "seqqc"),
  pattern = "test_peaks.bam$", full.names = TRUE)

query_gr2 = easyLoad_bed(peak_file)[[1]]
set.seed(0)
ssvSignalHeatmap(ssvFetchBam(bam_file, query_gr2), nclust = 4) +
  labs(title = "Before centering")

query_gr2.centered = make_centered_query_gr(bam_file, query_gr2, fragLens = 180)
set.seed(0)
ssvSignalHeatmap(ssvFetchBam(bam_file, query_gr2.centered), nclust = 4) +
  labs(title = "After centering")

FrietzeLabUVM/ssvQC documentation built on March 25, 2024, 12:24 a.m.