論文
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)一下論文中的圖
今天的推文我們?cè)囍鴱?fù)現(xiàn)一下論文中的Figure2中的熱圖岁经,figure2中有3個(gè)熱圖冰寻,按照復(fù)制程度排序是 figure2m figure2f 和figure2o
我們從最簡(jiǎn)單的開始稻爬,先復(fù)現(xiàn)figure2m
論文中提供的數(shù)據(jù)如下
數(shù)據(jù)中有很多缺失值,看論文中的配色 我猜是把缺失值替換成0了秘车,我不太確定這種處理方式是否可以
我把數(shù)據(jù)單獨(dú)復(fù)制到一個(gè)excel文件里
給第一列添加一個(gè)表頭
代碼
讀取數(shù)據(jù)
library(readxl)
dat<-read_excel("data/20230207/figure2o.xlsx",na='NA')
dat
寬格式轉(zhuǎn)換為長(zhǎng)格式
library(tidyverse)
dat%>%
mutate(gene_name=factor(gene_name,levels = gene_name))%>%
pivot_longer(!gene_name)%>%
mutate(name=str_replace(name,'_logFC',''),
value=replace_na(value,0))%>%
mutate(name=factor(name,levels = c("sc","vis","liver",
"kidney","lung","heart","brain")))-> new.dat
熱圖代碼
library(ggplot2)
ggplot(data = new.dat,aes(x=gene_name,y=name))+
geom_tile(aes(fill=value),
color="black")+
theme_bw()+
theme(panel.border = element_blank(),
panel.grid = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
axis.text.x = element_text(angle=90,face="italic"),
axis.text.y = element_blank(),
legend.position = "bottom")+
scale_fill_gradient2(low="blue",mid="white",high = "red",
midpoint = 0,
breaks=c(-0.3,0,0.3),
name="log(FC)")+
guides(fill=guide_colorbar(title.position = "top",
title.hjust = 0.5,
barwidth = 10))+
coord_equal() -> p1
p1
左側(cè)的分組也用熱圖來(lái)實(shí)現(xiàn),就是一個(gè)一列的熱圖
new.dat %>% filter(gene_name == "Apoe") %>%
ggplot(aes(x=gene_name,y=name))+
geom_tile(aes(fill=name),color="black")+
theme_bw()+
theme(panel.border = element_blank(),
panel.grid = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.title = element_blank(),
legend.position = "none",
axis.text.y = element_text(size=15,face="bold"))+
scale_x_discrete(expand=expansion(mult=c(0,0)))+
coord_equal() -> p2
p2
最后是拼圖
library(patchwork)
p2 + p1
示例數(shù)據(jù)和代碼可以給推文點(diǎn)贊叮趴,然后點(diǎn)擊在看割笙,最后留言獲取
歡迎大家關(guān)注我的公眾號(hào)
小明的數(shù)據(jù)分析筆記本
小明的數(shù)據(jù)分析筆記本 公眾號(hào) 主要分享:1、R語(yǔ)言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡(jiǎn)單小例子眯亦;2伤溉、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)、基因組學(xué)妻率、群體遺傳學(xué)文獻(xiàn)閱讀筆記乱顾;3、生物信息學(xué)入門學(xué)習(xí)資料及自己的學(xué)習(xí)筆記舌涨!