当前位置:网站首页>addmodule_ allmerge_ ams_ im
addmodule_ allmerge_ ams_ im
2022-06-30 17:02: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)
# Scale
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)
# Score a given set of genes And draw
if(1==1){
d.all=AddModuleScore(d.all,
features = mymarker,
name = paste0(cellname))
# The results are saved here
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"), # Take only before 15 individual
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)
# Score a given set of genes And draw
if(1==1){
d.all=AddModuleScore(d.all,
features = mymarker,
name = paste0(cellname))
# The results are saved here
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"), # Take only before 15 individual
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] }
}
# as long as ns56 and 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)
# Score a given set of genes And draw
if(1==1){
d.all=AddModuleScore(d.all,
features = mymarker,
name = paste0(cellname))
# The results are saved here
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"), # Take only before 15 individual
height = 12, width = 12, units = 'in', res=600)
p=ggpubr::ggarrange(p4,p3,ncol = 1,nrow =2)
print(p)
dev.off()}
}
边栏推荐
- Headhunter 50, 000, I'll go to VC
- POJ Project Summer
- Mathematical modeling for war preparation 33- grey prediction model 2
- nichenet实战silicosis
- Undistorted resize using pil
- 异常类_日志框架
- [machine learning] K-means clustering analysis
- 删除有序数组中的重复项 II[双指针--多情况统一]
- [activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!
- go-micro教程 — 第一章 快速入门
猜你喜欢

TCP socket and TCP connection

Etcd tutorial - Chapter 8 compact, watch, and lease APIs for etcd

Headhunter 50, 000, I'll go to VC

Carry two load balancing notes and find them in the future

Multi terminal collaboration of Huawei accounts to create a better internet life

redis数据结构分析

Raft介绍

HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴

备战数学建模35-时间序列预测模型

数据安全合规之后,给风控团队带来了新的问题
随机推荐
RTP sending PS stream zero copy scheme
Data mining knowledge points sorting (final review version)
Mathematical modeling for war preparation 33- grey prediction model 2
IO流_递归
nichenet实战silicosis
基于51单片机的计件器设计
牛客网:乘积为正数的最长连续子数组
[Verilog quick start of Niuke online question series] ~ bit splitting and operation
Sub chain cross technology source level exploration: an overview of xcvm
Parler du télétravail
Delete duplicates in an ordered array ii[double pointers -- unified in multiple cases]
jspreadsheet/CE JExcel数据字段比给的字段(columns)多会导致空白列的问题解决方案
In order to make remote work unaffected, I wrote an internal chat room | community essay
Lambda expression_ Stream stream_ File class
Good partner for cloud skill improvement, senior brother cloud of Amazon officially opened today
利用PIL进行不失真的resize
Rong Lianyun launched rphone based on Tongxin UOS to create a new ecology of localization contact center
几个跨端开发神器
redis淘汰策略
Raft introduction