-
Notifications
You must be signed in to change notification settings - Fork 0
/
07_assigned_by_method.R
175 lines (158 loc) · 9.52 KB
/
07_assigned_by_method.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#load libraries
library(data.table)
library(tidyverse)
library(janitor)
library(ggpubr)
#create final empty data frame
final.df <- data.frame(method=as.character(), condition=as.character(),
n_assigned=as.numeric(),n_unassigned=as.numeric(),
n_assigned_perc=as.numeric(),n_assigned_perc=as.numeric(),
total=as.numeric())
#load summary for each method,
#compute total assigned and unassigned cells
#add to final df
for (m in c('vireo', 'demuxalot', 'souporcell', 'demuxlet')){
if (m=='vireo'){
tmp <- fread('../vireo/vireo_summary_s16h.csv') %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('vireo', 'stim16h', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../vireo/vireo_summary_s4d.csv') %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('vireo', 'stim4d', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../vireo/vireo_summary_u16h.csv') %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('vireo', 'unstim16h', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../vireo/vireo_summary_u4d.csv') %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('vireo', 'unstim4d', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
} else if (m=='demuxalot'){
tmp <- fread('../demuxalot/TCell1Stim16h/demuxalot_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('demuxalot', 'stim16h', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../demuxalot/TCell1Stim4d/demuxalot_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('demuxalot', 'stim4d', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../demuxalot/TCell1Unstim16h/demuxalot_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('demuxalot', 'unstim16h', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../demuxalot/TCell1Unstim4d/demuxalot_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('demuxalot', 'unstim4d', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
} else if (m=='souporcell'){
tmp <- fread('../souporcell/TCell1Stim16h/souporcell_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('souporcell', 'stim16h', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../souporcell/TCell1Stim4d/souporcell_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('souporcell', 'stim4d', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../souporcell/TCell1Unstim16h/souporcell_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('souporcell', 'unstim16h', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../souporcell/TCell1Unstim4d/souporcell_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('souporcell', 'unstim4d', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
} else if (m=='demuxlet'){
tmp <- fread('../demuxlet/TCell1Unstim16h//demuxlet_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('demuxlet', 'unstim16h', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
tmp <- fread('../demuxlet/TCell1Unstim4d//demuxlet_summary.tsv', header=T) %>% clean_names()
unassigned <- tmp %>% filter(classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
assigned <- tmp %>% filter(!classification %in% c('doublet', 'unassigned')) %>%
pull(assignment_n) %>% sum()
final.df <- rbind(final.df, c('demuxlet', 'unstim4d', assigned, unassigned,
assigned/(assigned+unassigned),
unassigned/(assigned+unassigned),
assigned+unassigned))
}
}
#rename column names
colnames(final.df) <- c('method', 'condition', 'n_assigned', 'n_unassigned',
'n_assigned_perc', 'n_unassigned_perc', 'total')
#correctly format numeric columns
for (i in 3:ncol(final.df)){
final.df[,i] <- as.numeric(final.df[,i])
}
#plot & save file
ggplot(final.df, aes(x=condition, y=n_assigned_perc, fill=method)) +
geom_col(position='dodge') + theme_bw()
ggsave('../n_assigned_perc_vs_condition_by_method.pdf', height=4, width=6)
fwrite(final.df, file='../summary_all_methods.txt', sep='\t')