当前位置:网站首页>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
边栏推荐
- Use compressorjs to compress pictures, optimize functions, and compress pictures in all formats
- Use source insight to view and edit source code
- XinChaCha Trust SSL Organization Validated
- V-model binding value in El select, data echo only displays value, not label
- How to prevent the website from being hacked and tampered with
- Go language mapping operation
- Byte warehouse intern interview SQL questions
- World Book Day: I'd like to recommend these books
- Redis deployment of cloud native kubesphere
- Ad20 supplementary note 3 - shortcut key + continuous update
猜你喜欢
Introduction to servlet listener & filter
V-model binding value in El select, data echo only displays value, not label
梳理网络IP代理的几大用途
产品开发都应该知道的8个网站,增强工作体验
MySQL supports IP access
Bert base Chinese Download (SMART)
Record Alibaba cloud server mining program processing
梳理網絡IP代理的幾大用途
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.
风尚云网学习-input属性总结
随机推荐
31. Next arrangement
98. Error s.e.errormvcautoconfiguration $staticview reported by freemaker framework: cannot render error page for request
Summary of JVM knowledge points - continuously updated
Translation of attention in natural language processing
4. DRF permission & access frequency & filtering & sorting
World Book Day: I'd like to recommend these books
Free and open source agricultural Internet of things cloud platform (version: 3.0.1)
将新增和编辑的数据同步更新到列表
Design of STM32 multi-channel temperature measurement wireless transmission alarm system (industrial timing temperature measurement / engine room temperature timing detection, etc.)
Install nngraph
The El table horizontal scroll bar is fixed at the bottom of the visual window
8 websites that should be known for product development to enhance work experience
Unable to create servlet under SRC subfile of idea
[csnote] ER diagram
[vulnhub range] - DC2
Custom nail robot alarm
Jiachen chapter Genesis "inner universe" joint Edition
Sort out several uses of network IP agent
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
风尚云网学习-input属性总结