論文
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ù)一下論文中的Figure1e 柱形圖 和 Figure1f的下三角熱圖
Figure1e的數(shù)據(jù)論文中是提供的,格式如下
這是3個(gè)柱形圖的數(shù)據(jù)邦邦,需要我們手動(dòng)整理成作圖格式
柱形圖的作圖代碼
df02<-read_excel("data/20230207/42255_2022_674_MOESM3_ESM.xlsx",
sheet = "Sheet1")
df02
df02$x<-factor(df02$x,levels = df02$x)
pe1<-ggplot()+
geom_col(data=df02,aes(x=x,y=y),
fill="red",color="black")+
theme_classic()+
scale_y_continuous(expand = expansion(mult=c(0,0)),
limits = c(0,120),
breaks = seq(0,120,20))+
labs(x=NULL,y="Number of DEGs",title="Art")+
theme(plot.title = element_text(hjust=0.5,face="bold"))
df03<-read_excel("data/20230207/42255_2022_674_MOESM3_ESM.xlsx",
sheet = "Sheet2")
df03
df03$x<-factor(df03$x,levels = df03$x)
pe2<-ggplot()+
geom_col(data=df03,aes(x=x,y=y),
fill="#46b198",color="black")+
theme_classic()+
scale_y_continuous(expand = expansion(mult=c(0,0)),
limits = c(0,900),
breaks = seq(0,900,300))+
labs(x=NULL,y="Number of DEGs",title="Cap")+
theme(plot.title = element_text(hjust=0.5,face="bold"))
df04<-read_excel("data/20230207/42255_2022_674_MOESM3_ESM.xlsx",
sheet = "Sheet3")
df04
df04$x<-factor(df04$x,levels = df04$x)
pe3<-ggplot()+
geom_col(data=df04,aes(x=x,y=y),
fill="#4472c4",color="black")+
theme_classic()+
scale_y_continuous(expand = expansion(mult=c(0,0)),
limits = c(0,350),
breaks = seq(0,350,50))+
labs(x=NULL,y="Number of DEGs",title="Ven")+
theme(plot.title = element_text(hjust=0.5,face="bold"))
三個(gè)柱形圖的代碼基本一樣
下三角相關(guān)系數(shù)熱圖
這個(gè)論文中沒有提供數(shù)據(jù)迟几,我手動(dòng)整理下來了格式如下
作圖代碼
library(readxl)
library(ggplot2)
library(tidyverse)
library(paletteer)
library(latex2exp)
df<-read_excel("data/20230207/figure1f.xlsx")
x_axis<-c('Brain','Heart','Lungs','Kidney','Liver','Vis AT')
y_axis<-c('Sc AT','Vis AT','Liver','Kidney','Lungs','Heart')
table(df$var1)
table(df$var2)
df<-df %>%
mutate(var1=factor(var1,levels = x_axis),
var2=factor(var2,levels = y_axis))
txt.df<-data.frame(x=1:7,
y=7:1,
label=c('Brain','Heart','Lungs','Kidney','Liver','Vis AT','Sc AT'))
p1<-ggplot(data=df,aes(x=var1,y=var2))+
geom_tile(aes(fill=value),
color="black")+
geom_text(aes(label=value))+
geom_text(data=txt.df,
aes(x=x,y=y,label=label))+
#scale_x_discrete(expand = expansion(mult = c(0,0)))+
#scale_y_discrete(expand = expansion(mult = c(0,0)))+
theme_bw()+
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank(),
panel.border = element_blank(),
legend.position = "left",
axis.title = element_blank())+
coord_cartesian(xlim = c(0,8),y=c(0,7))+
scale_fill_gradient2(low="blue",
mid="white",
high="red",
breaks=c(-0.11,0,0.17),
name=TeX(r"(\textit{r} value)"),
midpoint=0)+
guides(fill=guide_colorbar(barheight = 10,
ticks.colour = "black"))
p1
怎么把圖例做成和論文中的一樣我暫時(shí)想不到了古今,ggplot2這個(gè)這個(gè)圖例好像只能是最小值和最大值货邓,比如現(xiàn)在最大值是0.17,我先讓圖例映射到1馏艾,這個(gè)好像實(shí)現(xiàn)不了
做三個(gè)一樣的举瑰,然后拼圖
p1+
labs(title="Art")+
theme(plot.title = element_text(hjust=0.5,
face="bold",
size=20)) -> pA
p1+
labs(title="Cap")+
theme(plot.title = element_text(hjust=0.5,
face="bold",
size=20),
legend.position = "none") -> pB
p1+
labs(title="Ven")+
theme(plot.title = element_text(hjust=0.5,
face="bold",
size=20),
legend.position = "none") ->pC
library(patchwork)
pA+pB+pC
然后將柱形圖和熱圖拼到一起
(pe1+pe2+pe3)/(pA+pB+pC)
示例數(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í)筆記搅窿!