-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbenchmarks.Rmd
132 lines (93 loc) Β· 3.23 KB
/
benchmarks.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
title: "benchmarks"
author: "<h4>Author: <i>Brian M. Schilder</i></h4>"
date: "<h4>Most recent update: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
output: rmarkdown::html_vignette
editor_options:
chunk_output_type: inline
vignette: >
%\VignetteIndexEntry{benchmarks}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, root.dir=here::here())
knitr::opts_knit$set(root.dir=here::here())
```
Benchmark the following strategies:
1. **uppercase** : Simply making the genes uppercase.
2. **homologene** : `method="homologene"`
3. **gorth** : `method="gorth"`
For each method, benchmark the following metrics:
- % genes mapped within species (`all_genes`).
- % genes mapped to human (`map_orthologs`).
- Speed of each metric.
```{r setup}
library(orthogene)
library(dplyr)
library(ggplot2)
library(patchwork)
```
# Define species
Repeat tests across various common model organisms.
```{r}
species <- c(human="H sapiens",
chimp="P troglodytes",
baboon="P anubis",
macaque = "M mulatta",
marmoset = "C jacchus",
mouse = "M musculus",
rat = "R norvegicus",
hamster = "M auratus",
dog = "C lupus familiaris",
cat = "F catus",
cow = "B taurus",
chicken = "G gallus",
zebrafish = "D rerio",
fly = "D melanogaster",
worm = "C elegans",
rice = "O sativa"
)
species_mapped <- map_species(species = species) |> `names<-`(names(species))
```
# Benchmark
*Note* the `orthogene:::function` notation is needed to use these benchmarking functions,
as they are internal.
## Run benchmark
`run_benchmark()` will run the full benchmarking pipeline.
You can set `mc.cores` to speed this up with multi-core parallelisation.
**WARNING**: This step can take a long time. For the purposes of this example,
we'll not run the full benchmark and instead provide some pre-computed results.
```{r, eval=FALSE}
bench_res <- orthogene:::run_benchmark(species_mapped = species_mapped[c("human","mouse","fly")],
run_convert_orthologs = TRUE,
mc.cores = 10)
# write.csv(bench_res, here::here("inst/benchmark/bench_res_example.csv"), row.names = FALSE)
```
## Print results
Load stored benchmark results.
```{r}
if(!exists("bench_res")) {
bench_res <- read.csv(system.file(package = "orthogene","benchmark/bench_res_example.csv"))
}
knitr::kable(bench_res)
```
## Plot results
### Bar plot
For each method, plot the run time (a) and the number of genes returned (b).
```{r, fig.height=10}
bench_barplot <- orthogene:::plot_benchmark_bar(bench_res = bench_res)
# ggsave(here::here("inst/benchmark/bench_barplot.pdf"),bench_barplot, height = 8)
```
### Scatter plot
For each method, plot the relationship between number of genes returned and run time.
```{r}
bench_scatterplot <- orthogene:::plot_benchmark_scatter(bench_res = bench_res)
# ggsave(here::here("inst/benchmark/bench_scatterplot.pdf"),bench_scatterplot)
```
# Session Info
<details>
```{r Session Info}
utils::sessionInfo()
```
</details>