-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscds.doublets.R
30 lines (24 loc) · 1.2 KB
/
scds.doublets.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
library(scds)
library(SingleCellExperiment)
library(rsvd)
library(Rtsne)
library("scater")
sce <- SingleCellExperiment(list(counts=as.matrix(seu@assays$RNA@counts)))
colData(sce)<-DataFrame([email protected])
logcounts(sce) = log1p(counts(sce))
vrs = apply(logcounts(sce),1,var)
pc = rsvd::rpca(t(logcounts(sce)[order(vrs,decreasing=TRUE)[1:100],]))
reducedDim(sce, "umap")<-seu@[email protected]
rm(vrs,pc)
sce = cxds(sce,retRes = TRUE)
sce = bcds(sce,retRes = TRUE,verb=TRUE)
sce = cxds_bcds_hybrid(sce)
plotReducedDim(sce, "umap",colour_by = "cxds_score")
plotReducedDim(sce, "umap",colour_by = "bcds_score")
plotReducedDim(sce, "umap",colour_by = "hybrid_score")
scds.meta <- data.frame(colData(sce)[,c("cxds_score","bcds_score","hybrid_score")])
new.seu.meta <- cbind([email protected], scds.meta[rownames([email protected]),] )
[email protected]<-new.seu.meta
FeaturePlot(seu, features="cxds_score", order=T)&theme(legend.position=c(0.1,0.2))&ggtitle("SCDS_cxds_score")
FeaturePlot(seu, features="bcds_score", order=T)&theme(legend.position=c(0.1,0.2))&ggtitle("SCDS_bcds_score")
FeaturePlot(seu, features="hybrid_score", order=T)&theme(legend.position=c(0.1,0.2))&ggtitle("SCDS_hybrid_score")