Skip to content

Commit

Permalink
Add more information to benchmarks (method, metric and general info) (#…
Browse files Browse the repository at this point in the history
…365)

* Update jsons

* add method meta

* add task info

* Add metric info

* remove results temp

* remove results temp

* Update image url

* change nextflow component image link

* add doi bibtex extractor

* return bobs

* create library.bib and print refs

* Update data

* Transform to functions

* add reference changes to method description

* fix dataset references

* remove echo

* WIP for old result files

* WIP fix meta data methods and links for old data

* fix metric and method meta info

* restore other tasks

* Fix dataset refernce for old data

* set echo to false

* remove bat_int library.bib

* fix image link is missing

* Fix meta labels

* fix typo

* fix task meta info

* fix empty ref links

* add dataset meta info

* Make file_size human readable

* regenerate perturbation index

* Update spatialle variable genes data

* update gitignore

* update metdo data svg

* fix wrting library file

* WIP fix write to library file

* Wip fix write to library file

* WIP transform old results

* Add second library file to svg

* WIP transform results

* Update jsons

* add method meta

* add task info

* Add metric info

* remove results temp

* remove results temp

* Update image url

* change nextflow component image link

* add doi bibtex extractor

* return bobs

* create library.bib and print refs

* Update data

* Transform to functions

* add reference changes to method description

* fix dataset references

* remove echo

* WIP for old result files

* WIP fix meta data methods and links for old data

* fix metric and method meta info

* restore other tasks

* Fix dataset refernce for old data

* set echo to false

* remove bat_int library.bib

* fix image link is missing

* Fix meta labels

* fix typo

* fix task meta info

* fix empty ref links

* add dataset meta info

* Make file_size human readable

* regenerate perturbation index

* Update spatialle variable genes data

* update gitignore

* update metdo data svg

* fix wrting library file

* WIP fix write to library file

* Wip fix write to library file

* WIP transform old results

* Add second library file to svg

* WIP transform results

* Update jsons

* remove results temp

* remove results temp

* create library.bib and print refs

* Transform to functions

* add reference changes to method description

* fix dataset references

* remove echo

* WIP fix meta data methods and links for old data

* fix metric and method meta info

* restore other tasks

* set echo to false

* remove bat_int library.bib

* fix empty ref links

* regenerate perturbation index

* Update spatialle variable genes data

* WIP fix write to library file

* Add second library file to svg

* WIP transform results

* Fix dataset information Link

* WIP add authors to task_info.yaml

* finalise script task_info transform

* update task_info jsons

* Update method and metric json files

* Add info to control methods

* uniformize bibliography

* touch library.bib

---------

Co-authored-by: Robrecht Cannoodt <[email protected]>
  • Loading branch information
