ggroc.list parameter legacy.axes break
Describe the bug
Plotting a list of ROC objects with ggroc with parameter legacy.axes = T raises error:
geom_path: Each group consists of only one observation. Do you need to adjust the group
aesthetic?
Warning message:
Removed 366 row(s) containing missing values (geom_path).
Modifying the source code solves the error.
For get.aes.for.ggplot:
if(roc$percent) {
if (legacy.axes) {
aes_list <- list(x = "FNR", y = "sensitivity")
xlims <- ggplot2::scale_x_continuous(lim=c(0, 100))
}
else {
aes_list <- list(x = "specificity", y = "sensitivity")
xlims <- ggplot2::scale_x_reverse(lim=c(100, 0))
}
}
else {
if (legacy.axes) {
aes_list <- list(x = "FNR", y = "sensitivity")
xlims <- ggplot2::scale_x_continuous(lim=c(0, 1))
}
else {
aes_list <- list(x = "specificity", y = "sensitivity")
xlims <- ggplot2::scale_x_reverse(lim=c(1, 0))
}
}
For ggroc.list:
# Add a "name" colummn
for (i in seq_along(coord.dfs)) {
coord.dfs[[i]]$name <- names(coord.dfs)[i]
}
# Add a "1-specificity" colummn
for (i in seq_along(coord.dfs)) {
if(data[[1]]$percent) {
coord.dfs[[i]]$FNR <- 100 - coord.dfs[[i]]$specificity
}
else {
coord.dfs[[i]]$FNR <- 1 - coord.dfs[[i]]$specificity
}
}
This issue comes from misinterpretation of aes_list <- list(x = "1-specificity", y = "sensitivity")
> R.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 1.3
year 2022
month 03
day 10
svn rev 81868
language R
version.string R version 4.1.3 (2022-03-10)
nickname One Push-Up
Package pROC version 1.18.0
Hi Baytars, thanks for the bug report.
I can't reproduce it.
library(pROC)
data(aSAH)
rocobj <- roc(aSAH$outcome, aSAH$s100b)
ggroc(rocobj, legacy.axes = TRUE)
Works fine for me, and produce a plot with legacy axes as expected.
The bug report template asked for extra information that can help reproduce the issue, in particular sessionInfo and the exact code that triggered the error. It would be really helpful if you could include that information.
@Baytars: I am closing the bug report as I can't reproduce it. Please feel free to reopen it and provide the extra details requested above. Thanks!