View source: R/deletion-utils.R
preprocessData | R Documentation |
Collects preprocessed bin-level log2 ratios, segmentation, proper read
pairs surrounding deletions, improper read pairs supporting deletions,
a path to the bam file, and the reference genome build of the bam file into
a comprehensive list
that can be used as input to the
sv_deletions
and sv_amplicons2
functions.
preprocessData(bam.file = NULL, genome, bins, segments, read_pairs)
bam.file |
length-one character vector providing path to BAM file |
genome |
length-one character vector providing genome build (hg18 or hg19) |
bins |
a |
segments |
a |
read_pairs |
a length 2 |
a list
object
library(svbams)
library(svfilters.hg19)
data(bins1kb)
extdata <- system.file("extdata", package="svbams")
bamfile <- file.path(extdata, "cgov44t_revised.bam")
## Extract all improper readpairs
what <- c("flag", "mrnm", "mpos", "mapq")
iparams <- improperAlignmentParams(what=what)
improper_rp <- getImproperAlignmentPairs(bamfile,
param=iparams,
build="hg19")
ddir <- system.file("extdata", package="svbams",
mustWork=TRUE)
## load normalized read depth (see trellis vignette)
lr <- readRDS(file.path(ddir, "preprocessed_coverage.rds"))/1000
seqlevels(bins1kb, pruning.mode="coarse") <- paste0("chr", c(1:22, "X"))
bins1kb$log_ratio <- lr
bins <- keepSeqlevels(bins1kb, c("chr5", "chr8", "chr15"),
pruning.mode="coarse")
## Load segmentation data
path <- system.file("extdata", package="svbams")
segs <- readRDS(file.path(path, "cgov44t_segments.rds"))
seqlevels(segs, pruning.mode="coarse") <- seqlevels(bins)
## candidate deletions
dp <- DeletionParam(remove_hemizygous=FALSE)
dp
del.gr <- IRanges::reduce(segs[segs$seg.mean < hemizygousThr(dp)],
min.gapwidth=2000)
## sample properly and improperly paired read pairs near candidate deletions
proper_rp <- properReadPairs(bamfile, gr=del.gr, dp)
improper_rp <- keepSeqlevels(improper_rp, seqlevels(segs),
pruning.mode="coarse")
read_pairs <- list(proper_del=proper_rp, improper=improper_rp)
## Collect data from preprocessing in a single list object
pdata <- preprocessData(bam.file=bamfile,
genome="hg19",
bins=bins1kb,
segments=segs,
read_pairs=read_pairs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.