-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMap2.2_Doublet_Analysis.R
33 lines (25 loc) · 1.44 KB
/
Map2.2_Doublet_Analysis.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
# Auto-annotation
liver.integrated <- readRDS("All_merged_universal_genes_harmony_integrated_v2.rds");
prefix <- "All_harmony_integrated";
all_doublets <- readRDS("All20_doubletDetection2.rds")
[email protected]$DoubletScore <- rep(-1, ncol(liver.integrated));
[email protected]$is.Doublet <- rep("unknown", ncol(liver.integrated));
require(stringr)
for (sample in unique([email protected]$orig.ident)) {
cell_ids <- [email protected]$cell_barcode[[email protected]$sample == sample]
sample2 <- gsub("_NPC", "-NPC", sample)
doublets <- all_doublets[[sample2]];
doublets <- doublets[doublets$cell_barcode %in% cell_ids,]
doublets <- doublets[match(cell_ids, doublets$cell_barcode),]
doublets$DoubletScore <- as.numeric(doublets[,ncol(doublets)-1])
doublets$is.Doublet <- doublets[,ncol(doublets)-1]
[email protected]$DoubletScore[[email protected]$orig.ident == sample] <- as.numeric(doublets$DoubletScore)
[email protected]$is.Doublet[[email protected]$orig.ident == sample] <- as.character(doublets$is.Doublet)
}
require("Seurat")
png(paste(prefix, "DoubletScore.png", sep="_"), width=6, height=6, units="in", res=150)
Seurat::FeaturePlot(liver.integrated, "DoubletScore")
dev.off()
png(paste(prefix, "isDoublet.png", sep="_"), width=6, height=6, units="in", res=150)
Seurat::DimPlot(liver.integrated, group.by="is.Doublet")
dev.off()