论文
Single-cell profiling of vascular endothelial cells reveals progressive organ-specific vulnerabilities during obesity
https://www.nature.com/articles/s42255-022-00674-x#Sec58
s42255-022-00674-x.pdf
https://github.com/Osynchronika/sc_EC_obesity_atlas
大部分 作图的数据都有,可以试着用论文中提供的数据复现一下论文中的图
论文中figure2和figure3中有许多种柱形图,夺取把每个种类的柱形图都复现一下
加载作图用到的R包
library(readxl)library(tidyverse)library(ggplot2)起首是最平凡的柱形图
figure3m
示例数据集如下
作图代码
fig3m.df<-read_excel("data/20230207/ggplot2barplot.xlsx", sheet = "fig3m")fig3m.dfggplot(data=fig3m.df,aes(x=x,y=y))+ geom_col(fill="#5ab033",color="black")+ theme_classic()+ scale_y_continuous(expand = expansion(mult = c(0,0)), limits = c(0,0.5))+ labs(x=NULL,y="log(FC)")+ theme(panel.grid.major.y = element_line(), axis.text.x = element_text(angle=90,face="italic", vjust=0.5,hjust=1))
更多的时间会对数值举行排序,从小到大,大概从大到小
fig3m.df %>% arrange(y) %>% mutate(x=factor(x,levels = x)) %>% ggplot(aes(x=x,y=y))+ geom_col(fill="#5ab033",color="black")+ theme_classic()+ scale_y_continuous(expand = expansion(mult = c(0,0)), limits = c(0,0.5))+ labs(x=NULL,y="log(FC)")+ theme(panel.grid.major.y = element_line(), axis.text.x = element_text(angle=90,face="italic", vjust=0.5,hjust=1)) -> p1fig3m.df %>% arrange(desc(y)) %>% mutate(x=factor(x,levels = x)) %>% ggplot(aes(x=x,y=y))+ geom_col(fill="#5ab033",color="black")+ theme_classic()+ scale_y_continuous(expand = expansion(mult = c(0,0)), limits = c(0,0.5))+ labs(x=NULL,y="log(FC)")+ theme(panel.grid.major.y = element_line(), axis.text.x = element_text(angle=90,face="italic", vjust=0.5,hjust=1)) -> p2p1/p2柱形图除了水平摆放,也可以垂直摆放,我们把作图代码里的x和y对调位置就行,如果数据集里的数据有正有负,那么柱子出现的就是既有朝上的,又有朝下的
比如这个figure r s
代码
fig3r.df<-read_excel("data/20230207/ggplot2barplot.xlsx", sheet = "fig3r")fig3r.df %>% mutate(x=factor(x,levels = c("Vcam1","ecam1","Alcam","Icam1","Gja4","Gja5","F11r"))) %>% ggplot(aes(x,y))+ geom_col(fill="#ee7770",color="black")+ geom_text(aes(y=c(-0.01,-0.01,-0.01,-0.01,-0.01,0.01,0.01), label=x), angle=90,hjust=c(1,1,1,1,1,0,0), color=c("#bf1818","#bf1818","#bf1818","#bf1818","black","black","blue"))+ theme_classic()+ theme(axis.line.x = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank(), panel.grid.major.y = element_line(), plot.title = element_text(hjust = 0.5))+ scale_y_continuous(limits = c(-0.25,0.25), breaks = c(-0.25,seq(-0.2,0.2,by=0.1),0.25), expand = expansion(mult = c(0,0)), labels = c("",seq(-0.2,0.2,by=0.1),""))+ labs(x=NULL,y="log(FC)",title = "Art")
本日的推文就先容这么多,来日诰日继续
示例数据和代码可以给推文点赞,然后点击在看,末了留言获取
欢迎各人关注我的公众号
小明的数据分析条记本
小明的数据分析条记本 公众号 重要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读条记;3、生物信息学入门学习资料及本身的学习条记!
微信公众号好像又有改动,如果没有将这个公众号设为星标的话,会常常错过公众号的推文,个人发起将 小明的数据分析条记本 公众号添加星标,添加方法是
点开公众号的页面,右上角有三个点
点击三个点,会跳出界面
直接点击 设为星标 就可以了
|