-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster_naming.Rmd
631 lines (452 loc) · 15.4 KB
/
cluster_naming.Rmd
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
---
title: "scWBM Cluster Labeling"
author: "D. Ford Hannum"
date: "5/29/2020"
output:
html_document:
toc: true
toc_depth: 3
number_sections: false
theme: united
highlight: tango
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F)
library(Seurat)
library(ggplot2)
library(data.table)
library(SingleR)
library(MAST)
library(scRNAseq)
library(tidyr)
```
```{r reading in the data}
wbm <- readRDS('./data/wbm_clustered_filtered_named.rds')
```
# Introduction
In this document I am collecting all the information and figures that are used for naming the clusters of the Sang scWBM experiment one.
*Cluster naming workflow*
1. Using singleR to compare the cluster centroids in our analysis to reference datasets, to find the reference cell type with the highest correlation to our cell type. The datasets being compare to are: 830 microarray samples of pure mouse immune cells, generated by the Immunologic Genome Project (ImmGen, Aran et al., 2019); and 358 bulk RNA-seq samples of sorted cell populations that can be found at GEO (Benayoun et al., 2019)
2. Using singleR to compare individual cells to the reference cell types (same as step 1)
3. Using marker gene expression to either confirm or alter cluster labels generated from steps 1 and 2.
```{r singleR loading datasets, include = F, warnings = F}
m.ref <- ImmGenData()
m.ref2 <- MouseRNAseqData()
ref <- list(m.ref,m.ref2)
ref_lab <- list(m.ref$label.main, m.ref2$label.main)
```
\newpage
# SingleR Cluster Naming
```{r singleR cluster labeling}
SCwbm <- as.SingleCellExperiment(wbm)
# Predicitng cluster labels
pred_cluster <- SingleR(test = SCwbm,
ref = ref,
labels = ref_lab,
method = 'cluster',
clusters = SCwbm$seurat_clusters)
pred_cell <- SingleR(test = SCwbm,
ref = ref,
labels = ref_lab,
method = 'single')
```
```{r cluster final scores data manipulation}
clst_score_final <- pred_cluster$scores
# deleting columns with all NAs
clst_score_final <- as.data.frame(clst_score_final[, colSums(is.na(clst_score_final)) != nrow(clst_score_final)])
# adding the cluster as a factor instead of just a row name
clst_score_final$cluster<- as.factor(0:12)
# labeling the colnames by the reference they came from
colnames(clst_score_final)[1:7] <- paste0(colnames(clst_score_final)[1:7], '_ref1')
colnames(clst_score_final)[8:11] <- paste0(colnames(clst_score_final)[8:11], '_ref2')
clst_score_final <- gather(clst_score_final, cell_type, score, `B cells_ref1`:`T cells_ref2`, factor_key = T)
clst_score_final$score_round <- round(clst_score_final$score,2)
```
```{r built in SingleR plot}
library(pheatmap)
plotScoreHeatmap(pred_cluster)
```
Above is a graphic from a package associated with SingleR. It is interesting but has to much going on.
```{r cluster score graph bar chart}
#levels(clst_score_final$cell_type)
clst_bar <- clst_score_final[!is.na(clst_score_final$score),]
# splitting up the cell type and reference label
clst_bar$ref <- tstrsplit(clst_bar$cell_type, '_', keep = 2)[[1]]
clst_bar$cell_type <- tstrsplit(clst_bar$cell_type, '_', keep = 1)[[1]]
clst_bar$Reference <- ifelse(clst_bar$ref == 'ref1', 'ImmGen','GEO')
ggplot(clst_bar, aes( x = cluster, y = score, fill = ref)) +
geom_bar(stat = 'identity', position = position_dodge()) +
coord_flip() +
scale_fill_manual(values = c('darkgreen', 'orange'),
name = 'Reference\nDataset') +
theme_bw() +
ylim(0,1) +
geom_text(stat = 'identity', aes(label = cell_type),
position = position_dodge(width = 1),
hjust = -.1, size = 3) +
xlab('Cluster') + ylab ('SingleR Final Score') +
scale_x_discrete()
```
The final score given to each cluster. The higher score between the two references for each cluster was the final label.
# SingleR Cell Naming
```{r sc namming}
# head(pred_cell)
# dim(wbm@meta.data)
# dim(pred_cell)
# sum(rownames(pred_cell) == rownames(wbm@meta.data))
wbm@meta.data$cell_assignment <- pred_cell$pruned.labels
df <- as.data.frame(table(wbm@meta.data$seurat_clusters, wbm@meta.data$cell_assignment))
colnames(df) <- c('Cluster','Assigned Cell Type','Count')
cluster_counts <- c(summary(as.factor(wbm@meta.data$seurat_clusters)))
cluster_counts
dim(df)[1]/length(cluster_counts)
df$clst_counts <- rep(cluster_counts,18)
df$cell_perc <- round(df$Count/df$clst_counts,2)*100
new_levels <- levels(as.factor(df$`Assigned Cell Type`))[c(8,1,3,12,10,7,2,17,14,16,13,9,4,6,5,11,15,18)]
df$cell_type <- factor(df$`Assigned Cell Type`, levels = new_levels)
ggplot(df, aes(x = cell_type, y = Cluster, fill = cell_perc)) +
geom_tile() +
scale_fill_gradient2(high = 'darkred', low = 'white', mid = 'red', midpoint = 50,
limit = c(0,100), space ="Lab",
name = 'Percentage of Cells\n') +
ylab('Cluster Labels') + xlab('Cell Labels') +
ggtitle ("Heatmap of Individual Cell Labels within Cluster Labels") +
theme (plot.title = element_text(hjust = 0.5), axis.text.x = element_text(angle = 45, hjust = 1)) +
coord_fixed()
```
# Lineage Specific Markers
Next I'm going to use lineage specific markers to manually look at the cell clusters. List was provided by Dr. Sang.
* **Granulocytes**: *Elane, Mpo, Ctsg, Prtn3, Azu1*
* **B-cell**: *Ighd, Cd20, Cd22, Jchain*
* **Megakaryocytes**: *Itga2b, Gp9, Pf4, Selp, Gp1ba*
* **HSPC**: *Crhbp, Emcn, Hlf, Avp, Cd34, Kit, Sca-1*
* **Monocyte**: *Cd14*
* **Macrophage**: *Cd45, F480, Lyz2*
* **Erythroid**: *Epor, Klf1, Tfr2, Csf2rb, Gypa*
* **T-cell/NK**: *Cd3g*
* **MEP**: *Lbg, Nr4a1, Gpr141, Gata1*
## Granulocytes
```{r changing wbm identi}
# changing the identity to the cluster number again
new_cluster_ids <- 0:12
names(new_cluster_ids) <- levels(wbm)
wbm <- RenameIdents(wbm, new_cluster_ids)
```
```{r gran markers}
gran_markers <- c('Elane', 'Mpo', 'Ctsg', 'Prtn3', 'Azu1')
gran_markers %in% rownames(wbm)
gran_markers <- gran_markers[gran_markers %in% rownames(wbm)]
VlnPlot(wbm, features = gran_markers,
pt.size = 0)
FeaturePlot(wbm, features = gran_markers)
```
These markers are only consistently expressed in cluster 6. Some marker expression in clusters 4, 5 and 7.
\newpage
## B-cell
```{r b cell markers}
b_markers <- c('Ighd', 'Cd20', 'Cd22', 'Jchain')
b_markers <- b_markers[b_markers %in% rownames(wbm)]
VlnPlot(wbm, features = b_markers,
pt.size = 0)
FeaturePlot(wbm, features = b_markers)
```
Jchain showed little to no expression in any cluster.
Expression in clusters 3 and 10, almost exclusively.
\newpage
## Megakaryocytes
```{r mk markers}
mk_markers <- c('Itga2b', 'Gp9', 'Pf4', 'Selp', 'Gp1ba')
mk_markers <- mk_markers[mk_markers %in% rownames(wbm)]
VlnPlot(wbm, features = mk_markers,
pt.size = 0)
FeaturePlot(wbm, features = mk_markers)
```
Most expression was found in cluster 12, with strong Itga2b expression in 4 and some Pf4 expression in 8.
\newpage
## HSPC
```{r hspc markers}
hspc_markers <- c('Crhbp', 'Emcn', 'Hlf', 'Avp', 'Cd34', 'Kit', 'Sca-1')
hspc_markers <- hspc_markers[hspc_markers %in% rownames(wbm)]
VlnPlot(wbm, features = hspc_markers, pt.size = 0)
```
Emcn, Avp, Cd34, and Hlf showed little to no expression in any cluster.
Crhbp has mild expression in cluster 10, and Kit has mild expression in cluster 6.
\newpage
## Monocyte
```{r mono marker}
mono_marker <- 'Cd14'
#'Cd14' %in% rownames(wbm)
VlnPlot(wbm, features = mono_marker, pt.size = 0) + NoLegend()
```
Cd14 showed little to no expression
\newpage
## Macrophage
```{r macro markers}
macro_markers <- c('Cd45', 'F480', 'Lyz2')
macro_markers <- macro_markers[macro_markers %in% rownames(wbm)]
VlnPlot(wbm, features = macro_markers, pt.size = 0)
```
Lyz2 is widely expressed in all clusters
\newpage
## Erythroid
```{r ery markers}
ery_markers <- c('Epor', 'Klf1', 'Tfr2', 'Csf2rb', 'Gypa')
ery_markers <- ery_markers[ery_markers %in% rownames(wbm)]
VlnPlot(wbm, features = ery_markers, pt.size = 0)
FeaturePlot(wbm, features = ery_markers)
```
Epor, Klf1, and Tfr2 showed little to no expression in any clusters.
Csf2rb shows widespread expression, with highest expression in cluster 4. Gypa only shows expression in cluster 9
\newpage
## T-cell/NK
```{r tnk markers}
tnk_markers <- c('Cd3g')
tnk_markers <- tnk_markers[tnk_markers %in% rownames(wbm)]
VlnPlot(wbm, features = tnk_markers, pt.size =0)
FeaturePlot(wbm, features = tnk_markers)
```
Cd3g shows expression in cluster 11, almost exclusively.
\newpage
## MEP
```{r mep markers}
mep_markers <- c('Lbg', 'Nr4a1', 'Gpr141', 'Gata1')
mep_markers <- mep_markers[mep_markers %in% rownames(wbm)]
VlnPlot(wbm, features = mep_markers, pt.size = 0)
```
Gpr141 shows expression in multiple clusters. Expression of Gata1 is exclusive to cluster 4.
# Lineage Specfic Markers cont.
These are markers that I found through literature search and though looking at [pangloaddb](pangloadb.se) (for example top markers for [HSPCs](https://panglaodb.se/markers.html?cell_type=%27Hematopoietic%20stem%20cells%27))
Many of the markers are the same between my list and Dr. Sang's list.
```{r reading in marker list}
markers <- read.csv('./marker_list.csv', header = T)
markers
```
\newpage
## B-cells
```{r otro b-cell markers}
mrkrs <- markers$B.cell
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
Clusters 3 and 10 are high in B-cell markers which is consistent through all the stages
\newpage
## MKs
```{r otro mk markers}
mrkrs <- markers$MK
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## HSPCs
```{r otro hspc markers}
mrkrs <- markers$HSPC
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## Monocytes
```{r otro mono markers}
mrkrs <- markers$Monocyte
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## Macrophages
```{r otro macrophage markers}
mrkrs <- markers$Macrophage
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## Erythroid
```{r otro ery markers}
mrkrs <- markers$Erythroid
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## T-cell/NK
```{r otro tnk markers}
mrkrs <- markers$T.cell.NK
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## MEP
```{r otro mep markers}
mrkrs <- markers$MEP
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## Proliferation
```{r otro pro markers}
mrkrs <- markers$ProliferationMarkers
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## Myeloid
```{r otro myeloid markers}
mrkrs <- markers$Myeloid
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## Erythroid Prog.
```{r otro ery pro markers}
mrkrs <- markers$Eprog
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```
\newpage
## Plasma
```{r otro plasma markers}
mrkrs <- markers$Plasma
mrkrs <- mrkrs[mrkrs %in% rownames(wbm)]
VlnPlot(wbm, features = mrkrs, pt.size = 0)
loops <- ceiling(length(mrkrs) / 4)
for (i in 1:loops){
start <- 4*(i-1) + 1
end <- 4*i
if (end > length(mrkrs)){
mrkrs2 <- mrkrs[start:length(mrkrs)]
}
else{
mrkrs2 <- mrkrs[start:end]
}
print(FeaturePlot(wbm, features = mrkrs2, ncol = 2))
}
```