-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark_wholesample.R
118 lines (85 loc) · 3.09 KB
/
benchmark_wholesample.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
source("utils.R")
# MIBI ----
## DCIS progression ----
resp <- read_csv("data/DCISMIBI/Tissue Feature Data/Table_S1_Patient_Feature_Table.csv")
misty.results.ct <- read_rds("DCISct_ws.rds")
misty.results.expr <- read_rds("DCISexpr_ws.rds")
ws.repr.ct <- misty_labels(misty.results.ct) %>%
left_join(
resp %>%
select(PointNumber, Status) %>%
mutate(PointNumber = as.character(PointNumber)),
by = c("sample" = "PointNumber")
) %>%
rename(target = Status) %>%
mutate(target = as.factor(target)) %>%
select(-sample)
ws.repr.expr <- misty_labels(misty.results.expr) %>%
left_join(
resp %>%
select(PointNumber, Status) %>%
mutate(PointNumber = as.character(PointNumber)),
by = c("sample" = "PointNumber")
) %>%
rename(target = Status) %>%
mutate(target = as.factor(target)) %>%
select(-sample)
roc.ws.dcis.ct <- classify(ws.repr.ct)
roc.ws.dcis.expr <- classify(ws.repr.expr)
write_rds(list(ct = roc.ws.dcis.ct, expr = roc.ws.dcis.expr), "rocs/dcis.ws.rds")
# CODEX ----
## CTCL responders ----
lymph <- read_csv("data/LymphomaCODEX/single_cells.csv")
outcome <- lymph %>%
filter(Groups %in% c(1, 2)) %>%
group_by(Spots, Patients) %>%
summarize(Groups = Groups[1], .groups = "drop")
misty.results.ct <- read_rds("CTCLct_ws.rds")
misty.results.expr <- read_rds("CTCLexpr_ws.rds")
ws.repr.ct <- misty_labels(misty.results.ct) %>%
left_join(outcome %>% mutate(Spots = as.character(Spots)), by = c("sample" = "Spots")) %>%
rename(target = Groups) %>%
mutate(target = as.factor(make.names(target))) %>%
select(-sample, -Patients)
ws.repr.expr <- misty_labels(misty.results.expr) %>%
left_join(outcome %>% mutate(Spots = as.character(Spots)), by = c("sample" = "Spots")) %>%
rename(target = Groups) %>%
mutate(target = as.factor(make.names(target))) %>%
select(-sample, -Patients)
roc.ws.ctcl.ct <- classify(ws.repr.ct)
roc.ws.ctcl.expr <- classify(ws.repr.expr)
write_rds(list(ct = roc.ws.ctcl.ct, expr = roc.ws.ctcl.expr), "rocs/ctcl.ws.rds")
# IMC ----
## BC responders ----
bmeta <- read_csv("data/BCIMC/Basel_PatientMetadata.csv")
with_seed(
1,
cores <- bmeta %>%
filter(
diseasestatus == "tumor",
response %in% c("Sensitive", "Resistant"),
clinical_type == "HR+HER2-", Subtype == "PR+ER+"
) %>%
group_by(response) %>%
slice_sample(n = 15) %>%
arrange(core) %>%
pull(core)
)
resp <- bmeta %>%
filter(core %in% cores) %>%
select(core, response)
misty.results.ct <- read_rds("BCct_ws.rds")
misty.results.expr <- read_rds("BCexpr_ws.rds")
ws.repr.ct <- misty_labels(misty.results.ct) %>%
left_join(resp, by = c("sample" = "core")) %>%
rename(target = response) %>%
mutate(target = as.factor(make.names(target))) %>%
select(-sample)
ws.repr.expr <- misty_labels(misty.results.expr) %>%
left_join(resp, by = c("sample" = "core")) %>%
rename(target = response) %>%
mutate(target = as.factor(make.names(target))) %>%
select(-sample)
roc.ws.bc.ct <- classify(ws.repr.ct)
roc.ws.bc.expr <- classify(ws.repr.expr)
write_rds(list(ct = roc.ws.bc.ct, expr = roc.ws.bc.expr), "rocs/bc.ws.rds")