prepare demo layer functions
stat_aseg <- function(...){
statexpress:::stat_panel_sf(reference_aseg,
default_aes = aes(label = after_stat(region_id)), crs = NULL, ...)}
geom_aseg <- stat_aseg
geom_aseg_text <- function(geom = "text", ...){
stat_aseg(...)
}
Use… Not really clear when you might use framework with external data.
reference_aseg %>%
sf::st_drop_geometry() %>%
ggplot() +
aes(region_id = region_id) +
stat_aseg() +
stat_aseg(geom = "text",
check_overlap = T)
## Joining with `by = join_by(region_id)`
## Joining with `by = join_by(region_id)`
reference_aseg %>%
sf::st_drop_geometry() %>%
ggplot() +
aes(region_id = region_id) +
stat_aseg() +
stat_aseg(geom = "text",
check_overlap = T,
size = 2) +
aes(fill = hemi) +
ggstamp::stamp_wash() +
stat_aseg(keep_id = "Right-Amygdala", fill = "darkred")
## Warning in annotate(geom = "rect", xmin = xmin, ymin = ymin, xmax = xmax, :
## Ignoring unknown aesthetics: x and y
## Joining with `by = join_by(region_id)`
## Joining with `by = join_by(region_id)`
## Joining with `by = join_by(region_id)`
Body map - not really fitting the mold - just trying to figure out the structure of the data.
library(tidyverse)
library(gganatogram)
## Loading required package: ggpolypath
a <- gganatogram(data=hgFemale_key, outline = T, fillOutline='#a6bddb', organism='human', sex='female', fill="colour")
hgFemale_list[[156]]
## X1 X2 id x y group
## 1 NA NA submandibular_gland NA NA 156_2
## 2 85.39803 99.96623 submandibular_gland 56.76116 21.77207 156_2
## 3 84.75740 100.09123 submandibular_gland 56.12053 21.89707 156_2
## 4 84.75740 100.09123 submandibular_gland 56.12053 21.89707 156_2
## 5 84.00740 100.23185 submandibular_gland 55.37053 22.03769 156_2
## 6 83.86678 100.80998 submandibular_gland 55.22991 22.61582 156_2
## 7 83.86678 100.80998 submandibular_gland 55.22991 22.61582 156_2
## 8 83.86678 101.05998 submandibular_gland 55.22991 22.86582 156_2
## 9 84.11678 101.12248 submandibular_gland 55.47991 22.92832 156_2
## 10 84.11678 101.12248 submandibular_gland 55.47991 22.92832 156_2
## 11 85.22615 101.24748 submandibular_gland 56.58928 23.05332 156_2
## 12 85.81990 100.73186 submandibular_gland 57.18303 22.53770 156_2
## 13 85.81990 100.73186 submandibular_gland 57.18303 22.53770 156_2
## 14 86.00740 100.51311 submandibular_gland 57.37053 22.31895 156_2
## 15 86.00740 100.26310 submandibular_gland 57.37053 22.06894 156_2
## 16 86.00740 100.26310 submandibular_gland 57.37053 22.06894 156_2
# str(hgFemale_list)
hgFemale_df <- data.frame()
for (i in c(1:length(hgFemale_list))){
hgFemale_df <- bind_rows(hgFemale_df, hgFemale_list[[i]] %>% mutate(group = as.character(group)))
}
a +
coord_equal()
# gganatogram:::get_anatogram()
a +
ggstamp::stamp_wash() +
geom_path(data = hgFemale_list$brain, aes(x = x, y = -y), color = "red", size = .5, linetype = "dashed") +
coord_equal()
## Warning in annotate(geom = "rect", xmin = xmin, ymin = ymin, xmax = xmax, :
## Ignoring unknown aesthetics: x and y
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_path()`).
# hgFemale_df %>% sf::st_as_sf(coords = c("x", "y"))
# str(last_plot())
hgFemale_df %>%
left_join(hgFemale_key, by = join_by(id == organ)) %>%
ggplot() +
aes(x = x, y = -y) +
geom_polygon(color = "lightgrey", aes(fill = I(colour))) +
coord_equal() +
aes(group = group) +
# aes(fill = id == "pancreas") +
geom_polygon(data = . %>% filter( id == "pancreas"),
fill = "blue") +
facet_wrap(~type, nrow = 2)