Skip to content

Commit

Permalink
docs: demo S7 vs seurat memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Sep 9, 2024
1 parent 0252045 commit 7773ad0
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions vignettes/memory.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,39 @@ subset_mem <- lapply(c(10, 50, 100, 200, nrow(renee_ds@sample_meta)), function(n
bind_rows()
```

```{r single_cell}
to_bytes <- function(x, unit, base = 1024) {
bytes_units <- list(
K = 1,
M = 2,
G = 3,
T = 4
)
return(x * (base^bytes_units[[unit]]))
}
sc_dat <- tibble::tribble(
~"project", ~"n_cells", ~"n_samples", ~"n_genes", ~"object_size_GB",
"CCBR1329/CCBR1243", 64642, 10, 26359, 9.35,
"CCBR1297", 9991, 2, 20989, 1.78,
"CCBR1035", 170789, 19, 32100, 31.54,
"CCBR1203", 208169, 35, 30858, 37.38
) %>%
mutate(
object_size = to_bytes(object_size_GB, "G", base = 1000),
dataset_type = "single-cell (Seurat)"
)
```


```{r plot_memory}
# what is the resource spec of default NIDAP allocation?
# TODO: compare to seurat single cell object
palette_name <- "Set2"
subset_mem %>%
ggplot(aes(n_samples, object_size)) +
ggplot(aes(n_samples, object_size, color = "")) +
geom_point() +
geom_line(linewidth = 0.3) +
scale_y_continuous(labels = scales::label_bytes(units = "GB", accuracy = 0.1)) +
scale_color_manual(values = RColorBrewer::brewer.pal(3, palette_name)[[1]]) +
labs(
title = "Memory usage of S7 object",
x = "Number of samples",
Expand All @@ -89,5 +112,27 @@ subset_mem %>%
format(length(renee_ds@counts$raw$gene_id), big.mark = ",")
)
) +
theme_bw() +
theme(legend.position = "none")
```

```{r plot_memory_comp}
dat_comp <- bind_rows(
subset_mem %>% mutate(dataset_type = "bulk (S7)", object_size = as.double(object_size)),
sc_dat
)
dat_comp %>%
ggplot(aes(n_samples, object_size, colour = dataset_type)) +
geom_point() +
geom_line(linewidth = 0.3) +
scale_y_continuous(labels = scales::label_bytes(units = "GB", accuracy = 0.1)) +
scale_color_brewer(palette = palette_name) +
guides(colour = guide_legend(
title = "",
position = "top",
reverse = TRUE,
theme = theme(legend.text.position = "top")
)) +
labs(title = "Memory usage of bulk & single-cell RNA-seq objects", x = "Number of samples", y = "Memory usage") +
theme_bw()
```

0 comments on commit 7773ad0

Please sign in to comment.