# NOT RUN {
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (signal.tags1, control.tags1, signal.tags2, control.tags2,
tag.shift = 146/2, background.density.scaling = F, pseudocount = 1,
bg.weight1 = NULL, bg.weight2 = NULL, rngl = NULL, chrl = NULL,
...)
{
if (is.null(chrl)) {
chrl <- intersect(names(signal.tags1), names(signal.tags2))
names(chrl) <- chrl
}
if (is.null(rngl)) {
rngl <- lapply(chrl, function(chr) range(c(range(abs(signal.tags1[[chr]] +
tag.shift)), range(abs(signal.tags2[[chr]] + tag.shift)))))
}
else {
chrl <- names(rngl)
names(chrl) <- chrl
}
ssd1 <- get.smoothed.tag.density(signal.tags1, rngl = rngl,
..., scale.by.dataset.size = F)
ssd2 <- get.smoothed.tag.density(signal.tags2, rngl = rngl,
..., scale.by.dataset.size = F)
csd1 <- get.smoothed.tag.density(control.tags1, rngl = rngl,
..., scale.by.dataset.size = F)
csd2 <- get.smoothed.tag.density(control.tags2, rngl = rngl,
..., scale.by.dataset.size = F)
if (is.null(bg.weight1)) {
bg.weight1 <- dataset.density.ratio(signal.tags1, control.tags1,
background.density.scaling = background.density.scaling)
}
if (is.null(bg.weight2)) {
bg.weight2 <- dataset.density.ratio(signal.tags2, control.tags2,
background.density.scaling = background.density.scaling)
}
cmle <- lapply(chrl, function(chr) {
d <- ssd1[[chr]]
d$y <- log2(ssd1[[chr]]$y + pseudocount * bg.weight1) -
log2(csd1[[chr]]$y + pseudocount) - log2(bg.weight1) -
log2(ssd2[[chr]]$y + pseudocount * bg.weight2) +
log2(csd2[[chr]]$y + pseudocount) + log2(bg.weight2)
return(d)
})
}
# }
Run the code above in your browser using DataLab