当前位置:网站首页>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
边栏推荐
- Object.keys后key值数组乱序的问题
- [Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
- The project file '' has been renamed or is no longer in the solution, and the source control provider associated with the solution could not be found - two engineering problems
- XinChaCha Trust SSL Organization Validated
- 世界读书日:我想推荐这几本书
- Go language array operation
- Connect orcale
- three.js文字模糊问题
- Packet capturing and sorting -- TCP protocol [8]
- Deploying MySQL in cloud native kubesphere
猜你喜欢
R语言中dcast 和 melt的使用 简单易懂
Use Proteus to simulate STM32 ultrasonic srf04 ranging! Code+Proteus
No idle servers? Import OVF image to quickly experience smartx super fusion community version
Kubernetes 入門教程
leetcode:437. Path sum III [DFS selected or not selected?]
CGC: contractual graph clustering for community detection and tracking
数据库中的日期时间类型
Trier les principales utilisations de l'Agent IP réseau
Unable to create servlet under SRC subfile of idea
世界读书日:我想推荐这几本书
随机推荐
Process virtual address space partition
软件测试周刊(第68期):解决棘手问题的最上乘方法是:静观其变,顺水推舟。
7_Addmodule和基因加和法add 得到的细胞类型打分在空间上空转对比
Community version Alibaba MQ ordinary message sending subscription demo
BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction
Fashion cloud learning - input attribute summary
Byte warehouse intern interview SQL questions
Subscribe to Alibaba demo send business messages
在线计算过往日期天数,计算活了多少天
[csnote] ER diagram
Introduction to servlet listener & filter
5 free audio material websites, recommended collection
云原生KubeSphere部署Redis
Record some NPM related problems (messy records)
Timing role in the project
jmeter操作redis
STD:: shared of smart pointer_ ptr、std::unique_ ptr
Date time type in database
Golang implements MD5, sha256 and bcrypt encryption