library("ArchR")
library(Matrix)
library("Seurat")
#Load ArchR object
proj<-loadArchRProject("~/cluster/projects/lung_subset/")
proj.orig<-loadArchRProject("lung_snATAC/")
options(repr.plot.width=14, repr.plot.height=12)
p1 <- plotEmbedding(ArchRProj = proj.orig, colorBy = "cellColData", name = "Clusters", embedding = "UMAP") + ggtitle("Human lung snATAC-seq(74930 nuclei)")
p1
#predict gene scores for marker genes
markerGenes <- c(
'NCR1','CD8A','CD4','CD74',
'CCR7', 'ITGAE','CD69',
'IL7R', 'ICOS'
)
proj.orig <- addImputeWeights(proj.orig)
#make plots for marker genes
p <- plotEmbedding(
ArchRProj = proj.orig,
colorBy = "GeneScoreMatrix",
name = markerGenes,
embedding = "UMAP",
imputeWeights = getImputeWeights(proj.orig)
)
#Rearrange for grid plotting
p2 <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme(
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()
)
})
do.call(cowplot::plot_grid, c(list(ncol = 3),p2))
Procedures:
p2 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData", name = "Clusters", embedding = "UMAP", title="Sub-clustering of T cell/NK cells")
p2
#predict gene scores for marker genes
markerGenes <- c(
'NCR1','CD8A','CD4','CD74',
'CCR7', 'ITGAE','CD69',
'IL7R', 'ICOS'
)
proj<- addImputeWeights(proj)
#make plots for marker genes
p <- plotEmbedding(
ArchRProj = proj,
colorBy = "GeneScoreMatrix",
name = markerGenes,
embedding = "UMAP",
imputeWeights = getImputeWeights(proj)
)
#Rearrange for grid plotting
p2 <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme(
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()
)
})
do.call(cowplot::plot_grid, c(list(ncol = 3),p2))
seRNA<-readRDS("~/cluster/projects/lung_others/lung_scRNA/")
seRNA.orig<-readRDS("~/cluster/projects/lung_others/lung_scRNA/lung_Wang2020.rds")
markers<-c("AGER","SFTPA2","NDNF","KCNJ15","GDF15","SCGB3A2","TP63","MUC5B",
"MYB","RIMS2","COL2A1","LAMC3","NTRK3","MYOCD","LTBP2","TCF21","MFAP5",
"BMX","ACKR1","KIT","CA4","ABCB1","RELN","TREM1","PLTP","FCN1","FLT3",
"EPB42","TCF7","PRF1","PAX5","MS4A2")
options(repr.plot.width=12, repr.plot.height=10)
DotPlot(object=seRNA.orig, features=markers) + theme(axis.text.x = element_text(angle=45, vjust = 0.5))
DimPlot(seRNA, reduction="umap", label = T, label.size = 5) + ggtitle("Human lung scRNA-Seq T cells (3209 nuclei)")
DotPlot(object=seRNA, features=markerGenes) + theme(axis.text.x = element_text(angle=45, vjust = 0.5))
new.clusters.ids<-c("TRM", "non-TRM", "TRM", "TRM", "TRM", 'TRM', "TRM")
names(new.clusters.ids)<-levels(seRNA)
seRNA<-RenameIdents(seRNA, new.clusters.ids)
seRNA[["cell_types"]]<-seRNA@active.ident
DimPlot(seRNA, reduction="umap", label=TRUE)
projInteg <- addGeneIntegrationMatrix(
ArchRProj = proj,
useMatrix = "GeneScoreMatrix",
matrixName = "GeneIntegrationMatrix",
reducedDims = "IterativeLSI",
seRNA = seRNA,
addToArrow = FALSE,
groupRNA = "cell_types",
nameCell = "predictedCell_Un",
nameGroup = "predictedGroup_Un",
nameScore = "predictedScore_Un"
)
#Unconstrained integration
cM <- as.matrix(confusionMatrix(projInteg$Clusters, projInteg$predictedGroup_Un))
preClust <- colnames(cM)[apply(cM, 1 , which.max)]
cbind(preClust, rownames(cM)) #Assignments
cM