-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroc_curves.Rmd
61 lines (55 loc) · 2.48 KB
/
roc_curves.Rmd
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
54
55
56
57
58
59
60
61
---
title: ""
output: pdf_document
---
\centering
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE, fig.width = 6, fig.align = 'center', fig.height = 9)
library(targets)
library(dplyr)
library(ggplot2)
library(ggrepel)
library(pROC)
tar_load(c(detailed_stats, detailed_stats_mean, seqtype_all_results))
line_colors <- c("#d0ad2f", "#6cb649", "#bc5658", "#7f49b6", "#497db6")
```
```{r,results='asis'}
p <- lapply(unique(seqtype_all_results[["architecture"]]), function(ith_architecture) {
lapply(unique(seqtype_all_results[["method"]]), function(ith_method) {
lapply(unique(filter(seqtype_all_results, seq_source != "AMP=1")[["seq_source"]]), function(ith_benchmark) {
x <- lapply(1:5, function(i) {
dat <- filter(seqtype_all_results, architecture == ith_architecture, method == ith_method, seq_source %in% c("AMP=1", ith_benchmark), rep == i)
if(all(is.na(dat[["probability"]]))) {
roc(dat[["target"]], dat[["prediction"]])
} else {
roc(dat[["target"]], dat[["probability"]])
}
})
ggroc(x) +
theme_bw(base_size = 3) +
ggtitle(paste0("A:", ith_architecture, " TSM:", ith_method, " BSM:", ith_benchmark)) +
geom_line() +
coord_equal() +
scale_color_manual("Replication", values = line_colors) +
theme(legend.position = "none",
plot.title = element_text(size = 3))
})
})
})
l <- length(unlist(unlist(p, recursive = FALSE), recursive = FALSE))
for (i in seq(1, l, 24)) {
if(i+23 <= l) {
cat("\\begin{figure} \n\\renewcommand{\\thefigure}{S\\arabic{figure}} \n")
unlist(unlist(p, recursive = FALSE), recursive = FALSE)[i:(i+23)] %>%
gridExtra::grid.arrange(grobs = ., ncol = 4)
cat(paste0("\\caption[ROC curves ", i, "-", l, " of ", l, "]{ROC curves ", i, "-", i+23, " of ", l, ". Each subplot presents results for five replications indicated by different line colors.}"))
cat(paste0("\\label{roc", i, "-", i+23, "}\\end{figure}"))
} else {
cat("\\begin{figure} \n\\renewcommand{\\thefigure}{S\\arabic{figure}} \n")
unlist(unlist(p, recursive = FALSE), recursive = FALSE)[i:l] %>%
gridExtra::grid.arrange(grobs = ., ncol = 4)
cat(paste0("\\caption[ROC curves ", i, "-", l, " of ", l, "]{ROC curves ", i, "-", l, " of ", l, ". Each subplot presents results for five replications indicated by different line colors.}"))
cat(paste0("\\label{roc", i, "-", l, "} \n\\end{figure}"))
}
}
```