当前位置:网站首页>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
边栏推荐
- leetcode-791. Custom string sorting
- Plato farm - a game of farm metauniverse with Plato as the goal
- melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
- Free and open source intelligent charging pile SaaS cloud platform of Internet of things
- No idle servers? Import OVF image to quickly experience smartx super fusion community version
- leetcode-791. 自定义字符串排序
- 精度、速度完美平衡,最新图像分割SOTA模型重磅发布!!!
- ZigBee CC2530 minimum system and register configuration (1)
- 教你快速开发一个 狼人杀微信小程序(附源码)
- (个人)最近项目开发后存在的系统漏洞整理
猜你喜欢
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
云原生KubeSphere部署Redis
梳理網絡IP代理的幾大用途
Unable to create servlet under SRC subfile of idea
如何实现点击一下物体播放一次动画
STM32 is connected to the motor drive, the DuPont line supplies power, and then the back burning problem
Synchronously update the newly added and edited data to the list
风尚云网学习-input属性总结
数据库中的日期时间类型
Free and open source charging pile Internet of things cloud platform
随机推荐
leetcode:437. Path sum III [DFS selected or not selected?]
Important knowledge of transport layer (interview, retest, final)
Redis deployment of cloud native kubesphere
SSM框架系列——Junit单元测试优化day2-3
mysql8安装
Byte jump 2020 autumn recruitment programming question: quickly find your own ranking according to the job number
STM32 control stepper motor (ULN2003 + 28byj)
精度、速度完美平衡,最新图像分割SOTA模型重磅发布!!!
CGC: contractual graph clustering for community detection and tracking
mysql支持ip访问
PC starts multiple wechat at one time
Calculate the past date and days online, and calculate the number of live days
Remote sensing image classification and recognition system based on convolutional neural network
If you were a golang interviewer, what questions would you ask?
22. 括号生成
MySQL —— 16、索引的数据结构
Baserecyclerviewadapterhelper realizes pull-down refresh and pull-up loading
Customize the shortcut options in El date picker, and dynamically set the disabled date
风尚云网学习-input属性总结
4.22学习记录(你一天只做了水题是吗)