[5]:
library(Seurat)
library(gridExtra)
library(Matrix)
library(ggplot2)
T harmony#
[6]:
source('/home/public/ghx/software/my_seurat.r')
[7]:
RDSPath <- '/home/public/ghx/wuLab/Bladder/1217_all/seu'
[8]:
ct <- 'T'
[5]:
mtx <- readRDS(file = file.path(RDSPath,
paste0('V1_Celltype_',ct,'_matrix.rds')))
anno <- readRDS(file = file.path(RDSPath,
paste0('V1_Celltype_',ct,'_annotation.rds')))
[6]:
seu <- CreateSeuratObject(counts = mtx, meta.data = anno, project = ct)
[7]:
samples <- levels(seu@meta.data$orig.ident)
First, integrate all T cell raw data without doing any batch effect removal#
[8]:
seu <- Nml_Scl_Fvg_PCA_Fnb(seu = seu)
[34]:
seu <- FindClusters(object = seu,
resolution = 1.5, verbose = F)
[14]:
seu <- RunUMAP(object = seu, dims = 1:25, verbose = F,
umap.method = 'umap-learn', metric = 'correlation')
[ ]:
options(repr.plot.width=20, repr.plot.height=20, repr.plot.res = 200)
p1 <- DimPlot(seu, label = T, pt.size = 0.1) +
labs(title = 'cluster') #+ theme(legend.position = 'none')
p2 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'orig.ident') +
labs(title = 'sample.origin') #+ theme(legend.position = 'none')
p3 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'status') +
labs(title = 'status') #+ theme(legend.position = 'none')
p <- arrangeGrob(grobs = list(p1,p2,p3), ncol = 2,
top = paste0('MIBC5-16: raw merge'))
ggsave(plot = p, limitsize = FALSE, width = 20, height = 20,
filename = file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_raw_overview.jpg'))
grid.arrange(p)
[16]:
table(data.frame(cluster = seu@active.ident,
origin = seu@meta.data$orig.ident))
origin
cluster MIBC5P MIBC5T MIBC6P MIBC6T MIBC7P MIBC7T MIBC8P MIBC8T MIBC9P MIBC9T
0 15 14 248 10 1212 53 34 2 1060 19
1 82 39 147 152 6 10 9335 534 2 10
2 58 8 1801 33 65 1484 40 17 76 629
3 895 126 85 6593 1 13 68 0 0 3
4 88 81 294 1862 94 862 665 116 56 926
5 43 0 84 1 2249 30 16 1 297 34
6 10 38 8 16 1 2704 1 12 5 526
7 28 0 1362 29 1192 528 20 3 351 111
8 75 18 872 744 13 45 1875 181 16 69
9 18 3 0 17 4 5 3 0 13 3
10 1094 2 34 16 44 5 3 0 27 0
11 18 37 69 25 12 30 20 903 25 2529
12 0 0 3 1 3 1 2 2 3 2
13 0 5 7 4 25 11 18 205 695 18
14 3 1963 14 16 1 5 7 19 0 8
15 13 1 157 1 10 5 7 0 22 9
16 688 17 4 7 0 0 0 0 0 8
17 0 2 0 2 1 0 21 0 0 1
origin
cluster MIBC10P MIBC10T MIBC11P MIBC11T MIBC12P MIBC12T MIBC13P MIBC13T MIBC14P
0 820 448 1444 2198 322 281 1756 153 134
1 13 3 2 6 17 17 3 11 35
2 409 1813 5 11 5 34 423 829 760
3 17 17 0 7 15 87 1 7 0
4 80 123 7 37 99 1627 106 244 192
5 1937 150 580 3 124 22 23 21 359
6 0 0 2 0 1 24 36 2549 18
7 333 588 207 3 146 32 8 151 431
8 141 135 8 33 72 491 18 45 184
9 0 11 3 43 87 4869 3 8 0
10 113 5 178 25 2932 493 28 3 0
11 12 84 1 9 8 109 22 118 30
12 33 0 123 2 1 0 0 0 557
13 6 44 17 183 8 53 5 23 18
14 0 1 0 0 1 3 1 9 0
15 60 28 113 2 11 10 3 875 13
16 0 0 0 0 0 3 3 1 0
17 0 13 0 0 0 10 1 0 16
origin
cluster MIBC14T MIBC15P MIBC15T MIBC16P MIBC16T
0 604 144 1459 240 2551
1 0 7 48 10 0
2 2 116 58 55 7
3 0 15 107 1 0
4 0 28 330 7 8
5 12 1213 3 178 2
6 1 2 152 0 1
7 8 406 33 88 2
8 12 197 136 268 3
9 0 0 110 3 4
10 0 48 15 19 0
11 0 11 44 4 12
12 7 11 1 2343 5
13 207 11 1340 8 83
14 0 0 6 0 0
15 19 8 40 0 57
16 0 0 1 0 0
17 3 6 0 8 0
[17]:
sub.cells <- c()
for(c in levels(seu@active.ident)){
sub.cells <- c(sub.cells, sample(Cells(seu)[ seu@active.ident == c ], replace = F,
size = min(1000,sum(seu@active.ident == c))))
}
length(sub.cells)
16816
[ ]:
library(future)
plan("multiprocess", workers = 12)
plan()
options(future.globals.maxSize = 10000 * 1024^2)
markers <- FindAllMarkers(seu, verbose = F)
plan("sequential")
structure(function (expr, envir = parent.frame(), substitute = TRUE,
lazy = FALSE, seed = NULL, globals = TRUE, workers = 12,
gc = FALSE, earlySignal = FALSE, label = NULL, ...)
{
if (substitute)
expr <- substitute(expr)
fun <- if (supportsMulticore(warn = TRUE))
multicore
else multisession
fun(expr = expr, envir = envir, substitute = FALSE, lazy = lazy,
seed = seed, globals = globals, workers = workers, gc = gc,
earlySignal = earlySignal, label = label, ...)
}, class = c("FutureStrategy", "tweaked", "multiprocess", "future",
"function"), init = FALSE, call = plan("multiprocess", workers = 12))[22]:
top10 <- extractTopNMarkers(df = markers, top_n = 20)
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
p <- DoHeatmap(object = seu, cells = sub.cells,draw.lines = FALSE,
features = top10$gene, size = 5, angle = 0, disp.min = -2, disp.max = 2) +
theme(text = element_text(size = 4))
ggsave(plot = p, limitsize = FALSE, width = 20, height = 20,
filename = file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_raw_heatmap.jpg'))
p
[28]:
write.csv(markers, file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_raw_cluster_markers.csv'))
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
FeaturePlot(object = seu, features = c('CD4','CD8A','TRAC','TRDC'), pt.size = 0.01)
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
VlnPlot(object = seu, ncol = 1,
features = c('CD4','CD8A','TRAC','TRDC'), pt.size = 0.01)
[ ]:
options(repr.plot.width=10, repr.plot.height=5, repr.plot.res = 200)
FeaturePlot(object = seu, features = c('KRT17','JCHAIN'), pt.size = 0.01)
Harmony: remove batch effect between patients#
[11]:
library(harmony)
Loading required package: Rcpp
[ ]:
seu <- RunHarmony(seu, theta = 10, verbose = F,
group.by.vars = 'patient', plot_convergence = T)
[25]:
seu <- RunUMAP(object = seu, reduction.name = 'umap_harmony',
umap.method = 'umap-learn', metric = 'correlation',
reduction = 'harmony', dims = 1:20)
Warning message:
“Cannot add objects with duplicate keys (offending key: UMAP_), setting key to 'umap_harmony_'”
[26]:
seu <- FindNeighbors(seu, reduction = 'harmony', dims = 1:20, verbose = F)
[53]:
seu <- FindClusters(seu, verbose = F,resolution = 0.5)
[ ]:
options(repr.plot.width=20, repr.plot.height=20, repr.plot.res = 200)
p1 <- DimPlot(seu, label = T, pt.size = 0.1,
reduction = 'umap_harmony') +
labs(title = 'cluster') #+ theme(legend.position = 'none')
p2 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'orig.ident',
reduction = 'umap_harmony') +
labs(title = 'sample.origin') #+ theme(legend.position = 'none')
p3 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'status',
reduction = 'umap_harmony') +
labs(title = 'status') #+ theme(legend.position = 'none')
p4 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'patient',
reduction = 'umap_harmony') +
labs(title = 'patient') #+ theme(legend.position = 'none')
p <- arrangeGrob(grobs = list(p1,p2,p3,p4), ncol = 2,
top = paste0('MIBC5-16: raw merge'))
ggsave(plot = p, limitsize = FALSE, width = 20, height = 20,
filename = file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_harmony_patient_overview.jpg'))
grid.arrange(p)
[57]:
stats <- table(seu@active.ident, seu@meta.data$orig.ident)
stats <- as.data.frame(stats)
names(stats) <- c('cluster', 'origin', 'cell.number')
color <- rep(c(rep('white',length(levels(seu@active.ident))),
rep('black',length(levels(seu@active.ident)))), 12)
p5 <- ggplot(stats, aes(fill=cluster, y=cell.number, x=origin)) +
geom_bar( stat="identity", position="fill", color = color) +
theme(axis.text.x = element_text(size=10, angle = 90))
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
p5
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
FeaturePlot(object = seu, features = c('CD4','CD8A','TRAC','TRDC'), pt.size = 0.01,
reduction = 'umap_harmony')
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
VlnPlot(object = seu, ncol = 1,
features = c('CD4','CD8A','TRAC','TRDC'), pt.size = 0.01)
[ ]:
find clusters (resolution = 0.5, 12 clusters) and markers genes#
[58]:
library(future)
plan("multiprocess", workers = 12)
plan()
options(future.globals.maxSize = 10000 * 1024^2)
markers <- FindAllMarkers(seu, verbose = F)
plan("sequential")
structure(function (expr, envir = parent.frame(), substitute = TRUE,
lazy = FALSE, seed = NULL, globals = TRUE, workers = 12,
gc = FALSE, earlySignal = FALSE, label = NULL, ...)
{
if (substitute)
expr <- substitute(expr)
fun <- if (supportsMulticore(warn = TRUE))
multicore
else multisession
fun(expr = expr, envir = envir, substitute = FALSE, lazy = lazy,
seed = seed, globals = globals, workers = workers, gc = gc,
earlySignal = earlySignal, label = label, ...)
}, class = c("FutureStrategy", "tweaked", "multiprocess", "future",
"function"), init = FALSE, call = plan("multiprocess", workers = 12))[59]:
top10 <- extractTopNMarkers(df = markers, top_n = 20)
sub.cells <- c()
for(c in levels(seu@active.ident)){
sub.cells <- c(sub.cells, sample(Cells(seu)[ seu@active.ident == c ], replace = F,
size = min(1000,sum(seu@active.ident == c))))
}
length(sub.cells)
10095
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
p <- DoHeatmap(object = seu, cells = sub.cells,draw.lines = FALSE,
features = top10$gene, size = 5, angle = 0, disp.min = -2, disp.max = 2) +
theme(text = element_text(size = 4))
ggsave(plot = p, limitsize = FALSE, width = 20, height = 20,
filename = file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_harmony_patient_heatmap.jpg'))
p
[61]:
write.csv(markers, file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_harmony_patient_cluster_markers.csv'))
find clusters (resolution = 1.5, 22 clusters) and markers genes#
[3]:
length(levels(seu@active.ident))
23
[10]:
library(future)
plan("multiprocess", workers = 12)
options(future.globals.maxSize = 10000 * 1024^2)
markers <- FindAllMarkers(seu, verbose = F)
plan("sequential")
[11]:
top10 <- extractTopNMarkers(df = markers, top_n = 20)
sub.cells <- c()
for(c in levels(seu@active.ident)){
sub.cells <- c(sub.cells, sample(Cells(seu)[ seu@active.ident == c ], replace = F,
size = min(1000,sum(seu@active.ident == c))))
}
length(sub.cells)
21096
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
p <- DoHeatmap(object = seu, cells = sub.cells,draw.lines = FALSE,
features = top10$gene, size = 5, angle = 0, disp.min = -2, disp.max = 2) +
theme(text = element_text(size = 4))
ggsave(plot = p, limitsize = FALSE, width = 20, height = 20,
filename = file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_harmony_heatmap.jpg'))
p
[13]:
write.csv(markers, file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_harmony_cluster_markers.csv'))
use batch-effect-removal embedding(harmony) to reconstruct scaled expression data#
[9]:
# X=U*Sigma*V, U and V are Unitary Matrix, e.g. V^-1=t(V)
# U=X*t(V)*(1/Sigma)
# X(nGene*nCell)=U(nGene*nPC)*Sigma(nPC*nPC)*V(nPC*nCell)
#X <- seu@assays$RNA@scale.data
Sigma <- seu@reductions$pca@stdev
V <- seu@reductions$pca@cell.embeddings[, 1:100]
V <- apply(V,MARGIN = 2,FUN = function(x){
return(x/sqrt(sum(x^2)))
})
# here V(nCell*nPC) is actually t(V)
U <- seu@assays$RNA@scale.data %*% V %*% diag(1/Sigma)
[10]:
# after batch effect removal, X.new=U*Sigma*V.new
V.new <- seu@reductions$harmony@cell.embeddings[, 1:100]
V.new <- apply(V.new,MARGIN = 2,FUN = function(x){
return(x/sqrt(sum(x^2)))
})
#clean.data.full <- U %*% diag(Sigma) %*% t(V.new)
[11]:
seu <- SetAssayData(seu, slot = 'scale.data', new.data = U %*% diag(Sigma) %*% t(V.new))
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
p <- DoHeatmap(object = seu, cells = sub.cells,draw.lines = FALSE,
features = top10$gene, size = 5, angle = 0, disp.min = -2, disp.max = 2) +
theme(text = element_text(size = 4))
ggsave(plot = p, limitsize = FALSE, width = 20, height = 20,
filename = file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_harmony_patient_recons_heatmap.jpg'))
p
Harmony: remove batch effect between Paratumors but not Tumors#
wasted, bad results#
[12]:
patient.P <- as.character(seu@meta.data$orig.ident)
patient.P[ seu@meta.data$status == 'T' ] <- 'T'
seu@meta.data$patient.P <- patient.P
[17]:
seu <- RunHarmony(seu, theta = 10, verbose = F, reduction.save = 'harmony_P', project.dim = F,
group.by.vars = 'patient.P', plot_convergence = T)
Warning message:
“Quick-TRANSfer stage steps exceeded maximum (= 5024600)”
[18]:
seu <- RunUMAP(object = seu, reduction.name = 'umap_harmony_P',
umap.method = 'umap-learn', metric = 'correlation',
reduction = 'harmony_P', dims = 1:20)
[40]:
seu <- FindNeighbors(seu, reduction = 'harmony_P', dims = 1:20, verbose = F)
[41]:
seu <- FindClusters(seu, verbose = F,resolution = 1.5)
[ ]:
options(repr.plot.width=20, repr.plot.height=20, repr.plot.res = 200)
p1 <- DimPlot(seu, label = T, pt.size = 0.1,
reduction = 'umap_harmony_P') +
labs(title = 'cluster') #+ theme(legend.position = 'none')
p2 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'orig.ident',
reduction = 'umap_harmony_P') +
labs(title = 'sample.origin') #+ theme(legend.position = 'none')
p3 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'status',
reduction = 'umap_harmony_P') +
labs(title = 'status') #+ theme(legend.position = 'none')
p <- arrangeGrob(grobs = list(p1,p2,p3), ncol = 2,
top = paste0('MIBC5-16: raw merge'))
ggsave(plot = p, limitsize = FALSE, width = 20, height = 20,
filename = file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_harmony_patientP_overview.jpg'))
grid.arrange(p)
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
FeaturePlot(object = seu, features = c('CD4','CD8A','TRAC','TRDC'), pt.size = 0.01,
reduction = 'umap_harmony_P')
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
VlnPlot(object = seu, ncol = 1,
features = c('CD4','CD8A','TRAC','TRDC'), pt.size = 0.01)
[46]:
saveRDS(seu, file = file.path('/home/public/ghx/wuLab/Bladder/1217_all/seu',
'V1_Celltype_T_seu.rds'))
annotated cell type from each sample clusters by SZ#
[5]:
seu <- readRDS(file = file.path('/home/public/ghx/wuLab/Bladder/1217_all/seu',
'V1_Celltype_T_seu.rds'))
[6]:
old.clusters <- readRDS(file = '/home/public/ghx/wuLab/Bladder/1119_T/sampleCluster.rds')
new.clusters <- readRDS(file = '/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/sample_cluster.rds')
[11]:
sample.id <- sapply(old.clusters, USE.NAMES = T, simplify = T,
FUN = function(x){
return(strsplit(x, split = '-', fixed = T)[[1]][1])
})
sample.id <- paste0('MIBC',sample.id)
names(old.clusters) <- paste0(sample.id, '.',names(old.clusters))
[30]:
annostr <- '11P-1 CD4-?
6P-1 CD4-?
8P-3 CD4-?
5P-4 CD4-?
11T-4 CD4-?
11T-0 CD4-?
7T-4 CD4-?
6P-6 CD4-?1
5T-3 CD4-?1
7T-6 CD4-?1
9T-3 CD4-?1
6T-5 CD4-?1
8T-14 CD4-?1
10P-15 CD4-HSP-IG
10T-5 CD4-naïve
9T-10 CD4-naïve
7T-2 CD4-naïve-RPL
10T-4 CD4-naïve-RPL
10P-10 CD4-naïve-RPL
9P-2 CD4-naïve-RPL
5P-3 CD4-naïve-RPL
9T-4 CD4-naïve-RPL
5T-6 CD4-naïve-RPL
8P-5 CD4-naïve-RPL
10T-1 CD4-naïve
11T-5 CD4-naïve
10T-2 CD4-naïve
10P-2 CD4-naïve
6T-1 CD4-RPL
6P-2 CD4-RPL
11T-3 CD4-RPL
5P-6 CD4-Tfh
7P-1 CD4-Th1?
11P-9 CD4-Th17
10P-1 CD4-Th17
4P-5 CD4-Th17
10P-5 CD4-Th17
8T-5 CD4-Th17
7P-10 CD4-Th17
8P-8 CD4-Th17
11P-0 CD4-Th17
5T-2 CD4-Th17
5P-1 CD4-Th17
7P-8 CD4-Th17
5T-8 CD4-Th17
7P-2 CD4-Th17
9P-0 CD4-Th17
4P-2 CD4-Tr1
5P-8 CD4-Tr1
6T-10 CD4-Treg
10T-6 CD4-Treg
7P-6 CD4-Treg
7T-1 CD4-Treg
8P-7 CD4-Treg
9T-9 CD4-Treg
11T-6 CD4-Treg
8T-4 CD4-Treg
5T-11 CD4-Treg
4P-4 CD4-Treg(naïve)
5P-10 CD4-Treg(naïve)
6T-2 CD4-Treg(naïve)
6P-4 CD4-Treg(naïve)
11P-10 CD4-Treg(naïve)
9P-7 CD4-Treg(naïve)
5T-5 CD4-Treg(naïve)
11T-1 CD4-Treg(naïve)
10P-12 CD4-Treg(Th17)
6T-6 CD4-Treg(Th17)
9T-1 CD4-Treg(Th17)
4T-7 CD8-Exhau
7T-11 CD8-Exhau
9T-12 CD8-HSP
6P-8 CD8-HSP
11P-6 CD8-HSP
11P-13 CD8-IG
7P-13 CD8-IG
7T-9 CD8-IG
11T-11 CD8-IG
6T-9 CD8-MAIT(CRC)
10T-10 CD8-MAIT(CRC)
6P-12 CD8-MAIT(CRC)
11T-7 CD8-MAIT(CRC)
7P-11 Dead cell
10P-8 Dead cell
5P-9 Dead cell
10T-8 Dead cell
11P-4 Dead cell
7T-12 Dead cell
8P-1 Dead cell
8T-8 Dead cell
11T-9 Dead cell
9T-11 Dead cell
4P-3 Dead cell
6P-7 Dead cell
8T-7 Dead cell
5T-1 Dead cell
9P-8 Dump
11P-12 Dump
8P-12 Dump
10T-12 Dump
11T-10 Dump
4T-11 Dump
8P-13 gdT-antitumor
5P-11 gdT-antitumor
11P-8 gdT-antitumor
10T-13 gdT-antitumor
9P-4 gdT-antitumor
7P-12 gdT-antitumor
6T-11 gdT-antitumor
10P-9 gdT-antitumor
4P-6 gdT-antitumor'
annolines <- strsplit(annostr, split = '\n')[[1]]
[31]:
anno.ct <- rep(NA, length(old.clusters))
names(anno.ct) <- names(old.clusters)
for(anno in strsplit(annolines, split = '\t')){
anno.ct[old.clusters %in% anno[1]] <- anno[2]
}
[32]:
intersect.cells <- intersect(names(anno.ct), Cells(seu))
anno.ct.seu <- rep(NA, length(Cells(seu)))
names(anno.ct.seu) <- Cells(seu)
anno.ct.seu[intersect.cells] <- anno.ct[intersect.cells]
seu@meta.data$anno.ct <- anno.ct.seu
[ ]:
options(repr.plot.width=20, repr.plot.height=20, repr.plot.res = 200)
p1 <- DimPlot(seu, label = T, pt.size = 0.1,
reduction = 'umap_harmony') +
labs(title = 'cluster') #+ theme(legend.position = 'none')
p2 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'orig.ident',
reduction = 'umap_harmony') +
labs(title = 'sample.origin') #+ theme(legend.position = 'none')
p3 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'status',
reduction = 'umap_harmony') +
labs(title = 'status') #+ theme(legend.position = 'none')
p4 <- DimPlot(seu, label = T, pt.size = 0.1, group.by = 'patient',
reduction = 'umap_harmony') +
labs(title = 'patient') #+ theme(legend.position = 'none')
p <- arrangeGrob(grobs = list(p1,p2,p3,p4), ncol = 2,
top = paste0('MIBC5-16: raw merge'))
ggsave(plot = p, limitsize = FALSE, width = 20, height = 20,
filename = file.path('/home/public/ghx/wuLab/Bladder/1217_all/CellTypes/T/Merge',
'Merge_v1_T_harmony_patient_overview.jpg'))
grid.arrange(p)
[ ]:
options(repr.plot.width=10, repr.plot.height=10, repr.plot.res = 200)
cells.1 <- Cells(seu)[ is.na(anno.ct.seu) ]
cells.2 <- Cells(seu)[ !is.na(anno.ct.seu) ]
DimPlot(seu, label = T, pt.size = 0.1, group.by = 'anno.ct', cells = c(cells.1,cells.2),
reduction = 'umap_harmony') +
labs(title = 'annotated cell types')+ theme(legend.position = 'none')
[37]:
plots <- list()
for(temp.ct in unique(anno.ct.seu)){
if(is.na(temp.ct)) next
p <- DimPlot(seu, label = T, pt.size = 0.1, sizes.highlight = 0.2,
cells.highlight = Cells(seu)[seu@meta.data$anno.ct == temp.ct],
reduction = 'umap_harmony') +
labs(title = temp.ct)+ theme(legend.position = 'none')
plots[[temp.ct]] <- p
}
[38]:
p <- arrangeGrob(grobs = plots, ncol = 2,
top = paste0('annotated cell type'))
[ ]:
options(repr.plot.width=10, repr.plot.height=50, repr.plot.res = 200)
grid.arrange(p)
[ ]:
p1 <- DimPlot(seu,label = T, pt.size = 0.1, sizes.highlight = 0.2, group.by = 'anno.ct',
cells = Cells(seu)[seu@meta.data$status == 'P'],
reduction = 'umap_harmony')
p2 <- DimPlot(seu,label = T, pt.size = 0.1, sizes.highlight = 0.2, group.by = 'anno.ct',
cells = Cells(seu)[seu@meta.data$status == 'T'],
reduction = 'umap_harmony')
options(repr.plot.width=20, repr.plot.height=10, repr.plot.res = 200)
grid.arrange(grobs = list(p1,p2), ncol = 2,
top = paste0('status'))
[ ]: