Description Usage Arguments Value Author(s) See Also Examples
View source: R/dataset_functions.R
Computes strand-specific coverage signal, and returns a GRanges object. Function also works for non-strand-specific data.
1 2 3 4 5 | getStrandedCoverage(
dataset.gr,
field = "score",
ncores = getOption("mc.cores", 2L)
)
|
dataset.gr |
A GRanges object either containing ranges for each read, or
one in which readcounts for individual ranges are contained in metadata
(typically in the "score" field). |
field |
The name of the metadata field that contains readcounts. If no metadata field contains readcounts, and each range represents a single read, set to NULL. |
ncores |
Number of cores to use for calculating coverage. For a single
dataset, the max that will be used is 3, one for each possible strand
(plus, minus, and unstranded). More cores can be used if |
A GRanges object with signal in the "score" metadata column. Note
that the output is not automatically converted into a
"basepair-resolution"
GRanges
object.
Mike DeBerardine
makeGRangesBRG
,
GenomicRanges::coverage
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #--------------------------------------------------#
# Using included full-read data
#--------------------------------------------------#
# -> whole-read coverage sacrifices meaningful readcount
# information, but can be useful for visualization,
# e.g. for looking at RNA-seq data in a genome browser
data("PROseq_paired")
PROseq_paired[1:6]
getStrandedCoverage(PROseq_paired, ncores = 1)[1:6]
#--------------------------------------------------#
# Getting coverage from single bases of single reads
#--------------------------------------------------#
# included PROseq data is already single-base coverage
data("PROseq")
range(width(PROseq))
# undo coverage for the first 100 positions
ps <- PROseq[1:100]
ps_reads <- rep(ps, times = ps$score)
mcols(ps_reads) <- NULL
ps_reads[1:6]
# re-create coverage
getStrandedCoverage(ps_reads, field = NULL, ncores = 1)[1:6]
#--------------------------------------------------#
# Reversing makeGRangesBRG
#--------------------------------------------------#
# -> getStrandedCoverage doesn't return single-width
# GRanges, which is useful because getting coverage
# will merge adjacent bases with equivalent scores
# included PROseq data is already single-width
range(width(PROseq))
isDisjoint(PROseq)
ps_cov <- getStrandedCoverage(PROseq, ncores = 1)
range(width(ps_cov))
sum(score(PROseq)) == sum(score(ps_cov) * width(ps_cov))
# -> Look specifically at ranges that could be combined
neighbors <- c(shift(PROseq, 1), shift(PROseq, -1))
hits <- findOverlaps(PROseq, neighbors)
idx <- unique(from(hits)) # indices for PROseq with neighbor
PROseq[idx]
getStrandedCoverage(PROseq[idx], ncores = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.