Description Usage Arguments Value Author(s) Examples
Compute false positive and false negative rates in order to draw ROC curves.
1 | errorRates(guess.list, break.vec, last.base)
|
guess.list |
List of integer vectors, model guesses. |
break.vec |
Integer vector, breakpoints in true signal. |
last.base |
Integer scalar, last base in true signal. |
data.frame with columns FP, FN, FPR, FNR, TPR.
Toby Dylan Hocking
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 | seg.size <- 100
means <- c(-3,0,3,0,2,-1,3)/3
mu <- do.call(c,lapply(means,rep,seg.size))
mu.break.after <- which(diff(mu)!=0)
## Choose some bases to sample, and pick them from a normal
## distribution.
base <- as.integer(seq(1,length(mu),l=300))
set.seed(1)
signal <- rnorm(length(base),mu[base],0.5)
profile <- data.frame(base, signal)
library(ggplot2)
ggplot()+
geom_point(aes(base, signal), data=profile)
library(flsa)
flsa.fit <- flsa(signal, lambda2=10^seq(-2, 2, l=100))
between.vec <- as.integer((base[-1]+base[-length(base)])/2)
flsa.list <- apply(flsa.fit, 1, function(x)between.vec[which(diff(x)!=0)])
flsa.rates <- errorRates(flsa.list, mu.break.after, length(mu))
## Segment that signal with cghseg, and quantify model fit using the
## breakpointError.
result <- run.cghseg(signal, base, maxSegments=15)
cghseg.rates <- errorRates(result$breaks, mu.break.after, length(mu))
rates <-
rbind(data.frame(cghseg.rates, package="cghseg"),
data.frame(flsa.rates, package="flsa"))
getMin <- function(df, package, xdiff){
m <- subset(df, seq_along(error)==which.min(error))
data.frame(m, package, xdiff)
}
min.err <-
rbind(getMin(cghseg.rates, "cghseg", -1),
getMin(flsa.rates, "flsa", 1))
ggplot()+
ggtitle("ROC curves and minimum breakpointError of two models")+
scale_y_continuous("True positive rate", limits=c(0, 1))+
scale_x_continuous("False positive rate")+
guides(color="none")+
geom_point(aes(FPR, TPR, color=package),
data=min.err,
pch=1)+
geom_text(aes(FPR+xdiff*0.01, TPR, color=package,
label=sprintf("FP=%d\nFN=%d\nI=%.1f\n%s",
FP, FN, I, package)),
data=min.err)+
geom_path(aes(FPR, TPR, group=package, color=package),
data=rates)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.