cell annotation细胞注释 给已经做成seurat对象的细胞统一改换名字 换标签 加标签
load(file = “G:/silicosis/geo/GSE127803_scRNA-seq_ibrogenic particle_and_non-fibrogenic particle_14_days/papercodes/lung_clean.rds”)
1################################cell.type.lable
DimPlot(lung)
Idents(lung)
lung$cell.type=Idents(lung)
levels(lung)
which(Idents(lung)==“AT2”)
length(Idents(lung)“AT2”)
length(which(Idents(lung)“AT2”))
table(Idents(lung)==“AT2”)
rep(1,times=4)
cell.type.lable=rep(NA,times=ncol(lung))
paste(rep(1,length(which(Idents(lung)==“AT2”))),
“AT2”,sep = “_”)
#https://mlog.club/article/4289366
mylevels=levels(lung)
myloop=1:25
for (i in 1:length(myloop)) {
#i=1
cell.type.lable[which(Idents(lung)==mylevels[i])]<- paste(rep(myloop[i],
times=length(which(Idents(lung)==mylevels[i]))),
mylevels[i],sep = “_”)
}
length(cell.type.lable)
table(cell.type.lable)
table(lung c e l l . t y p e ) l u n g cell.type) lung cell.type)lungcell.type.lable=cell.type.lable
DimPlot(lung,group.by = “cell.type.lable”)
2#######################cell.label.num
cell.label.num=rep(NA,ncol(lung))
mylevels=levels(lung)
myloop=1:25
for (i in 1:length(unique(Idents(lung)))) {
#i=1
cell.label.num[which(Idents(lung)==mylevels[i])]<- paste(rep(myloop[i],
times=length(which(Idents(lung)==mylevels[i]))))
}
table(cell.label.num)
lung$cell.label.num=cell.label.num
3####画图
getwd()
DimPlot(lung,group.by = “cell.type”,label = TRUE)
path=“G:/silicosis/geo/GSE127803_scRNA-seq_ibrogenic particle_and_non-fibrogenic particle_14_days/papercodes/”
setwd(path)
save(lung,file = “G:/silicosis/geo/GSE127803_scRNA-seq_ibrogenic particle_and_non-fibrogenic particle_14_days/papercodes/lung_clean_cell_label.number.rds”)
pdf(“1_cell.type.pdf”,width = 14,height = 8)
p=DimPlot(lung,group.by = “cell.type”,label = TRUE)
print§
dev.off()
pdf(“2_.pdf”,width = 14,height = 8)
p=DimPlot(lung,group.by = “cell.type”)
print§
dev.off()
pdf(“3_.pdf”,width = 14,height = 8)
p=DimPlot(lung,group.by = “cell.label.num”,label = TRUE)
print§
dev.off()
pdf(“4_.pdf”,width = 14,height = 8)
p=DimPlot(lung,group.by = “cell.type.lable”,label = TRUE)
print§
dev.off()