diff --git a/data/example_data_network_demo_data_long.csv b/data/example_data_network_demo_data_long.csv new file mode 100644 index 0000000..9999dcd --- /dev/null +++ b/data/example_data_network_demo_data_long.csv @@ -0,0 +1,5 @@ +"","modid","avgweight","modul","avgclustco_both","num_comms_modul","part_coef_pos","part_coef_neg","system_segreg","mean_within_sys","mean_between_sys","system_conn_1","system_conn_2","system_conn_3","system_conn_4","system_conn_5","system_conn_6","system_conn_7","system_conn_8","system_conn_9","system_conn_10","system_conn_11","system_conn_12","system_conn_13","system_conn_14","system_conn_15","system_conn_16","system_conn_17","system_conn_18","system_conn_19","system_conn_20","system_conn_21","system_conn_22","system_conn_23","system_conn_24","system_conn_25","system_conn_26","system_conn_27","system_conn_28","system_conn_29","system_conn_30","system_conn_31","system_conn_32","system_conn_33","system_conn_34","system_conn_35","system_conn_36","system_conn_37","system_conn_38","system_conn_39","system_conn_40","system_conn_41","system_conn_42","system_conn_43","system_conn_44","system_conn_45","system_conn_46","system_conn_47","system_conn_48","system_conn_49","system_conn_50","system_conn_51","system_conn_52","system_conn_53","system_conn_54","system_conn_55","system_conn_56","system_conn_57","system_conn_58","system_conn_59","system_conn_60","system_conn_61","system_conn_62","system_conn_63","system_conn_64","system_conn_65","system_conn_66","system_conn_67","system_conn_68","system_conn_69","system_conn_70","system_conn_71","system_conn_72","system_conn_73","system_conn_74","system_conn_75","system_conn_76","system_conn_77","system_conn_78","system_conn_79","system_conn_80","system_conn_81","system_conn_82","system_conn_83","system_conn_84","system_conn_85","system_conn_86","system_conn_87","system_conn_88","system_conn_89","system_conn_90","system_conn_91","system_conn_92","system_conn_93","system_conn_94","system_conn_95","system_conn_96","system_conn_97","system_conn_98","system_conn_99","system_conn_100","system_conn_101","system_conn_102","system_conn_103","system_conn_104","system_conn_105","system_conn_106","system_conn_107","system_conn_108","system_conn_109","system_conn_110","system_conn_111","system_conn_112","system_conn_113","system_conn_114","system_conn_115","system_conn_116","system_conn_117","system_conn_118","system_conn_119","system_conn_120","system_conn_121","system_conn_122","system_conn_123","system_conn_124","system_conn_125","system_conn_126","system_conn_127","system_conn_128","system_conn_129","system_conn_130","system_conn_131","system_conn_132","system_conn_133","system_conn_134","system_conn_135","system_conn_136","system_conn_137","system_conn_138","system_conn_139","system_conn_140","system_conn_141","system_conn_142","system_conn_143","system_conn_144","system_conn_145","system_conn_146","system_conn_147","system_conn_148","system_conn_149","system_conn_150","system_conn_151","system_conn_152","system_conn_153","system_conn_154","system_conn_155","system_conn_156","system_conn_157","system_conn_158","system_conn_159","system_conn_160","system_conn_161","system_conn_162","system_conn_163","system_conn_164","system_conn_165","system_conn_166","system_conn_167","system_conn_168","system_conn_169","timepoint","part_coef_avg","child_age_mri","child_sex","disadv_prenatal","disadv_y1","disadv_y2","disadv_y3","income_needs_demo_b","income_needs_demo_b_unlogged","income_needs_demo_b_log","demo_edu_b","demo_edu_b_filled_in","avg_FD_of_retained_frames","retained_frames","total_frames.x","avg_FD_of_all_frames","total_frames.y","retained_frames_min","total_frames_min","percent_retained" +"1","1",1.630418e-05,0.400843047775193,0.065581046271814,5.51,0.817990660667419,0.866936028003693,1.110295,0.1196473,-0.01319646,0.2953032,0.0623395,-0.09164974,-0.08310618,-0.06719951,-0.05316828,-0.01675522,-0.0006647618,0.03867096,-0.03063877,0.1524509,0.02531424,-0.04050373,0.0623395,0.07690803,-0.01815335,-0.02205419,-0.01341501,-0.05819147,-0.01013919,-0.01514476,0.1086776,-0.002970814,0.04815514,0.0008726087,-0.05747232,-0.09164976,-0.01815335,0.1295523,0.004521913,0.06153335,0.003550299,0.0414838,-0.04961604,0.04964035,-0.0662123,-0.1336459,0.0162791,-0.0284697,-0.08310617,-0.02205419,0.004521917,0.0792248,0.04451551,0.007798953,-0.006680264,-0.04588262,-0.06464918,0.01997392,-0.06266452,0.02011381,-0.002850922,-0.0671995,-0.01341502,0.06153334,0.0445155,0.1002005,0.007946736,0.02015433,-0.04617264,-0.004487476,-0.05797741,-0.05142374,0.02297722,-0.01706374,-0.05316828,-0.05819147,0.003550298,0.007798953,0.007946735,0.1563765,-0.001799903,0.07576801,-0.07635046,-0.006689662,-0.03454016,-0.05204425,0.03067475,-0.01675522,-0.01013919,0.04148378,-0.006680268,0.02015433,-0.001799904,0.05539706,-0.005638255,0.02246678,-0.03678603,-0.06304325,0.02125456,-0.03072811,-0.0006647594,-0.01514476,-0.04961604,-0.04588262,-0.04617264,0.07576802,-0.005638254,0.1771513,0.009279369,-0.04550238,-0.04990336,-0.04335145,0.09880181,0.03867096,0.1086776,0.04964036,-0.06464916,-0.004487472,-0.07635045,0.02246678,0.009279371,0.2556688,-0.06321201,-0.02937405,-0.01116807,-0.06279981,-0.03063876,-0.002970811,-0.0662123,0.01997392,-0.05797742,-0.006689662,-0.03678602,-0.04550239,-0.06321201,0.1810212,0.1386178,-0.0592942,-0.04077669,0.1524509,0.04815515,-0.1336459,-0.06266452,-0.05142375,-0.03454017,-0.06304325,-0.04990336,-0.02937405,0.1386178,0.5329639,-0.03183712,-0.06913435,0.02531424,0.0008726124,0.0162791,0.02011381,0.02297722,-0.05204425,0.02125457,-0.04335145,-0.01116807,-0.0592942,-0.03183712,0.1442474,-0.01426028,-0.04050372,-0.05747231,-0.02846971,-0.002850921,-0.01706374,0.03067475,-0.03072812,0.0988018,-0.06279981,-0.0407767,-0.06913434,-0.01426028,0.1302662,"y0",0.842463344335556,0.037037037037037,"Male",0.618,-0.95,0.491,0.587,NA,1.16055751110257,0.0646666666666667,NA,2,0.076,1456,1680,1.369,1680,19.4133333333333,22.4,0.866666666666667 +"2","1",0.007279763,0.531962549458161,0.155618245236944,3.98,0.792895972728729,0.844165086746216,1.073275,0.2174772,-0.01593569,0.18361721932888,0.0334383472800255,-0.053065050393343,-0.0504359900951385,-0.0772527158260345,0.00566702010110021,-0.0217555575072765,0.0146859912201762,-0.0193777251988649,0.0396812744438648,0.103006027638912,0.00206602131947875,-0.0446188934147358,0.0334383361041546,0.194852158427238,0.0124546075239778,0.0168815441429615,0.0248924177139997,-0.0420698784291744,-0.0126507263630629,-0.131037399172783,0.189825847744942,0.0426831059157848,0.0864585340023041,-0.0360115393996239,-0.106699429452419,-0.0530650429427624,0.0124546075239778,0.233711868524551,-0.072090670466423,0.115748874843121,0.0551871433854103,0.135643690824509,0.0280384179204702,0.11009892821312,-0.125931426882744,-0.043552253395319,0.139964893460274,-0.130123361945152,-0.0504359863698483,0.0168815515935421,-0.0720906853675842,0.206360548734665,0.101672478020191,-0.152180939912796,-0.0404276698827744,-0.18453723192215,-0.0672630369663239,0.00190259795635939,-0.0701667368412018,-0.0104442676529288,0.029161075130105,-0.0772527158260345,0.0248924121260643,0.115748874843121,0.101672492921352,0.180993586778641,-0.0736987143754959,0.0706630870699883,-0.133780956268311,0.0505833737552166,-0.0945772975683212,-0.0691884681582451,0.0866706594824791,-0.0743778571486473,0.00566701870411634,-0.0420698821544647,0.0551871508359909,-0.152180954813957,-0.0736986920237541,0.37170797586441,-0.00684849498793483,0.293181777000427,0.0866924151778221,-0.0340079553425312,0.0445652790367603,-0.05888407304883,0.0287459008395672,-0.0217555575072765,-0.0126507254317403,0.135643675923347,-0.0404276810586452,0.0706630945205688,-0.00684849545359612,0.138999179005623,0.0252234656363726,0.0215236451476812,-0.0974932909011841,-0.0652120038866997,0.125395923852921,-0.0907294228672981,0.0146859930828214,-0.131037414073944,0.0280384235084057,-0.18453723192215,-0.133780956268311,0.293181717395782,0.0252234656363726,0.671651721000671,-0.0147070605307817,-0.0463925898075104,-0.0012911157682538,-0.0962149873375893,0.0859813168644905,-0.0193777251988649,0.189825862646103,0.11009892821312,-0.0672630295157433,0.050583366304636,0.0866924151778221,0.0215236488729715,-0.0147070605307817,0.35698065161705,-0.0469904839992523,0.00965074170380831,-0.0230182018131018,-0.0577266998589039,0.0396812632679939,0.042683120816946,-0.125931411981583,0.00190259946975857,-0.0945773273706436,-0.0340079516172409,-0.0974932760000229,-0.046392597258091,-0.0469904839992523,0.264982938766479,0.125327870249748,-0.139144882559776,-0.0357894152402878,0.103006027638912,0.0864585265517235,-0.0435522608458996,-0.0701667442917824,-0.0691884681582451,0.0445652939379215,-0.0652120038866997,-0.00129111390560865,0.00965072866529226,0.125327855348587,0.568808674812317,-0.136870950460434,-0.110454939305782,0.00206602085381746,-0.0360115393996239,0.139964878559113,-0.0104442704468966,0.0866706743836403,-0.0588840767741203,0.125395968556404,-0.0962149873375893,-0.0230182055383921,-0.139144912362099,-0.136870965361595,0.283994883298874,-0.0886491984128952,-0.0446189008653164,-0.106699429452419,-0.130123376846313,0.0291610676795244,-0.0743778571486473,0.028745898976922,-0.0907294452190399,0.0859813168644905,-0.0577267073094845,-0.0357894189655781,-0.110454924404621,-0.0886492133140564,0.270027041435242,"y2",0.818530529737473,1.98,"Male",0.618,-0.95,0.491,0.587,NA,1.16055751110257,0.0646666666666667,NA,2,0.049,2036,2100,1.247,2100,27.1466666666667,28,0.96952380952381 +"3","1",0.008218218,0.548833687572573,0.19144964614237,3,0.815198540687561,0.843683540821075,1.071498,0.2343097,-0.01675268,0.298923,0.06383901,-0.05997922,-0.05076693,-0.05040234,-0.03404608,-0.0184657,-0.08206814,0.05889739,-0.0171008,-0.02434524,0.04650611,-0.03738948,0.06383903,0.2135937,-0.02492008,0.009026771,0.03437007,-0.1194968,-0.0730052,-0.118953,0.1974657,0.1002792,0.06413057,-0.03068409,-0.09352682,-0.05997922,-0.02492008,0.2522004,-0.006993895,0.1267337,-0.007685033,0.1291875,0.04039339,0.1266193,-0.1712254,-0.1655251,0.1544903,-0.09513173,-0.05076693,0.009026771,-0.006993895,0.1949181,0.1149267,-0.09875359,-0.03960712,-0.1870146,-0.04110636,-0.002032994,-0.00550865,0.01358226,-0.005913692,-0.05040235,0.03437006,0.1267337,0.1149267,0.1864543,-0.1129375,0.0504303,-0.08693912,0.07246184,-0.1052239,-0.114603,0.1010483,-0.05472828,-0.03404608,-0.1194968,-0.007685033,-0.09875359,-0.1129375,0.4494055,0.01092133,0.213587,-0.07777207,-0.008838182,0.1041789,-0.1091543,0.03448796,-0.01846571,-0.07300517,0.1291874,-0.03960711,0.0504303,0.01092133,0.1679888,0.08295982,-0.01865136,-0.1708745,-0.1955879,0.1683894,-0.0213042,-0.08206813,-0.118953,0.04039339,-0.1870146,-0.08693912,0.213587,0.08295982,0.6518294,-0.108285,-0.0914916,-0.05610474,-0.04225273,0.1110962,0.05889739,0.1974657,0.1266194,-0.04110637,0.07246184,-0.07777206,-0.01865137,-0.108285,0.3378452,0.0171734,-0.02452263,0.01692253,-0.1374163,-0.01710079,0.1002793,-0.1712254,-0.002032985,-0.1052239,-0.008838184,-0.1708745,-0.0914916,0.0171734,0.3572869,0.289851,-0.2038974,-0.02374697,-0.02434524,0.06413056,-0.1655252,-0.005508654,-0.114603,0.1041789,-0.1955879,-0.05610474,-0.02452263,0.289851,0.7144995,-0.2556178,-0.02757985,0.0465061,-0.0306841,0.1544903,0.01358226,0.1010483,-0.1091543,0.1683893,-0.04225273,0.01692253,-0.2038974,-0.2556177,0.3054237,-0.08667443,-0.03738948,-0.09352684,-0.09513173,-0.005913692,-0.05472826,0.03448796,-0.02130421,0.1110962,-0.1374163,-0.02374697,-0.02757985,-0.08667441,0.1745817,"y3",0.829441040754318,3.13,"Male",0.618,-0.95,0.491,0.587,NA,1.16055751110257,0.0646666666666667,NA,2,0.051,571,668,2.67,706,7.61333333333333,8.90666666666667,0.854790419161677 +"4","2",0.004531833,0.472028367269128,0.11435836962254,3.92,0.789107859134674,0.840110599994659,1.084772,0.1960085,-0.016616,0.404855,0.08454632,-0.1602931,-0.1324247,-0.1685127,-0.1846554,-0.07343561,-0.05972126,-0.04652515,0.05561884,0.1480996,0.02105884,-0.08754654,0.08454633,0.1656057,-0.05412673,0.02462967,-0.03963608,-0.1070152,-0.01077752,-0.07392618,0.1184958,0.01505152,0.05681951,0.05195133,-0.1231572,-0.160293,-0.05412672,0.2707914,0.03559415,0.1637123,0.2250901,0.0738583,0.002607056,0.111921,-0.1568542,-0.1806165,0.04497133,-0.01970555,-0.1324248,0.02462968,0.03559415,0.1809177,0.13982,0.0561987,0.009413222,-0.06313499,0.01689602,-0.02477149,-0.1497936,-0.01460181,-0.02919295,-0.1685128,-0.03963607,0.1637122,0.13982,0.2600995,0.1219488,0.04484457,-0.01580385,0.06325718,-0.1083445,-0.1866321,-0.007801543,-0.006372548,-0.1846554,-0.1070152,0.22509,0.0561987,0.1219488,0.4497342,0.045985,0.09392245,0.02982699,-0.1694789,-0.227138,0.006386574,0.02731313,-0.0734356,-0.01077751,0.07385831,0.009413223,0.04484458,0.045985,0.0797499,0.04771155,0.07175721,-0.07360028,-0.05829988,0.03235281,-0.008894896,-0.05972125,-0.07392619,0.002607057,-0.06313498,-0.01580385,0.09392247,0.04771155,0.3536482,-0.01831797,-0.1049636,-0.0009738961,-0.02627704,0.1405385,-0.04652515,0.1184958,0.111921,0.01689602,0.06325718,0.02982699,0.07175721,-0.01831797,0.222181,-0.1106311,-0.05463327,0.07444331,-0.08459405,0.05561884,0.01505153,-0.1568542,-0.02477149,-0.1083445,-0.1694789,-0.07360028,-0.1049635,-0.1106311,0.2408461,0.1532361,-0.09165961,-0.01047159,0.1480996,0.05681951,-0.1806165,-0.1497936,-0.1866321,-0.227138,-0.05829987,-0.0009738975,-0.05463328,0.1532361,0.6295632,-0.03369337,-0.013889,0.02105884,0.05195133,0.04497134,-0.01460181,-0.00780154,0.006386573,0.03235279,-0.02627704,0.07444332,-0.09165959,-0.03369337,0.1603006,-0.04504481,-0.08754653,-0.1231572,-0.01970555,-0.02919295,-0.006372545,0.02731313,-0.008894896,0.1405385,-0.08459405,-0.01047159,-0.01388899,-0.04504481,0.1669776,"y0",0.814609229564667,0.0555555555555556,"Female",0.359,-0.85,0.458,0.774,NA,1.14200147979943,0.0576666666666667,NA,2,0.078,1389,1680,1.368,1680,18.52,22.4,0.826785714285714 diff --git a/gamm_models/manuscript_analyses.R b/gamm_models/manuscript_analyses.R index 3784b35..8a58a1e 100644 --- a/gamm_models/manuscript_analyses.R +++ b/gamm_models/manuscript_analyses.R @@ -53,6 +53,28 @@ demo_data$PMA_scan <- demo_data$mri_test_pma_scan_dob #make sex a factor demo_data$child_sex <- factor(demo_data$child_sex, labels = c("Male", "Female")) +# Load race data ---------------------------------------------------------- +#1, White | 2, Black or African American | 3, American Indian or Alaska Native | 4, Asian Indian | 5, Chinese | 6, Filipino | 7, Japanese | 8, Korean | 9, Vietnamese | 10, Other Asian | 11, Native Hawaiian | +#12, Guamanian or Chamorro | 13, Samoan | 14, Other Pacific Islander | 15, Other +race_data <- read.csv("~/Box/Tooley 01_18_2023 eLABE Requested Data/Tooley_02_14_2024_race_hispanic.csv") +race_data$child_race <- ifelse(grepl( ",",race_data$child_race), "Multiracial", race_data$child_race) + +race_data %>% + mutate( + #Replace with words for race + child_race_word=case_match(child_race, + "1" ~ "White", + "2" ~ "Black", + "4" ~ "Asian Indian", + "5" ~ "Chinese", + "8" ~ "Korean", + "14"~ "Other Pacific Islander", + "15" ~ "Other", + .default=child_race)) %>% + pull(child_race_word) + +race_data$child_hispanic <- factor(race_data$child_hispanic, labels=c("Not Hispanic or Latino","Hispanic or Latino", "Unspecified")) + # Fill in the birth income and education data ------------------------- edu_income_prenatal <- read.csv("~/Box/Tooley 01_18_2023 eLABE Requested Data/Prenatal_Edu_LogIN.csv") #add in the full data for parental education edu_income_prenatal$modid <- edu_income_prenatal$MODID @@ -116,9 +138,9 @@ demo_data <- left_join(demo_data, age_y3_mri, by = "modid") # Reshape data to long format -------------------------------------------- colnames(demo_data) -demo <- demo_data %>% dplyr::select(c("modid","child_birthweight","child_sex", "PMA_scan"),contains("age"), contains("disadv"),contains("income_needs_demo"), contains("demo_edu")) +demo <- demo_data %>% dplyr::select(c("modid","child_birthweight","child_sex", "PMA_scan"),contains("age"), contains("disadv"),contains("income_needs_demo"), contains("demo_edu"), contains("child_birthweight"), contains("GAWEEKS")) demo$child_age_y0_mri <- (demo$PMA_scan-38)/54 #change PMA to age in years at scan for later plotting -demo_long <- reshape(demo, direction="long", varying =list(c("child_age_y0_mri","child_age_y2_mri_fun","child_age_y3_mri_fun")), v.names = c("child_age_mri"), times=c("y0","y2","y3"), idvar = "modid", timevar = "timepoint") %>% select(.,modid, timepoint,child_age_mri,child_sex,disadv_prenatal, disadv_y1,disadv_y2,disadv_y3, income_needs_demo_b, income_needs_demo_b_unlogged, income_needs_demo_b_log, demo_edu_b,demo_edu_b_filled_in) +demo_long <- reshape(demo, direction="long", varying =list(c("child_age_y0_mri","child_age_y2_mri_fun","child_age_y3_mri_fun")), v.names = c("child_age_mri"), times=c("y0","y2","y3"), idvar = "modid", timevar = "timepoint") %>% select(.,modid, timepoint,child_age_mri,child_sex,disadv_prenatal, disadv_y1,disadv_y2,disadv_y3, income_needs_demo_b, income_needs_demo_b_unlogged, income_needs_demo_b_log, demo_edu_b,demo_edu_b_filled_in, child_birthweight, GAWEEKS) #merge network data in with demo data network_demo_data_long <- left_join(all_network_data, demo_long, by=c("modid", "timepoint")) @@ -206,6 +228,35 @@ table <- apa_corrTable(birth_demo, rmDiag = F, summarystats = F, method = "spear table table %>% save_flextable(., "~/Downloads/table.docx") +#look at those who came in at all at a time point versus those who didn't +modids_missing_at_year2 <- filter(demo_data_all, is.na(child_age_y2_assessment)); #who doesn't have age assessed at y2 +modids_missing_at_year2 <- left_join(modids_missing_at_year2, SEM_birth_indicators, by="modid");modids_missing_at_year2 <- left_join(modids_missing_at_year2, SEM_psychosocial_stress_y0, by="modid"); +modids_missing_at_year2 <- left_join(modids_missing_at_year2, ADI_all_timepoints, by="modid") +y2_data <- filter(demo_data_all, !is.na(child_age_y2_assessment)); y2_data <- left_join(y2_data, SEM_birth_indicators, by="modid");y2_data <- left_join(y2_data, SEM_psychosocial_stress_y0, by="modid"); +y2_data <- left_join(y2_data, ADI_all_timepoints, by="modid");#%>%filter(.,combined_exclusion_initial_analyses ==0 & irb_exclusion == 0) +modids_missing_at_year3 <- filter(demo_data_all, is.na(child_age_y3_assessment)); #who doesn't have age assessed at y2 +modids_missing_at_year3 <- left_join(modids_missing_at_year3, SEM_birth_indicators, by="modid");modids_missing_at_year3 <- left_join(modids_missing_at_year3, SEM_psychosocial_stress_y0, by="modid"); +modids_missing_at_year3 <- left_join(modids_missing_at_year3, ADI_all_timepoints, by="modid") +y3_data <- filter(demo_data_all, !is.na(child_age_y3_assessment));y3_data <- left_join(y3_data, SEM_birth_indicators, by="modid");y3_data <- left_join(y3_data, SEM_psychosocial_stress_y0, by="modid"); +y3_data <- left_join(y3_data, ADI_all_timepoints, by="modid")#%>%filter(.,combined_exclusion_initial_analyses ==0 & irb_exclusion == 0) + +t.test(y2_data$disadv_prenatal, modids_missing_at_year2$disadv_prenatal) +t.test(y3_data$disadv_prenatal, modids_missing_at_year3$disadv_prenatal) +t.test(y2_data$neighborhood_natlcentile_b.x, modids_missing_at_year2$ADI) +t.test(y3_data$neighborhood_natlcentile_b.x, modids_missing_at_year3$ADI) +chisq.test(cbind(table(y2_data$child_sex), table(modids_missing_at_year2$child_sex))) +chisq.test(cbind(table(y3_data$child_sex), table(modids_missing_at_year3$child_sex))) +t.test(y2_data$GAWEEKS, modids_missing_at_year2$GAWEEKS) +t.test(y3_data$GAWEEKS, modids_missing_at_year3$GAWEEKS) +t.test(y2_data$child_birthweight, modids_missing_at_year2$child_birthweight) +t.test(y3_data$child_birthweight, modids_missing_at_year3$child_birthweight) +t.test(y2_data$psych_prenatal, modids_missing_at_year2$psych_prenatal) +t.test(y3_data$psych_prenatal, modids_missing_at_year3$psych_prenatal) +t.test(y2_data$income_needs_demo_b, modids_missing_at_year2$income_needs_demo_b) +t.test(y2_data$income_needs_demo_y2, modids_missing_at_year2$income_needs_demo_y2) +t.test(y3_data$income_needs_demo_b, modids_missing_at_year3$income_needs_demo_b) +t.test(y3_data$income_needs_demo_y3, modids_missing_at_year3$income_needs_demo_y3) + # Figure 1: GAMMs for age ------------------------------------------------------------- source("~/Box/projects/in_progress/Tooley2023_prenatal_env_cortical_network_dev/gamm_models/gamm_functions.R") #system segregation @@ -282,10 +333,11 @@ p.adjust(c(summary(gam_age_ses_segreg_by$gam)$s.table[2,4],summary(gam_age_ses_m # Prenatal SES moderates trajectories of cortical network segregation ------------------------------- #Correlations between segregation measures -anova(lmer(avgclustco_both ~ modul +(1|modid), data=network_demo_data_long)) -cor.test(network_demo_data_long$avgclustco_both, network_demo_data_long$modul) -cor.test(network_demo_data_long$avgclustco_both, network_demo_data_long$system_segreg) -cor.test(network_demo_data_long$modul, network_demo_data_long$system_segreg) +anova(lmer(avgclustco_both ~ modul + (1|modid), data=network_demo_data_long)) +net_data <- filter(network_demo_data_long, !is.na(child_sex)) +cor.test(net_data$avgclustco_both, net_data$modul) +cor.test(net_data$avgclustco_both, net_data$system_segreg) +cor.test(net_data$modul, net_data$system_segreg) #which measure of segregation accounts for the age x SES effect ## Check local segregation inclusion in other models ## @@ -297,6 +349,7 @@ pb <- pboot(gam_age_ses_segreg_by);pb #modul gam_age_ses_modul_by <- gamm(modul ~ child_sex + s(child_age_mri, k=4)+ s(child_age_mri,by=disadv_prenatal, k=4) + avg_FD_of_retained_frames +retained_frames + avgweight +avgclustco_both, random = list(modid =~ 1), data=network_demo_data_long, method = "REML") summary(gam_age_ses_modul_by$lme);summary(gam_age_ses_modul_by$gam) +confint(gam_age_ses_modul_by$lme) gam_age_ses_modul_by <- gamm(modul ~ child_sex + s(child_age_mri, k=4) + avg_FD_of_retained_frames + retained_frames + avgweight+ +avgclustco_both + s(child_age_mri,by=disadv_prenatal, k=4) , random = list(modid =~ 1), data=network_demo_data_long, method = "REML") pb <- pboot(gam_age_ses_modul_by);pb @@ -369,6 +422,10 @@ head(gam.age.ses.clustco.gordon.fx.TRUE) gam.age.ses.clustco.gordon.fx.TRUE$GAM.age.ses.pvalue.fdr <- p.adjust(gam.age.ses.clustco.gordon.fx.TRUE$GAM.age.ses.pvalue, method = "fdr") gam.age.ses.clustco.gordon.fx.TRUE$network <- gordon_networks kruskal.test(GAM.age.ses.Fvalue~network, data = gam.age.ses.clustco.gordon.fx.TRUE) +library(rstatix) +kruskal_effsize(data = gam.age.ses.clustco.gordon.fx.TRUE, + GAM.age.ses.Fvalue~network, + ci = T) #make a boxplot g <- ggplot(data = dplyr::filter(gam.age.ses.clustco.gordon.fx.TRUE, network !="None"), aes(x = reorder(network, -GAM.age.ses.Fvalue, median), y= GAM.age.ses.Fvalue, fill=network)) + @@ -394,6 +451,8 @@ load("~/Box/projects/in_progress/struct_funct_neonates/data/rotations_gordon333_ sa_axis_gordon <- read.csv("~/Box/tools/parcellations/Gordon_fs_LR/SensorimotorAssociation_Axis_Gordon333.csv") print(perm.sphere.p(gam.age.ses.clustco.gordon.fx.TRUE$GAM.age.ses.Fvalue,sa_axis_gordon$SA.Axis.ranks, rotations, "spearman")) #test the spin test cor.test(gam.age.ses.clustco.gordon.fx.TRUE$GAM.age.ses.Fvalue,sa_axis_gordon$SA.Axis.ranks, method = "spearman") +library(rcompanion) +spearmanRho(x= gam.age.ses.clustco.gordon.fx.TRUE$GAM.age.ses.Fvalue, y = sa_axis_gordon$SA.Axis.ranks,ci = T) mydata <- data.frame(sa_axis_gordon,gam.age.ses.clustco.gordon.fx.TRUE) mydata$sig_or_not <- factor(ifelse(mydata$GAM.age.ses.pvalue.fdr<0.05, 1,1)) @@ -438,10 +497,12 @@ describe(y2_data_only$bayley_cog_comp_y2) lm_bayley_lang_clustco <- lm(avgclustco_both ~ child_sex + child_age_y2_mri_fun + avgweight + avg_FD_of_retained_frames + retained_frames+ bayley_lang_comp_y2, data=y2_data_only) summary(lm_bayley_lang_clustco) lm.beta(lm_bayley_lang_clustco) +confint(lm_bayley_lang_clustco) visreg(lm_bayley_lang_clustco) #cognition lm_bayley_cog_clustco <- lm(avgclustco_both ~ child_sex + child_age_y2_mri_fun + avgweight + avg_FD_of_retained_frames + retained_frames+ bayley_cog_comp_y2, data=y2_data_only) summary(lm_bayley_cog_clustco) +confint(lm_bayley_cog_clustco) lm.beta(lm_bayley_cog_clustco) visreg(lm_bayley_cog_clustco) @@ -460,6 +521,7 @@ p.adjust(c(summary(lm_bayley_lang_clustco)$coefficients[7,4], summary(lm_bayley_ #language lm_bayley_lang_clustco <- lm(bayley_lang_comp_y2 ~ child_sex + disadv_prenatal + avgclustco_both, data=y2_data_only) summary(lm_bayley_lang_clustco) +confint(lm_bayley_lang_clustco) lm.beta(lm_bayley_lang_clustco) visreg(lm_bayley_lang_clustco) #clust co significant when including disadvantage in the model, disadvantage also sig @@ -468,12 +530,14 @@ visreg(lm_bayley_lang_clustco) #clust co significant when including disadvantage lm_bayley_elang_clustco <- lm(avgclustco_both ~ child_sex + child_age_y2_mri_fun + avgweight + avg_FD_of_retained_frames + retained_frames+ bayley_elang_scale_y2, data=y2_data_only) lm.beta(lm_bayley_elang_clustco) summary(lm_bayley_elang_clustco) +confint(lm_bayley_elang_clustco) visreg(lm_bayley_elang_clustco, "bayley_elang_scale_y2") visreg(lm_bayley_elang_clustco, "bayley_elang_scale_y2",xlim=c(1,13)) ##when you control for SES, is this accounting for the effect or not? lm_bayley_elang_clustco <- lm(bayley_elang_scale_y2 ~ child_sex + avgclustco_both + disadv_prenatal, data=y2_data_only) summary(lm_bayley_elang_clustco) +confint(lm_bayley_elang_clustco) lm.beta(lm_bayley_elang_clustco) visreg(lm_bayley_elang_clustco) #clust co no longer significant when including disadvantage in the model, disadvantage also marginal visreg(lm_bayley_elang_clustco, "avgclustco_both") @@ -482,6 +546,7 @@ visreg(lm_bayley_elang_clustco, "avgclustco_both") lm_bayley_rlang_clustco <- lm(avgclustco_both ~ child_sex + child_age_y2_mri_fun + avgweight + avg_FD_of_retained_frames + retained_frames+ bayley_rlang_scale_y2, data=y2_data_only) lm.beta(lm_bayley_rlang_clustco) summary(lm_bayley_rlang_clustco) +confint(lm_bayley_rlang_clustco) visreg(lm_bayley_rlang_clustco) a <- visreg(lm_bayley_rlang_clustco, "bayley_rlang_scale_y2");plot(a) plot(a, xlim=c(1,13)) @@ -490,6 +555,7 @@ p.adjust(c(summary(lm_bayley_rlang_clustco)$coefficients[7,4], summary(lm_bayley ##when you control for SES, is this accounting for the effect or not? lm_bayley_rlang_clustco <- lm(bayley_rlang_scale_y2 ~ child_sex + avgclustco_both + disadv_prenatal, data=y2_data_only) summary(lm_bayley_rlang_clustco) +confint(lm_bayley_rlang_clustco) lm.beta(lm_bayley_rlang_clustco) visreg(lm_bayley_rlang_clustco, "avgclustco_both") @@ -505,12 +571,14 @@ describe(y3_data_only$bayley_cog_scale_y3) #language lm_bayley_lang_clustco <- lm(avgclustco_both ~ child_sex + child_age_y3_mri_fun + avgweight + avg_FD_of_retained_frames + retained_frames+ bayley_lang_comp_y3, data=y3_data_only) summary(lm_bayley_lang_clustco) +confint(lm_bayley_lang_clustco) lm.beta(lm_bayley_lang_clustco) visreg(lm_bayley_lang_clustco) #cognition lm_bayley_cog_clustco <- lm(avgclustco_both ~ child_sex + child_age_y3_mri_fun + avgweight + avg_FD_of_retained_frames + retained_frames+ bayley_cog_comp_y3, data=y3_data_only) summary(lm_bayley_cog_clustco) +confint(lm_bayley_cog_clustco) lm.beta(lm_bayley_cog_clustco) visreg(lm_bayley_cog_clustco) p.adjust(c(summary(lm_bayley_lang_clustco)$coefficients[7,4], summary(lm_bayley_cog_clustco)$coefficients[7,4])) @@ -525,6 +593,7 @@ p.adjust(c(summary(lm_bayley_lang_clustco)$coefficients[7,4], summary(lm_bayley_ ##when you control for SES, is this accounting for the effect or not? lm_bayley_lang_clustco <- lm(bayley_lang_comp_y3 ~ child_sex + disadv_prenatal + avgclustco_both, data=y3_data_only) summary(lm_bayley_lang_clustco) +confint(lm_bayley_lang_clustco) lm.beta(lm_bayley_lang_clustco) visreg(lm_bayley_lang_clustco) #clust co no longer significant when including disadvantage in the model, disadvantage also marginal @@ -533,12 +602,14 @@ visreg(lm_bayley_lang_clustco) #clust co no longer significant when including di lm_bayley_elang_clustco <- lm(avgclustco_both ~ child_sex + child_age_y3_mri_fun + avgweight + avg_FD_of_retained_frames + retained_frames+ bayley_elang_scale_y3, data=y3_data_only) lm.beta(lm_bayley_elang_clustco) summary(lm_bayley_elang_clustco) +confint(lm_bayley_elang_clustco) visreg(lm_bayley_elang_clustco, "bayley_elang_scale_y3") visreg(lm_bayley_elang_clustco, "bayley_elang_scale_y3",xlim=c(1,13)) ##when you control for SES, is this accounting for the effect or not? lm_bayley_elang_clustco <- lm(bayley_elang_scale_y3 ~ child_sex + avgclustco_both + disadv_prenatal, data=y3_data_only) summary(lm_bayley_elang_clustco) +confint(lm_bayley_elang_clustco) lm.beta(lm_bayley_elang_clustco) visreg(lm_bayley_elang_clustco) #clust co no longer significant when including disadvantage in the model, disadvantage also marginal visreg(lm_bayley_elang_clustco, "avgclustco_both") @@ -546,6 +617,7 @@ visreg(lm_bayley_elang_clustco, "avgclustco_both") ## Receptive lm_bayley_rlang_clustco <- lm(avgclustco_both ~ child_sex + child_age_y3_mri_fun + avgweight + avg_FD_of_retained_frames + retained_frames+ bayley_rlang_scale_y3, data=y3_data_only) lm.beta(lm_bayley_rlang_clustco) +confint(lm_bayley_rlang_clustco) summary(lm_bayley_rlang_clustco) visreg(lm_bayley_rlang_clustco) a <- visreg(lm_bayley_rlang_clustco, "bayley_rlang_scale_y3");plot(a) @@ -555,6 +627,7 @@ p.adjust(c(summary(lm_bayley_rlang_clustco)$coefficients[7,4], summary(lm_bayley ##when you control for SES, is this accounting for the effect or not? lm_bayley_rlang_clustco <- lm(bayley_rlang_scale_y3 ~ child_sex + avgclustco_both + disadv_prenatal, data=y3_data_only) summary(lm_bayley_rlang_clustco) +confint(lm_bayley_rlang_clustco) lm.beta(lm_bayley_rlang_clustco) visreg(lm_bayley_rlang_clustco, "avgclustco_both") diff --git a/sensitivity_analyses/sensitivity_analyses_revisions.R b/sensitivity_analyses/sensitivity_analyses_revisions.R index 53ecb09..c137447 100644 --- a/sensitivity_analyses/sensitivity_analyses_revisions.R +++ b/sensitivity_analyses/sensitivity_analyses_revisions.R @@ -62,6 +62,8 @@ demo_data <- left_join(demo_data, edu_income_prenatal, by= "modid") demo_data$income_needs_demo_b_log <- demo_data %>% dplyr::select(contains("LOG_")) %>% rowMeans(na.rm=T) demo_data$income_needs_demo_b_unlogged <- 10^(demo_data$income_needs_demo_b_log) +demo_data$LOG_IN1_unlogged <- 10^(demo_data$LOG_IN1);demo_data$LOG_IN2_unlogged <- 10^(demo_data$LOG_IN2);demo_data$LOG_IN3_unlogged <- 10^(demo_data$LOG_IN3); +demo_data$income_needs_demo_b_unlogged2 <- demo_data %>% dplyr::select(matches("LOG_IN[1-9]_unlogged")) %>% rowMeans(na.rm = T) #birth #0 – Less than high school 1 – Completed high school 2 – College graduate 3 – Advanced degree