-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathdataset_cellbench_luyitian.R
50 lines (42 loc) · 1.35 KB
/
dataset_cellbench_luyitian.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
library(dynbenchmark)
library(tidyverse)
dataset_preprocessing("real/gold/cellbench")
rda_location <- download_dataset_source_file(
"9cellmix_qc.RData",
"https://raw.githubusercontent.com/LuyiTian/CellBench_data/master/data/9cellmix_qc.RData"
)
settings <- list(
list(
object = sce_SC1_qc,
id = "real/gold/cellbench-SC1_luyitian"
),
list(
object = sce_SC2_qc,
id = "real/gold/cellbench-SC2_luyitian"
),
list(
object = sce_SC3_qc,
id = "real/gold/cellbench-SC3_luyitian"
),
list(
object = sce_SC4_qc,
id = "real/gold/cellbench-SC4_luyitian"
)
)
for (setting in settings) {
cell_info <- colData(setting$object) %>%
as.data.frame() %>%
rownames_to_column("cell_id") %>%
mutate_at(vars(H1975, H2228, HCC827), ~.>0) %>%
filter(traj == "YES") # why isn't this a logical?
cell_info$group_id <- cell_info[, c("H1975", "H2228", "HCC827")] %>% apply(1, function(x) glue::glue_collapse(names(x)[x], ","))
grouping <- cell_info %>% select(cell_id, group_id) %>% deframe()
milestone_network <- tribble(
~from, ~to,
"H1975", "H1975,H2228,HCC827",
"HCC827", "H1975,H2228,HCC827",
"H2228", "H1975,H2228,HCC827"
) %>% mutate(length = 1, directed = FALSE)
counts <- t(counts(setting$object))[cell_info$cell_id, ]
save_raw_dataset(lst(milestone_network, cell_info, grouping, counts), setting$id)
}