KaiWaldrant and rcannood authored Nov 26, 2024
1 parent 89ee628 commit d3b719d
Show file tree
Hide file tree
Showing 63 changed files with 5,966 additions and 5,742 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/.quarto/
/_site
/_freeze
# local created libraries
/results/*/library.bib

# Temporary files generated by quarto preview
/site_libs
Expand Down
5 changes: 4 additions & 1 deletion results/_generate_task_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
for task_info_file in task_info_files:
print(f"Reading {task_info_file}", flush=True)
task_info = json.loads(task_info_file.read_text())
task_id = task_info.get("task_id", "task_id_missing")
task_id = task_info.get("task_id", "task_id_missing").replace("task_", "")
task_name = task_info.get("task_name", "<Name missing>")
task_summary = task_info.get("task_summary", "<Summary missing>")

Expand All @@ -24,6 +24,9 @@
engine: knitr
fig-cap-location: bottom
citation-location: document
bibliography:
- library.bib
- ../../library.bib
toc: false
---
Expand Down
49 changes: 47 additions & 2 deletions results/_include/_baseline_descriptions.qmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,58 @@
```{r baseline_descriptions}
#| echo: false
baselines <- method_info %>% filter(is_baseline)
lines <- pmap_chr(baselines, function(method_name, method_summary, method_description, reference, code_url, ...) {
lines <- pmap_chr(baselines, function(method_name, method_summary, method_description, reference, code_url, implementation_url, ...) {
rest <- list(...)
image <- pluck(rest, "image", .default = NULL)
documentation_url <- pluck(rest, "documentation_url", .default = NULL)
code_version <- pluck(rest, "code_version", .default = NULL)
references_doi <- pluck(rest, "references_doi", .default = NULL)
references_bibtex <- pluck(rest, "references_bibtex", .default = NULL)
if ("paper_reference" %in% names(rest)) {
ref <- split_cite_fun(rest$paper_reference)
} else {
bibs <- c()
if (!is.null(references_doi) && !is.na(references_doi)) {
bibs <- get_bibtex_from_doi(references_doi)
}
if (!is.null(references_bibtex) && !is.na(references_bibtex)) {
bibs <- c(bibs, references_bibtex)
}
# Write new entries to library.bib
write_library(bibs)
# Get bibtex references
if (!is.null(bibs)) {
ref <- get_bibtex_entries(bibs)
} else {
ref <- ""
}
}
if (ref != "") ref <- paste0(" ", ref)
summ <- (method_summary %|% "Missing 'method_summary'") %>% str_replace_all("\\n", " ") %>% str_replace_all("\\. *$", "")
method_meta <- tribble(
~icon, ~value,
"bi bi-book", if (!is.null(documentation_url)) paste0("[Documentation](", documentation_url, ")") else NULL,
"bi bi-globe", if (!is.null(code_url)) paste0("[Repository](", code_url, ")") else NULL,
"bi bi-file-earmark-code", if (!is.null(implementation_url)) paste0("[Source Code](", implementation_url, ")") else NULL,
"bi bi-box-seam", if (!is.null(image)) paste0("[Container](", image, ")") else NULL,
"bi bi-tag", if (!is.null(code_version) && !is.na(code_version)) code_version else NULL,
) %>% filter(!sapply(value, is.null))
meta_list <- paste(
paste0("<i class=\"", method_meta$icon, "\"></i> ", method_meta$value),
collapse = " · "
)
strip_margin(glue::glue("
|### {method_name}
|
|{summ}
|{meta_list}
|
|{summ} {ref}
|
|{method_description %|% ''}
|"
Expand Down
60 changes: 49 additions & 11 deletions results/_include/_dataset_descriptions.qmd
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
```{r dataset_description}
#| echo: false
lines <- pmap_chr(dataset_info, function(dataset_name, dataset_summary, dataset_description, data_reference, ...) {
ref <- split_cite_fun(data_reference)
lines <- pmap_chr(dataset_info, function(dataset_id, dataset_name, dataset_summary, dataset_description, data_reference, ...) {
rest <- list(...)
source_dataset_id <- if ("source_dataset_id" %in% names(rest)) rest$source_dataset_id else NULL
dataset_link <- if (!is.null(source_dataset_id) && dir.exists(paste0("../../datasets/", source_dataset_id))) {
glue::glue("[{dataset_name}](/datasets/{source_dataset_id})")
} else if ("scPerturb" %in% dataset_name) {
dataset_name
} else if (dir.exists(paste0("../../datasets/", rest$dataset_id))) {
glue::glue("[{dataset_name}](/datasets/{rest$dataset_id})")
source_dataset_id <- pluck(rest, "source_dataset_id", .default = NULL)
data_url <- pluck(rest, "data_url", .default = NULL)
date_created <- pluck(rest, "date_created", .default = NULL)
file_size <- pluck(rest, "file_size", .default = NULL)
if (grep("^[a-zA-Z0-9]+[0-9]{4}[a-z]+$",data_reference) && !grepl("^@",data_reference)) {
ref <- split_cite_fun(data_reference)
} else {
dataset_name
bibs <- convert_to_bibtex(data_reference)
# Write new entries to library.bib
write_library(bibs)
ref <- get_bibtex_entries(bibs)
}
if (ref != "") ref <- paste0(" ", ref)
dataset_link <- if (!is.null(source_dataset_id) && dir.exists(paste0("../../datasets/", source_dataset_id))) {
glue::glue("../../datasets/{source_dataset_id}")
} else if (dir.exists(paste0("../../datasets/", dataset_id))) {
glue::glue("../../datasets/{dataset_id}")
} else {
NULL
}
# Make file_size human readable
if (!is.null(file_size)) {
file_size_str <- format(
structure(file_size, class = "object_size"),
units = "auto",
standard = "IEC",
digits = 2
)
}
dataset_meta <- tribble(
~icon, ~value,
"bi bi-link-45deg", if(!is.null(dataset_link)) paste0("[Source dataset](", dataset_link, ")") else NULL,
"bi bi-box-arrow-up-right", if(!is.null(data_url)) paste0("[Data source](", data_url, ")") else NULL,
"bi bi-calendar", if(!is.null(date_created)) paste0(date_created) else NULL,
"bi bi-file-earmark-text", if(!is.null(file_size)) file_size_str else NULL,
) %>% filter(!sapply(value, is.null))
meta_list <- paste(
paste0("<i class=\"", dataset_meta$icon, "\"></i> ", dataset_meta$value),
collapse = " · "
)
summ <- (dataset_summary %|% "Missing 'dataset_summary'") %>% str_replace_all("\\n", " ") %>% str_replace_all("\\. *$", "")
strip_margin(glue::glue("
|### {dataset_link}
|### {dataset_name}
|
|{meta_list}
|
|{summ}{ref}.
|
Expand Down
88 changes: 88 additions & 0 deletions results/_include/_load_data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ library(tidyverse)
library(funkyheatmap)
library(kableExtra)
# touch library.bib in data dir
if (!file.exists("library.bib")) {
file.create("library.bib")
}
# read task info
task_info <- jsonlite::read_json(paste0(params$data_dir, "/task_info.json"))
Expand Down Expand Up @@ -52,6 +57,89 @@ split_cite_fun <- function(keys) {
paste0("[@", paste(refs, collapse = "; @"), "]")
}
convert_to_bibtex <- function(refs) {
bibtexhandle <- curl::new_handle()
curl::handle_setheaders(bibtexhandle, "accept" = "application/x-bibtex")
bibs <- map(refs, function(ref) {
if (grepl("^@", ref)) {
# text is already a bibtex, update citation key
ref
} else {
url <- paste0("https://doi.org/", ref)
res <- curl::curl_fetch_memory(url, handle = bibtexhandle)
if (res$status_code != 200) {
cli::cli_alert_warning(paste0("Error processing doi '", ref, "'"))
""
} else {
rawToChar(res$content)
}
}
})
return(unlist(bibs))
}
get_bibtex_from_doi <- function(dois) {
if (is.null(dois)) return("")
dois <- dois[!is.na(dois)]
if (length(dois) == 0) return("")
bibtexhandle <- curl::new_handle()
curl::handle_setheaders(bibtexhandle, "accept" = "application/x-bibtex")
refs <- unlist(dois)
bibs <- map (refs,function(ref) {
url <- paste0("https://doi.org/", ref)
res <- curl::curl_fetch_memory(url, handle = bibtexhandle)
if (res$status_code != 200) {
cli::cli_alert_warning(paste0("Error processing doi '", text, "'"))
""
} else {
rawToChar(res$content)
}
})
return(unlist(bibs))
}
write_library <- function(library) {
# Read existing entries from library.bib
existing_bibs <- if (file.exists("library.bib")) {
readLines("library.bib")
} else {
c()
}
# Filter out bibs that already exist in library.bib
new_bibs <- library[!library %in% existing_bibs]
# Write new entries to library.bib
if (length(new_bibs) > 0) {
write(new_bibs, "library.bib", append=TRUE)
}
}
get_bibtex_entries <- function(bibs) {
ref <-sapply(bibs, function(bib) {
matches <- regmatches(bib, regexpr("@.*?\\{(.*?),", bib))
if (length(matches) > 0) {
sub("@.*?\\{(.*?),", "\\1", matches)
} else {
NA
}
})
ref <- na.omit(ref)
ref_string <- paste0("[@", ref, "]", collapse = " ")
return(ref_string)
}
aggregate_scores <- function(scaled_score) {
mean(pmin(1, pmax(0, scaled_score)) %|% 0)
}
Expand Down
62 changes: 44 additions & 18 deletions results/_include/_method_descriptions.qmd
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
```{r method_description}
#| echo: false
# show each method just once
lines <- pmap_chr(method_info %>% filter(!is_baseline), function(method_name, method_summary, method_description, paper_reference, code_url, code_version, ...) {
links <- c()
if (!is.na(code_url)) {
links <- c(links, glue::glue(" [Docs]({code_url})"))
}
version_label <-
if (!is.na(code_version) && code_version != "missing-version") {
glue::glue(" Software version {code_version}.")
} else {
""
lines <- pmap_chr(method_info %>% filter(!is_baseline), function(method_name, method_summary, method_description, code_url, implementation_url, ...) {
rest <- list(...)
image <- pluck(rest, "image", .default = NULL)
documentation_url <- pluck(rest, "documentation_url", .default = NULL)
code_version <- pluck(rest, "code_version", .default = NULL)
references_doi <- pluck(rest, "references_doi", .default = NULL)
references_bibtex <- pluck(rest, "references_bibtex", .default = NULL)
if ("paper_reference" %in% names(rest)) {
ref <- split_cite_fun(rest$paper_reference)
} else {
bibs <- c()
if (!is.null(references_doi) && !is.na(references_doi)) {
bibs <- get_bibtex_from_doi(references_doi)
}
ref <- split_cite_fun(paper_reference)
if (ref != "") ref <- paste0(" ", ref)
links_label <-
if (length(links) > 0) {
glue::glue(" Links: {paste(links, collapse = ', ')}.")
if (!is.null(references_bibtex) && !is.na(references_bibtex)) {
bibs <- c(bibs, references_bibtex)
}
# Write new entries to library.bib
write_library(bibs)
# Get bibtex references
if (!is.null(bibs)) {
ref <- get_bibtex_entries(bibs)
} else {
""
ref <- ""
}
}
if (ref != "") ref <- paste0(" ", ref)
summ <- (method_summary %|% "Missing 'method_summary'") %>% str_replace_all("\\n", " ") %>% str_replace_all("\\. *$", "")
method_meta <- tribble(
~icon, ~value,
"bi bi-book", if (!is.null(documentation_url)) paste0("[Documentation](", documentation_url, ")") else NULL,
"bi bi-globe", if (!is.null(code_url)) paste0("[Repository](", code_url, ")") else NULL,
"bi bi-file-earmark-code", if (!is.null(implementation_url)) paste0("[Source Code](", implementation_url, ")") else NULL,
"bi bi-box-seam", if (!is.null(image)) paste0("[Container](", image, ")") else NULL,
"bi bi-tag", if (!is.null(code_version) && !is.na(code_version)) code_version else NULL,
) %>% filter(!sapply(value, is.null))
meta_list <- paste(
paste0("<i class=\"", method_meta$icon, "\"></i> ", method_meta$value),
collapse = " · "
)
strip_margin(glue::glue("
|### {method_name}
|
|{summ}{ref}.{version_label}{links_label}
|{meta_list}
|
|{summ}{ref}
|
|{method_description %|% ''}
|"
Expand Down
47 changes: 44 additions & 3 deletions results/_include/_metric_descriptions.qmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,53 @@
```{r}
```{r metric_descriptions}
#| echo: false
lines <- pmap_chr(metric_info, function(metric_name, metric_summary, metric_description, paper_reference, ...) {
ref <- split_cite_fun(paper_reference)
lines <- pmap_chr(metric_info, function(metric_name, metric_summary, metric_description, implementation_url, code_version, ...) {
rest <- list(...)
image <- pluck(rest, "image", .default = NULL)
code_version <- pluck(rest, "code_version", .default = NULL)
references_doi <- pluck(rest, "references_doi", .default = NULL)
references_bibtex <- pluck(rest, "references_bibtex", .default = NULL)
if ("paper_reference" %in% names(rest)) {
ref <- split_cite_fun(rest$paper_reference)
} else {
bibs <- c()
if (!is.null(references_doi) && !is.na(references_doi)) {
bibs <- get_bibtex_from_doi(references_doi)
}
if (!is.null(references_bibtex) && !is.na(references_bibtex)) {
bibs <- c(bibs, references_bibtex)
}
# Write new entries to library.bib
write_library(bibs)
# Get bibtex references
if (!is.null(bibs)) {
ref <- get_bibtex_entries(bibs)
} else {
ref <- ""
}
}
if (ref != "") ref <- paste0(" ", ref)
summ <- (metric_summary %|% "Missing 'metric_summary'") %>% str_replace_all("\\n", " ") %>% str_replace_all("\\. *$", "")
metric_meta <- tribble(
~icon, ~value,
"bi bi-file-earmark-code", if (!is.null(implementation_url)) paste0("[Source code](", implementation_url, ")") else NULL,
"bi bi-box-seam", if (!is.null(image)) paste0("[Container](", image, ")") else NULL,
"bi bi-tag", if (!is.null(code_version) && !is.na(code_version)) code_version else NULL,
) %>% filter(!sapply(value, is.null))
meta_list <- paste(
paste0("<i class=\"", metric_meta$icon, "\"></i> ", metric_meta$value),
collapse = " · "
)
strip_margin(glue::glue("
|### {metric_name}
|
|{meta_list}
|
|{summ}{ref}.
|
|{metric_description %|% ''}
Expand Down
Loading

0 comments on commit d3b719d

Please sign in to comment.