当前位置:网站首页>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()}
}
边栏推荐
- 7 月 2 日邀你来TD Hero 线上发布会
- HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴
- Eight basic sorting (detailed explanation)
- [machine learning] K-means clustering analysis
- Parler du télétravail
- Simpleitk encountered an ITK only supports orthonormal direction cosines error while reading NII
- [Verilog basics] octal and hexadecimal representation of decimal negative numbers
- 巩固入门-C#基础变量和常量
- Data mining knowledge points sorting (final review version)
- 香港回归25周年 香港故宫博物馆正式开放成文化新地标
猜你喜欢

居家办公浅谈远程协助快速提效心得 | 社区征文

猎头5万挖我去VC

BC1.2 PD协议

Niuke.com: minimum cost of climbing stairs

AVIC UAV technology innovation board is listed: the fist product with a market value of 38.5 billion is pterodactyl UAV

idea必用插件

7 月 2 日邀你来TD Hero 线上发布会

Wechat emoticons are written into the judgment, and the OK and bomb you send may become "testimony in court"

Carry two load balancing notes and find them in the future
![[Verilog quick start of Niuke online question series] ~ bit splitting and operation](/img/17/4b8f5607c4cba1596435233a6cf30a.png)
[Verilog quick start of Niuke online question series] ~ bit splitting and operation
随机推荐
云技能提升好伙伴,亚马逊云师兄今天正式营业
异常类_日志框架
Halcon knowledge: matrix topic [02]
Cesium-1.72 learning (add points, lines, cubes, etc.)
聊聊遠程辦公那些事兒 | 社區征文
赛芯电子冲刺科创板:拟募资6.2亿 实控人谭健为美国籍
Research on helmet wearing detection algorithm
Parler du télétravail
Lambda表达式_Stream流_File类
RT thread heap size setting
Substrate 跨链技术源码级探索: XCVM的概览
Eight basic sorting (detailed explanation)
牛客网:乘积为正数的最长连续子数组
On July 2, I invited you to TD Hero online conference
Hologres shared cluster helps Taobao subscribe to the extreme refined operation
Multi terminal collaboration of Huawei accounts to create a better internet life
CMakeLists 基础
Siyuan notes: can you provide shortcut keys for folding all titles on the page?
Drug management system plus database, overnight, plus report
【微信小程序】常用组件基本使用(view/scroll-view/swiper、text/rich-text、button/image)