跟着Nature Communications学作图:R语言ggplot2画图展示捐赠者的临床概况
2023-02-19 12:27:47 时间
论文
Common anti-cancer therapies induce somatic mutations in stem cells of healthy tissue
https://www.nature.com/articles/s41467-022-33663-5#Sec18
今天的推文我们重复一下论文中的Figure1a,看起来非常像一个表格,很有意思
image.png
我们使用ggplot2来实现,主要分为三个部分,文本,形状,和背景的灰色条
首先是文本的部分数据截图
image.png
形状的三个数据截图
image.png
背景灰色条数据截图
image.png
总共5份数据,放在同一个excel文件里,5个不同的子表格
读取数据并作图
library(readxl)
library(ggplot2)
library(stringr)
library(tidyverse)
dat01<-read_excel("data/20221009/example_data.xlsx",
sheet = "Sheet1")
dat01 %>%
mutate(label01=case_when(
length(label) == 7 ~ str_pad(label,8,"right"),
TRUE ~ label
)) -> new.dat01
new.dat01
dat02<-read_excel("data/20221009/example_data.xlsx",
sheet = "Sheet2")
dat02
dat03<-read_excel("data/20221009/example_data.xlsx",
sheet = "Sheet3")
dat03
dat04<-read_excel("data/20221009/example_data.xlsx",
sheet = "Sheet4")
dat04
dat05<-read_excel("data/20221009/example_data.xlsx",
sheet = "Sheet5")
dat05
x_labels<-c("","Age","Normal\nTissue","Tissue\nSubtype",
"Treatment\ntype","Treatment\ncycli",
"Sampling after\ntreatment\n(months)",
"Seqenced\nsamples")
ggplot()+
scale_x_continuous(limits = c(0.5,8),
breaks = 1:8,
labels = x_labels,
position = "top")+
geom_text(data=new.dat01,aes(x=x,y=y,label=label01))+
geom_point(data=dat02,aes(x=x,y=y,color=`Normal tissue type`),
size=5)+
scale_color_manual(values = c("Colon"="#d38e91",
"Liver"="#1f639a"))+
ggnewscale::new_scale_color()+
geom_point(data=dat03,aes(x=x,y=y,color=`Tissue subtype`),
size=5)+
scale_color_manual(values = c("Descending colon"="#f6d65b",
"Sigmoid"="#3eada2",
"Rectum"="#eb553a",
"Liver"="#206599"))+
ggnewscale::new_scale_color()+
geom_point(data=dat04,aes(x=x,y=y,color=Treatment),
size=5,shape=15)+
scale_color_manual(values = c("5-FU + platinum"="#f49b5e",
"5-FU + radiation"="#c44657",
"5-FU + platinum + radiation"=
"#89520e"))+
theme_bw()+
theme(axis.title = element_blank(),
panel.grid = element_blank(),
panel.border = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_text(hjust=0.5,vjust=0.5))+
geom_rect(data=dat05,
aes(xmin=-Inf,xmax=Inf,ymin=ymin,ymax=ymax),
fill="gray",alpha=0.2)
相关文章
- Jgit的使用笔记
- 利用Github Action实现Tornadofx/JavaFx打包
- 叹息!GitHub Trending 即将成为历史!
- 微软软了?开源社区讨论炸锅,GitHub CEO 亲自来答
- GitHub Trending 列表频现重复项,前后端都没去重?
- Photoshop Elements 2021版本软件安装教程(mac+windows全版本都有)
- (ps全版本)Photoshop 2020的安装与破解教程(mac+windows全版本都有)
- (ps全版本)Photoshop cc2018的安装与破解教程(mac+windows全版本,包括2023
- 环境搭建:Oracle GoldenGate 大数据迁移到 Redshift/Flat file/Flume/Kafka测试流程
- 每个开发人员都要掌握的:最小 Linux 基础课
- 来撸羊毛了!Windows 环境下 Hexo 博客搭建,并部署到 GitHub Pages
- 超实用!手把手入门 MongoDB:这些坑点请一定远离
- 【GitHub日报】22-10-09 zustand、neovim、webtorrent、express 等4款App今日上新
- 【GitHub日报】22-10-10 brew、minio、vite、seaweedfs、dbeaver 等8款App今日上新
- 【GitHub日报】22-10-11 cobra、grafana、vue、ToolJet、redwood 等13款App今日上新
- Photoshop 2018 下载及安装教程(mac+windows全版本都有,包括最新的2023)
- Photoshop 2017 下载及安装教程(mac+windows全版本都有,包括最新的2023)
- Photoshop 2020 下载及安装教程(mac+windows全版本都有,包括最新的2023)
- Photoshop 2023 资源免费下载(mac+windows全版本都有,包括最新的2023)
- 最新版本Photoshop CC2018软件安装教程(mac+windows全版本都有,包括2023