論文
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
大部分 作圖的數(shù)據(jù)都有,可以試著用論文中提供的數(shù)據(jù)復(fù)現(xiàn)一下論文中的圖
今天的推文我們復(fù)現(xiàn)一下論文中的figure4f

之前的推文也介紹過這種形式的餅圖,可以也看看之前的推文
今天的這個(gè)圖上下兩層分開做,然后采用拼圖的方式實(shí)現(xiàn)
餅圖上展示比例的文本如何添加的精確的位置我暫時(shí)想不到比較好的方法了,推文里的解決辦法是構(gòu)造大體的坐標(biāo),然后出圖后手動(dòng)調(diào)節(jié)
論文中提供的數(shù)據(jù)

第一層餅圖的數(shù)據(jù)整理成如下格式

作圖代碼
library(ggplot2)
library(scatterpie)
library(readxl)
library(tidyverse)
fig4f.df01<-read_excel("data/20230207/figure4f.xlsx",
sheet = "Sheet1")
fig4f.df01
ggplot()+
geom_scatterpie(data=fig4f.df01,
aes(x,y,group=region,r=0.4),
cols = c("A","B"))+
coord_equal()
fig4f.df01
fig4f.df01 %>%
rowwise() %>%
mutate(A_prop=paste0(round(A/(A+B),2)*100,"%"),
B_prop=paste0(round(B/(A+B),2)*100,"%"),
x_A=x+0.1,
x_B=x-0.1,
y_A=y,y_B=y) -> fig4f.df01.1
ggplot()+
geom_scatterpie(data=fig4f.df01.1,
aes(x,y,group=region,r=0.4),
cols = c("A","B"))+
coord_equal()+
geom_text(data=fig4f.df01.1,
aes(x=x_A,y=y_A,label=A_prop),
hjust=0,color="black")+
geom_text(data=fig4f.df01.1,
aes(x=x_B,y=y_B,label=B_prop),
hjust=1,color="white")+
theme_void()+
theme(axis.title.y = element_text(angle = 90),
legend.title = element_blank())+
scale_fill_manual(values = c("A"="#89bd41","B"="#e20613"),
labels=c("A"="Obesity: up\nRev: restored",
"B"="Obesity: up\nRev: not restored"))+
labs(y="Upregulated")+
geom_text(data = data.frame(x=1:7,y=1.5,label=c("Brain","Heart","Lungs",
"Kidneys","Liver","Vis AT","Sc AT")),
aes(x=x,y=y,label=label),
fontface="bold")

第二層的思路是一樣的
作圖數(shù)據(jù)手動(dòng)整理成如下格式

作圖代碼
fig4f.df02<-read_excel("data/20230207/figure4f.xlsx",
sheet = "Sheet2")
fig4f.df02
fig4f.df02
fig4f.df02 %>%
rowwise() %>%
mutate(A_prop=paste0(round(A/(A+B),2)*100,"%"),
B_prop=paste0(round(B/(A+B),2)*100,"%"),
x_A=x+0.1,
x_B=x-0.1,
y_A=y,y_B=y) -> fig4f.df02.1
ggplot()+
geom_scatterpie(data=fig4f.df02.1,
aes(x,y,group=region,r=0.4),
cols = c("A","B"))+
coord_equal()+
geom_text(data=fig4f.df02.1,
aes(x=x_A,y=y_A,label=A_prop),
hjust=0,color="white")+
geom_text(data=fig4f.df02.1,
aes(x=x_B,y=y_B,label=B_prop),
hjust=1,color="black")+
theme_void()+
theme(axis.title.y = element_text(angle = 90),
legend.title = element_blank())+
scale_fill_manual(values = c("A"="#312782","B"="#8abe42"),
labels=c("A"="Obesity: down\nRev: restored",
"B"="Obesity: down\nRev: not restored"))+
labs(y="Downregulated")

最后是拼圖
library(patchwork)
p1/p2
出圖后再手動(dòng)編輯文本的位置

示例數(shù)據(jù)和代碼可以給推文點(diǎn)贊,然后點(diǎn)擊在看,最后留言獲取
歡迎大家關(guān)注我的公眾號(hào)
小明的數(shù)據(jù)分析筆記本
小明的數(shù)據(jù)分析筆記本 公眾號(hào) 主要分享:1、R語言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡(jiǎn)單小例子;2、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)、基因組學(xué)、群體遺傳學(xué)文獻(xiàn)閱讀筆記;3、生物信息學(xué)入門學(xué)習(xí)資料及自己的學(xué)習(xí)筆記!
微信公眾號(hào)好像又有改動(dòng),如果沒有將這個(gè)公眾號(hào)設(shè)為星標(biāo)的話,會(huì)經(jīng)常錯(cuò)過公眾號(hào)的推文,個(gè)人建議將 小明的數(shù)據(jù)分析筆記本 公眾號(hào)添加星標(biāo),添加方法是
點(diǎn)開公眾號(hào)的頁面,右上角有三個(gè)點(diǎn)

點(diǎn)擊三個(gè)點(diǎn),會(huì)跳出界面

直接點(diǎn)擊 設(shè)為星標(biāo) 就可以了
