table(su_y_mypi$eventname)
##
## 18_month_follow_up_arm_1 30_month_follow_up_arm_1 42_month_follow_up_arm_1
## 11084 10256 8567
## 6_month_follow_up_arm_1
## 11389
mri_y_qc_incl %>% group_by(eventname) %>% summarise(n = n())
## # A tibble: 2 × 2
## eventname n
## <chr> <int>
## 1 2_year_follow_up_y_arm_1 7693
## 2 baseline_year_1_arm_1 3964
#table(mri_y_qc_incl$eventname)
#baseline_year_1_arm_1
11393
## [1] 11393
abcd_y_lt %>% group_by(eventname) %>% summarise_at(vars(interview_age),
list(Mean_Age = mean), na.rm=TRUE) %>% mutate(Mean_Age_Years= Mean_Age/12) %>% arrange(Mean_Age_Years)
## # A tibble: 9 × 3
## eventname Mean_Age Mean_Age_Years
## <chr> <dbl> <dbl>
## 1 baseline_year_1_arm_1 119. 9.91
## 2 6_month_follow_up_arm_1 125. 10.4
## 3 1_year_follow_up_y_arm_1 131. 10.9
## 4 18_month_follow_up_arm_1 137. 11.4
## 5 2_year_follow_up_y_arm_1 144. 12.0
## 6 30_month_follow_up_arm_1 149. 12.4
## 7 3_year_follow_up_y_arm_1 155. 12.9
## 8 42_month_follow_up_arm_1 161. 13.4
## 9 4_year_follow_up_y_arm_1 169. 14.1
#find for each person the total that have used drugs *ever* since the start of study
su_y_mypi<- su_y_mypi %>% mutate(Total_Drugs = select(., c(mypi_alc_full_drink, mypi_mj_30, mypi_ecig)) %>% rowSums(na.rm = TRUE))
data <- su_y_mypi %>%
group_by(Total_Drugs) %>%
summarise(n = n()) %>% filter(Total_Drugs < 777)
ggbarplot(data,
x = "Total_Drugs", y = 'n',
palette = c("red", "green"),
main = 'Total Drugs Lifetime',
label = TRUE) +
expand_limits(y = 0) +
theme_grey()
opts_chunk$set(fig.path='figure/graphics-',
cache.path='cache/graphics-',
fig.align='center',
external=TRUE,
echo=TRUE,
warning=FALSE,
fig.pos='H' #use this so that text and plots align
)
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
su_y_mypi %>% dplyr::select(mypi_alc_full_drink, mypi_mj_30, mypi_ecig, eventname)%>% #get drug use scores in long format
tidyr::pivot_longer(cols=c(mypi_alc_full_drink, mypi_mj_30 ,mypi_ecig),
names_to="drug_use",
values_to = "value") %>%
group_by(drug_use, value, eventname) %>%
summarise(N=n()) %>% #sum of n to find out the occurences of each dsm dx
mutate(drug_use= factor(drug_use),
N= as.numeric(N),
value= recode_factor(value, "0"= "No substances last 6 mo",
"1"= "Had substance in last 6 mo")) %>%
filter(value != "NA") %>% ungroup() %>% mutate(eventname = recode_factor(eventname,
"baseline_year_1_arm_1" = "9yo",
"6_month_follow_up_arm_1" = "10.3yo",
"1_year_follow_up_y_arm_1" = "10.9yo",
"18_month_follow_up_arm_1" ="11.4yo",
"2_year_follow_up_y_arm_1" ="12yo",
"30_month_follow_up_arm_1" ="12.4yo",
"3_year_follow_up_y_arm_1"="12.9yo",
"42_month_follow_up_arm_1" ="13.4yo",
"4_year_follow_up_y_arm_1"="14yo")) %>%
ggplot(aes(x=fct_reorder(drug_use, N), y=N, fill=eventname)) + geom_bar(position="dodge", stat="identity")+ facet_wrap(value~., scales="free_y", ncol=1) + labs(x= "Drug") +
scale_x_discrete(labels=c("mypi_alc_full_drink"="Alcohol", "mypi_ecig" ="Ecigs", "mypi_mj_30" ="Marijuana")) + theme_bw()+ geom_text(
aes(label = N),
size = 3,
vjust = 1.5, position = position_dodge(.9) )+ scale_fill_brewer(palette = "Set3")
#+ scale_fill_manual(values=c("#DDCC77","#44AA99" )) + theme_minimal()
#use geom_text to plot the counts in the bars
opts_chunk$set(fig.path='figure/graphics-',
cache.path='cache/graphics-',
fig.align='center',
external=TRUE,
echo=TRUE,
warning=FALSE,
fig.pos='H' #use this so that text and plots align
)
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
safe_colorblind_palette <- c( "#DDCC77", #use accessible hex codes
"#44AA99")
#how to find missingness
missing<- su_y_mypi %>%
purrr::map(~sum(is.na(.))) %>%
as_tibble()
abcd_sub_use %>% dplyr::select(mypi_alc_full_drink, mypi_mj_30, mypi_ecig, sex)%>% #get drug use scores in long format
tidyr::pivot_longer(cols=c(mypi_alc_full_drink, mypi_mj_30 ,mypi_ecig),
names_to="drug_use",
values_to = "value") %>%
group_by(drug_use, value, sex) %>%
summarise(N=n()) %>% #sum of n to find out the occurences of each dsm dx
mutate(drug_use= factor(drug_use),
N= as.numeric(N),
value= recode_factor(value, "0"= "No substances last 6 mo",
"1"= "Had substance in last 6 mo")) %>%
filter(value != "NA") %>% ungroup() %>% mutate(sex = recode_factor(sex,
"1" = "Male",
"2" = "Female")) %>%
ggplot(aes(x=fct_reorder(drug_use, N), y=N, fill=sex)) + geom_bar(position="dodge", stat="identity")+
facet_wrap(value~., scales="free_y", ncol=1) + labs(x= "Drug") +
scale_x_discrete(labels=c("mypi_alc_full_drink"="Alcohol", "mypi_ecig" ="Ecigs", "mypi_mj_30" ="Marijuana")) + theme_bw()+ geom_text(
aes(label = N),
size = 3,
vjust = 1.5, position = position_dodge(.9) #use geom_text to plot the counts in the bars
) + scale_fill_manual(values=c("#DDCC77","#44AA99" )) + labs(caption = "42 month follow up \n ~13.5yo") + theme_minimal()
Correlations of Cortical Measures & PRS scores entire sample