Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into update-perturb-pred-r…
Browse files Browse the repository at this point in the history
…esults
  • Loading branch information
rcannood committed Nov 26, 2024
2 parents fb96427 + 3119674 commit 401a805
Show file tree
Hide file tree
Showing 119 changed files with 6,360 additions and 5,843 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/quarto_netlify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

- name: If PR, cache several directories
if: github.event_name == 'pull_request'
uses: actions/cache@v2
uses: actions/cache@v4
with:
key: quarto-${{ github.ref_name }}
restore-keys: quarto
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
/.quarto/
/_site
/_freeze
# local created libraries
/results/*/library.bib

# Temporary files generated by quarto preview
/site_libs
*.rmarkdown
/.luarc.json
/tmp
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

* Fix "used in" section in dataset pages (PR #362).

* Rescale resources in funkyheatmap when methods and/or datasets are filtered (PR #368).

# openproblems.bio v2.3.6

## NEW CONTENT
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
Loading

0 comments on commit 401a805

Please sign in to comment.