论绘图方法那家强?当然编程语言还看R-ggplot2,作为骨灰级科研绘图包-ggplot2除了可以绘制我们所熟知的几十种可视化图表(目前ggplot2生态圈扩展包已经有79个,统计时间2020.09.28 23:43),还可以绘制各种生物模型图,如:gganatogram
(绘制人体、鼠模型)、choropleths
(人体棍棒模型)、ggseg(绘制大脑区域)等等。
ggseg主要包含以下两个大脑图谱数据:
dk
– Desikan-Killany atlas (aparc)aseg
– Automatic subcortical segmentation
安装:
# 建议安装正式版
# https://github.com/LCBC-UiO/ggseg/releases
# 直接用remotes::install_github("LCBC-UiO/ggseg", build_vignettes = TRUE)安装可能会导致失败
ggseg()
默认图例如下:
下面介绍其简单使用:
# 示例1:绘制不同区域显著程度
library(ggseg)
library(dplyr)
# 创建演示数据
someData = data.frame(
# 大脑区域
region = c("transverse temporal", "insula",
"pre central","superior parietal"),
# p值
p = sample(seq(0,.5,.001), 4),
stringsAsFactors = FALSE)
# 指定绘制右半边大脑
someData$hemi = "right"
# 绘图
ggseg(.data=someData, colour="white", hemisphere = "right",
mapping=aes(fill=p)) +
theme_void() +
# 颜色梯度
scale_fill_gradient(low="firebrick",high="goldenrod") +
labs(title="Aparc plots rule")
library(ggseg)
library(ggplot2)
library(dplyr)
# 示例2:绘制脑区对比图
someData = data.frame(
region = rep(
c(
"transverse temporal",
"insula",
"pre central",
"superior parietal"
),
2
),
p = sample(seq(0, .5, .001), 8),
AgeG = c(rep("Young", 4), rep("Old", 4)),
stringsAsFactors = FALSE
)
someData %>%
group_by(AgeG) %>%
ggseg(atlas = dk,
colour = "white",
mapping = aes(fill = p)) +
facet_wrap( ~ AgeG, ncol = 1) +
theme(legend.position = "bottom") +
scale_fill_gradientn(colours = c("royalblue", "firebrick", "goldenrod"),
na.value = "grey")
参考资料:
1.https://lcbc-uio.github.io/ggseg/index.html
2.https://github.com/LCBC-UiO/ggseg