Skip to content

Latest commit

 

History

History
117 lines (99 loc) · 4.44 KB

demog.org

File metadata and controls

117 lines (99 loc) · 4.44 KB

Demographics

source("MRS_GabaGlu.R")
library(ggplot2)
library(cowplot)
theme_set(theme_cowplot())
MRS_GG_keep <- MRS_GabaGlu %>% filter(roi %in% keep_rois)
# keep_rois <- c(1,2,7,8,9,10) # from MRS_GabaGlu.R
length(unique(MRS_GG_keep$ld8)) 
137
group_demo <- MRS_GG_keep %>%
   group_by(agegrp,sex,region) %>%
   summarise(n=length(unique(ld8)))

p_age_n <- ggplot(group_demo) +
   aes(x=agegrp,y=n,fill=sex) +
   geom_col(position='dodge') +
   facet_wrap(~region) +
   theme(axis.text.x=element_text(angle=45, hjust=1)) +
   guides(fill="none") # have guide on plot below

d <- MRS_GabaGlu %>%  filter(roi %in% keep_rois)
p_g1 <- plot_grid(
    ggplot(d) +
     aes(x=region,fill=agegrp)+
     geom_bar(position='dodge') +
     theme(axis.text.x=element_text(angle=45, hjust=1)),
    ggplot(d) +
     aes(x=region,fill=sex)+
     geom_bar(position='dodge') +
     theme(axis.text.x=element_text(angle=45, hjust=1)),
    nrow=2)
plot_grid(p_age_n, p_g1)

imgs/region_agegrp.png

20220815

MRS_GG_keep %>%
    group_by(region,sex) %>%
    summarise(n=length(unique(ld8)), y=min(age), o=max(age)) %>%
    pivot_wider(c("region"), names_from="sex", values_from = c("n","y","o")) %>%
    mutate(n=n_M+n_F, y=min(c_across(c(y_F,y_M))), o=max(c_across(c(o_F,o_M))))
regionn_Fn_My_Fy_Mo_Fo_Mnyo
ACC576510.5910.1829.6330.4412210.1830.44
LAntInsula556010.5910.1829.6330.4411510.1830.44
LDLPFC475410.5910.1829.6330.4410110.1830.44
MPFC565710.5911.4829.6329.4811310.5929.63
RAntInsula626110.5910.1829.6330.4412310.1830.44
RDLPFC465310.8910.1829.6329.489910.1829.63

including age groups

MRS_GG_keep %>%
    group_by(region,agegrp, sex) %>%
    summarise(n=length(unique(ld8)), y=min(age), o=max(age)) %>%
    pivot_wider(c("region","agegrp"), names_from="sex", values_from = c("n","y","o")) %>%
    mutate(n=n_M+n_F, y=min(c_across(c(y_F,y_M))), o=max(c_across(c(o_F,o_M))))
regionagegrpn_Fn_My_Fy_Mo_Fo_Mnyo
ACC10-16191910.610.215.916.03810.216.0
ACC17-22232316.016.221.921.94616.021.9
ACC23-30152322.722.129.630.43822.130.4
LAntInsula10-16201510.610.215.916.03510.216.0
LAntInsula17-22202416.016.221.921.94416.021.9
LAntInsula23-30152122.722.129.630.43622.130.4
LDLPFC10-16191610.610.215.916.03510.216.0
LDLPFC17-22162316.216.221.721.93916.221.9
LDLPFC23-30121522.722.129.630.42722.130.4
MPFC10-16171510.611.515.916.03210.616.0
MPFC17-22212216.016.221.921.94316.021.9
MPFC23-30182022.722.129.629.53822.129.6
RAntInsula10-16201610.610.215.916.03610.216.0
RAntInsula17-22232216.016.221.921.94516.021.9
RAntInsula23-30192322.722.129.630.44222.130.4
RDLPFC10-16171710.910.215.616.03410.216.0
RDLPFC17-22161716.216.321.921.93316.221.9
RDLPFC23-30131922.822.129.629.53222.129.6
MRS_GG_keep %>%
    group_by(ld8) %>%
    mutate(nregion=n()) %>%
    ggplot() +
    aes(y=age, x=region, color=nregion) +
    geom_point(alpha=.8) +
    cowplot::theme_cowplot()

imgs/age_region_id.png