Visualize distrubtions of brain variables:

brain_l <- brain %>%
  pivot_longer(
    cols = -subnum,            # Specify columns to pivot (all except subnum)
    names_to = "network_pair", # Name of the new column for variable names
    values_to = "value"        # Name of the new column for values
  )

ggplot(data = brain_l, aes(x = network_pair, y=value,fill=network_pair)) +
  geom_violin(alpha=.5) +
  geom_point(aes(color=network_pair), fill="black",shape=19,alpha=.65,position="jitter") +
  labs(y = "Connectivity", x = "Networks") +
  ggtitle("Within and Between Netowrk connectivity distributions") +
  theme_minimal() 

### Correlations between connectivity measures:

# Compute a correlation matrix
brain_corr <- cor(brain_sr_red[,c(2:7)])

# Compute a matrix of correlation p-values
brain_p.mat <- cor_pmat(brain_sr_red[,c(2:7)])

#Display Heatmap
ggcorrplot(brain_corr, hc.order = TRUE, type = "lower",
  outline.color = "white", insig = "blank",
  lab = TRUE, digits = 2)

ggplot(data = brain_sr_red, aes(x = SAL_SAL, y=SAL_DMN)) +
  geom_point(fill="skyblue4",shape=19,alpha=.75) +
  labs(y = "SAL - DMN connectivity", x = "SAL - SAL connectivity") +
  ggtitle(".5 correlation between sal-dmn and sal-sal connecitivity") +
  theme_minimal() 

Visualize the distrubtions of resting state cognition domains:

sr_l <- brain_sr_red[,c(1,44:50)] %>%
  pivot_longer(
    cols = -subnum,            # Specify columns to pivot (all except subnum)
    names_to = "thoughtdomain", # Name of the new column for variable names
    values_to = "value"        # Name of the new column for values
  )

ggplot(data = sr_l, aes(x = thoughtdomain, y=value,fill=thoughtdomain)) +
  geom_violin(alpha=.5) +
  geom_point(aes(color=thoughtdomain), fill="black",shape=19,alpha=.65,position="jitter") +
  labs(y = "Factor Score", x = "Thought Domains") +
  ggtitle("Resting State Thought Domain distributions") +
  theme_minimal()
## Warning: Removed 315 rows containing non-finite outside the scale range
## (`stat_ydensity()`).
## Warning: Removed 315 rows containing missing values or values outside the scale range
## (`geom_point()`).

# Compute a correlation matrix
sr_corr <- cor(brain_sr_red[,c(44:50)],use = "complete")

# Compute a matrix of correlation p-values
sr_p.mat <- cor_pmat(brain_sr_red[,c(44:50)])

#Display Heatmap
ggcorrplot(sr_corr, hc.order = TRUE, type = "lower",
  outline.color = "white", insig = "blank",
  lab = TRUE, digits = 2)

Models with FC as outcome:

Within Network

