Skip to content

Commit

Permalink
Update task result rendering (#296)
Browse files Browse the repository at this point in the history
* add OPv2 PR #269

* set OP to metadata branch

* wip batch_integration results

* WIP add v2 results

* WIP fix pmap issue

Co-authored-by: Robrecht Cannoodt <[email protected]>

* restore original code

* update bat_int_feat results

* remove obsolete code

* update OP-v2 repo

* fix task description error

* update OPv2 version

* replace "\n" from descriptions

* update results

* Update results

* update for funky heatmap

* update results

* update metrics for multiple references

* remove bat_int substasks

* update bibliography

* fix references, use native referencing functionality, minor adjustments to task rendering

* remove unused file

* add bib library to pages

* restore batch_integration dirs

* rerun `_generate_task_pages.py`

* fix script

* fix script

* fixes to task info

* update changelog

---------

Co-authored-by: Robrecht Cannoodt <[email protected]>
Co-authored-by: Robrecht Cannoodt <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2023
1 parent d5a5a23 commit b7301b1
Show file tree
Hide file tree
Showing 23 changed files with 1,605 additions and 1,559 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
- Simplify footer
- Update openproblems-v2 submodule

* Updates to the way tasks are rendered (PR #296):

- Show task motivation, if present.
- Allow multiple citations for datasets, methods, and metrics.
- Render dataset name instead of dataset id in figures and tables.
- Change the way bibliographic references are rendered.

## BUG FIXES

* Updated the `openproblems-v2` submodule (PR #295). This fixes a deprecation error due to an update in ruamel.yaml.
Expand Down
2 changes: 1 addition & 1 deletion _openproblems-v2
Submodule _openproblems-v2 updated 116 files
2,504 changes: 1,526 additions & 978 deletions bibliography/library.bib

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion results/_generate_task_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
title: "{task_name}"
subtitle: "{task_summary}"
engine: knitr
image: featured.png
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---
```{{r}}
Expand Down
4 changes: 2 additions & 2 deletions results/_include/_baseline_descriptions.qmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
```{r}
```{r baseline_descriptions}
#| echo: false
baselines <- method_info %>% filter(is_baseline)
lines <- pmap_chr(baselines, function(method_name, method_summary, reference, code_url, ...) {
summ <- (method_summary %|% "Missing 'method_summary'") %>% str_replace_all("\\. *$", "")
summ <- (method_summary %|% "Missing 'method_summary'") %>% str_replace_all("\\n", " ") %>% str_replace_all("\\. *$", "")
glue::glue("* **{method_name}**: {summ}.")
})
knitr::asis_output(paste(lines, collapse = "\n"))
Expand Down
12 changes: 4 additions & 8 deletions results/_include/_dataset_descriptions.qmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
```{r}
```{r dataset_description}
#| echo: false
lines <- pmap_chr(dataset_info, function(dataset_name, dataset_summary, data_reference, ...) {
ref <-
if (!is.na(data_reference)) {
paste0("<sup>", cite_fun(data_reference, "html"), "</sup>")
} else {
""
}
summ <- (dataset_summary %|% "Missing 'dataset_summary'") %>% str_replace_all("\\. *$", "")
ref <- split_cite_fun(data_reference)
if (ref != "") ref <- paste0(" ", ref)
summ <- (dataset_summary %|% "Missing 'dataset_summary'") %>% str_replace_all("\\n", " ") %>% str_replace_all("\\. *$", "")
glue::glue("* **{dataset_name}**{ref}: {summ}.")
})
knitr::asis_output(paste(lines, collapse = "\n"))
Expand Down
39 changes: 18 additions & 21 deletions results/_include/_load_data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ library(kableExtra)
# read task info
task_info <- jsonlite::read_json(paste0(params$data_dir, "/task_info.json"))
# add missing data
task_info$task_description <- task_info$task_description %||% NA_character_
task_info$task_motivation <- task_info$task_motivation %||% NA_character_
`%|%` <- function(x, y) {
ifelse(is.na(x), y, x)
Expand All @@ -22,43 +25,37 @@ dataset_info <- jsonlite::read_json(paste0(params$data_dir, "/dataset_info.json"
results <- jsonlite::read_json(paste0(params$data_dir, "/results.json"), simplifyVector = TRUE)
qc <- jsonlite::read_json(paste0(params$data_dir, "/quality_control.json"), simplifyVector = TRUE)
# add missing columns
for (col in c("method_summary")) {
method_info[[col]] <- method_info[[col]] %||% NA_character_
}
for (col in c("metric_summary")) {
metric_info[[col]] <- metric_info[[col]] %||% NA_character_
}
for (col in c("dataset_summary")) {
for (col in c("dataset_summary", "dataset_name")) {
dataset_info[[col]] <- dataset_info[[col]] %||% NA_character_
}
# fill missing data
dataset_info$dataset_name <- dataset_info$dataset_name %|% dataset_info$dataset_id
num_methods <- sum(!method_info$is_baseline)
num_baselines <- sum(method_info$is_baseline)
num_datasets <- nrow(dataset_info)
num_metrics <- nrow(metric_info)
split_cite_fun <- function(keys) {
if (is.null(keys)) return("")
keys <- keys[!is.na(keys)]
if (length(keys) == 0) return("")
link_fun <- function(label, url, format = "markdown") {
if (format == "markdown") {
paste0("[", label, "](", url, ")")
} else {
paste0("<a href=\"", url, "\" target=\"_blank\">", label, "</a>")
}
refs <- unlist(stringr::str_split(keys, ", *"))
# inner_str <- sapply(refs, function(ref) cite_fun(ref, format = format))
# paste0("<sup>", paste(inner_str, collapse = ", "), "</sup>")
# paste0("[", paste(inner_str, collapse = ", "), "]")
paste0("[@", paste(refs, collapse = "; @"), "]")
}
cite_map <- list()
cite_fun <- function(key, format = "markdown") {
# if (is.null(options("citation_map"))) {
# options("citation_map" = list())
# }
# cm <- options("citation_map")
if (!key %in% names(cite_map)) {
cite_map[[key]] <<- length(cite_map) + 1
# options("citation_map" = cm)
}
num <- cite_map[[key]]
link_fun(num, paste0("/bibliography/#", key), format = format)
}
```


Expand Down
16 changes: 9 additions & 7 deletions results/_include/_method_descriptions.qmd
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
```{r}
```{r method_description}
#| echo: false
# show each method just once
lines <- pmap_chr(method_info, function(method_name, method_summary, 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)) {
if (!is.na(code_version) && code_version != "missing-version") {
glue::glue(" Software version {code_version}.")
} else {
""
}
ref <-
if (!is.na(paper_reference)) {
paste0("<sup>", cite_fun(paper_reference, "html"), "</sup>")
ref <- split_cite_fun(paper_reference)
if (ref != "") ref <- paste0(" ", ref)
links_label <-
if (length(links) > 0) {
glue::glue(" Links: {paste(links, collapse = ', ')}.")
} else {
""
}
links_label <- glue::glue(" Links: {paste(links, collapse = ', ')}.")
summ <- (method_summary %|% "Missing 'method_summary'") %>% str_replace_all("\\. *$", "")
summ <- (method_summary %|% "Missing 'method_summary'") %>% str_replace_all("\\n", " ") %>% str_replace_all("\\. *$", "")
glue::glue("* **{method_name}**{ref}: {summ}.{version_label}{links_label}")
})
knitr::asis_output(paste(lines, collapse = "\n"))
Expand Down
10 changes: 3 additions & 7 deletions results/_include/_metric_descriptions.qmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
```{r}
#| echo: false
lines <- pmap_chr(metric_info, function(metric_name, metric_summary, paper_reference, ...) {
ref <-
if (!is.na(paper_reference)) {
paste0("<sup>", cite_fun(paper_reference, "html"), "</sup>")
} else {
""
}
summ <- (metric_summary %|% "Missing 'metric_summary'") %>% str_replace_all("\\. *$", "")
ref <- split_cite_fun(paper_reference)
if (ref != "") ref <- paste0(" ", ref)
summ <- (metric_summary %|% "Missing 'metric_summary'") %>% str_replace_all("\\n", " ") %>% str_replace_all("\\. *$", "")
glue::glue("* **{metric_name}**{ref}: {summ}.")
})
knitr::asis_output(paste(lines, collapse = "\n"))
Expand Down
12 changes: 4 additions & 8 deletions results/_include/_results_table.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Results table of the scores per method, dataset and metric (after scaling). Use
```{r resultstable}
#| echo: false
res_tib0 <- results %>%
unnest(scaled_scores) %>%
unnest(metric_values) %>%
unnest(resources) %>%
left_join(method_info %>% select(-commit_sha, -code_version, -task_id), by = "method_id") %>%
filter(!is_baseline) %>%
Expand All @@ -14,7 +14,7 @@ mean_na_zero <- function(x) {
}
res_tib1 <- res_tib0 %>%
group_by(method_id, method_name, paper_reference, code_url, code_version) %>%
group_by(method_id, method_name, paper_reference, code_url) %>%
summarise_if(is.numeric, mean_na_zero) %>%
ungroup() %>%
mutate(
Expand All @@ -27,16 +27,12 @@ res_tib <- res_tib1 %>%
arrange(desc(mean_score)) %>%
rowwise() %>%
mutate(
method_label = ifelse(is.na(paper_reference), method_name, glue::glue("{method_name} <sup>{cite_fun(paper_reference, format = 'html')}</sup>")),
dataset_label = ifelse(is.na(data_reference), dataset_name, glue::glue("{dataset_name} <sup>{cite_fun(data_reference, format = 'html')}</sup>")),
# method_label = method_name,
# dataset_label = dataset_name,
peak_memory_gb = peak_memory_mb / 1024
) %>%
ungroup() %>%
select(
method_label,
dataset_label,
method_name,
dataset_name,
mean_score,
any_of(metric_info$metric_id),
duration_sec,
Expand Down
10 changes: 6 additions & 4 deletions results/_include/_summary_figure.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ palettes <- list(
# column_info = column_info %>% filter(id %in% colnames(summary_all)),
# column_groups = column_groups,
# palettes = palettes,
# # determine xmax expand heuristically
# expand = c(xmax = max(str_length(tail(column_info$name, 4))) / 5),
# # determine offset heuristically
# col_annot_offset = max(str_length(column_info$name)) / 5,
# position_args = position_arguments(
# # determine xmax expand heuristically
# expand_xmax = max(str_length(tail(column_info$name, 4))) / 5,
# # determine offset heuristically
# col_annot_offset = max(str_length(column_info$name)) / 5
# ),
# add_abc = FALSE,
# scale_column = FALSE
# )
Expand Down
26 changes: 11 additions & 15 deletions results/_include/_task_template.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
`r num_methods` methods • `r num_metrics` metrics • `r num_datasets` datasets
:::

## Description
`r task_info$task_description %|% "Missing 'task_description'"`
Data:
<a href="data/task_info.json" class="btn btn-secondary">Task info</a>
<a href="data/method_info.json" class="btn btn-secondary">Method info</a>
<a href="data/metric_info.json" class="btn btn-secondary">Metric info</a>
<a href="data/dataset_info.json" class="btn btn-secondary">Dataset info</a>
<a href="data/results.json" class="btn btn-secondary">Results</a>
<a href="data/quality_control.json" class="btn btn-secondary">Quality control</a>

`r task_info$task_motivation %|% ""`

`r task_info$task_description %|% ""`

## Summary

Expand Down Expand Up @@ -40,19 +49,6 @@

</details>


<details><summary>Download raw data</summary>

<a href="data/task_info.json" class="btn btn-secondary">Task info</a>
<a href="data/method_info.json" class="btn btn-secondary">Method info</a>
<a href="data/metric_info.json" class="btn btn-secondary">Metric info</a>
<a href="data/dataset_info.json" class="btn btn-secondary">Dataset info</a>
<a href="data/results.json" class="btn btn-secondary">Results</a>
<a href="data/quality_control.json" class="btn btn-secondary">Quality control</a>

</details>


<details><summary>Quality control results</summary>

{{< include ../_include/_qc_table.qmd >}}
Expand Down
1 change: 1 addition & 0 deletions results/batch_integration_embed/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
1 change: 1 addition & 0 deletions results/batch_integration_feature/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
1 change: 1 addition & 0 deletions results/batch_integration_graph/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
1 change: 1 addition & 0 deletions results/cell_cell_communication_ligand_target/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
1 change: 1 addition & 0 deletions results/cell_cell_communication_source_target/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
1 change: 1 addition & 0 deletions results/denoising/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
1 change: 1 addition & 0 deletions results/dimensionality_reduction/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
1 change: 1 addition & 0 deletions results/label_projection/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
3 changes: 2 additions & 1 deletion results/matching_modalities/index.qmd
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: "Matching modalities"
title: "Multimodal Data Integration"
subtitle: "Alignment of cellular profiles from two different modalities"
engine: knitr
image: thumbnail.svg
page-layout: full
css: ../task_template.css
bibliography: ../../bibliography/library.bib
---

```{r}
Expand Down
Loading

0 comments on commit b7301b1

Please sign in to comment.