当前位置:网站首页>addmodule_allmerge_ams_im
addmodule_allmerge_ams_im
2022-06-30 15:48:00 【youngleeyoung】
library(patchwork)
library(ggplot2)
library(ggalluvial)
library(svglite)
library(Seurat)
library(openxlsx)
library(Hmisc)
#https://www.jianshu.com/p/cef5663888ff
getwd()
path="G:/silicosis/sicosis/silicosis_ST/overlapped_map/addmodule_allmarkers_from_findallmarkers_allmerge_ams_im"
dir.create(path)
setwd(path)
getwd()
load("G:/silicosis/sicosis/yll/macrophage/no cluster2/0.3/pure_cluster3_in_allmerge-IM/silicosis_cluster_merge.rds")
table(All.merge$new.cluster.idents)
#比例图
markers=FindAllMarkers(All.merge,min.pct = 0.75,logfc.threshold = 0.8,only.pos = T)
head(markers)
unique(markers$cluster)
library(stringr)
Myselectedmarekrs=markers %>% filter(str_detect(markers$cluster,"AM"))
DotPlot(All.merge,features=Myselectedmarekrs$gene[1:30])+RotatedAxis()
#openxlsx::write.xlsx(markers,file = "G:/silicosis/sicosis/silicosis_ST/overlapped_map/addmodule/markers_forallmerge_ams_im.xlsx")
library(openxlsx)
load("G:/silicosis/sicosis/silicosis_ST/yll/0214/harmony_cluster/d_all/silicosis_ST_harmony_SCT_r0.6.rds")
load("G:/silicosis/sicosis/silicosis_ST/yll/0214/harmony_cluster/d_all/silicosis_ST_harmony_SCT_r0.6.rds")
#marker = read.xlsx("G:/silicosis/sicosis/silicosis_ST/overlapped_map/Rigional and cell markers.xlsx",
# sheet = "SingleCell_markers")
#markers=read.xlsx('G:/silicosis/sicosis/yll/macrophage/no cluster2/0.3/findmarkers_1and2/30cluster_markers.xlsx')
#markers=read.xlsx("G:/silicosis/sicosis/silicosis-1122-merge/silicosis_cluster_merge_markers.xlsx")
markers=read.xlsx("G:/silicosis/sicosis/silicosis_ST/overlapped_map/addmodule/markers_forallmerge_ams_im.xlsx")
head(markers)
library(dplyr)
markers=markers %>% group_by(cluster) %>% slice_head(n=20) %>%select(cluster,gene)
head(markers)
library(reshape2)
markers2=dcast(markers,gene~cluster)
head(markers2)
markers2[is.na(markers2)]<-0
head(markers2)
markers2=markers2[,-1]
marker=markers2
head(marker)
cellnames=colnames(marker) ##number=length(marker[,cellname])
library(Hmisc)
getwd()
#path="G:/silicosis/sicosis/silicosis_ST/overlapped_map/addmodule_allmarkers_from_findallmarkers"
path="G:/silicosis/sicosis/silicosis_ST/overlapped_map/addmodule_allmarkers_from_findallmarkers_allmerge_ams_im"
dir.create(path)
setwd(path)
getwd()
for (each in cellnames) {
#each='Myofibroblast/vascular smooth muscle cell'
cellname=each
mymarker=marker[,paste0(cellname)] %>% na.exclude() %>% unique() %>%
list() #capitalize() %>%
number=length(mymarker[[1]])
unlist(mymarker)
#对给定的基因集合进行打分 并画图
if(1==1){
d.all=AddModuleScore(d.all,
features = mymarker,
name = paste0(cellname))
#结果保存在这里
colnames(d.all@meta.data)
head(d.all@meta.data)
colnames(d.all@meta.data)[[9]]=paste0(cellname)
###
p1=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image")+ ggtitle(paste0("SiO2_7d")) #sio27d
p2=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.1")+ggtitle(paste0("NS_7d"))
p3=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.2")+ ggtitle(paste0("SiO2_56d"))
p4=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.3")+ggtitle(paste0(("NS_56d")))
jpeg(paste0(ifelse(grep(paste0(cellname),pattern = "/"),"Myofibroblast-vascular smooth muscle cell",paste0(cellname))
,paste0(cellname),"_","total_",length(unlist(mymarker)),"_",paste0(min(number),"-",max(number)),
paste(unlist(mymarker)[1:15],collapse = "_"),"_.jpeg"), #只取前15个
height = 12, width = 12, units = 'in', res=600)
p=ggpubr::ggarrange(p2,p1,p4,p3,ncol = 2,nrow =2)
print(p)
dev.off()
d.all@meta.data=d.all@meta.data[,1:8] }
}
for (each in c("Neutrophil","NK cell","T cell")) {
#each='Myofibroblast/vascular smooth muscle cell'
cellname=each
mymarker=marker[,paste0(cellname)] %>% na.exclude() %>% unique() %>%
list() #capitalize() %>%
number=length(mymarker[[1]])
unlist(mymarker)
#对给定的基因集合进行打分 并画图
if(1==1){
d.all=AddModuleScore(d.all,
features = mymarker,
name = paste0(cellname))
#结果保存在这里
colnames(d.all@meta.data)
head(d.all@meta.data)
colnames(d.all@meta.data)[[9]]=paste0(cellname)
###
p1=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image")+ ggtitle(paste0("SiO2_7d")) #sio27d
p2=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.1")+ggtitle(paste0("NS_7d"))
p3=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.2")+ ggtitle(paste0("SiO2_56d"))
p4=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.3")+ggtitle(paste0(("NS_56d")))
jpeg(paste0(ifelse(grep(paste0(cellname),pattern = "/"),"Myofibroblast-vascular smooth muscle cell",paste0(cellname))
,paste0(cellname),"_","total_",length(unlist(mymarker)),"_",paste0(min(number),"-",max(number)),
paste(unlist(mymarker)[1:15],collapse = "_"),"_.jpeg"), #只取前15个
height = 12, width = 12, units = 'in', res=600)
p=ggpubr::ggarrange(p2,p1,p4,p3,ncol = 2,nrow =2)
print(p)
dev.off()
d.all@meta.data=d.all@meta.data[,1:8] }
}
#只要ns56 和sio2_56d
for (each in cellnames) {
#each='Myofibroblast/vascular smooth muscle cell'
cellname=each
mymarker=marker[,paste0(cellname)] %>% na.exclude() %>% unique() %>%
list() #capitalize() %>%
number=length(mymarker[[1]])
unlist(mymarker)
#对给定的基因集合进行打分 并画图
if(1==1){
d.all=AddModuleScore(d.all,
features = mymarker,
name = paste0(cellname))
#结果保存在这里
colnames(d.all@meta.data)
colnames(d.all@meta.data)[[9]]=paste0(cellname)
###
# p1=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image")+ ggtitle(paste0("SiO2_7d")) #sio27d
# p2=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.1")+ggtitle(paste0("NS_7d"))
p3=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.2")+ ggtitle(paste0("SiO2_56d"))
p4=SpatialFeaturePlot(d.all, features = paste0(cellname), slot = "scale.data",images = "image.3")+ggtitle(paste0(("NS_56d")))
jpeg(paste0(paste0(cellname),"_","total_",length(unlist(mymarker)),"_",paste0(min(number),"-",max(number)),
paste(unlist(mymarker)[1:15],collapse = "_"),"_.jpeg"), #只取前15个
height = 12, width = 12, units = 'in', res=600)
p=ggpubr::ggarrange(p4,p3,ncol = 1,nrow =2)
print(p)
dev.off()}
}
边栏推荐
- Li Zexiang, a legendary Chinese professor, is making unicorns in batches
- [demo] write file circularly
- Rong Lianyun launched rphone based on Tongxin UOS to create a new ecology of localization contact center
- HMS core audio editing service 3D audio technology helps create an immersive auditory feast
- Mathematical modeling for war preparation 36 time series model 2
- [Demo] 循环写文件
- 【活动报名】探秘元宇宙,就差你了!7月2号我在深圳现场等你!
- Observation cloud reached in-depth cooperation with tdengine to optimize enterprise cloud experience
- 观测云与 TDengine 达成深度合作,优化企业上云体验
- ArcMap operation series: 80 plane to latitude and longitude 84
猜你喜欢

