Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/normalization.R
Randomly subsample reads according to spike-in normalization
1 2 3 4 5 6 7 8 9 10 11 12 13 |
dataset.gr, si_pattern, si_names, ctrl_pattern, ctrl_names, batch_norm, field, sample_names, expand_ranges, ncores |
See |
RPM_units |
If set to |
Note that if field = NULL
,
An object parallel to dataset.gr
, but with fewer reads. E.g.
if dataset.gr
is a list of GRanges, the output is a list of the same
GRanges, but in which each GRanges has fewer reads.
Mike DeBerardine
getSpikeInCounts
,
getSpikeInNFs
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 | #--------------------------------------------------#
# Make list of dummy GRanges
#--------------------------------------------------#
gr1_rep1 <- GRanges(seqnames = c("chr1", "chr2", "spikechr1", "spikechr2"),
ranges = IRanges(start = 1:4, width = 1),
strand = "+")
gr2_rep2 <- gr2_rep1 <- gr1_rep2 <- gr1_rep1
# set readcounts
score(gr1_rep1) <- c(1, 1, 1, 1) # 2 exp + 2 spike = 4 total
score(gr2_rep1) <- c(2, 2, 1, 1) # 4 exp + 2 spike = 6 total
score(gr1_rep2) <- c(1, 1, 2, 1) # 2 exp + 3 spike = 5 total
score(gr2_rep2) <- c(4, 4, 2, 2) # 8 exp + 4 spike = 12 total
grl <- list(gr1_rep1, gr2_rep1,
gr1_rep2, gr2_rep2)
names(grl) <- c("gr1_rep1", "gr2_rep1",
"gr1_rep2", "gr2_rep2")
grl
#--------------------------------------------------#
# (The simple spike-in NFs)
#--------------------------------------------------#
# see examples for getSpikeInNFs for more
getSpikeInNFs(grl, si_pattern = "spike", ctrl_pattern = "gr1",
method = "SNR", ncores = 1)
#--------------------------------------------------#
# Subsample the GRanges according to the spike-in NFs
#--------------------------------------------------#
ss <- subsampleBySpikeIn(grl, si_pattern = "spike", ctrl_pattern = "gr1",
ncores = 1)
ss
lapply(ss, function(x) sum(score(x))) # total reads in each
# Put in units of RPM for the negative control
ssr <- subsampleBySpikeIn(grl, si_pattern = "spike", ctrl_pattern = "gr1",
RPM_units = TRUE, ncores = 1)
ssr
lapply(ssr, function(x) sum(score(x))) # total signal in each
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.