当前位置:网站首页>7_ The cell type scores obtained by addmodule and gene addition method are compared in space
7_ The cell type scores obtained by addmodule and gene addition method are compared in space
2022-04-23 13:01:00 【qq_ fifty-two million eight hundred and thirteen thousand one h】
7_Addmodule And gene addition add The cell type scores obtained are compared in space
library(ggplot2)
library(ggalluvial)
library(svglite)
library(Seurat)
library(openxlsx)
library(tibble)
library(ggpubr)
path = "G:/silicosis/sicosis/silicosis_ST/overlapped_map/contrast_between_addmodule_and addtion"
dir.create(path)
setwd(path)
getwd()
marker=read.xlsx('G:/silicosis/sicosis/yll/macrophage/no cluster2/0.3/pure_cluster01345_dotplot/cluster01345.xlsx')
#marker=read.xlsx("D:/Win10 System/Desktop/singlecell _marker.xlsx",sheet=1)
head(marker)
#names(marker) = c("B cell", "AT", "Fib", "Endo", "neutrophil", "Cycling base", "T", "Mono", "Macro")
colnames(marker)
load("G:/silicosis/ demand / silicosis - Data analysis results -0308_yll/ silicosis - Data analysis results -0308/NS_7_sct.rds")
load("G:/silicosis/ demand / silicosis - Data analysis results -0308_yll/ silicosis - Data analysis results -0308/NS_56_sct.rds")
load("G:/silicosis/ demand / silicosis - Data analysis results -0308_yll/ silicosis - Data analysis results -0308/sio2_7_sct.rds")
load("G:/silicosis/ demand / silicosis - Data analysis results -0308_yll/ silicosis - Data analysis results -0308/sio2_56_sct.rds")
load()
library(dplyr)
library(Hmisc)
# With ciliated As an example
marker
names(marker)
marker$`cluster1_AM`
cellname="cluster1_AM"
mymarker=na.omit(unique(marker$"cluster1_AM")) %>% capitalize() %>% as.character() %>%list()
mymarker
length(mymarker) # Look at how many genes there are
length(mymarker) # Look at how many genes there are
# Or use random functions directly to get
number=c(1:5) # For naming , Set it according to the size of the sample
number
cellname # For naming
mymarker
library(ggpubr)
library(ggplot2)
# The sum of simple genes adds up
for (i in 1:6) {
# The number of cycles should preferably be determined by the total mymarker number length(mymarkers) decision
markers=sample(mymarker,size=5) # The sample size must be less than length(mymarkers)
#markers=mymarker[i]
number=c(1:length(markers))
print(paste0(" The first ",i," Time :",markers,collapse=";"))
if (1==1){
#ns_7d
#markers = rownames(NS_7_sct)[number]## input markes
expr = colMeans(NS_7_sct@assays$SCT@scale.data[markers, ])
NS_7_sct@assays$SCT@scale.data[markers[1], ] = expr
p1=SpatialFeaturePlot(NS_7_sct, features = markers[1], slot = "scale.data")+
ggtitle(paste(markers, collapse = "|"))
#ns_56d
#markers = rownames(NS_56_sct)[number]## input markes
expr = colMeans(NS_56_sct@assays$SCT@scale.data[markers, ])
NS_56_sct@assays$SCT@scale.data[markers[1], ] = expr
p2 = SpatialFeaturePlot(NS_56_sct, features = markers[1], slot = "scale.data") +
ggtitle(paste(markers, collapse = "|"))
#sio2_7d
#markers = rownames(sio2_7_sct)[number]## input markes
expr = colMeans(sio2_7_sct@assays$SCT@scale.data[markers, ])
sio2_7_sct@assays$SCT@scale.data[markers[1], ] = expr
p3 = SpatialFeaturePlot(sio2_7_sct, features = markers[1], slot = "scale.data")+
ggtitle(paste(markers, collapse = "|"))
#sio2_56d
#markers = rownames(sio2_56_sct)[number]## input markes
expr = colMeans(sio2_56_sct@assays$SCT@scale.data[markers, ])
sio2_56_sct@assays$SCT@scale.data[markers[1], ] = expr
p4 = SpatialFeaturePlot(sio2_56_sct, features = markers[1], slot = "scale.data")+
ggtitle(paste(markers, collapse = "|"))
#ggarrange(p1,p2,p3,p4,ncol = 2,nrow =2)
jpeg(paste0(cellname,"_","total_",length(mymarker),"_",paste0(min(number),"-",max(number)),
paste(markers,collapse = "_"),"_.jpeg"),
height = 12, width = 12, units = 'in', res=300)
p=ggarrange(p1,p2,p3,p4,ncol = 2,nrow =2)
print(p)
dev.off()
}
}
getwd()
# The sum of genes adds up addmodule
DefaultAssay(NS_7_sct)
for (i in 1) {
# The number of cycles should preferably be determined by the total mymarker number length(mymarkers) decision
markers=sample(mymarker,size=6,replace = FALSE) # The sample size must be less than length(mymarkers)
#markers=mymarker[i]
number=c(1:length(markers))
print(paste0(" The first ",i," Time :",markers,collapse=";"))
if (1==1){
#ns_7d
#markers = rownames(NS_7_sct)[number]## input markes
expr = colMeans(NS_7_sct@assays$SCT@scale.data[markers, ])
NS_7_sct@assays$SCT@scale.data[markers[1], ] = expr
p1=SpatialFeaturePlot(NS_7_sct, features = markers[1], slot = "scale.data")+
ggtitle(paste(markers, collapse = "|"))
#ns_7d addmodule
if(1==1){
markerlist=list(markers)
NS_7_sct=AddModuleScore(NS_7_sct,
features =markerlist,
name = "markerlist")
# The results are saved here
colnames(NS_7_sct@meta.data)
head(NS_7_sct@meta.data)
colnames(NS_7_sct@meta.data)[7]<-"markerlist"
p1addmodule=SpatialFeaturePlot(NS_7_sct, features = "markerlist", slot = "scale.data")+
ggtitle(paste(unlist(markerlist), collapse = "|"))
NS_7_sct@meta.data<-NS_7_sct@meta.data[,-7]
}
#ns_56d
#markers = rownames(NS_56_sct)[number]## input markes
expr = colMeans(NS_56_sct@assays$SCT@scale.data[markers, ])
NS_56_sct@assays$SCT@scale.data[markers[1], ] = expr
p2 = SpatialFeaturePlot(NS_56_sct, features = markers[1], slot = "scale.data") +
ggtitle(paste(markers, collapse = "|"))
#ns_56d addmodule
if(1==1){
markerlist=list(markers)
NS_56_sct=AddModuleScore(NS_56_sct,
features =markerlist,
name = "markerlist")
# The results are saved here
colnames(NS_56_sct@meta.data)
head(NS_56_sct@meta.data)
colnames(NS_56_sct@meta.data)[7]<-"markerlist"
p2addmodule=SpatialFeaturePlot(NS_56_sct, features = "markerlist", slot = "scale.data")
NS_56_sct@meta.data<-NS_56_sct@meta.data[,-7]
}
#sio2_7d
#markers = rownames(sio2_7_sct)[number]## input markes
expr = colMeans(sio2_7_sct@assays$SCT@scale.data[markers, ])
sio2_7_sct@assays$SCT@scale.data[markers[1], ] = expr
p3 = SpatialFeaturePlot(sio2_7_sct, features = markers[1], slot = "scale.data")+
ggtitle(paste(markers, collapse = "|"))
#sio2_7d addmodule
if(1==1){
markerlist=list(markers)
sio2_7_sct=AddModuleScore(sio2_7_sct,
features =markerlist,
name = "markerlist")
# The results are saved here
colnames(sio2_7_sct@meta.data)
head(sio2_7_sct@meta.data)
colnames(sio2_7_sct@meta.data)[7]<-"markerlist"
p3addmodule=SpatialFeaturePlot(sio2_7_sct, features = "markerlist", slot = "scale.data")+
ggtitle(paste(cellname))
sio2_7_sct@meta.data<-sio2_7_sct@meta.data[,-7]
}
#sio2_56d
#markers = rownames(sio2_56_sct)[number]## input markes
expr = colMeans(sio2_56_sct@assays$SCT@scale.data[markers, ])
sio2_56_sct@assays$SCT@scale.data[markers[1], ] = expr
p4 = SpatialFeaturePlot(sio2_56_sct, features = markers[1], slot = "scale.data")+
ggtitle(paste(markers, collapse = "|"))
#ggarrange(p1,p2,p3,p4,ncol = 2,nrow =2)
#sio2_56d addmodule
if(1==1){
markerlist=list(markers)
sio2_56_sct=AddModuleScore(sio2_56_sct,
features =markerlist,
name = "markerlist")
# The results are saved here
colnames(sio2_56_sct@meta.data)
head(sio2_56_sct@meta.data)
colnames(sio2_56_sct@meta.data)[7]<-"markerlist"
p4addmodule=SpatialFeaturePlot(sio2_56_sct, features = "markerlist", slot = "scale.data")+
ggtitle(paste(unlist(markerlist), collapse = "|"))
sio2_56_sct@meta.data<-sio2_56_sct@meta.data[,-7]
}
#addition
jpeg(paste0(cellname,"_","total_",length(mymarker),"_",paste0(min(number),"-",max(number)),
paste(markers,collapse = "_"),"_.jpeg"),
height = 12, width = 12, units = 'in', res=300)
p=ggarrange(p1,p2,p3,p4,ncol = 2,nrow =2)
print(p)
dev.off()
#addmodule
jpeg(paste0(cellname,"_","total_",length(unlist(markerlist)),"_",paste0(min(number),"-",max(number)),
paste(unlist(markerlist)[1:15],collapse = "_"),"_.jpeg"), # Take only before 15 individual
height = 12, width = 12, units = 'in', res=600)
p=ggpubr::ggarrange(p1addmodule,p2addmodule,p3addmodule,p4addmodule,ncol = 2,nrow =2)
print(p)
dev.off()
}
}
while (dev.off()) {
dev.off()
}
getwd()
# Determine whether the gene is in idle
for (each in mymarker) {
if (each %in% c(rownames(NS_7_sct@assays$SCT@scale.data),
rownames(NS_56_sct@assays$SCT@scale.data),
rownames(sio2_7_sct@assays$SCT@scale.data),
rownames(sio2_56_sct@assays$SCT@scale.data)
)==FALSE)
print(paste0(each," No... Detected in idle data "))
if (each %in% c(rownames(NS_7_sct@assays$SCT@scale.data))==FALSE)
print(paste0(each," Not in NS_7 Idle data detected "))
if (each %in% c(rownames(NS_56_sct@assays$SCT@scale.data))==FALSE)
print(paste0(each," Not in NS_56 Idle data detected "))
if (each %in% c(rownames(sio2_7_sct@assays$SCT@scale.data))==FALSE)
print(paste0(each," Not in sio2_7 Idle data detected "))
if (each %in% c(rownames(sio2_56_sct@assays$SCT@scale.data))==FALSE)
print(paste0(each," Not in sio2_56 Idle data detected "))
} # Determine whether the gene is in idle
版权声明
本文为[qq_ fifty-two million eight hundred and thirteen thousand one h]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231258305883.html
边栏推荐
- 7_Addmodule和基因加和法add 得到的细胞类型打分在空间上空转对比
- Mysql8 installation
- 98. Error s.e.errormvcautoconfiguration $staticview reported by freemaker framework: cannot render error page for request
- 只是不断地建构平台,不断地收拢流量,并不能够做好产业互联网
- leetcode-791. Custom string sorting
- Unable to create servlet under SRC subfile of idea
- Community version Alibaba MQ ordinary message sending subscription demo
- At instruction of nbiot
- About the 'enum' enumeration type and structure.
- HQL statement tuning
猜你喜欢
Use source insight to view and edit source code
有趣的IDEA插件推荐,给你的开发工作增添色彩
V-model binding value in El select, data echo only displays value, not label
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
STM32 is connected to the motor drive, the DuPont line supplies power, and then the back burning problem
Object.keys后key值数组乱序的问题
About the 'enum' enumeration type and structure.
31. 下一个排列
云原生KubeSphere部署Mysql
The quill editor image zooms, multiple rich text boxes are used on one page, and the quill editor upload image address is the server address
随机推荐
Teach you to quickly develop a werewolf killing wechat applet (with source code)
Golang implements MD5, sha256 and bcrypt encryption
Packet capturing and sorting -- TCP protocol [8]
Recommended website for drawing result map
Customize the shortcut options in El date picker, and dynamically set the disabled date
Record some NPM related problems (messy records)
Introducing vant components on demand
1130 - host XXX is not allowed to connect to this MySQL server error in Navicat remote connection database
pyqt5 将opencv图片存入内置SQLlite数据库,并查询
8086 of x86 architecture
Customize classloader and implement hot deployment - use loadclass
Embrace the new blue ocean of machine vision and hope to open a new "Ji" encounter for the development of digital economy
JMeter operation redis
4.DRF 权限&访问频率&过滤&排序
Software testing weekly (issue 68): the best way to solve difficult problems is to wait and see the changes and push the boat with the current.
31. 下一个排列
The continuous construction of the Internet industry platform is not only able to collect traffic
有趣的IDEA插件推荐,给你的开发工作增添色彩
Learning materials
STM32 is connected to the motor drive, the DuPont line supplies power, and then the back burning problem