restartProcessIfVisible的流程

ArcMap operation series: 80 plane to latitude and longitude 84

Restartprocessifvisible process

Rongsheng biology rushes to the scientific innovation board: it plans to raise 1.25 billion yuan, with an annual revenue of 260million yuan

Carry two load balancing notes and find them in the future

TCP socket and TCP connection

华为帐号多端协同,打造美好互联生活

Niuke.com: minimum cost of climbing stairs

Etcd tutorial - Chapter 9 etcd implementation of distributed locks

【微信小程序】常用组件基本使用(view/scroll-view/swiper、text/rich-text、button/image)
随机推荐
[machine learning] K-means clustering analysis
The meaning of linetypes enumeration values (line_4, line_8, line_aa) in opencv
编译丨迅为iTOP4412开发板Makefile编译
声网自研传输层协议 AUT 的落地实践丨Dev for Dev 专栏
数据库系统概论习题册
simpleITK读取nii遇到ITK only supports orthonormal direction cosines的错误
CGR 21 (D,E,F)
Cmakelists Basics
Headhunter 50, 000, I'll go to VC
Home office discussion on the experience of remote assistance to quickly improve efficiency | community essay solicitation
互联网研发效能实践之去哪儿网(Qunar)核心领域DevOps落地实践
Carry two load balancing notes and find them in the future
Observation cloud reached in-depth cooperation with tdengine to optimize enterprise cloud experience
2022蓝桥杯国赛B组-费用报销-(线性dp|状态dp)
[Verilog basics] octal and hexadecimal representation of decimal negative numbers
Substrate 跨链技术源码级探索: XCVM的概览
香港回归25周年 香港故宫博物馆正式开放成文化新地标
编译丨迅为STM32P157开发板编译U-Boot源码
halcon知识:区域专题【07】
The new tea drinks are "dead and alive", but the suppliers are "full of pots and bowls"?