こんなのを見かけた。
ggplot で人体を描いて、臓器やその臓器に与えられたパラメータに応じた色を描いてくれるらしい。
devtools::install_github("jespermaag/gganatogram") library(ggplot2) library(ggpolypath) library(gganatogram) library(dplyr) library(gridExtra) gganatogram(data=hgMale_key, fillOutline='#a6bddb', organism='human', sex='male', fill="colour") + theme_void()
hgMake_key にはデフォルトで入っている臓器とタイプ分け、タイプに応じた色が入っている。
organ type colour value 1 bone marrow other #41ab5d 3.465121 2 frontal cortex nervous system purple 16.279637 3 prefrontal cortex nervous system purple 19.914552 4 gastroesophageal junction digestion orange 1.007031 5 caecum digestion orange 1.805996 6 ileum digestion orange 9.911434 7 rectum digestion orange 19.989139 8 nose other #41ab5d 12.858249 9 tongue digestion orange 8.574843 10 penis other #41ab5d 15.586977 11 nasal pharynx other #41ab5d 18.635302 12 spinal cord nervous system purple 10.512042 13 throat digestion orange 17.288282 14 diaphragm respiratory steelblue 10.941339 15 liver digestion orange 5.335311 16 stomach digestion orange 8.305132 17 spleen digestion orange 16.728927 18 duodenum digestion orange 4.879619 19 gall bladder digestion orange 14.012052 20 pancreas digestion orange 10.786245 21 colon digestion orange 16.293596 22 small intestine digestion orange 4.601459 23 appendix other #41ab5d 12.857249 24 urinary bladder digestion orange 2.420635 25 bone other #41ab5d 1.624326 26 cartilage other #41ab5d 17.913499 27 esophagus digestion orange 19.941666 28 skin other #41ab5d 2.310034 29 brain nervous system purple 16.736891 30 heart circulation red 8.383394 31 lymph_node circulation red 16.455134 32 skeletal_muscle other #41ab5d 19.707006 33 leukocyte circulation red 10.528939 34 temporal_lobe nervous system purple 16.984754 35 atrial_appendage other #41ab5d 17.094688 36 coronary_artery circulation red 13.996476 37 hippocampus nervous system purple 15.832699 38 vas_deferens nervous system purple 17.723010 39 seminal_vesicle other #41ab5d 1.047456 40 epididymis other #41ab5d 13.174310 41 tonsil digestion orange 6.264270 42 lung respiratory steelblue 13.708475 43 trachea digestion orange 1.825725 44 bronchus respiratory steelblue 14.416962 45 nerve nervous system purple 17.915368 46 kidney digestion orange 15.225223
46臓器各々やろうと思ったけどfacet_grid がorgan をなぜか受け付けてくれないのでtype 別にプロットする。
gganatogram(data=hgMale_key, fillOutline=grey(0.9), organism='human', sex='male', fill="colour") + theme_void() + theme(title=element_text(size=24,face="bold")) + facet_grid(. ~ type) ggsave("gganatogram.png", width=5, height=2)
実際には、正常と病気で比較したいだろうから、例では癌として適当な図を作っている。
compareGroups <- rbind(data.frame(organ = c("heart", "leukocyte", "nerve", "brain", "liver", "stomach", "colon"), colour = c("red", "red", "purple", "purple", "orange", "orange", "orange"), value = c(10, 5, 1, 8, 2, 5, 5), 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(5, 5, 10, 8, 2, 5, 5), 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")