#Brain ~ TD1 ... TD7 + Age + SAB
dmn_win <- lm(DMN_DMN ~ sleepiness + self_other + comfort + visual_thought + self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
summary(dmn_win) 
## 
## Call:
## lm(formula = DMN_DMN ~ sleepiness + self_other + comfort + visual_thought + 
##     self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, 
##     data = brain_sr_red)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.051170 -0.026998 -0.009671  0.025015  0.086144 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)
## (Intercept)                    0.0678030  0.0636823   1.065    0.292
## sleepiness                     0.0047825  0.0068717   0.696    0.490
## self_other                     0.0032847  0.0077885   0.422    0.675
## comfort                        0.0001450  0.0070278   0.021    0.984
## visual_thought                -0.0066841  0.0067264  -0.994    0.325
## self_talk                      0.0004631  0.0066859   0.069    0.945
## ephemeral                      0.0001330  0.0074788   0.018    0.986
## somatic                        0.0047066  0.0078302   0.601    0.551
## AgeatMRI                      -0.0004415  0.0028990  -0.152    0.880
## GeneralInformation_SexAtBirth  0.0175467  0.0136667   1.284    0.205
## 
## Residual standard error: 0.03981 on 48 degrees of freedom
##   (155 observations deleted due to missingness)
## Multiple R-squared:  0.09165,    Adjusted R-squared:  -0.07867 
## F-statistic: 0.5381 on 9 and 48 DF,  p-value: 0.8394
fp_win <- lm(FP_FP ~ sleepiness + self_other + comfort + visual_thought + self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
summary(fp_win) 
## 
## Call:
## lm(formula = FP_FP ~ sleepiness + self_other + comfort + visual_thought + 
##     self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, 
##     data = brain_sr_red)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.101057 -0.045278 -0.009729  0.034283  0.144649 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)
## (Intercept)                    8.359e-02  1.041e-01   0.803    0.426
## sleepiness                    -2.218e-03  1.123e-02  -0.197    0.844
## self_other                     8.716e-03  1.273e-02   0.685    0.497
## comfort                        8.440e-03  1.149e-02   0.735    0.466
## visual_thought                -2.060e-03  1.100e-02  -0.187    0.852
## self_talk                     -1.064e-03  1.093e-02  -0.097    0.923
## ephemeral                     -2.612e-03  1.223e-02  -0.214    0.832
## somatic                        8.105e-03  1.280e-02   0.633    0.530
## AgeatMRI                       2.332e-05  4.740e-03   0.005    0.996
## GeneralInformation_SexAtBirth  2.655e-02  2.234e-02   1.188    0.241
## 
## Residual standard error: 0.06508 on 48 degrees of freedom
##   (155 observations deleted due to missingness)
## Multiple R-squared:  0.03962,    Adjusted R-squared:  -0.1405 
## F-statistic:  0.22 on 9 and 48 DF,  p-value: 0.9902
sal_win <- lm(SAL_SAL ~ sleepiness + self_other + comfort + visual_thought + self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
summary(sal_win) 
## 
## Call:
## lm(formula = SAL_SAL ~ sleepiness + self_other + comfort + visual_thought + 
##     self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, 
##     data = brain_sr_red)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.095748 -0.027877 -0.002153  0.025918  0.159472 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)  
## (Intercept)                    0.1780249  0.0826567   2.154   0.0363 *
## sleepiness                     0.0042285  0.0089191   0.474   0.6376  
## self_other                     0.0142181  0.0101091   1.406   0.1660  
## comfort                        0.0009873  0.0091218   0.108   0.9143  
## visual_thought                -0.0046916  0.0087305  -0.537   0.5935  
## self_talk                     -0.0110343  0.0086780  -1.272   0.2097  
## ephemeral                     -0.0017381  0.0097072  -0.179   0.8587  
## somatic                        0.0055976  0.0101632   0.551   0.5843  
## AgeatMRI                      -0.0035276  0.0037628  -0.937   0.3532  
## GeneralInformation_SexAtBirth  0.0042394  0.0177388   0.239   0.8121  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.05167 on 48 degrees of freedom
##   (155 observations deleted due to missingness)
## Multiple R-squared:  0.1051, Adjusted R-squared:  -0.06267 
## F-statistic: 0.6265 on 9 and 48 DF,  p-value: 0.7686

Between Network

dmn_fp <- lm(FP_DMN ~ sleepiness + self_other + comfort + visual_thought + self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
summary(dmn_fp) 
## 
## Call:
## lm(formula = FP_DMN ~ sleepiness + self_other + comfort + visual_thought + 
##     self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, 
##     data = brain_sr_red)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.101602 -0.014112  0.002437  0.016969  0.048497 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)  
## (Intercept)                   -0.0033728  0.0479833  -0.070   0.9443  
## sleepiness                     0.0055323  0.0051777   1.068   0.2906  
## self_other                    -0.0034000  0.0058685  -0.579   0.5650  
## comfort                        0.0014496  0.0052953   0.274   0.7854  
## visual_thought                 0.0003465  0.0050682   0.068   0.9458  
## self_talk                      0.0093473  0.0050377   1.855   0.0697 .
## ephemeral                     -0.0038896  0.0056352  -0.690   0.4934  
## somatic                       -0.0057243  0.0058999  -0.970   0.3368  
## AgeatMRI                      -0.0006764  0.0021843  -0.310   0.7581  
## GeneralInformation_SexAtBirth -0.0053639  0.0102976  -0.521   0.6048  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02999 on 48 degrees of freedom
##   (155 observations deleted due to missingness)
## Multiple R-squared:  0.1329, Adjusted R-squared:  -0.02967 
## F-statistic: 0.8175 on 9 and 48 DF,  p-value: 0.6028
fp_sal <- lm(SAL_FP ~ sleepiness + self_other + comfort + visual_thought + self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
summary(fp_sal) 
## 
## Call:
## lm(formula = SAL_FP ~ sleepiness + self_other + comfort + visual_thought + 
##     self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, 
##     data = brain_sr_red)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.075193 -0.015626 -0.001681  0.015252  0.068077 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)
## (Intercept)                    0.0464472  0.0494308   0.940    0.352
## sleepiness                     0.0037822  0.0053339   0.709    0.482
## self_other                    -0.0010928  0.0060455  -0.181    0.857
## comfort                        0.0002129  0.0054551   0.039    0.969
## visual_thought                -0.0065655  0.0052211  -1.257    0.215
## self_talk                     -0.0002003  0.0051896  -0.039    0.969
## ephemeral                      0.0004673  0.0058052   0.080    0.936
## somatic                        0.0048086  0.0060778   0.791    0.433
## AgeatMRI                      -0.0014194  0.0022502  -0.631    0.531
## GeneralInformation_SexAtBirth -0.0039365  0.0106083  -0.371    0.712
## 
## Residual standard error: 0.0309 on 48 degrees of freedom
##   (155 observations deleted due to missingness)
## Multiple R-squared:  0.09784,    Adjusted R-squared:  -0.07132 
## F-statistic: 0.5784 on 9 and 48 DF,  p-value: 0.8081
sal_dmn <- lm(SAL_DMN ~ sleepiness + self_other + comfort + visual_thought + self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
summary(sal_dmn) 
## 
## Call:
## lm(formula = SAL_DMN ~ sleepiness + self_other + comfort + visual_thought + 
##     self_talk + ephemeral + somatic + AgeatMRI + GeneralInformation_SexAtBirth, 
##     data = brain_sr_red)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.081294 -0.011442  0.004415  0.014590  0.055840 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)
## (Intercept)                   -0.0287258  0.0493698  -0.582    0.563
## sleepiness                    -0.0036234  0.0053273  -0.680    0.500
## self_other                    -0.0025579  0.0060381  -0.424    0.674
## comfort                       -0.0023398  0.0054483  -0.429    0.670
## visual_thought                 0.0043569  0.0052146   0.836    0.408
## self_talk                      0.0078546  0.0051832   1.515    0.136
## ephemeral                     -0.0042605  0.0057980  -0.735    0.466
## somatic                        0.0013662  0.0060703   0.225    0.823
## AgeatMRI                       0.0007032  0.0022475   0.313    0.756
## GeneralInformation_SexAtBirth -0.0065801  0.0105952  -0.621    0.538
## 
## Residual standard error: 0.03086 on 48 degrees of freedom
##   (155 observations deleted due to missingness)
## Multiple R-squared:  0.08551,    Adjusted R-squared:  -0.08596 
## F-statistic: 0.4987 on 9 and 48 DF,  p-value: 0.868

Alternative mdoel with thought domain as DV:

# sleepiness <- lm(sleepiness ~ DMN_DMN + FP_FP + SAL_SAL + FP_DMN + SAL_FP + SAL_DMN + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
# summary(sleepiness) 
# 
# selfother <- lm(self_other ~ DMN_DMN + FP_FP + SAL_SAL + FP_DMN + SAL_FP + SAL_DMN + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
# summary(selfother) 
# 
# comfort <- lm(comfort ~ DMN_DMN + FP_FP + SAL_SAL + FP_DMN + SAL_FP + SAL_DMN + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
# summary(comfort)
# 
# visual_thought <- lm(visual_thought ~ DMN_DMN + FP_FP + SAL_SAL + FP_DMN + SAL_FP + SAL_DMN + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
# summary(visual_thought)
# 
# selftalk <- lm(self_talk ~ DMN_DMN + FP_FP + SAL_SAL + FP_DMN + SAL_FP + SAL_DMN + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
# summary(selftalk)
# 
# ephemeral <- lm(ephemeral ~ DMN_DMN + FP_FP + SAL_SAL + FP_DMN + SAL_FP + SAL_DMN + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
# summary(ephemeral)
# 
# somatic <- lm(somatic ~ DMN_DMN + FP_FP + SAL_SAL + FP_DMN + SAL_FP + SAL_DMN + AgeatMRI + GeneralInformation_SexAtBirth, data=brain_sr_red)
# summary(somatic)