从findallmarkers函数得到的marker基因表格批量画dotplot气泡图 批量dotplot 批量出图
rm(list=ls())
library(CellChat)
###从findallmarkers函数得到的marker基因表格批量画dotplot气泡图
library(patchwork)
library(ggplot2)
library(ggalluvial)
library(svglite)
library(Seurat)
library(openxlsx)
library(harmony)
options(stringsAsFactors = FALSE)
getwd()
path = “G:/silicosis/sicosis/yll/all_SingleCell_markers_dotplot-combined”
dir.create(path,recursive = TRUE)
setwd(path)
getwd()
library(clusterProfiler)
library(org.Mm.eg.db)
k <- keys(org.Mm.eg.db, keytype = “ENTREZID”)
gene.list <- select(org.Mm.eg.db, keys = k, columns = c(“SYMBOL”, “ENSEMBL”), keytype = “ENTREZID”)## 11223 7
cluster_gene_stat = read.xlsx(“G:/silicosis/需求/矽肺-数据分析结果-0324/YLL/combined_cluster_markers.xlsx”)## 4937 35
head(cluster_gene_stat)
#######一定要注意列名!!!!搞错了后面一步怎么都做不出来
dim(cluster_gene_stat)
cluster_marker = list()
#一定要注意列名!!!!搞错了后面一步怎么都做不出来
for(i in unique(cluster_gene_statKaTeX parse error: Expected '}', got '#' at position 12: cluster)){ #̲按照p0.05值、flodch…cluster==i &cluster_gene_statKaTeX parse error: Expected 'EOF', got '&' at position 22: …adj<0.00000001 &̲cluster_gene_st…avg_log2FC>1.5, “gene”]
}
head(cluster_marker)
unlist(lapply(cluster_marker, length))
cluster_marker[[8]]
load(file = “G:/silicosis/sicosis/silicosis-1122-merge/silicosis_cluster_merge.rds”)
head(cluster_marker[[1]])
getwd()
#批量做气泡图 Dotplot 记得修改allmerge的名字如果是其他数据的话
for (j in 1:length(cluster_marker)) {#一定要记得是向量 而不是一个数 for j in(1:11) 一定记得加括号!!!!!!!!!!!!
#j=1
times=(length(cluster_marker[[j]])+10)/10
times
if (floor(times)>=2 ){
try(for (i in seq(1,190,10)) { #使用循环出图 画图 以最多的基因数目为准!!!!!!!!!!!!!!!!!!1
#i=1
if ((i+9)>(10*floor(times))) {next}
# print(cluster_marker[[j]][i:(i+9)])
jpeg(paste0(“cluster_”,j,"",unique(cluster_gene_stat$cluster)[j],
paste0(unlist(strsplit(cluster_marker[[j]][i:(i+9)], " "))[seq(1,10,1)],
seq='',collapse = “”) , “.jpeg”),
height = 9, width = 18, units = ‘in’, res=300)
p=DotPlot(All.merge,
features = cluster_marker[[j]][i:(i+9)])
print§
dev.off()
print(paste0(“cluster_”,j))#;print(cluster_marker[[j]][i:(i+9)])
} ,silent = TRUE)
} else{ #条件一定记得加括号! !!!!!!!!!!!!!!!11!!!!!!!!!!!
print(paste0(“cluster_”,j))#; print(cluster_marker[[j]][1:(1+9)])
jpeg(paste0(“cluster_”,j,"",unique(cluster_gene_stat$cluster)[j],
paste0(unlist(strsplit(cluster_marker[[j]][1:(1+9)], " "))[seq(1,10,1)],seq='',collapse = “”),
“.jpeg”),
height = 9, width = 18, units = ‘in’, res=300)
p=DotPlot(All.merge,features = cluster_marker[[j]][1:(1+9)])
print§
dev.off()
}
}
DotPlot(All.merge,features = cluster_marker[[7]][1:10])
for (i in length(cluster_marker)) { #使用循环出图 画图
#i=1
jpeg(paste0(paste0(unlist(strsplit(top_features_moransi[i:(i+2)], " “))[seq(1,3,1)],seq=‘_’,collapse = “”),”.jpeg"),height = 12, width = 12, units = ‘in’, res=700)
p=SpatialFeaturePlot(d.all_moransi,
features = top_features_moransi[i:(i+2)],
ncol = 2,alpha = c(0.1,1))
print§
dev.off()
print(i)
}
结果 示例图样图
相关文章
- 命令行中执行批量SQL的方法
- Python-批量刷博客园访问量脚本
- 批量下载ts视频文件
- Python 批量抓取help()函数的帮助内容(附36M帮助文档)
- C++ 抓取和批量下载网站上的图片或文件
- Dev 控件绑定的数据源批量操作应避免自动刷新
- mybatis 批量添加
- 使用await和async关键字开发nodejs应用批量取出简书网站的文章标题和超链接
- 成功解决将python的列表格式输出数值(如pandas.read_excel().describe())批量转到表格内
- MongoDB批量操作隐含的特性
- ant 打批量渠道包,第三方项目作为library打包出错的问题
- 初入软件测试必备:不知如何下手?一篇文章带你上手批量功能测试
- JDBC Statement对象执行批量处理实例
- docker批量删除容器、镜像
- Springboot+百度的WebUploader组件实现普通文件的批量上传