gganatogram—基于 ggplot2 的解剖图和组织模块化可视化(动植物、细胞)

西瓜站长 生信益站 2023-12-23 08:30
图片

组织动画热图介绍给大家。

安装 R 包

gganatogram:基于 ggplot2 的解剖图和组织模块化可视化的 R 包。

# install from Github
devtools::install_github("jespermaag/gganatogram")
devtools::install_github("mdsumner/ggpolypath")

案例演示

加载 R 包。

library(gganatogram)
library(ggpolypath)
library(dplyr)
library(viridis)
library(gridExtra)

人类男性

hgMale <- gganatogram(data=hgMale_key, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") + theme_void()
hgFemale <- gganatogram(data=hgFemale_key, fillOutline='#a6bddb', organism='human', sex='female', fill="colour") + theme_void()
# mmMale <- gganatogram(data=mmMale_key, fillOutline='#a6bddb', organism='mouse', sex='male', fill="colour") + theme_void()
# mmFemale <- gganatogram(data=mmFemale_key, outline = T, fillOutline='#a6bddb', organism='mouse', sex='female', fill="colour")  +theme_void()

grid.arrange(hgMale, hgFemale, mmMale, mmFemale, ncol=4)
图片
hgMale <- gganatogram(data=hgMale_key, fillOutline='#440154FF', organism='human', sex='male', fill="value") + theme_void() +  scale_fill_viridis()
hgFemale <- gganatogram(data=hgFemale_key, fillOutline='#440154FF', organism='human', sex='female', fill="value") + theme_void() +  scale_fill_viridis()
# mmMale <- gganatogram(data=mmMale_key, fillOutline='#440154FF', organism='mouse', sex='male', fill="value") + theme_void() +  scale_fill_viridis()
# mmFemale <- gganatogram(data=mmFemale_key, outline = T, fillOutline='#440154FF', organism='mouse', sex='female', fill="value")  +theme_void()   +  scale_fill_viridis()

grid.arrange(hgMale, hgFemale, mmMale, mmFemale, ncol=2)
图片

数据格式大概是这样:

图片

为了使用函数 gganatogram,如果需要,您需要有一个包含器官、颜色和值的数据框

organPlot <- data.frame(organ = c("heart""leukocyte""nerve""brain""liver""stomach""colon"),
 type = c("circulation""circulation",  "nervous system""nervous system""digestion""digestion""digestion"),
 colour = c("red""red""purple""purple""orange""orange""orange"),
 value = c(10518255),
 stringsAsFactors=F)

 head(organPlot)
#>       organ           type colour value
#> 1     heart    circulation    red    10
#> 2 leukocyte    circulation    red     5
#> 3     nerve nervous system purple     1
#> 4     brain nervous system purple     8
#> 5     liver      digestion orange     2
#> 6   stomach      digestion orange     5

使用函数 gganatogram 并使用颜色填充器官。

gganatogram(data=organPlot, fillOutline='#a6bddb', organism='human', sex='male', fill="colour")
图片

当然,我们可以使用ggplot主题和功能来调整图片。

gganatogram(data=organPlot, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") +
theme_void()
图片

我们还可以使用 hgMale_key绘制所有可用的组织。

hgMale_key$organ
#>  [1] "thyroid_gland"             "bone_marrow"
#>  [3] "frontal_cortex"            "prefrontal_cortex"
#>  [5] "pituitary_gland"           "aorta"
#>  [7] "gastroesophageal_junction" "left_ventricle"
#>  [9] "caecum"                    "ileum"
#> [11] "rectum"                    "nose"
#> [13] "breast"                    "tongue"
#> [15] "left_atrium"               "pulmonary_valve"
#> [17] "mitral_valve"              "penis"
#> [19] "nasal_pharynx"             "spinal_cord"
#> [21] "throat"                    "tricuspid_valve"
#> [23] "diaphragm"                 "liver"
#> [25] "stomach"                   "spleen"
#> [27] "duodenum"                  "gall_bladder"
#> [29] "pancreas"                  "colon"
#> [31] "small_intestine"           "appendix"
#> [33] "smooth_muscle"             "urinary_bladder"
#> [35] "bone"                      "cartilage"
#> [37] "esophagus"                 "salivary_gland"
#> [39] "parotid_gland"             "submandibular_gland"
#> [41] "skin"                      "pleura"
#> [43] "brain"                     "heart"
#> [45] "adrenal_gland"             "lymph_node"
#> [47] "adipose_tissue"            "skeletal_muscle"
#> [49] "leukocyte"                 "temporal_lobe"
#> [51] "atrial_appendage"          "coronary_artery"
#> [53] "hippocampus"               "vas_deferens"
#> [55] "seminal_vesicle"           "epididymis"
#> [57] "tonsil"                    "lung"
#> [59] "amygdala"                  "trachea"
#> [61] "bronchus"                  "nerve"
#> [63] "cerebellum"                "cerebellar_hemisphere"
#> [65] "kidney"                    "renal_cortex"
#> [67] "testis"                    "prostate"

gganatogram(data=hgMale_key, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") +theme_void()
图片

我们也可以跳过绘制图形的轮廓。

organPlot %>%
    dplyr::filter(type %in% c('circulation''nervous system')) %>%
gganatogram(outline=F, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") +
theme_void()
图片

我们可以根据给每个器官的值来填充组织。

gganatogram(data=organPlot, fillOutline='#a6bddb', organism='human', sex='male', fill="value") +
theme_void() +
scale_fill_gradient(low = "white", high = "red")
图片

我们还可以使用 facet_wrap 来比较组。

compareGroups <- rbind(data.frame(organ = c("heart""leukocyte""nerve""brain""liver""stomach""colon"),
  colour = c("red""red""purple""purple""orange""orange""orange"),
 value = c(10518255),
 type = rep('Normal'7),
 stringsAsFactors=F),
 data.frame(organ = c("heart""leukocyte""nerve""brain""liver""stomach""colon"),
  colour = c("red""red""purple""purple""orange""orange""orange"),
 value = c(55108255),
 type = rep('Cancer'7),
 stringsAsFactors=F))
gganatogram(data=compareGroups, fillOutline='#a6bddb', organism='human', sex='male', fill="value") +
theme_void() +
facet_wrap(~type) +
scale_fill_gradient(low = "white", high = "red")
图片

您还可以在保留轮廓的同时将组织分成不同类型。

gganatogram(data=hgMale_key, outline = T, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") +
facet_wrap(~type, ncol=4) +
theme_void()
图片

人类女性

hgFemale_key$organ
#>  [1] "atrial_appendage"          "ectocervix"
#>  [3] "hippocampus"               "pleura"
#>  [5] "bronchus"                  "trachea"
#>  [7] "lung"                      "tonsil"
#>  [9] "submandibular_gland"       "breast"
#> [11] "spinal_cord"               "pancreas"
#> [13] "liver"                     "colon"
#> [15] "bone_marrow"               "urinary_bladder"
#> [17] "stomach"                   "duodenum"
#> [19] "esophagus"                 "gall_bladder"
#> [21] "spleen"                    "small_intestine"
#> [23] "placenta"                  "endometrium"
#> [25] "vagina"                    "aorta"
#> [27] "pituitary_gland"           "gastroesophageal_junction"
#> [29] "caecum"                    "appendix"
#> [31] "ileum"                     "left_atrium"
#> [33] "left_ventricle"            "pulmonary_valve"
#> [35] "mitral_valve"              "diaphragm"
#> [37] "bone"                      "cartilage"
#> [39] "throat"                    "rectum"
#> [41] "nasal_septum"              "nasal_pharynx"
#> [43] "cerebellum"                "cerebellar_hemisphere"
#> [45] "prefrontal_cortex"         "frontal_cortex"
#> [47] "nose"                      "temporal_lobe"
#> [49] "cerebral_cortex"           "kidney"
#> [51] "renal_cortex"              "coronary_artery"
#> [53] "tricuspid_valve"           "thyroid_gland"
#> [55] "skin"                      "parotid_gland"
#> [57] "adipose_tissue"            "heart"
#> [59] "smooth_muscle"             "brain"
#> [61] "adrenal_gland"             "lymph_node"
#> [63] "skeletal_muscle"           "ovary"
#> [65] "leukocyte"                 "salivary_gland"
#> [67] "fallopian_tube"            "uterus"
#> [69] "uterine_cervix"            "nerve"

gganatogram(data=hgFemale_key, outline = T, fillOutline='#a6bddb', organism='human', sex='female', fill="colour")  +theme_void()

轮廓显示女性生殖系统:

hgFemale_key %>%
    dplyr::filter(type=='reproductive') %>%
    gganatogram( outline = T, fillOutline='#a6bddb', organism='human', sex='female', fill="colour")  +
    theme_void()  +
    coord_cartesian(xlim = c(3075), ylim = c(-110, -80))
图片

雄鼠组织

mmMale_key$organ
#>  [1] "aorta"                     "brown_adipose_tissue"
#>  [3] "stomach"                   "duodenum"
#>  [5] "pancreas"                  "spleen"
#>  [7] "adrenal_gland"             "kidney"
#>  [9] "colon"                     "small_intestine"
#> [11] "caecum"                    "jejunum"
#> [13] "ileum"                     "esophagus"
#> [15] "gall_bladder"              "lymph_node"
#> [17] "seminal_vesicle"           "penis"
#> [19] "femur"                     "bone_marrow"
#> [21] "cartilage"                 "quadriceps_femoris"
#> [23] "spinal_cord"               "lung"
#> [25] "diaphragm"                 "trachea"
#> [27] "hindlimb"                  "trigeminal_nerve"
#> [29] "sciatic_nerve"             "intestinal_mucosa"
#> [31] "liver"                     "heart"
#> [33] "brain"                     "skeletal_muscle"
#> [35] "circulatory_system"        "blood_vessel"
#> [37] "skin"                      "prostate_gland"
#> [39] "vas_deferens"              "epididymis"
#> [41] "testis"                    "urinary_bladder"
#> [43] "thymus"                    "peripheral_nervous_system"
#> [45] "eye"

gganatogram(data=mmMale_key, outline = T, fillOutline='#a6bddb', organism='mouse', sex='male', fill="colour")  +theme_void()  +coord_fixed()
图片

雌鼠组织

mmFemale_key$organ
#>  [1] "aorta"                     "circulatory_system"
#>  [3] "brown_adipose_tissue"      "stomach"
#>  [5] "duodenum"                  "pancreas"
#>  [7] "spleen"                    "adrenal_gland"
#>  [9] "kidney"                    "colon"
#> [11] "small_intestine"           "caecum"
#> [13] "jejunum"                   "ileum"
#> [15] "esophagus"                 "gall_bladder"
#> [17] "vagina"                    "uterus"
#> [19] "urinary_bladder"           "tongue"
#> [21] "Peyer's_patch"             "femur"
#> [23] "bone_marrow"               "cartilage"
#> [25] "quadriceps_femoris"        "skeletal_muscle"
#> [27] "spinal_cord"               "diaphragm"
#> [29] "hindlimb"                  "trigeminal_nerve"
#> [31] "eye"                       "intestinal_mucosa"
#> [33] "brain"                     "heart"
#> [35] "liver"                     "sciatic_nerve"
#> [37] "blood_vessel"              "skin"
#> [39] "mammary_gland"             "title8178"
#> [41] "reproductive_system"       "lymph_node"
#> [43] "thymus"                    "thyroid_gland"
#> [45] "lung"                      "peripheral_nervous_system"
#> [47] "trachea"

gganatogram(data=mmFemale_key, outline = T, fillOutline='#a6bddb', organism='mouse', sex='female', fill="colour")  +theme_void()    +coord_fixed()
图片

细胞结构

可以使用 cell_key 访问细胞数据。

length(cell_key)
#> [1] 1
cell_key
#> $cell
#>                            organ  type    colour       value
#> 1                        cytosol other steelblue  2.07159434
#> 4         intermediate_filaments other   #984EA3 14.89497057
#> 6                actin_filaments other   #FFFF33  5.87440944
#> 8           focal_adhesion_sites other   #F781BF  8.12483660
#> 10 microtubule_organizing_center other   #66C2A5  8.67564889
#> 12                    centrosome other   #8DA0CB  1.02852838
#> 13                  microtubules other   #E78AC3  9.48882657
#> 16              microtubule_ends other   #E5C494  4.80457195
#> 18             secreted_proteins other   #8DD3C7  9.20191105
#> 20                lipid_droplets other   #BEBADA  3.48903574
#> 22                     lysosomes other   #80B1D3  3.73790434
#> 24                   peroxisomes other   #B3DE69  6.79465458
#> 26                     endosomes other   #D9D9D9 13.48636296
#> 28         endoplasmic_reticulum other   #CCEBC5 11.36654344
#> 30               golgi_apparatus other   #7FC97F 11.29225961
#> 32                   nucleoplasm other   #FDC086  2.07964782
#> 34              nuclear_membrane other   #386CB0  7.98595837
#> 36                nuclear_bodies other   #BF5B17  0.05868359
#> 38              nuclear_speckles other   #1B9E77  0.61672243
#> 40                      nucleoli other   #7570B3 14.96900579
#> 42     nucleoli_fibrillar_center other   #66A61E  8.72324527
#> 44                rods_and_rings other   #A6761D  9.53194209
#> 46                  mitochondria other   #A6CEE3  1.29396698
#> 48               plasma_membrane other   #B2DF8A 13.45657571

要使用颜色或值绘制整个细胞,请使用以下命令。如果要指定背景颜色,则必须移除胞质溶胶或将胞质溶胶的颜色更改为所需的颜色。

gganatogram(data=cell_key[['cell']], outline = T, fillOutline='steelblue', organism="cell", fill="colour")  +theme_void()   + coord_fixed()
图片
gganatogram(data=cell_key[['cell']], outline = T, fillOutline='lightgray', organism="cell", fill="value")  +theme_void() +  coord_fixed() +  scale_fill_viridis()
图片

其他物种

length(other_key)
#> [1] 24
names(other_key)
#>  [1] "anolis_carolinensis"
#>  [2] "arabidopsis_thaliana"
#>  [3] "bos_taurus"
#>  [4] "brachypodium_distachyon.flower_parts"
#>  [5] "brachypodium_distachyon.whole_plant"
#>  [6] "gallus_gallus"
#>  [7] "hordeum_vulgare.flower_parts"
#>  [8] "hordeum_vulgare.whole_plant"
#>  [9] "macaca_mulatta"
#> [10] "monodelphis_domestica"
#> [11] "oryza_sativa.flower_parts"
#> [12] "oryza_sativa.whole_plant"
#> [13] "papio_anubis"
#> [14] "rattus_norvegicus"
#> [15] "solanum_lycopersicum.flower_parts"
#> [16] "solanum_lycopersicum.whole_plant"
#> [17] "sorghum_bicolor.flower_parts"
#> [18] "sorghum_bicolor.whole_plant"
#> [19] "tetraodon_nigroviridis"
#> [20] "triticum_aestivum.flower_parts"
#> [21] "triticum_aestivum.whole_plant"
#> [22] "xenopus_tropicalis"
#> [23] "zea_mays.flower_parts"
#> [24] "zea_mays.whole_plant"

画个牛。

other_key[["bos_taurus"]]
#>             organ  type  colour     value
#> 2        duodenum other #E41A1C 11.381132
#> 3           brain other #377EB8  2.264810
#> 4          kidney other #4DAF4A  4.131599
#> 5            lung other #984EA3  3.182946
#> 6           colon other #FF7F00  3.114481
#> 7           heart other #FFFF33 13.141334
#> 8           liver other #A65628 17.251310
#> 9  pulmonary vein other #F781BF 13.414659
#> 19 UBERON_0001013 other #999999 12.126515
#> 20 UBERON_0001013 other #66C2A5  1.898023
#> 21 UBERON_0001013 other #FC8D62 19.290389
#> 22 UBERON_0014892 other #8DA0CB 10.994221
#> 23 UBERON_0014892 other #E78AC3 16.761115
#> 24 UBERON_0014892 other #A6D854  2.468627
#> 25 UBERON_0014892 other #FFD92F  1.556285
#> 26 UBERON_0014892 other #E5C494  3.461740
#> 27 UBERON_0014892 other #B3B3B3 18.595027

gganatogram(data=other_key[["bos_taurus"]], outline = T, fillOutline='white', organism="bos_taurus", sex='female', fill="colour")  +
        theme_void() +
        ggtitle("bos_taurus") +
        theme(plot.title = element_text(hjust=0.5)) +
        coord_fixed()
图片

这是一种遍历所有其他生物并绘制其器官的方法。

library(gridExtra)
plotList <- list()
for (organism in names(other_key)) {
    plotList[[organism]] <- gganatogram(data=other_key[[organism]], outline = T, fillOutline='white', organism=organism, sex='female', fill="colour")  +
                theme_void() +
                ggtitle(organism) +
                theme(plot.title = element_text(hjust=0.5, size=9)) +
                coord_fixed()
}

do.call(grid.arrange,  c(plotList[1:4], ncol=2))
图片
do.call(grid.arrange,  c(plotList[5:8], ncol=2))
图片
do.call(grid.arrange,  c(plotList[9:12], ncol=2))
图片
do.call(grid.arrange,  c(plotList[13:16], ncol=2))
图片
do.call(grid.arrange,  c(plotList[17:20], ncol=2))
图片
do.call(grid.arrange,  c(plotList[21:24], ncol=2))
图片

参考链接

  1. https://www.ebi.ac.uk/gxa/home
  2. https://github.com/jespermaag/gganatogram
  3. https://github.com/ebi-gene-expression-group/anatomogram

联系站长

OK,今天的分享到此为止。您的关注、点赞、在看、转发是对站长最大的鼓励和支持哈。

对本篇文章有疑问,可以在益站发消息留言,也欢迎各位童鞋来 QQ837738558 进行交流学习

图片
我们的企鹅群

个人观点,仅供参考

微信扫一扫
关注该公众号