当前位置:网站首页>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()}
}
边栏推荐
- Bc1.2 PD protocol
- 《网络是怎么样连接的》读书笔记 - 汇总篇
- Installing jupyter notebook under Anaconda
- 【微信小程序】常用组件基本使用(view/scroll-view/swiper、text/rich-text、button/image)
- On July 2, I invited you to TD Hero online conference
- Substrate 跨链技术源码级探索: XCVM的概览
- RTP sending PS stream zero copy scheme
- 2022蓝桥杯国赛B组-2022-(01背包求方案数)
- 为了使远程工作不受影响,我写了一个内部的聊天室 | 社区征文
- Drug management system plus database, overnight, plus report
猜你喜欢
![删除有序数组中的重复项 II[双指针--多情况统一]](/img/e2/cadfdbe476a86cb2d72c1ae0160a4a.png)
删除有序数组中的重复项 II[双指针--多情况统一]

9:第三章:电商工程分析:4:【通用模块】;(待写……)

搬运两个负载均衡的笔记,日后省的找

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

Mathematical modeling for war preparation 35 time series prediction model

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

数据挖掘知识点整理(期末复习版)

数据库系统概论习题册

“推广+搞笑剧情”,如何碰撞出爆款的火花?

Niuke network: longest continuous subarray with positive product
随机推荐
On July 2, I invited you to TD Hero online conference
Etcd tutorial - Chapter 8 compact, watch, and lease APIs for etcd
jspreadsheet/CE JExcel数据字段比给的字段(columns)多会导致空白列的问题解决方案
牛客网:乘积为正数的最长连续子数组
[wechat applet] the hosting environment of the applet
Headhunter 50, 000, I'll go to VC
列表变成向量 列表变向量 list vector
Sub chain cross technology source level exploration: an overview of xcvm
Go micro tutorial - Chapter 1 getting started
Undistorted resize using pil
Cmakelists Basics
Mathematical modeling for war preparation 33- grey prediction model 2
利用PIL进行不失真的resize
Hologres共享集群助力淘宝订阅极致精细化运营
go-micro教程 — 第一章 快速入门
Deep learning - (2) several common loss functions
您工厂的MES再不升级,就要被淘汰啦
居家办公浅谈远程协助快速提效心得 | 社区征文
Niuke.com: minimum cost of climbing stairs
JS Es5 can also create constants?