Last updated: 2024-01-01

Checks: 7 0

Knit directory: mage_2020_marker-gene-benchmarking/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20190102) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 2632193. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Renviron
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    .snakemake/
    Ignored:    NSForest/.Rhistory
    Ignored:    NSForest/NS-Forest_v3_Extended_Binary_Markers_Supplmental.csv
    Ignored:    NSForest/NS-Forest_v3_Full_Results.csv
    Ignored:    NSForest/NSForest3_medianValues.csv
    Ignored:    NSForest/NSForest_v3_Final_Result.csv
    Ignored:    NSForest/__pycache__/
    Ignored:    NSForest/data/
    Ignored:    RankCorr/picturedRocks/__pycache__/
    Ignored:    benchmarks/
    Ignored:    config/
    Ignored:    data/cellmarker/
    Ignored:    data/downloaded_data/
    Ignored:    data/expert_annotations/
    Ignored:    data/expert_mgs/
    Ignored:    data/raw_data/
    Ignored:    data/real_data/
    Ignored:    data/sim_data/
    Ignored:    data/sim_mgs/
    Ignored:    data/special_real_data/
    Ignored:    figures/
    Ignored:    logs/
    Ignored:    results/
    Ignored:    weights/

Unstaged changes:
    Deleted:    analysis/expert-mgs-direction.Rmd
    Modified:   smash-fork

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/memory.Rmd) and HTML (public/memory.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd bc98f8b Jeffrey Pullin 2023-11-20 GB resubmission July 2023
html fcecf65 Jeffrey Pullin 2022-09-09 Build site.
html af96b34 Jeffrey Pullin 2022-08-30 Build site.
html 0e47874 Jeffrey Pullin 2022-05-04 Build site.
html 781c4f8 Jeffrey Pullin 2022-05-02 Build site.
html 8b989e1 Jeffrey Pullin 2022-05-02 Build site.
html 0548273 Jeffrey Pullin 2022-05-02 Build site.
Rmd 50bca7c Jeffrey Pullin 2022-05-02 workflowr::wflow_publish(all = TRUE, republish = TRUE)
html 50bca7c Jeffrey Pullin 2022-05-02 workflowr::wflow_publish(all = TRUE, republish = TRUE)
html 5cc008f Jeffrey Pullin 2022-02-09 Build site.
Rmd d1aca16 Jeffrey Pullin 2022-02-09 Refresh website
Rmd afbca9a Jeffrey Pullin 2022-01-27 Add memory measurement and analysis of memory usage

Aim

Compare the memory usage of the the different methods.

library(tibble)
library(dplyr)
library(ggplot2)
library(tidyr)
library(purrr)
library(forcats)
library(khroma)
library(stringr)
library(readr)
library(ggrepel)

source(here::here("code", "analysis-utils.R"))
source(here::here("code", "plot-utils.R"))

Simulated data

sim_pars <- retrive_simulation_parameters()

memory_sim_data <- sim_pars %>%
  filter(sim_label == "num_cells") %>% 
  mutate(
    memory_file_name = full_filename %>% 
      basename() %>% 
      str_sub(end = -5) %>%
      paste0("_benchmark.txt")
  ) %>%
  mutate(memory_path = here::here("benchmarks", memory_file_name)) %>%
  rowwise() %>%
  mutate(memory = read.csv(memory_path, sep = "\t")$max_vms)

memory_sim_num_clusters_data <- sim_pars %>%
  filter(sim_label == "num_clusters") %>% 
  mutate(
    memory_file_name = full_filename %>% 
      basename() %>% 
      str_sub(end = -5) %>%
      paste0("_benchmark.txt")
  ) %>%
  mutate(memory_path = here::here("benchmarks", memory_file_name)) %>%
  rowwise() %>%
  mutate(memory = read.csv(memory_path, sep = "\t")$max_vms)
label_pars <- c(
  "edger_ql",
  "scran_t_any", 
  "nsforest", 
  "cepo", 
  "rankcorr_2", 
  "seurat_negbinom", 
  "limma_trend", 
  "limma_voom",
  "glmgampoi", 
  "seurat_MAST", 
  "scanpy_wilcoxon_rankby_abs",
  "edger_ql_none",
  "presto", 
  "smash"
)

memory_by_num_cells_plot <- memory_sim_data %>% 
  filter(sim_label == "num_cells") %>% 
   # Remove methods we implemented.
  filter(!(pars %in% c("lm_two_sample", "logfc_abs", "logfc_raw", "random"))) %>% 
  group_by(pars, method, batchCells) %>%  
  summarise(memory = mean(memory), .groups = "drop") %>% 
  mutate(method = method_lookup[method]) %>%  
  mutate(gb = memory / 1000) %>% 
  ggplot(aes(x = batchCells, y = gb, colour = method)) +
  geom_point() + 
  geom_smooth(se = FALSE, formula = y ~ x, method = "loess", span = 1) +
  geom_text_repel(
    aes(label = if_else(
      pars %in% label_pars & batchCells == 100000, 
      pars_lookup[pars], 
      "")
    ),
    hjust = -0.1, colour = "black", size = 3, xlim = c(101000, NA)
  ) + 
  external_package_colour + 
  coord_cartesian(xlim = c(1000, 130000)) + 
  scale_x_continuous(
    breaks = c(1000, 25000, 50000, 75000, 100000)
  ) + 
  scale_y_continuous(
    breaks = c(1, 5, 10, 20, 30, 40)
  ) + 
  labs(
    title = "Memory usage vs total number of cells",
    x = "Number of cells", 
    y = "Memory usage (GB)", 
    colour = "Method"
  ) + 
  guides(color = "none") + 
  theme_bw()

memory_by_num_cells_plot
Warning: ggrepel: 2 unlabeled data points (too many overlaps). Consider
increasing max.overlaps

ggsave(
  here::here("figures", "final", "memory-num-cells.pdf"),
  memory_by_num_cells_plot,
  width = 8,
  height = 8,
  units = "in"
)
label_pars <- c(
  "edger_ql",
  "scran_t_any", 
  "nsforest", 
  "cepo", 
  "rankcorr_2", 
  "seurat_negbinom", 
  "limma_trend", 
  "limma_voom",
  "glmgampoi", 
  "seurat_MAST", 
  "scanpy_wilcoxon_rankby_abs",
  "edger_ql_none",
  "presto", 
  "smash"
)

memory_by_num_clusters_plot <- memory_sim_num_clusters_data %>% 
  # Remove methods we implemented.
  filter(!(pars %in% c("lm_two_sample", "logfc_abs", "logfc_raw", "random"))) %>% 
  group_by(pars, method, n_clus) %>%  
  summarise(memory = mean(memory), .groups = "drop") %>% 
  mutate(method = method_lookup[method]) %>%  
  mutate(gb = memory / 1000) %>% 
  ggplot(aes(x = n_clus, y = gb, colour = method)) +
  geom_point() + 
  geom_smooth(se = FALSE, formula = y ~ x, method = "loess", span = 1) +
  geom_text_repel(
    aes(label = if_else(
      pars %in% label_pars & n_clus == 20, 
      pars_lookup[pars], 
      "")
    ),
    hjust = -0.1, colour = "black", size = 3, xlim = c(21, NA)
  ) + 
  external_package_colour + 
  coord_cartesian(xlim = c(5, 28)) + 
  scale_x_continuous(
    breaks = c(5, 10, 15, 20)
  ) + 
  scale_y_continuous(
    breaks = c(2.5, 5, 7.5, 10)
  ) + 
  labs(
    title = "Memory usage vs. numbers of clusters",
    x = "Number of clusters", 
    y = "Memory usage (GB)", 
    colour = "Method"
  ) + 
  theme_bw()

memory_by_num_clusters_plot
Warning: ggrepel: 3 unlabeled data points (too many overlaps). Consider
increasing max.overlaps

saveRDS(memory_by_num_clusters_plot, here::here("figures", "raw", "memory-num-clusters.rds"))

Real data

real_data_memory <- retrieve_real_data_parameters() %>% 
  mutate(
    memory_file_name = full_filename %>% 
      basename() %>% 
      str_sub(string = , end = -5) %>% 
      paste0("_benchmark.txt")
  ) %>% 
  mutate(memory_path = here::here("benchmarks", memory_file_name)) %>% 
  rowwise() %>%  
  mutate(memory = read.csv(memory_path, sep = "\t")$max_vms) %>% 
  ungroup()

Endothelial

endothelial_memory <- real_data_memory %>% 
  filter(data_id == "endothelial") %>% 
  filter(!(method %in% c("lm", "difference", "random"))) %>% 
  mutate(method = method_lookup[method]) %>%  
  mutate(pars = pars_lookup[pars]) %>% 
  mutate(pars = fct_reorder(factor(pars), memory)) %>% 
  mutate(gb = memory / 1000) %>% 
  ggplot(aes(x = pars, y = gb, colour = method)) + 
  geom_point(alpha = 0.8, size = 3) + 
  external_package_colour + 
  coord_flip() + 
  labs(
    y = "Memory usage (GB)", 
    x = "Method",
    title = "Endothelial data",
    colour = "Package"
  ) + 
  theme_bw()

endothelial_memory

saveRDS(endothelial_memory, here::here("figures", "raw", "endothelial-memory.rds"))

Zhao

zhao_memory <- real_data_memory %>% 
  filter(data_id == "zhao") %>% 
  filter(!(method %in% c("lm", "logfc", "random"))) %>% 
  mutate(method = method_lookup[method]) %>%  
  mutate(pars = pars_lookup[pars]) %>% 
  mutate(pars = fct_reorder(factor(pars), memory)) %>% 
  mutate(gb = memory / 1000) %>% 
  ggplot(aes(x = pars, y = gb, colour = method)) + 
  scale_y_continuous(breaks = seq(0, 30, by = 5)) + 
  geom_point(alpha = 0.8, size = 3) + 
  external_package_colour + 
  coord_flip(ylim = c(0, 25)) + 
  labs(
    y = "Memory usage (GB)", 
    x = "Method",
    title = "Zhao data",
    colour = "Package"
  ) + 
  theme_bw()

zhao_memory

saveRDS(zhao_memory, here::here("figures", "raw", "zhao-memory.rds"))

Overall

overall_memory <- real_data_memory %>% 
  filter(!(pars %in% c("lm_two_sample", "logfc_abs", "logfc_raw", "random"))) %>%
  mutate(log_memory = log(memory, base = 10)) %>% 
  mutate(
    plot_method = method_lookup[method], 
    plot_pars = pars_lookup[pars],
    plot_data_id = dataset_lookup[data_id]
  ) %>% 
  mutate(plot_pars = fct_reorder(factor(plot_pars), memory)) %>% 
  ggplot(aes(x = plot_data_id, y = plot_pars)) +
  geom_tile(aes(fill = log_memory), colour = "black") + 
  scale_fill_distiller(
    breaks = log(c(1200, 2000, 5000, 10000, 20000), base = 10), 
    labels = c("1.2GB", "2GB", "5GB", "10GB", "20GB"),
    palette = "RdYlBu") + 
  theme_bw() + 
  labs(
    title = "Memory across datasets",
    x = "Dataset", 
    y = "Method", 
    fill = "Memory",
  ) + 
  theme(
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    panel.border = element_blank(),
    axis.ticks.y = element_blank(),
    axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)
  )
