Repository navigation
Expand file tree
/
Copy pathplot_loom.r
More file actions
94 lines (77 loc) · 2.94 KB
/
Copy pathplot_loom.r
File metadata and controls
94 lines (77 loc) · 2.94 KB
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
library(hdf5r)
library(SeuratDisk)
library(scater)
library(tidyverse)
library(Seurat)
library(ggplot2)
library(cowplot)
# load loom
allcell <- Connect(filename = "./Thienpont_Tumors_52k_v4_R_fixed.loom", mode = "r")
allcell
allcell[["col_attrs/"]]
allcell[["row_attrs/"]]
metadata <- data.frame(
CellID = allcell[["col_attrs/CellID"]][],
ClusterName = allcell[["col_attrs/ClusterName"]][],
CellFromTumor = allcell[["col_attrs/CellFromTumor"]][],
PatientNumber = allcell[["col_attrs/PatientNumber"]][],
ClusterID = allcell[["col_attrs/ClusterID"]][],
nUMI = allcell[["col_attrs/nUMI"]][],
Embedding = allcell[["col_attrs/Embedding"]][]
)
colnames(metadata)
# plot
# CellFromTumor
p1 <- ggplot(metadata,aes(x = Embedding._X,y = Embedding._Y,
color = CellFromTumor)) +
geom_point(size = 0.2) +
theme_bw(base_size = 16) +
theme(panel.grid = element_blank(),
legend.position = c(0.2,0.1),
legend.background = element_blank(),
aspect.ratio = 1) +
xlab('tSNE 1') + ylab('tSNE 2') +
scale_color_manual(values = c('0' = '#66CC99','1' = '#336699'),
name = '',
label = c('0' = 'Non-malignant','1' = 'Tumour')) +
guides(color = guide_legend(override.aes = list(size = 3)))
# PatientNumber
p2 <- ggplot(metadata,aes(x = Embedding._X,y = Embedding._Y,
color = PatientNumber)) +
geom_point(size = 0.2) +
theme_bw(base_size = 16) +
theme(panel.grid = element_blank(),
legend.position = c(0.1,0.2),
legend.background = element_blank(),
aspect.ratio = 1) +
xlab('tSNE 1') + ylab('tSNE 2') +
scale_color_manual(values = c('1' = '#339933','2' = '#FF6600','3' = '#CCFF99',
'4' = '#FFCC33','5' = '#336699'),
name = '') +
guides(color = guide_legend(override.aes = list(size = 3)))
# ClusterName
p3 <- ggplot(metadata,aes(x = Embedding._X,y = Embedding._Y,
color = ClusterName)) +
geom_point(size = 0.2,show.legend = F) +
theme_bw(base_size = 16) +
theme(panel.grid = element_blank(),
legend.position = c(0.1,0.1),
legend.background = element_blank(),
aspect.ratio = 1) +
xlab('tSNE 1') + ylab('tSNE 2')
# nUMI
p4 <- ggplot(metadata,aes(x = Embedding._X,y = Embedding._Y,
color = log10(nUMI))) +
geom_point(size = 0.2) +
theme_bw(base_size = 16) +
theme(panel.grid = element_blank(),
legend.position = c(0.1,0.1),
legend.background = element_blank(),
aspect.ratio = 1) +
xlab('tSNE 1') + ylab('tSNE 2') +
scale_color_gradient2(low = 'white',mid = 'grey80',high = 'blue',midpoint = 2.5,
name = '',
limits = c(2,5),
guide = guide_colorbar(direction = 'horizontal'))
# combine
plot_grid(plotlist = list(p1,p2,p3,p4),ncol = 2,align = 'hv')