# 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 (ftl1, ftl2, btl1, btl2, fws, bws = 1 * fws, step = 50,
tag.shift = 146/2, alpha = 0.05, background.density.scaling = T,
bg.weight1 = NULL, bg.weight2 = NULL, posl = NULL, return.mle = F)
{
ftl1 <- ftl1[unlist(lapply(ftl1, length)) > 2]
chrl <- names(ftl1)
names(chrl) <- chrl
if (!is.null(posl)) {
chrl <- chrl[chrl %in% names(posl)]
}
if (is.null(bg.weight1)) {
bg.weight1 <- dataset.density.ratio(ftl1, btl1,
background.density.scaling = background.density.scaling)
}
if (is.null(bg.weight2)) {
bg.weight2 <- dataset.density.ratio(ftl2, btl2,
background.density.scaling = background.density.scaling)
}
lapply(chrl, function(chr) {
x <- binomial.proportion.ratio.bounds(abs(ftl1[[chr]] +
tag.shift), abs(btl1[[chr]] + tag.shift), abs(ftl2[[chr]] +
tag.shift), abs(btl2[[chr]] + tag.shift), fws = fws,
bws = bws, step = step, bg.weight1 = bg.weight1,
bg.weight2 = bg.weight2, alpha = alpha, pos = if (is.null(posl)) {
NULL
}
else {
posl[[chr]]
})
ps <- rep(0, length(x$mle))
vi <- which(!is.na(x$lb) & x$lb > 0)
ps[vi] <- x$lb[vi]
vi <- which(!is.na(x$ub) & x$ub < 0)
ps[vi] <- x$ub[vi]
if (is.null(posl)) {
if (return.mle) {
return(data.frame(x = x$x, y = ps, mle = x$mle,
lb = x$lb, ub = x$ub))
}
else {
return(data.frame(x = x$x, y = ps))
}
}
else {
if (return.mle) {
return(data.frame(x = posl[[chr]], y = ps, mle = x$mle,
lb = x$lb, ub = x$ub))
}
else {
return(data.frame(x = posl[[chr]], y = ps))
}
}
})
}
# }
Run the code above in your browser using DataLab