overall_memory

saveRDS(overall_memory, here::here("figures", "raw", "overall-memory.rds"))

devtools::session_info()
─ Session info  ──────────────────────────────────────────────────────────────
 hash: woman firefighter: medium-light skin tone, flag: Åland Islands, flag: Denmark

 setting  value
 version  R version 4.1.2 (2021-11-01)
 os       Red Hat Enterprise Linux 9.2 (Plow)
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  en_AU.UTF-8
 ctype    en_AU.UTF-8
 tz       Australia/Melbourne
 date     2024-01-01
 pandoc   2.18 @ /apps/easybuild-2022/easybuild/software/MPI/GCC/11.3.0/OpenMPI/4.1.4/RStudio-Server/2022.07.2+576-Java-11-R-4.1.2/bin/pandoc/ (via rmarkdown)

─ Packages ───────────────────────────────────────────────────────────────────
 package      * version date (UTC) lib source
 assertthat     0.2.1   2019-03-21 [2] CRAN (R 4.1.2)
 bslib          0.3.1   2021-10-06 [1] CRAN (R 4.1.0)
 cachem         1.0.6   2021-08-19 [1] CRAN (R 4.1.0)
 callr          3.7.0   2021-04-20 [2] CRAN (R 4.1.2)
 cli            3.6.1   2023-03-23 [1] CRAN (R 4.1.0)
 colorspace     2.1-0   2023-01-23 [1] CRAN (R 4.1.0)
 crayon         1.5.1   2022-03-26 [1] CRAN (R 4.1.0)
 DBI            1.1.2   2021-12-20 [1] CRAN (R 4.1.0)
 desc           1.4.0   2021-09-28 [2] CRAN (R 4.1.2)
 devtools       2.4.2   2021-06-07 [2] CRAN (R 4.1.2)
 digest         0.6.29  2021-12-01 [1] CRAN (R 4.1.0)
 dplyr        * 1.0.9   2022-04-28 [1] CRAN (R 4.1.0)
 ellipsis       0.3.2   2021-04-29 [2] CRAN (R 4.1.2)
 evaluate       0.14    2019-05-28 [2] CRAN (R 4.1.2)
 fansi          1.0.4   2023-01-22 [1] CRAN (R 4.1.0)
 farver         2.1.1   2022-07-06 [1] CRAN (R 4.1.0)
 fastmap        1.1.0   2021-01-25 [2] CRAN (R 4.1.2)
 forcats      * 0.5.1   2021-01-27 [2] CRAN (R 4.1.2)
 fs             1.5.2   2021-12-08 [1] CRAN (R 4.1.0)
 generics       0.1.3   2022-07-05 [1] CRAN (R 4.1.0)
 ggplot2      * 3.3.6   2022-05-03 [1] CRAN (R 4.1.0)
 ggrepel      * 0.9.1   2021-01-15 [2] CRAN (R 4.1.2)
 git2r          0.28.0  2021-01-10 [2] CRAN (R 4.1.2)
 glue           1.6.0   2021-12-17 [1] CRAN (R 4.1.0)
 gtable         0.3.0   2019-03-25 [2] CRAN (R 4.1.2)
 here           1.0.1   2020-12-13 [1] CRAN (R 4.1.0)
 highr          0.9     2021-04-16 [2] CRAN (R 4.1.2)
 hms            1.1.1   2021-09-26 [2] CRAN (R 4.1.2)
 htmltools      0.5.2   2021-08-25 [1] CRAN (R 4.1.0)
 httpuv         1.6.5   2022-01-05 [1] CRAN (R 4.1.0)
 jquerylib      0.1.4   2021-04-26 [2] CRAN (R 4.1.2)
 jsonlite       1.8.0   2022-02-22 [1] CRAN (R 4.1.0)
 khroma       * 1.7.0   2021-09-02 [1] CRAN (R 4.1.0)
 knitr          1.36    2021-09-29 [1] CRAN (R 4.1.0)
 labeling       0.4.2   2020-10-20 [2] CRAN (R 4.1.2)
 later          1.3.0   2021-08-18 [1] CRAN (R 4.1.0)
 lattice        0.20-45 2021-09-22 [2] CRAN (R 4.1.2)
 lifecycle      1.0.1   2021-09-24 [1] CRAN (R 4.1.0)
 magrittr       2.0.3   2022-03-30 [1] CRAN (R 4.1.0)
 Matrix         1.3-4   2021-06-01 [2] CRAN (R 4.1.2)
 memoise        2.0.1   2021-11-26 [1] CRAN (R 4.1.0)
 mgcv           1.8-38  2021-10-06 [2] CRAN (R 4.1.2)
 munsell        0.5.0   2018-06-12 [2] CRAN (R 4.1.2)
 nlme           3.1-153 2021-09-07 [2] CRAN (R 4.1.2)
 pillar         1.7.0   2022-02-01 [1] CRAN (R 4.1.0)
 pkgbuild       1.2.0   2020-12-15 [2] CRAN (R 4.1.2)
 pkgconfig      2.0.3   2019-09-22 [2] CRAN (R 4.1.2)
 pkgload        1.2.3   2021-10-13 [2] CRAN (R 4.1.2)
 prettyunits    1.1.1   2020-01-24 [2] CRAN (R 4.1.2)
 processx       3.5.2   2021-04-30 [2] CRAN (R 4.1.2)
 promises       1.2.0.1 2021-02-11 [2] CRAN (R 4.1.2)
 ps             1.7.1   2022-06-18 [1] CRAN (R 4.1.0)
 purrr        * 0.3.4   2020-04-17 [2] CRAN (R 4.1.2)
 R6             2.5.1   2021-08-19 [1] CRAN (R 4.1.0)
 RColorBrewer   1.1-3   2022-04-03 [1] CRAN (R 4.1.0)
 Rcpp           1.0.8.3 2022-03-17 [1] CRAN (R 4.1.0)
 readr        * 2.1.1   2021-11-30 [1] CRAN (R 4.1.0)
 remotes        2.4.2   2021-11-30 [1] CRAN (R 4.1.0)
 rlang          1.0.3   2022-06-27 [1] CRAN (R 4.1.0)
 rmarkdown      2.14    2022-04-25 [1] CRAN (R 4.1.0)
 rprojroot      2.0.3   2022-04-02 [1] CRAN (R 4.1.0)
 rstudioapi     0.14    2022-08-22 [1] CRAN (R 4.1.0)
 sass           0.4.1   2022-03-23 [1] CRAN (R 4.1.0)
 scales         1.2.1   2022-08-20 [1] CRAN (R 4.1.0)
 sessioninfo    1.2.0   2021-10-31 [2] CRAN (R 4.1.2)
 stringi        1.7.6   2021-11-29 [1] CRAN (R 4.1.0)
 stringr      * 1.4.0   2019-02-10 [2] CRAN (R 4.1.2)
 testthat       3.1.0   2021-10-04 [2] CRAN (R 4.1.2)
 tibble       * 3.1.7   2022-05-03 [1] CRAN (R 4.1.0)
 tidyr        * 1.2.0   2022-02-01 [1] CRAN (R 4.1.0)
 tidyselect     1.1.2   2022-02-21 [1] CRAN (R 4.1.0)
 tzdb           0.2.0   2021-10-27 [1] CRAN (R 4.1.0)
 usethis        2.1.3   2021-10-27 [2] CRAN (R 4.1.2)
 utf8           1.2.3   2023-01-31 [1] CRAN (R 4.1.0)
 vctrs          0.4.1   2022-04-13 [1] CRAN (R 4.1.0)
 whisker        0.4     2019-08-28 [2] CRAN (R 4.1.2)
 withr          2.5.0   2022-03-03 [1] CRAN (R 4.1.0)
 workflowr      1.7.0   2021-12-21 [1] CRAN (R 4.1.0)
 xfun           0.31    2022-05-10 [1] CRAN (R 4.1.0)
 yaml           2.3.5   2022-02-21 [1] CRAN (R 4.1.0)

 [1] /home/jpullin/R/x86_64-pc-linux-gnu-library/4.1
 [2] /apps/easybuild-2022/easybuild/software/MPI/GCC/11.3.0/OpenMPI/4.1.4/R/4.1.2/lib64/R/library

──────────────────────────────────────────────────────────────────────────────