当前位置:网站首页>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
边栏推荐
- Record the problems encountered in using v-print
- After the data of El table is updated, the data in the page is not updated this$ Forceupdate() has no effect
- Introduction to servlet listener & filter
- SSM framework series - JUnit unit test optimization day2-3
- Kubernetes 入門教程
- Remote sensing image classification and recognition system based on convolutional neural network
- Bert base Chinese Download (SMART)
- [Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
- Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误
- Customize classloader and implement hot deployment - use loadclass
猜你喜欢

SSM framework series - JUnit unit test optimization day2-3

SSL certificate refund instructions

98. Error s.e.errormvcautoconfiguration $staticview reported by freemaker framework: cannot render error page for request

Record the problems encountered in using v-print

CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction

Remote sensing image classification and recognition system based on convolutional neural network

云原生KubeSphere部署Mysql

Unlock openharmony technology day! The annual event is about to open!

世界读书日:我想推荐这几本书

Jupiter notebook installation
随机推荐
云原生KubeSphere部署Mysql
STM32 is connected to the motor drive, the DuPont line supplies power, and then the back burning problem
The accuracy and speed are perfectly balanced, and the latest image segmentation SOTA model is released!!!
【蓝桥杯】4月17日省赛刷题训练(前3道题)
JMeter operation redis
Important knowledge of transport layer (interview, retest, final)
Go language: passing slices between functions
31. Next arrangement
Translation of multi modal visual tracking: review and empirical comparison
Wonderful review | the sixth issue of "source" - open source economy and industrial investment
Introducing vant components on demand
22. Bracket generation
Introduction to servlet listener & filter
[Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
Record a website for querying compatibility, string Replaceall() compatibility error
Get the punch in record of nailing attendance machine
Image attribute of input: type attribute of fashion cloud learning -h5
Embrace the new blue ocean of machine vision and hope to open a new "Ji" encounter for the development of digital economy
Jupiter notebook installation
Plato farm - a game of farm metauniverse with Plato as the goal