Statistics & Data Visualizaition for Brainlinks T1 COSY paper (2020)

By Philip Brandner September 2020

Table of Contents

In [1]:
# Import necessary libaries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import ppscore as pps
import seaborn as sns
import dabest
import scipy as sp
import scipy.stats as stats
import pingouin as pg


%matplotlib inline
In [2]:
pg.__version__
Out[2]:
'0.3.8'
In [3]:
sns.__version__
Out[3]:
'0.11.0'
In [4]:
!git clone https://github.com/psinger/CorrelationStats.git
fatal: destination path 'CorrelationStats' already exists and is not an empty directory.
In [5]:
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')
/Users/philipb/anaconda3/lib/python3.7/site-packages/outdated/utils.py:18: OutdatedPackageWarning: The package outdated is out of date. Your version is 0.2.0, the latest is 0.2.1.
Set the environment variable OUTDATED_IGNORE=1 to disable these warnings.
  **kwargs
/Users/philipb/anaconda3/lib/python3.7/site-packages/outdated/utils.py:18: OutdatedPackageWarning: The package pingouin is out of date. Your version is 0.3.8, the latest is 0.3.11.
Set the environment variable OUTDATED_IGNORE=1 to disable these warnings.
  **kwargs
In [6]:
# let's import the data CSV file

df = pd.read_csv('/Users/philipb/surfdrive/PhD/Writing/02_COSY_T1/behavior/T1_MASTER_all_2020.csv')
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 140 entries, 0 to 139
Data columns (total 43 columns):
 #   Column                     Non-Null Count  Dtype  
---  ------                     --------------  -----  
 0   PPN                        140 non-null    object 
 1   gender                     140 non-null    object 
 2   age                        140 non-null    float64
 3   age2                       140 non-null    float64
 4   LW_self                    139 non-null    float64
 5   LW_mother                  139 non-null    float64
 6   LW_father                  139 non-null    float64
 7   LW_stranger                139 non-null    float64
 8   PD_Cooperations            92 non-null     float64
 9   SD_Cooperations            92 non-null     float64
 10  PD_cooperations_mother     92 non-null     float64
 11  PD_cooperations_father     92 non-null     float64
 12  PD_cooperations_stranger   92 non-null     float64
 13  SD_cooperations_mother     92 non-null     float64
 14  SD_cooperations_father     92 non-null     float64
 15  SD_cooperations_stranger   92 non-null     float64
 16  PTM                        128 non-null    float64
 17  IRI_EM                     128 non-null    float64
 18  IRI_PT                     128 non-null    float64
 19  FATHER_self2other2         140 non-null    object 
 20  FATHER_self0other4         140 non-null    object 
 21  FATHER_self4other0         140 non-null    object 
 22  FATHER_bothnogain          140 non-null    object 
 23  MOTHER_self2other2         140 non-null    object 
 24  MOTHER_self0other4         140 non-null    object 
 25  MOTHER_self4other0         140 non-null    object 
 26  MOTHER_bothnogain          140 non-null    object 
 27  STRANGER_self2other2       140 non-null    object 
 28  STRANGER_self0other4       140 non-null    object 
 29  STRANGER_self4other0       140 non-null    object 
 30  STRANGER_bothnogain        140 non-null    object 
 31  MPFC_FATHER_self2other2    130 non-null    float64
 32  MPFC_FATHER_self0other4    130 non-null    float64
 33  MPFC_FATHER_self4other0    130 non-null    float64
 34  MPFC_FATHER_bothnogain     130 non-null    float64
 35  MPFC_MOTHER_self2other2    130 non-null    float64
 36  MPFC_MOTHER_self0other4    130 non-null    float64
 37  MPFC_MOTHER_self4other0    130 non-null    float64
 38  MPFC_MOTHER_bothnogain     130 non-null    float64
 39  MPFC_STRANGER_self2other2  130 non-null    float64
 40  MPFC_STRANGER_self0other4  130 non-null    float64
 41  MPFC_STRANGER_self4other0  130 non-null    float64
 42  MPFC_STRANGER_bothnogain   130 non-null    float64
dtypes: float64(29), object(14)
memory usage: 47.2+ KB
In [7]:
df_faces = pd.read_csv('/Users/philipb/surfdrive/PhD/BRAINLINKS/T1/data/T1_FACES_final.csv')
df_faces
Out[7]:
Unnamed: 0 PPN cohesion_dim flexibility_dim
0 0 BL1P065 140.0 130.0
1 1 BL1P066 60.5 135.0
2 2 BL1P067 72.0 73.5
3 3 BL1P068 101.0 117.0
4 4 BL1P070 132.0 79.5
... ... ... ... ...
123 131 BL1P212 111.0 41.0
124 132 BL1P213 56.0 51.0
125 133 BL1P215 87.0 72.5
126 134 BL1P217 68.5 87.0
127 135 BL1P260 105.0 118.0

128 rows × 4 columns

In [8]:
#Let's join data from the FACES dataframe
# https://datacarpentry.org/python-ecology-lesson/05-merging-data/index.html

df = pd.merge(left=df, right=df_faces,how='left',left_on='PPN',right_on="PPN")
df.drop(['Unnamed: 0'],axis=1,inplace=True)
In [9]:
df_hexaco = pd.read_csv('/Users/philipb/surfdrive/PhD/BRAINLINKS/T1/Vragenlijsten/T1_HEXACO_scored.csv')
df_hexaco
Out[9]:
Unnamed: 0 PPN altruism honesty emotionality extraversion agreeableness conscientiousness openness
0 1 BL1P065 3.00 4.642857 2.4375 2.3125 2.6875 3.3750 2.666667
1 4 BL1P066 3.00 4.000000 3.5625 2.8750 3.5625 3.8750 3.000000
2 5 BL1P067 2.75 3.500000 2.5625 3.2500 2.8750 3.0625 2.000000
3 6 BL1P068 3.25 4.000000 3.9375 3.6250 3.4375 3.0000 3.400000
4 7 BL1P070 3.00 2.000000 1.8125 3.3750 3.6250 3.2500 2.800000
... ... ... ... ... ... ... ... ... ...
107 109 BL1P211 2.50 3.428571 3.1875 3.6875 3.5625 3.4375 3.333333
108 3 BL1P212 3.50 3.500000 3.7500 2.3125 2.8750 3.6250 3.600000
109 110 BL1P213 3.00 2.571429 2.1875 4.3125 3.3750 4.1875 2.666667
110 111 BL1P213 2.50 2.214286 2.1250 4.3125 2.9375 4.0000 3.266667
111 112 BL1P215 3.00 3.142857 2.2500 3.0625 3.5625 3.1250 3.600000

112 rows × 9 columns

In [10]:
df = pd.merge(left=df, right=df_hexaco,how='left',left_on='PPN',right_on='PPN')
df.drop(['Unnamed: 0'],axis=1,inplace=True)
In [11]:
df['FATHER_self2other2'] = df.FATHER_self2other2.astype(float)
df['FATHER_self4other0'] = df.FATHER_self4other0.astype(float)
df['FATHER_self0other4'] = df.FATHER_self0other4.astype(float)
df['FATHER_bothnogain'] = df.FATHER_bothnogain.astype(float)

df['MOTHER_self2other2'] = df.MOTHER_self2other2.astype(float)
df['MOTHER_self4other0'] = df.MOTHER_self4other0.astype(float)
df['MOTHER_self0other4'] = df.MOTHER_self0other4.astype(float)
df['MOTHER_bothnogain'] = df.MOTHER_bothnogain.astype(float)

df['STRANGER_self2other2'] = df.STRANGER_self2other2.astype(float)
df['STRANGER_self4other0'] = df.STRANGER_self4other0.astype(float)
df['STRANGER_self0other4'] = df.STRANGER_self0other4.astype(float)
df['STRANGER_bothnogain'] = df.STRANGER_bothnogain.astype(float)

Mean values for bothnogain

  • FATHER_bothnogain -1.786401
  • MOTHER_bothnogain -1.692383
  • STRANGER_bothnogain -1.925077
In [12]:
df['nacc_average_nogain'] = df[['MOTHER_bothnogain','FATHER_bothnogain','STRANGER_bothnogain']].mean(axis=1)
df['nacc_average_nogain'].hist()
Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc1cc59ab00>
In [13]:
df['mpfc_average_nogain'] = df[['MPFC_MOTHER_bothnogain','MPFC_FATHER_bothnogain','MPFC_STRANGER_bothnogain']].mean(axis=1)
df['mpfc_average_nogain'].hist()
Out[13]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc1cc45bf60>
In [14]:
# Normalize NAcc ROI results against baseline of both-nowin


df['FATHER_self4other0'] = df['FATHER_self4other0'] - df['nacc_average_nogain']
df['FATHER_self0other4'] = df['FATHER_self0other4'] - df['nacc_average_nogain']
df['FATHER_self2other2'] = df['FATHER_self2other2'] - df['nacc_average_nogain']

df['MOTHER_self4other0'] = df['MOTHER_self4other0'] - df['nacc_average_nogain']
df['MOTHER_self0other4'] = df['MOTHER_self0other4'] - df['nacc_average_nogain']
df['MOTHER_self2other2'] = df['MOTHER_self2other2'] - df['nacc_average_nogain']

df['STRANGER_self4other0'] = df['STRANGER_self4other0'] - df['nacc_average_nogain']
df['STRANGER_self0other4'] = df['STRANGER_self0other4'] - df['nacc_average_nogain']
df['STRANGER_self2other2'] = df['STRANGER_self2other2'] - df['nacc_average_nogain']


# normalize MPFC results against baseline of both-win

df['MPFC_FATHER_self4other0'] = df['MPFC_FATHER_self4other0'] - df['mpfc_average_nogain']
df['MPFC_FATHER_self0other4'] = df['MPFC_FATHER_self0other4'] - df['mpfc_average_nogain']
df['MPFC_FATHER_self2other2'] = df['MPFC_FATHER_self2other2'] - df['mpfc_average_nogain']

df['MPFC_MOTHER_self4other0'] = df['MPFC_MOTHER_self4other0'] - df['mpfc_average_nogain']
df['MPFC_MOTHER_self0other4'] = df['MPFC_MOTHER_self0other4'] - df['mpfc_average_nogain']
df['MPFC_MOTHER_self2other2'] = df['MPFC_MOTHER_self2other2'] - df['mpfc_average_nogain']

df['MPFC_STRANGER_self4other0'] = df['MPFC_STRANGER_self4other0'] - df['mpfc_average_nogain']
df['MPFC_STRANGER_self0other4'] = df['MPFC_STRANGER_self0other4'] - df['mpfc_average_nogain']
df['MPFC_STRANGER_self2other2'] = df['MPFC_STRANGER_self2other2'] - df['mpfc_average_nogain']


df.head()
Out[14]:
PPN gender age age2 LW_self LW_mother LW_father LW_stranger PD_Cooperations SD_Cooperations ... flexibility_dim altruism honesty emotionality extraversion agreeableness conscientiousness openness nacc_average_nogain mpfc_average_nogain
0 BL1P065 female 16.8 0.364828 3.0 4.0 4.0 3.0 NaN NaN ... 130.0 3.00 4.642857 2.4375 2.3125 2.6875 3.3750 2.666667 -6.068067 -6.874933
1 BL1P066 female 17.2 0.502759 5.0 5.0 5.0 5.0 NaN NaN ... 135.0 3.00 4.000000 3.5625 2.8750 3.5625 3.8750 3.000000 -6.579900 -9.552067
2 BL1P067 male 16.9 0.397241 7.0 6.0 6.0 2.0 0.0 17.0 ... 73.5 2.75 3.500000 2.5625 3.2500 2.8750 3.0625 2.000000 -2.969067 -4.578033
3 BL1P068 female 14.3 0.002759 5.0 6.0 6.0 5.0 18.0 17.0 ... 117.0 3.25 4.000000 3.9375 3.6250 3.4375 3.0000 3.400000 -1.585900 -3.689233
4 BL1P071 male 17.8 0.751034 6.0 6.0 5.0 3.0 NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN -3.818200 -4.680967

5 rows × 54 columns

In [15]:
tidy_nacc_nowin_stranger = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['STRANGER_self0other4','STRANGER_bothnogain'],
               value_name='NAcc')

# Rename new column
tidy_nacc_nowin_stranger.rename(columns={'variable':'NAcc_target'},inplace=True)

# Duplicate
tidy_nacc_nowin_stranger['NAcc_outcome'] = tidy_nacc_nowin_stranger['NAcc_target']

# Now delete the duplicate information for both newly created column variables

tidy_nacc_nowin_stranger['NAcc_target'] = tidy_nacc_nowin_stranger['NAcc_target'].str.replace('STRANGER_self0other4','stranger')
tidy_nacc_nowin_stranger['NAcc_target'] = tidy_nacc_nowin_stranger['NAcc_target'].str.replace('STRANGER_bothnogain','stranger')

tidy_nacc_nowin_stranger['NAcc_outcome'] = tidy_nacc_nowin_stranger['NAcc_outcome'].str.replace('STRANGER_self0other4','otherwin')

tidy_nacc_nowin_stranger['NAcc_outcome'] = tidy_nacc_nowin_stranger['NAcc_outcome'].str.replace('STRANGER_bothnogain','nowin')

# Rearange the columns order
tidy_nacc_nowin_stranger = tidy_nacc_nowin_stranger[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT',
             'NAcc_target','NAcc_outcome','NAcc']]


tidy_nacc_nowin_stranger.head()
Out[15]:
PPN gender age age2 PTM IRI_EM IRI_PT NAcc_target NAcc_outcome NAcc
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 stranger otherwin 1.070967
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 stranger otherwin -0.217100
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 stranger otherwin 0.422867
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN stranger otherwin -1.322600
4 BL1P071 male 17.8 0.751034 NaN NaN NaN stranger otherwin 7.124400
In [16]:
tidy_nacc_nowin = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['FATHER_self4other0','FATHER_bothnogain',
                          'MOTHER_self4other0','MOTHER_bothnogain',
                          'STRANGER_self4other0','STRANGER_bothnogain'],
               value_name='NAcc')

# Rename new column
tidy_nacc_nowin.rename(columns={'variable':'NAcc_target'},inplace=True)

# Duplicate
tidy_nacc_nowin['NAcc_outcome'] = tidy_nacc_nowin['NAcc_target']

# Now delete the duplicate information for both newly created column variables
tidy_nacc_nowin['NAcc_target'] = tidy_nacc_nowin['NAcc_target'].str.replace('FATHER_self4other0','father')
tidy_nacc_nowin['NAcc_target'] = tidy_nacc_nowin['NAcc_target'].str.replace('FATHER_bothnogain','father')

tidy_nacc_nowin['NAcc_target'] = tidy_nacc_nowin['NAcc_target'].str.replace('MOTHER_self4other0','mother')
tidy_nacc_nowin['NAcc_target'] = tidy_nacc_nowin['NAcc_target'].str.replace('MOTHER_bothnogain','mother')

tidy_nacc_nowin['NAcc_target'] = tidy_nacc_nowin['NAcc_target'].str.replace('STRANGER_self4other0','stranger')
tidy_nacc_nowin['NAcc_target'] = tidy_nacc_nowin['NAcc_target'].str.replace('STRANGER_bothnogain','stranger')

tidy_nacc_nowin['NAcc_outcome'] = tidy_nacc_nowin['NAcc_outcome'].str.replace('FATHER_self4other0','selfwin')
tidy_nacc_nowin['NAcc_outcome'] = tidy_nacc_nowin['NAcc_outcome'].str.replace('MOTHER_self4other0','selfwin')
tidy_nacc_nowin['NAcc_outcome'] = tidy_nacc_nowin['NAcc_outcome'].str.replace('STRANGER_self4other0','selfwin')

tidy_nacc_nowin['NAcc_outcome'] = tidy_nacc_nowin['NAcc_outcome'].str.replace('FATHER_bothnogain','nowin')
tidy_nacc_nowin['NAcc_outcome'] = tidy_nacc_nowin['NAcc_outcome'].str.replace('MOTHER_bothnogain','nowin')
tidy_nacc_nowin['NAcc_outcome'] = tidy_nacc_nowin['NAcc_outcome'].str.replace('STRANGER_bothnogain','nowin')

# Rearange the columns order
tidy_nacc_nowin = tidy_nacc_nowin[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT',
             'NAcc_target','NAcc_outcome','NAcc']]


tidy_nacc_nowin.head()
Out[16]:
PPN gender age age2 PTM IRI_EM IRI_PT NAcc_target NAcc_outcome NAcc
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father selfwin 3.303667
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father selfwin 2.025500
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father selfwin 4.298567
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father selfwin 0.799700
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father selfwin 6.056600
In [17]:
tidy_nacc_self = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['FATHER_self4other0',
                          'MOTHER_self4other0',
                          'STRANGER_self4other0'],
               value_name='NAcc')

# Rename new column
tidy_nacc_self.rename(columns={'variable':'NAcc_target'},inplace=True)

# Duplicate
tidy_nacc_self['NAcc_outcome'] = tidy_nacc_self['NAcc_target']

# Now delete the duplicate information for both newly created column variables
tidy_nacc_self['NAcc_target'] = tidy_nacc_self['NAcc_target'].str.replace('FATHER_self4other0','father')

tidy_nacc_self['NAcc_target'] = tidy_nacc_self['NAcc_target'].str.replace('MOTHER_self4other0','mother')

tidy_nacc_self['NAcc_target'] = tidy_nacc_self['NAcc_target'].str.replace('STRANGER_self4other0','stranger')

tidy_nacc_self['NAcc_outcome'] = tidy_nacc_self['NAcc_outcome'].str.replace('FATHER_self4other0','selfwin')
tidy_nacc_self['NAcc_outcome'] = tidy_nacc_self['NAcc_outcome'].str.replace('MOTHER_self4other0','selfwin')
tidy_nacc_self['NAcc_outcome'] = tidy_nacc_self['NAcc_outcome'].str.replace('STRANGER_self4other0','selfwin')



# Rearange the columns order
tidy_nacc_self = tidy_nacc_self[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT',
             'NAcc_target','NAcc_outcome','NAcc']]


tidy_nacc_self.head()
Out[17]:
PPN gender age age2 PTM IRI_EM IRI_PT NAcc_target NAcc_outcome NAcc
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father selfwin 3.303667
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father selfwin 2.025500
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father selfwin 4.298567
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father selfwin 0.799700
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father selfwin 6.056600
In [18]:
tidy_nacc_both = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['FATHER_self2other2',
                          'MOTHER_self2other2',
                          'STRANGER_self2other2'],
               value_name='NAcc')

# Rename new column
tidy_nacc_both.rename(columns={'variable':'NAcc_target'},inplace=True)

# Duplicate
tidy_nacc_both['NAcc_outcome'] = tidy_nacc_both['NAcc_target']

# Now delete the duplicate information for both newly created column variables
tidy_nacc_both['NAcc_target'] = tidy_nacc_both['NAcc_target'].str.replace('FATHER_self2other2','father')

tidy_nacc_both['NAcc_target'] = tidy_nacc_both['NAcc_target'].str.replace('MOTHER_self2other2','mother')

tidy_nacc_both['NAcc_target'] = tidy_nacc_both['NAcc_target'].str.replace('STRANGER_self2other2','stranger')

tidy_nacc_both['NAcc_outcome'] = tidy_nacc_both['NAcc_outcome'].str.replace('FATHER_self2other2','bothwin')
tidy_nacc_both['NAcc_outcome'] = tidy_nacc_both['NAcc_outcome'].str.replace('MOTHER_self2other2','bothwin')
tidy_nacc_both['NAcc_outcome'] = tidy_nacc_both['NAcc_outcome'].str.replace('STRANGER_self2other2','bothwin')



# Rearange the columns order
tidy_nacc_both = tidy_nacc_both[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT',
             'NAcc_target','NAcc_outcome','NAcc']]


tidy_nacc_both.head()
Out[18]:
PPN gender age age2 PTM IRI_EM IRI_PT NAcc_target NAcc_outcome NAcc
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father bothwin 6.320367
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father bothwin 4.112300
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father bothwin 0.311067
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father bothwin -3.108800
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father bothwin 5.771400
In [19]:
tidy_nacc = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['FATHER_self4other0','FATHER_self2other2','FATHER_self0other4',
                          'MOTHER_self4other0','MOTHER_self2other2','MOTHER_self0other4',
                          'STRANGER_self4other0','STRANGER_self2other2','STRANGER_self0other4'],
               value_name='NAcc')

# Rename new column
tidy_nacc.rename(columns={'variable':'NAcc_target'},inplace=True)

# Duplicate
tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_target']

# Now delete the duplicate information for both newly created column variables
tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('FATHER_self4other0','father')
tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('FATHER_self0other4','father')
tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('FATHER_self2other2','father')


tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('MOTHER_self4other0','mother')
tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('MOTHER_self0other4','mother')
tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('MOTHER_self2other2','mother')


tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('STRANGER_self4other0','stranger')
tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('STRANGER_self0other4','stranger')
tidy_nacc['NAcc_target'] = tidy_nacc['NAcc_target'].str.replace('STRANGER_self2other2','stranger')


tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('FATHER_self4other0','selfwin')
tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('MOTHER_self4other0','selfwin')
tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('STRANGER_self4other0','selfwin')

tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('FATHER_self2other2','bothwin')
tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('MOTHER_self2other2','bothwin')
tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('STRANGER_self2other2','bothwin')

tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('FATHER_self0other4','otherwin')
tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('MOTHER_self0other4','otherwin')
tidy_nacc['NAcc_outcome'] = tidy_nacc['NAcc_outcome'].str.replace('STRANGER_self0other4','otherwin')


# Rearange the columns order
tidy_nacc = tidy_nacc[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT',
             'NAcc_target','NAcc_outcome','NAcc']]


tidy_nacc.head()
Out[19]:
PPN gender age age2 PTM IRI_EM IRI_PT NAcc_target NAcc_outcome NAcc
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father selfwin 3.303667
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father selfwin 2.025500
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father selfwin 4.298567
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father selfwin 0.799700
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father selfwin 6.056600
In [28]:
tidy_mpfc = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['MPFC_FATHER_self4other0','MPFC_FATHER_self2other2','MPFC_FATHER_self0other4',
                          'MPFC_MOTHER_self4other0','MPFC_MOTHER_self2other2','MPFC_MOTHER_self0other4',
                          'MPFC_STRANGER_self4other0','MPFC_STRANGER_self2other2','MPFC_STRANGER_self0other4'],
               value_name='vmPFC')

# Rename new column
tidy_mpfc.rename(columns={'variable':'vmPFC_target'},inplace=True)

# Duplicate
tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_target']

# Now delete the duplicate information for both newly created column variables
tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_FATHER_self4other0','father')
tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_FATHER_self0other4','father')
tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_FATHER_self2other2','father')


tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_MOTHER_self4other0','mother')
tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_MOTHER_self0other4','mother')
tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_MOTHER_self2other2','mother')


tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_STRANGER_self4other0','stranger')
tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_STRANGER_self0other4','stranger')
tidy_mpfc['vmPFC_target'] = tidy_mpfc['vmPFC_target'].str.replace('MPFC_STRANGER_self2other2','stranger')


tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_FATHER_self4other0','selfwin')
tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_MOTHER_self4other0','selfwin')
tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_STRANGER_self4other0','selfwin')

tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_FATHER_self2other2','bothwin')
tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_MOTHER_self2other2','bothwin')
tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_STRANGER_self2other2','bothwin')

tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_FATHER_self0other4','otherwin')
tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_MOTHER_self0other4','otherwin')
tidy_mpfc['vmPFC_outcome'] = tidy_mpfc['vmPFC_outcome'].str.replace('MPFC_STRANGER_self0other4','otherwin')


# Rearange the columns order
tidy_mpfc = tidy_mpfc[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT',
             'vmPFC_target','vmPFC_outcome','vmPFC']]


tidy_mpfc.head()
Out[28]:
PPN gender age age2 PTM IRI_EM IRI_PT vmPFC_target vmPFC_outcome vmPFC
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father selfwin -1.220267
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father selfwin 3.037767
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father selfwin 5.042333
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father selfwin -4.594867
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father selfwin 9.060267
In [29]:
tidy_mPFC_self = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['MPFC_FATHER_self4other0',
                          'MPFC_MOTHER_self4other0',
                          'MPFC_STRANGER_self4other0'],
               value_name='vmPFC')

# Rename new column
tidy_mPFC_self.rename(columns={'variable':'vmPFC_target'},inplace=True)

# Duplicate
tidy_mPFC_self['vmPFC_outcome'] = tidy_mPFC_self['vmPFC_target']

# Now delete the duplicate information for both newly created column variables
tidy_mPFC_self['vmPFC_target'] = tidy_mPFC_self['vmPFC_target'].str.replace('MPFC_FATHER_self4other0','father')

tidy_mPFC_self['vmPFC_target'] = tidy_mPFC_self['vmPFC_target'].str.replace('MPFC_MOTHER_self4other0','mother')

tidy_mPFC_self['vmPFC_target'] = tidy_mPFC_self['vmPFC_target'].str.replace('MPFC_STRANGER_self4other0','stranger')

tidy_mPFC_self['vmPFC_outcome'] = tidy_mPFC_self['vmPFC_outcome'].str.replace('MPFC_FATHER_self4other0','selfwin')
tidy_mPFC_self['vmPFC_outcome'] = tidy_mPFC_self['vmPFC_outcome'].str.replace('MPFC_MOTHER_self4other0','selfwin')
tidy_mPFC_self['vmPFC_outcome'] = tidy_mPFC_self['vmPFC_outcome'].str.replace('MPFC_STRANGER_self4other0','selfwin')



# Rearange the columns order
tidy_mPFC_self = tidy_mPFC_self[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT','vmPFC_target','vmPFC_outcome','vmPFC']]


tidy_mPFC_self.head()
Out[29]:
PPN gender age age2 PTM IRI_EM IRI_PT vmPFC_target vmPFC_outcome vmPFC
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father selfwin -1.220267
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father selfwin 3.037767
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father selfwin 5.042333
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father selfwin -4.594867
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father selfwin 9.060267
In [31]:
tidy_mPFC_both = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['MPFC_FATHER_self2other2',
                          'MPFC_MOTHER_self2other2',
                          'MPFC_STRANGER_self2other2'],
               value_name='vmPFC')

# Rename new column
tidy_mPFC_both.rename(columns={'variable':'vmPFC_target'},inplace=True)

# Duplicate
tidy_mPFC_both['vmPFC_outcome'] = tidy_mPFC_both['vmPFC_target']

# Now delete the duplicate information for both newly created column variables
tidy_mPFC_both['vmPFC_target'] = tidy_mPFC_both['vmPFC_target'].str.replace('MPFC_FATHER_self2other2','father')

tidy_mPFC_both['vmPFC_target'] = tidy_mPFC_both['vmPFC_target'].str.replace('MPFC_MOTHER_self2other2','mother')

tidy_mPFC_both['vmPFC_target'] = tidy_mPFC_both['vmPFC_target'].str.replace('MPFC_STRANGER_self2other2','stranger')

tidy_mPFC_both['vmPFC_outcome'] = tidy_mPFC_both['vmPFC_outcome'].str.replace('MPFC_FATHER_self2other2','selfwin')
tidy_mPFC_both['vmPFC_outcome'] = tidy_mPFC_both['vmPFC_outcome'].str.replace('MPFC_MOTHER_self2other2','selfwin')
tidy_mPFC_both['vmPFC_outcome'] = tidy_mPFC_both['vmPFC_outcome'].str.replace('MPFC_STRANGER_self2other2','selfwin')



# Rearange the columns order
tidy_mPFC_both = tidy_mPFC_both[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT','vmPFC_target','vmPFC_outcome','vmPFC']]


tidy_mPFC_both.head()
Out[31]:
PPN gender age age2 PTM IRI_EM IRI_PT vmPFC_target vmPFC_outcome vmPFC
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father selfwin 6.006233
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father selfwin 5.014967
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father selfwin 4.544233
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father selfwin -3.253067
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father selfwin 7.078267
In [32]:
tidy_mPFC_other = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['MPFC_FATHER_self0other4',
                          'MPFC_MOTHER_self0other4',
                          'MPFC_STRANGER_self0other4'],
               value_name='vmPFC')

# Rename new column
tidy_mPFC_other.rename(columns={'variable':'vmPFC_target'},inplace=True)

# Duplicate
tidy_mPFC_other['vmPFC_outcome'] = tidy_mPFC_other['vmPFC_target']

# Now delete the duplicate information for both newly created column variables
tidy_mPFC_other['vmPFC_target'] = tidy_mPFC_other['vmPFC_target'].str.replace('MPFC_FATHER_self0other4','father')

tidy_mPFC_other['vmPFC_target'] = tidy_mPFC_other['vmPFC_target'].str.replace('MPFC_MOTHER_self0other4','mother')

tidy_mPFC_other['vmPFC_target'] = tidy_mPFC_other['vmPFC_target'].str.replace('MPFC_STRANGER_self0other4','stranger')

tidy_mPFC_other['vmPFC_outcome'] = tidy_mPFC_other['vmPFC_outcome'].str.replace('MPFC_FATHER_self0other4','selfwin')
tidy_mPFC_other['vmPFC_outcome'] = tidy_mPFC_other['vmPFC_outcome'].str.replace('MPFC_MOTHER_self0other4','selfwin')
tidy_mPFC_other['vmPFC_outcome'] = tidy_mPFC_other['vmPFC_outcome'].str.replace('MPFC_STRANGER_self0other4','selfwin')



# Rearange the columns order
tidy_mPFC_other = tidy_mPFC_other[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT','vmPFC_target','vmPFC_outcome','vmPFC']]


tidy_mPFC_other.head()
Out[32]:
PPN gender age age2 PTM IRI_EM IRI_PT vmPFC_target vmPFC_outcome vmPFC
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father selfwin 2.656433
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father selfwin 1.098167
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father selfwin 6.457233
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father selfwin 3.010433
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father selfwin 4.395567
In [24]:
tidy_nacc_other = pd.melt(df.reset_index(),
              id_vars=['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT'],
              value_vars=['FATHER_self0other4',
                          'MOTHER_self0other4',
                          'STRANGER_self0other4'],
               value_name='NAcc')

# Rename new column
tidy_nacc_other.rename(columns={'variable':'NAcc_target'},inplace=True)

# Duplicate
tidy_nacc_other['NAcc_outcome'] = tidy_nacc_other['NAcc_target']

# Now delete the duplicate information for both newly created column variables
tidy_nacc_other['NAcc_target'] = tidy_nacc_other['NAcc_target'].str.replace('FATHER_self0other4','father')

tidy_nacc_other['NAcc_target'] = tidy_nacc_other['NAcc_target'].str.replace('MOTHER_self0other4','mother')

tidy_nacc_other['NAcc_target'] = tidy_nacc_other['NAcc_target'].str.replace('STRANGER_self0other4','stranger')

tidy_nacc_other['NAcc_outcome'] = tidy_nacc_other['NAcc_outcome'].str.replace('FATHER_self0other4','otherwin')
tidy_nacc_other['NAcc_outcome'] = tidy_nacc_other['NAcc_outcome'].str.replace('MOTHER_self0other4','otherwin')
tidy_nacc_other['NAcc_outcome'] = tidy_nacc_other['NAcc_outcome'].str.replace('STRANGER_self0other4','otherwin')


# Rearange the columns order
tidy_nacc_other = tidy_nacc_other[['PPN','gender','age','age2','PTM','IRI_EM','IRI_PT',
             'NAcc_target','NAcc','NAcc_outcome']]


tidy_nacc_other.head()
Out[24]:
PPN gender age age2 PTM IRI_EM IRI_PT NAcc_target NAcc NAcc_outcome
0 BL1P065 female 16.8 0.364828 0.4 3.2 4.3 father -0.058533 otherwin
1 BL1P066 female 17.2 0.502759 3.1 2.8 3.7 father 3.701300 otherwin
2 BL1P067 male 16.9 0.397241 -4.1 3.5 3.3 father 4.881967 otherwin
3 BL1P068 female 14.3 0.002759 4.6 NaN NaN father 0.144700 otherwin
4 BL1P071 male 17.8 0.751034 NaN NaN NaN father 4.592100 otherwin
In [25]:
# Create a tidy dataset using MELT function 


tidy = pd.melt(df.reset_index(),
                  id_vars=['PPN','gender','age','age2','PD_Cooperations','SD_Cooperations','PTM','IRI_EM','IRI_PT','LW_self','LW_mother','LW_father','LW_stranger',
                           'FATHER_self2other2','FATHER_self4other0','FATHER_self0other4','FATHER_bothnogain',
                          'MOTHER_self2other2','MOTHER_self4other0','MOTHER_self0other4','MOTHER_bothnogain',
                          'STRANGER_self2other2','STRANGER_self4other0','STRANGER_self0other4','STRANGER_bothnogain'],
                  value_vars=['PD_cooperations_mother','PD_cooperations_father','PD_cooperations_stranger',
                             'SD_cooperations_mother','SD_cooperations_father','SD_cooperations_stranger'],
                  value_name='PD')

# Rename Column that has just been created
tidy.rename(columns={'variable': 'PD_target'}, inplace=True)
tidy.rename(columns={'PD_Cooperations': 'PD_total'}, inplace=True)
tidy.rename(columns={'SD_Cooperations': 'SD_total'}, inplace=True)


# Duplicate that column to create a TARGET variable 
tidy['PD_context'] = tidy['PD_target']


# Now delete the duplicate information for both newly created column variables
tidy['PD_target'] = tidy['PD_target'].str.replace('PD_cooperations_mother','mother')
tidy['PD_target'] = tidy['PD_target'].str.replace('PD_cooperations_father','father')
tidy['PD_target'] = tidy['PD_target'].str.replace('PD_cooperations_stranger','stranger')
tidy['PD_target'] = tidy['PD_target'].str.replace('SD_cooperations_mother','mother')
tidy['PD_target'] = tidy['PD_target'].str.replace('SD_cooperations_father','father')
tidy['PD_target'] = tidy['PD_target'].str.replace('SD_cooperations_stranger','stranger')

# Now delete the duplicate information for both newly created column variables
tidy['PD_context'] = tidy['PD_context'].str.replace('PD_cooperations_mother','PD')
tidy['PD_context'] = tidy['PD_context'].str.replace('PD_cooperations_father','PD')
tidy['PD_context'] = tidy['PD_context'].str.replace('PD_cooperations_stranger','PD')
tidy['PD_context'] = tidy['PD_context'].str.replace('SD_cooperations_mother','SD')
tidy['PD_context'] = tidy['PD_context'].str.replace('SD_cooperations_father','SD')
tidy['PD_context'] = tidy['PD_context'].str.replace('SD_cooperations_stranger','SD')

# Rearange the columns order
tidy = tidy[['PPN','gender','age','age2','PD_total','SD_total','PTM','IRI_EM','IRI_PT','LW_self',
             'LW_mother','LW_father','LW_stranger','PD_target','PD_context','PD','FATHER_self2other2','FATHER_self4other0',
             'FATHER_self0other4','FATHER_bothnogain','MOTHER_self2other2','MOTHER_self4other0','MOTHER_self0other4',
             'MOTHER_bothnogain','STRANGER_self2other2','STRANGER_self4other0','STRANGER_self0other4','STRANGER_bothnogain']]

tidy.head()
Out[25]:
PPN gender age age2 PD_total SD_total PTM IRI_EM IRI_PT LW_self ... FATHER_self0other4 FATHER_bothnogain MOTHER_self2other2 MOTHER_self4other0 MOTHER_self0other4 MOTHER_bothnogain STRANGER_self2other2 STRANGER_self4other0 STRANGER_self0other4 STRANGER_bothnogain
0 BL1P065 female 16.8 0.364828 NaN NaN 0.4 3.2 4.3 3.0 ... -0.058533 -7.0811 2.248667 2.093067 3.812467 -5.4168 0.521267 -0.593433 1.070967 -5.7063
1 BL1P066 female 17.2 0.502759 NaN NaN 3.1 2.8 3.7 5.0 ... 3.701300 -6.5928 4.852100 11.661700 2.648400 -5.8586 2.631800 2.279400 -0.217100 -7.2883
2 BL1P067 male 16.9 0.397241 0.0 17.0 -4.1 3.5 3.3 7.0 ... 4.881967 -4.6200 1.909567 3.275667 6.120167 -1.3567 1.664067 0.176167 0.422867 -2.9305
3 BL1P068 female 14.3 0.002759 18.0 17.0 4.6 NaN NaN 5.0 ... 0.144700 0.7252 -1.719000 -2.519600 -2.192100 -3.3331 -1.725800 -0.034000 -1.322600 -2.1498
4 BL1P071 male 17.8 0.751034 NaN NaN NaN NaN NaN 6.0 ... 4.592100 -5.3919 7.131600 8.283900 8.504600 -5.2178 6.049500 2.704200 7.124400 -0.8449

5 rows × 28 columns

In [26]:
tidy = pd.melt(tidy.reset_index(),
                  id_vars=['PPN','gender','age','age2','PD_total','SD_total','PD_target','PD_context',
                           'PD','PTM','IRI_EM','IRI_PT',
                          'FATHER_self2other2','FATHER_self4other0','FATHER_self0other4','FATHER_bothnogain',
                          'MOTHER_self2other2','MOTHER_self4other0','MOTHER_self0other4','MOTHER_bothnogain',
                          'STRANGER_self2other2','STRANGER_self4other0','STRANGER_self0other4','STRANGER_bothnogain'],
                  value_vars=['LW_self','LW_mother','LW_father','LW_stranger'],
                  value_name='LW')

# Rename Column that has just been created
tidy.rename(columns={'variable': 'LW_target'}, inplace=True)

# Now delete the duplicate information for both newly created column variables
# For Partner
tidy['LW_target'] = tidy['LW_target'].str.replace('LW_mother','mother')
tidy['LW_target'] = tidy['LW_target'].str.replace('LW_self','self')
tidy['LW_target'] = tidy['LW_target'].str.replace('LW_father','father')
tidy['LW_target'] = tidy['LW_target'].str.replace('LW_stranger','stranger')

tidy.head()
Out[26]:
PPN gender age age2 PD_total SD_total PD_target PD_context PD PTM ... MOTHER_self2other2 MOTHER_self4other0 MOTHER_self0other4 MOTHER_bothnogain STRANGER_self2other2 STRANGER_self4other0 STRANGER_self0other4 STRANGER_bothnogain LW_target LW
0 BL1P065 female 16.8 0.364828 NaN NaN mother PD NaN 0.4 ... 2.248667 2.093067 3.812467 -5.4168 0.521267 -0.593433 1.070967 -5.7063 self 3.0
1 BL1P066 female 17.2 0.502759 NaN NaN mother PD NaN 3.1 ... 4.852100 11.661700 2.648400 -5.8586 2.631800 2.279400 -0.217100 -7.2883 self 5.0
2 BL1P067 male 16.9 0.397241 0.0 17.0 mother PD 0.0 -4.1 ... 1.909567 3.275667 6.120167 -1.3567 1.664067 0.176167 0.422867 -2.9305 self 7.0
3 BL1P068 female 14.3 0.002759 18.0 17.0 mother PD 6.0 4.6 ... -1.719000 -2.519600 -2.192100 -3.3331 -1.725800 -0.034000 -1.322600 -2.1498 self 5.0
4 BL1P071 male 17.8 0.751034 NaN NaN mother PD NaN NaN ... 7.131600 8.283900 8.504600 -5.2178 6.049500 2.704200 7.124400 -0.8449 self 6.0

5 rows × 26 columns

In [27]:
# Set figure style aestethics
# The four preset contexts, in order of relative size, are paper, notebook, talk, and poster. The notebook style is the default, and was used in the plots above.
# There are five preset seaborn themes: darkgrid, whitegrid, dark, white, and ticks. 
# There are six variations of the default theme, called deep, muted, pastel, bright, dark, and colorblind.

sns.set(context='notebook',palette='muted',style='ticks',font_scale=2)
colors_targets = ['#3A9E70','#2B749E','#4BB1EB','#EB8C57'] #Self , Mother, Father, Stranger
colors_targets3 = ['#2B749E','#4BB1EB','#EB8C57'] # Mother, Father, Stranger
colors_targets3_father = ['#4BB1EB','#2B749E','#EB8C57'] # Mother, Father, Stranger
colors_outcomes = ['#FABF3C','#2E739E','#BD432A'] # SelfWin,BothWin,OtherWinc
colors_PDG = ['#6AC27E','#6EF5DA']

Distribution & Descriptives

In [26]:
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 149 entries, 0 to 148
Data columns (total 54 columns):
 #   Column                     Non-Null Count  Dtype  
---  ------                     --------------  -----  
 0   PPN                        149 non-null    object 
 1   gender                     149 non-null    object 
 2   age                        149 non-null    float64
 3   age2                       149 non-null    float64
 4   LW_self                    147 non-null    float64
 5   LW_mother                  147 non-null    float64
 6   LW_father                  147 non-null    float64
 7   LW_stranger                147 non-null    float64
 8   PD_Cooperations            96 non-null     float64
 9   SD_Cooperations            96 non-null     float64
 10  PD_cooperations_mother     96 non-null     float64
 11  PD_cooperations_father     96 non-null     float64
 12  PD_cooperations_stranger   96 non-null     float64
 13  SD_cooperations_mother     96 non-null     float64
 14  SD_cooperations_father     96 non-null     float64
 15  SD_cooperations_stranger   96 non-null     float64
 16  PTM                        137 non-null    float64
 17  IRI_EM                     133 non-null    float64
 18  IRI_PT                     133 non-null    float64
 19  FATHER_self2other2         133 non-null    float64
 20  FATHER_self0other4         133 non-null    float64
 21  FATHER_self4other0         133 non-null    float64
 22  FATHER_bothnogain          133 non-null    float64
 23  MOTHER_self2other2         133 non-null    float64
 24  MOTHER_self0other4         133 non-null    float64
 25  MOTHER_self4other0         133 non-null    float64
 26  MOTHER_bothnogain          133 non-null    float64
 27  STRANGER_self2other2       133 non-null    float64
 28  STRANGER_self0other4       133 non-null    float64
 29  STRANGER_self4other0       133 non-null    float64
 30  STRANGER_bothnogain        133 non-null    float64
 31  MPFC_FATHER_self2other2    138 non-null    float64
 32  MPFC_FATHER_self0other4    138 non-null    float64
 33  MPFC_FATHER_self4other0    138 non-null    float64
 34  MPFC_FATHER_bothnogain     138 non-null    float64
 35  MPFC_MOTHER_self2other2    138 non-null    float64
 36  MPFC_MOTHER_self0other4    138 non-null    float64
 37  MPFC_MOTHER_self4other0    138 non-null    float64
 38  MPFC_MOTHER_bothnogain     138 non-null    float64
 39  MPFC_STRANGER_self2other2  138 non-null    float64
 40  MPFC_STRANGER_self0other4  138 non-null    float64
 41  MPFC_STRANGER_self4other0  138 non-null    float64
 42  MPFC_STRANGER_bothnogain   138 non-null    float64
 43  cohesion_dim               128 non-null    float64
 44  flexibility_dim            128 non-null    float64
 45  altruism                   107 non-null    float64
 46  honesty                    107 non-null    float64
 47  emotionality               107 non-null    float64
 48  extraversion               107 non-null    float64
 49  agreeableness              107 non-null    float64
 50  conscientiousness          107 non-null    float64
 51  openness                   107 non-null    float64
 52  nacc_average_nogain        133 non-null    float64
 53  mpfc_average_nogain        138 non-null    float64
dtypes: float64(52), object(2)
memory usage: 64.0+ KB
In [27]:
plt.figure(figsize = (10,8))
sns.kdeplot(data=df,x='age',y='PD_cooperations_stranger',hue='gender', palette='crest',fill=True)
sns.despine()
In [36]:
plt.figure(figsize=(14,8))
sns.distplot(df['PD_Cooperations'])
sns.distplot(df['SD_Cooperations'])
plt.ylim(0,0.1)
sns.despine()
/Users/philipb/anaconda3/lib/python3.7/site-packages/seaborn/distributions.py:2551: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
  warnings.warn(msg, FutureWarning)
/Users/philipb/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/__init__.py:1402: FutureWarning: Support for multi-dimensional indexing (e.g. `obj[:, None]`) is deprecated and will be removed in a future version.  Convert to a numpy array before indexing instead.
  x[:, None]
/Users/philipb/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py:276: FutureWarning: Support for multi-dimensional indexing (e.g. `obj[:, None]`) is deprecated and will be removed in a future version.  Convert to a numpy array before indexing instead.
  x = x[:, np.newaxis]
/Users/philipb/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py:278: FutureWarning: Support for multi-dimensional indexing (e.g. `obj[:, None]`) is deprecated and will be removed in a future version.  Convert to a numpy array before indexing instead.
  y = y[:, np.newaxis]
/Users/philipb/anaconda3/lib/python3.7/site-packages/seaborn/distributions.py:2551: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
  warnings.warn(msg, FutureWarning)
/Users/philipb/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/__init__.py:1402: FutureWarning: Support for multi-dimensional indexing (e.g. `obj[:, None]`) is deprecated and will be removed in a future version.  Convert to a numpy array before indexing instead.
  x[:, None]
/Users/philipb/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py:276: FutureWarning: Support for multi-dimensional indexing (e.g. `obj[:, None]`) is deprecated and will be removed in a future version.  Convert to a numpy array before indexing instead.
  x = x[:, np.newaxis]
/Users/philipb/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py:278: FutureWarning: Support for multi-dimensional indexing (e.g. `obj[:, None]`) is deprecated and will be removed in a future version.  Convert to a numpy array before indexing instead.
  y = y[:, np.newaxis]

BEHAVIOR: Like Winning (ANOVA)

In [37]:
# FIGURE 1: Behavioral Like winning for targets

plt.figure(figsize=(14,8),dpi=300)
a = sns.violinplot(data=tidy, x='LW_target',y='LW',bw=0.5,
                   palette=sns.color_palette(colors_targets, n_colors=4, desat=0.8))

# Formatting
sns.despine(offset=0,trim=False)
#plt.legend(loc='lower left')
a.set_ylabel('Like Winning')
a.set_xlabel('')
Out[37]:
Text(0.5, 0, '')

test assumptions

In [38]:
pg.normality(tidy,dv='LW',group='LW_target')
Out[38]:
W pval normal
self 0.900594 1.816224e-23 False
mother 0.908132 1.246971e-22 False
father 0.916549 1.240212e-21 False
stranger 0.940380 2.483346e-18 False

Seems like we do not have a normal distribution for LW & LW Target

In [39]:
pg.homoscedasticity(tidy,dv='LW',group='LW_target')
/Users/philipb/anaconda3/lib/python3.7/site-packages/numpy/lib/function_base.py:3250: RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)
Out[39]:
W pval equal_var
levene NaN NaN False

Traditional ANOVA can be quite unstable when the groups have unequal variances (see Liu 2015).

Therefore, it is recommanded to use a Welch ANOVA instead, followed by Games-Howell post-hoc tests, which do not require the groups to have equal variances.

In [28]:
# Run the ANOVA
welch_aov_LW = pg.welch_anova(data=tidy,dv='LW',between='LW_target')
welch_aov_LW
Out[28]:
Source ddof1 ddof2 F p-unc np2
0 LW_target 3 1952.349648 434.023306 5.248575e-216 0.307078
  • Interpretation: Differences between the groups detected, let's use a non-parametric post-hoc test like games-howell to dig into the pair-wise group differences.
In [30]:
# FDR-corrected post hocs TUKEY-HSD with Hedges'g effect size
posthoc_LW = pg.pairwise_gameshowell(data=tidy, dv='LW', between='LW_target')

# Pretty printing of table
posthoc_LW
Out[30]:
A B mean(A) mean(B) diff se T df pval hedges
0 father mother 5.102041 5.258503 -0.156463 0.051060 -3.064264 1757.390426 0.011757 -0.145855
1 father self 5.102041 5.442177 -0.340136 0.051518 -6.602249 1760.127618 0.001000 -0.314259
2 father stranger 5.102041 3.551020 1.551020 0.057342 27.048462 1714.476038 0.001000 1.287474
3 mother self 5.258503 5.442177 -0.183673 0.050206 -3.658427 1761.388634 0.001458 -0.174137
4 mother stranger 5.258503 3.551020 1.707483 0.056166 30.400692 1683.550292 0.001000 1.447036
5 self stranger 5.442177 3.551020 1.891156 0.056582 33.423036 1695.508358 0.001000 1.590896
  • CONCLUSION: We can see significant differences across the board, with large effect sizes for any comparison with the stranger.
In [22]:
# FIGURE 2: Behavioral Like winning across age
#colors_targets = ['#3A9E70','#2B749E','#4BB1EB','#EB8C57'] #Self , Mother, Father, Stranger

plt.figure(figsize=(12,10),dpi=250)
b = sns.regplot(data=df,x='age',y='LW_self',order=1,ci=95,truncate=True,label='Self',color='#3A9E70')
b = sns.regplot(data=df,x='age',y='LW_mother',order=1,ci=95,truncate=True,label='Mother',color='#2B749E')
b = sns.regplot(data=df,x='age',y='LW_father',order=1,ci=95,truncate=True,label='Father',color='#4BB1EB')
b = sns.regplot(data=df,x='age',y='LW_stranger',order=2,ci=95,truncate=True,label='Stranger',color='#EB8C57')
sns.despine(offset=0,trim=False)
b.set(ylim=(0,7.5))
# Formatting
b.set(ylabel='Like Winning') # FacetGrid requires labelS
b.legend(bbox_to_anchor=(0.98, 0.65), loc=2)
Out[22]:
<matplotlib.legend.Legend at 0x7f91c3ee1438>

BEHAVIOR: Prisoner's Dilemma (RM-ANOVA)

In [36]:
tidy.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3576 entries, 0 to 3575
Data columns (total 26 columns):
PPN                     3576 non-null object
gender                  3576 non-null object
age                     3576 non-null float64
age2                    3576 non-null float64
PD_total                2304 non-null float64
SD_total                2304 non-null float64
PD_target               3576 non-null object
PD_context              3576 non-null object
PD                      2304 non-null float64
PTM                     3288 non-null float64
IRI_EM                  3192 non-null float64
IRI_PT                  3192 non-null float64
FATHER_self2other2      3216 non-null float64
FATHER_self4other0      3216 non-null float64
FATHER_self0other4      3216 non-null float64
FATHER_bothnogain       3216 non-null float64
MOTHER_self2other2      3216 non-null float64
MOTHER_self4other0      3216 non-null float64
MOTHER_self0other4      3216 non-null float64
MOTHER_bothnogain       3216 non-null float64
STRANGER_self2other2    3216 non-null float64
STRANGER_self4other0    3216 non-null float64
STRANGER_self0other4    3216 non-null float64
STRANGER_bothnogain     3216 non-null float64
LW_target               3576 non-null object
LW                      3528 non-null float64
dtypes: float64(21), object(5)
memory usage: 726.5+ KB
In [28]:
# FIGURE 3: Behavioral Prisoner's dilemma
#plt.figure(figsize=(14,8),dpi=300)
c = sns.catplot(data=tidy,x='PD_context',y='PD',hue='PD_target',kind='bar',height=10,
               palette=sns.color_palette(colors_targets3, n_colors=3, desat=0.9))
sns.despine(offset=10,trim=False)

# Formatting
plt.ylim(0,5)
c.set_ylabels('Number of Cooperations')
c.set_xlabels('Zero-Sum')
c.set_axis_labels('Context')
Out[28]:
<seaborn.axisgrid.FacetGrid at 0x7f91b2a9af60>
In [26]:
aov_PD = pg.rm_anova(data=tidy,dv='PD',within=['PD_target','PD_context'], subject='PPN')
aov_PD
Out[26]:
Source SS ddof1 ddof2 MS F p-unc p-GG-corr np2 eps
0 PD_target 77.293478 2 182 38.646739 16.838872 1.950793e-07 2.601398e-06 0.156148 0.787446
1 PD_context 294.219203 1 91 294.219203 54.646568 6.805404e-11 6.805404e-11 0.375200 1.000000
2 PD_target * PD_context 5.438406 2 182 2.719203 2.302962 1.028685e-01 1.099527e-01 0.024683 0.879974
In [27]:
pg.homoscedasticity(tidy,dv='PD',group='PD_target')
Out[27]:
W pval equal_var
levene NaN NaN False
  • Interpretation: Main effects for target & context, no interaction effect

Let's test pairwise-post-hoc with Games-Howell because Lavene's test of heteroscedascity is not met

In [31]:
pg.pairwise_gameshowell(data=tidy, dv='PD', between='PD_target')
Out[31]:
A B mean(A) mean(B) diff se T df pval hedges
0 father mother 3.583333 3.786458 -0.203125 0.099328 -2.044994 1533.804054 0.101733 -0.104307
1 father stranger 3.583333 2.911458 0.671875 0.102995 6.523397 1528.602386 0.001000 0.332733
2 mother stranger 3.786458 2.911458 0.875000 0.102452 8.540596 1526.375146 0.001000 0.435622

Interpretation:

  • There is a small (non-sig) difference between mother & father (hedges g = -0.1, p = .11)
  • There is a medium difference between father & stranger (hedges g = 0.33, p <.001)
  • There is a medium difference between mother & stranger (hedges g = 0.43, p < .001 )
In [32]:
pg.pairwise_gameshowell(data=tidy, dv='PD', between='PD_context')
Out[32]:
A B mean(A) mean(B) diff se T df pval hedges
0 PD SD 2.684028 4.170139 -1.486111 0.078504 -18.930435 2280.666406 0.001 -0.788511

Interpretation:

  • There is a large difference between contexts (hedges g = -0.77, p < .001 )
In [18]:
# FIGURE 4: Behavioral Prisoner's dilemma + AGE
plt.figure(figsize=(12,8),dpi=300)
d = sns.regplot(data=tidy,x='age',y='PD_total',order=1,ci=95,
                scatter_kws={'s':10},truncate=False)
e = sns.regplot(data=tidy,x='age',y='SD_total',order=2,ci=95,
                scatter_kws={'s':10},truncate=False)

# Formatting
plt.xlim(8,20)
d.set_ylabel('Number of Cooperations')
d.axes.legend(labels=['Prisoners dilemma','Social dilemma'],loc='upper left')
sns.despine(offset=0,trim=True)
In [39]:
pg.ancova(data=tidy, dv='PD',between='PD_target',covar='age')
Out[39]:
Source SS DF F p-unc np2
0 PD_target 322.125000 2 41.314441 2.355859e-18 0.034680
1 age 155.177804 1 39.804946 3.355590e-10 0.017012
2 Residual 8966.447196 2300 NaN NaN NaN
In [94]:
# FIGURE 5: Behavioral Prisoner's dilemma + AGE + context
# LM plot: https://seaborn.pydata.org/generated/seaborn.lmplot.html

f = sns.lmplot(data=tidy,x='age',y='PD',hue='PD_target',col='PD_context',order=2,ci=95,
               palette=sns.color_palette(colors_targets3, n_colors=3, desat=0.9),
                                         legend=True,truncate=True,height=10)

# Formatting
plt.ylim(-0.5,6.5)
plt.xlim(8,19)
f.set_ylabels('Number of Cooperations')
axes = f.axes.flatten() # not sure why this is necessary but otherwise it thinks it's a numpy array
axes[0].set_title("Prisoner's Dilemma")
axes[1].set_title('Social Dilemma')
sns.despine(offset=0,trim=False)
In [78]:
# FIGURE 6: Behavioral Prisoner's dilemma + AGE + GENDER + TARGET
# LM plot: https://seaborn.pydata.org/generated/seaborn.lmplot.html

g = sns.lmplot(data=tidy,x='age',y='PD',hue='PD_target',col='gender',order=2,ci=95,
               legend=True,truncate=True,height=8)

# Formatting
plt.ylim(-0.5,6.5)
plt.xlim(8,19)
g.set_ylabels('Number of Cooperations')
axes = f.axes.flatten() # not sure why this is necessary but otherwise it thinks it's a numpy array
axes[0].set_title('Zero-Sum')
axes[1].set_title('Non-Zero-Sum')
sns.despine(offset=0,trim=False)

Predictive Power Score (PPS)

In [33]:
# The way to use pps is
# pps.score(df, "feature_column", "target_column")
# https://github.com/8080labs/ppscore

BEHAVIOR: Correlations

image.png

In [34]:
#df.corr()

# Shepherds correlation within a multivariate mahalanobis distance outlier correction:
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3397314/#:~:text=Appendix%202-,Shepherd's%20PI%20correlation,covariance%20structure%20of%20the%20data.&text=Shepherd's%20pi%20is%20equal%20to%20rho.
In [ ]:
plt.figure(figsize=(8,5),dpi=250)
m = sns.regplot(data=df,x='LW_mother',y='LW_father',x_jitter=0.5)
sns.despine()
In [86]:
pg.corr(df['LW_father'],df['LW_mother'],method='shepherd')
Out[86]:
n outliers r CI95% r2 adj_r2 p-val power
shepherd 147 7 0.934067 [0.91, 0.95] 0.872481 0.87071 1.396159e-63 1.0
In [37]:
plt.figure(figsize=(12,8))
n = sns.regplot(data=df,x='LW_self',y='PD_Cooperations',order=1,x_jitter=0.2,label='Self')
#n = sns.regplot(data=df,x='LW_father',y='SD_Cooperations',order=1,x_jitter=0.2,label='Father')
#n = sns.regplot(data=df,x='LW_mother',y='SD_Cooperations',order=1,x_jitter=0.2,label='Mother')
n = sns.regplot(data=df,x='LW_stranger',y='PD_Cooperations',order=1,x_jitter=0.2,label='Stranger')
n.legend(bbox_to_anchor=(1, 0.65), loc='best')
#n.set(x_label='Like winning')
sns.despine()
In [38]:
pg.corr(df['PD_Cooperations'],df['LW_stranger'],method='shepherd')
Out[38]:
n outliers r CI95% r2 adj_r2 p-val power
shepherd 94 3 0.341512 [0.15, 0.51] 0.116631 0.097216 0.000923 0.926506
In [39]:
plt.figure(figsize=(12,8))
m = sns.regplot(data=df,x='LW_self',y='SD_Cooperations',order=1,x_jitter=0.2,label='Self')
#m = sns.regplot(data=df,x='LW_father',y='SD_Cooperations',order=1,x_jitter=0.2,label='Father')
#m = sns.regplot(data=df,x='LW_mother',y='SD_Cooperations',order=1,x_jitter=0.2,label='Mother')
m = sns.regplot(data=df,x='LW_stranger',y='SD_Cooperations',order=1,x_jitter=0.2,label='Stranger')
m.legend(bbox_to_anchor=(1, 0.65), loc='best')
#m.set(x_label='Like winning')
sns.despine()
In [40]:
pg.corr(df['LW_self'],df['SD_Cooperations'],method='shepherd')
Out[40]:
n outliers r CI95% r2 adj_r2 p-val power
shepherd 94 6 -0.329521 [-0.5, -0.14] 0.108584 0.088992 0.001718 0.906705

Nucleus Accumbens (ROI)

image.png

Hypothesis 15 & 16: NAcc by target & condition

  • We expect to find higher peak activation within the Nucleus Accumbens (NAcc) (defined as a priori region-of-interest (ROI)) for the self-gain condition contrasted with the both-no-gain condition. We expect this activity to be stronger in mid-adolescence based on prior studies showing a peak in NAcc activity for self [Braams et al., 2015].
  • We further expect significant differences in ROI NAcc activation depending on the target for the self-no-gain, other-gain condition (compared to baseline condition of both-no-gain). We expect stronger NAcc activity when gaining for mother and father compared to unknown targets. We expect that NAcc activity will be stronger in mid-adolescence based on prior studies showing a peak in NAcc for mothers [Braams and Crone, 2014]. We have no specific hypothesis concerning developmental differences in neural responses for fathers or strangers.
In [305]:
q = sns.catplot(data=tidy_nacc,x='NAcc_target',y='NAcc',hue='NAcc_outcome',kind='bar',height=10,aspect=1.33,ci=95,
               palette=sns.color_palette(colors_outcomes, n_colors=3, desat=0.9))
q.set_axis_labels('Target','NAcc parameter estimate')
#q.set_legend('Target','NAcc parameter estimate')
#q.legend(loc='best')
sns.despine()
In [74]:
#colors_targets = ['#3A9E70','#2B749E','#4BB1EB','#EB8C57'] #Self , Mother, Father, Stranger

plt.figure(figsize=(14,10))
#q = sns.violinplot(data=tidy_nacc_other,x='NAcc_target',y='NAcc',hue='gender',split=True,
#               palette=sns.color_palette(colors_targets3_father, desat=0.9),inner=None)
q = sns.swarmplot(data=tidy_nacc_other,x='NAcc_target',y='NAcc',
               palette=sns.color_palette(colors_targets3_father, n_colors=3, desat=1))
#q.set_axis_labels('Target','NAcc parameter estimate')
#q.set_legend('Target','NAcc parameter estimate')
#q.legend(loc='best')
sns.despine()
In [42]:
plt.figure(figsize=(10,8),dpi=150)
q = sns.catplot(data=tidy_nacc,x='NAcc_outcome',y='NAcc',kind='bar',hue = 'gender', col='NAcc_target', height=8,aspect=1.33,ci=95)
#q.set_axis_labels('Target','NAcc parameter estimate')
#q.set_legend('Target','NAcc parameter estimate')
#q.legend(loc='best')
sns.despine()
<Figure size 1500x1200 with 0 Axes>
Let's test for equal of varaince assumption

pg.homoscedasticity(tidy_nacc, dv='NAcc', group='NAcc_target')

In [234]:
# Let's test for equal of varaince assumption
pg.homoscedasticity(tidy_nacc_other, dv='NAcc', group='NAcc_target')
Out[234]:
W pval equal_var
levene NaN NaN False
In [246]:
# ANOVA for SelfWin > NoWin (page 14)
rma_nacc_self = pg.rm_anova(data=tidy_nacc_nowin,dv='NAcc',within=['NAcc_outcome'],subject='PPN',detailed=True)
rma_nacc_self
Out[246]:
Source SS DF MS F p-unc np2 eps
0 NAcc_outcome 677.77953 1 677.779530 96.842133 3.076938e-17 0.438513 1.0
1 Error 867.85224 124 6.998808 NaN NaN NaN NaN
In [248]:
# ANCOVA + age2 for SelfWin > NoWin (page 14)
ancova_nowin = pg.ancova(data=tidy_nacc_nowin,dv='NAcc',between='NAcc_outcome',covar='age2')
ancova_nowin
Out[248]:
Source SS DF F p-unc np2
0 NAcc_outcome 2098.018963 1 251.030291 2.437305e-49 0.239984
1 age2 1.561599 1 0.186847 6.656711e-01 0.000235
2 Residual 6644.317981 795 NaN NaN NaN
In [250]:
# ANCOVA + age for SelfWin > NoWin (page 14)

ancova_nowin = pg.ancova(data=tidy_nacc_nowin,dv='NAcc',between='NAcc_outcome',covar='age')
ancova_nowin
Out[250]:
Source SS DF F p-unc np2
0 NAcc_outcome 2098.018963 1 251.679702 1.902591e-49 0.240455
1 age 18.705994 1 2.243983 1.345320e-01 0.002815
2 Residual 6627.173586 795 NaN NaN NaN
In [235]:
# 3x3 RM-ANOVA: BothWin > OtherWin (page 14)
rma_nacc = pg.rm_anova(data=tidy_nacc,dv='NAcc',within=['NAcc_target','NAcc_outcome'],subject='PPN',detailed=True)
rma_nacc
/Users/philipb/anaconda3/lib/python3.7/site-packages/pingouin/distribution.py:460: UserWarning: Epsilon values might be innaccurate in two-way repeated measures design where each  factor has more than 2 levels. Please  double-check your results.
  warnings.warn("Epsilon values might be innaccurate in "
Out[235]:
Source SS ddof1 ddof2 MS F p-unc p-GG-corr np2 eps
0 NAcc_target 12.487368 2 248 6.243684 1.289688 0.277197 0.277081 0.010294 0.989799
1 NAcc_outcome 100.632936 2 248 50.316468 9.426661 0.000113 0.000141 0.070651 0.965426
2 NAcc_target * NAcc_outcome 101.647414 4 496 25.411853 4.863584 0.000744 0.001430 0.037742 0.864234

Interpretation: No target effects but outcome & interaction effects

Interpretation: No differences between targets

In [46]:
pg.pairwise_ttests(data=tidy_nacc, dv='NAcc', between='NAcc_outcome')
Out[46]:
Contrast A B Paired Parametric T dof Tail p-unc BF10 hedges
0 NAcc_outcome selfwin bothwin False True 1.379785 802.0 two-sided 0.168037 0.201 0.097231
1 NAcc_outcome selfwin otherwin False True 4.276718 802.0 two-sided 0.000021 573.799 0.301374
2 NAcc_outcome bothwin otherwin False True 3.184941 802.0 two-sided 0.001504 11.175 0.224438
In [262]:
# ANOVA for EACH conditions separately (page 14) -- SELF
pg.rm_anova(data=tidy_nacc_self, dv='NAcc',within='NAcc_target',subject='PPN')
Out[262]:
Source ddof1 ddof2 F p-unc np2 eps
0 NAcc_target 2 248 2.765596 0.064881 0.021817 0.973858
In [263]:
# ANOVA for EACH conditions separately (page 14) -- BOTH
pg.rm_anova(data=tidy_nacc_both, dv='NAcc',within='NAcc_target',subject='PPN')
Out[263]:
Source ddof1 ddof2 F p-unc np2 eps
0 NAcc_target 2 248 0.575761 0.563026 0.004622 0.958589
In [268]:
# ANOVA for EACH conditions separately (page 14) -- OTHER
pg.rm_anova(data=tidy_nacc_other, dv='NAcc',within='NAcc_target',subject='PPN')
Out[268]:
Source ddof1 ddof2 F p-unc np2 eps
0 NAcc_target 2 248 9.530768 0.000103 0.071375 0.974743
In [301]:
# simple t-test to compare STRANGER OtherWin > NoWin
pg.ttest(df['STRANGER_self0other4'],df['STRANGER_bothnogain'])
Out[301]:
T dof tail p-val CI95% cohen-d BF10 power
T-test 0.571745 264 two-sided 0.567981 [-0.44, 0.8] 0.070112 0.157 0.087929
In [299]:
sns.catplot(data=tidy_nacc_nowin_stranger,x='NAcc_outcome',y='NAcc',kind='swarm')
Out[299]:
<seaborn.axisgrid.FacetGrid at 0x7f870eeec4a8>
In [51]:
# Gender split
pg.mixed_anova(data=tidy_nacc_other, dv='NAcc',between='gender',within='NAcc_target',subject='PPN')
Out[51]:
Source SS DF1 DF2 MS F p-unc np2 eps
0 gender 34.067033 1 124 34.067033 3.806759 0.053301 0.029785 NaN
1 NAcc_target 66.450208 2 248 33.225104 9.161131 0.000145 0.068797 0.97881
2 Interaction 1.013130 2 248 0.506565 0.139675 0.869709 0.001125 NaN
In [52]:
pg.ancova(data=tidy_nacc, dv='NAcc',between='NAcc_outcome',covar='age')
Out[52]:
Source SS DF F p-unc np2
0 NAcc_outcome 142.605310 2 10.004070 0.000049 0.016373
1 age 25.315623 1 3.551891 0.059719 0.002946
2 Residual 8567.092453 1202 NaN NaN NaN
In [306]:
plt.figure(figsize=(10,8),dpi=200)
sns.lmplot(data=tidy_nacc,x='age',y='NAcc',hue='NAcc_outcome',col='NAcc_target',height=8,
          palette=sns.color_palette(colors_targets3, n_colors=3, desat=0.9))
Out[306]:
<seaborn.axisgrid.FacetGrid at 0x7f8712930f60>
<Figure size 2000x1600 with 0 Axes>
In [202]:
# Correlation matrix (page 18)
df.corr()
Out[202]:
age age2 LW_self LW_mother LW_father LW_stranger PD_Cooperations SD_Cooperations PD_cooperations_mother PD_cooperations_father ... cohesion_dim flexibility_dim altruism honesty emotionality extraversion agreeableness conscientiousness openness average_nogain
age 1.000000 -0.288059 -0.091526 -0.034663 -0.116611 -0.025464 0.038409 0.290055 0.110810 0.153689 ... -0.111752 -0.022316 -0.067702 -0.113146 0.082301 0.067359 0.040347 0.159143 0.052738 -0.131875
age2 -0.288059 1.000000 0.149851 0.003100 -0.001248 -0.225295 -0.131756 -0.274092 -0.059953 -0.110396 ... -0.152018 -0.178365 0.026831 -0.138697 -0.061631 0.072717 -0.125635 0.048293 0.096417 -0.059946
LW_self -0.091526 0.149851 1.000000 0.424031 0.357259 -0.230387 -0.145264 -0.270093 -0.152086 -0.117428 ... 0.093608 -0.142749 0.082416 -0.158584 -0.039094 0.098596 -0.169946 -0.077817 -0.191009 -0.084584
LW_mother -0.034663 0.003100 0.424031 1.000000 0.730257 0.115621 0.028453 -0.233536 0.003777 -0.022743 ... 0.037450 0.058963 0.126772 -0.071493 0.081146 0.013458 -0.037698 0.024836 -0.113234 -0.194803
LW_father -0.116611 -0.001248 0.357259 0.730257 1.000000 0.136867 0.082969 -0.281694 -0.019952 0.156742 ... -0.022666 0.055832 0.040572 -0.126396 -0.066582 0.017284 -0.099797 0.007509 -0.175204 -0.195458
LW_stranger -0.025464 -0.225295 -0.230387 0.115621 0.136867 1.000000 0.299719 0.126860 0.267766 0.222285 ... 0.121426 0.149180 0.196766 0.309862 0.264334 -0.129736 0.192761 0.270028 0.080862 -0.024425
PD_Cooperations 0.038409 -0.131756 -0.145264 0.028453 0.082969 0.299719 1.000000 0.219142 0.814605 0.808093 ... 0.255920 0.193048 -0.153973 0.196207 0.181073 -0.135527 0.032602 0.149945 0.147579 0.127382
SD_Cooperations 0.290055 -0.274092 -0.270093 -0.233536 -0.281694 0.126860 0.219142 1.000000 0.256658 0.131864 ... 0.031899 0.191841 -0.114859 0.327029 0.251438 0.027216 0.040731 0.034930 -0.116250 0.170344
PD_cooperations_mother 0.110810 -0.059953 -0.152086 0.003777 -0.019952 0.267766 0.814605 0.256658 1.000000 0.690540 ... 0.199450 0.164323 -0.033183 0.087776 0.153493 -0.124706 0.046782 0.068792 0.077446 0.141331
PD_cooperations_father 0.153689 -0.110396 -0.117428 -0.022743 0.156742 0.222285 0.808093 0.131864 0.690540 1.000000 ... 0.146491 0.156390 -0.144481 0.212599 0.047242 -0.061433 0.009764 0.110043 -0.040287 0.216963
PD_cooperations_stranger -0.146228 -0.125448 -0.102743 0.105149 0.063955 0.318366 0.715922 0.103956 0.327497 0.322292 ... 0.239883 0.114351 -0.109386 0.184630 0.228370 -0.156599 0.135615 0.157910 0.246609 -0.052326
SD_cooperations_mother 0.251601 -0.233354 -0.204101 -0.216984 -0.258669 0.062555 0.201106 0.897695 0.271002 0.151333 ... 0.078918 0.221933 -0.155332 0.300406 0.253824 0.154648 0.139804 0.023490 -0.157719 0.159995
SD_cooperations_father 0.313707 -0.300448 -0.219309 -0.315204 -0.228805 0.038319 0.169152 0.856870 0.225339 0.215923 ... 0.022604 0.145722 -0.093668 0.243038 0.168523 0.085931 0.032216 0.001347 -0.097918 0.150475
SD_cooperations_stranger 0.187916 -0.171761 -0.265104 -0.077418 -0.232092 0.220164 0.180150 0.802673 0.172067 -0.006085 ... -0.015502 0.126035 -0.039810 0.283398 0.211423 -0.140761 -0.039968 0.053774 -0.058630 0.127674
PTM -0.051362 -0.063468 -0.013274 0.052466 0.014486 0.259117 0.176918 -0.019081 0.184545 0.066816 ... -0.004423 -0.071627 0.329205 0.029279 0.357780 0.115424 0.182999 0.116641 0.234353 -0.016152
IRI_EM -0.104649 0.043928 -0.147068 0.022890 -0.037079 0.138036 0.255482 0.042405 0.194194 0.210275 ... 0.069990 -0.077159 0.127691 0.253779 0.590264 0.041416 0.262428 0.301229 0.263962 0.077171
IRI_PT 0.157919 0.022057 -0.299723 -0.104905 -0.100230 0.141058 0.174431 0.020170 0.169782 0.256278 ... -0.090064 0.198025 -0.118483 0.295557 0.197835 0.123306 0.379815 0.305447 0.326794 0.068482
FATHER_self2other2 0.148044 -0.065526 0.000373 0.109339 0.141706 0.145004 -0.205770 -0.060761 -0.148569 -0.170434 ... -0.045205 0.066557 0.249172 -0.264922 -0.071557 0.047531 -0.148349 -0.068274 0.048454 -0.489607
FATHER_self0other4 0.080805 -0.060001 0.199380 0.342309 0.319257 0.105013 -0.037640 -0.026861 -0.061009 -0.116807 ... 0.044948 0.116150 0.253809 -0.068565 -0.018025 -0.004131 -0.007412 -0.124268 -0.092563 -0.442746
FATHER_self4other0 0.014643 0.055876 0.121821 0.076199 0.055468 0.013953 0.003952 -0.085377 -0.153321 -0.090031 ... -0.034193 -0.067455 0.073799 0.026180 -0.018521 -0.003578 0.059406 -0.054738 0.134331 -0.297758
FATHER_bothnogain -0.079855 0.045180 -0.002536 -0.110136 -0.062174 -0.035865 0.091594 0.111745 0.098402 0.165411 ... -0.112701 0.020734 -0.058086 -0.178145 -0.092981 0.269666 -0.085020 0.030988 0.048894 0.745918
MOTHER_self2other2 0.043437 0.067156 0.116687 0.108757 0.085353 0.190826 -0.000829 -0.085920 -0.024342 -0.044579 ... 0.081846 -0.112307 0.168753 0.018328 0.018100 0.002793 0.172516 0.220868 -0.029489 -0.307824
MOTHER_self0other4 0.151469 0.064548 0.121041 0.341996 0.246752 0.050750 0.012803 -0.027802 -0.026015 -0.081513 ... 0.065208 0.049368 0.055260 -0.241274 -0.024050 -0.059695 0.012710 -0.112397 -0.101704 -0.470150
MOTHER_self4other0 -0.060596 0.133219 -0.004129 -0.008946 -0.035148 -0.100095 -0.258236 -0.246636 -0.286014 -0.262929 ... -0.079641 -0.157041 0.211794 0.120410 0.046903 -0.026026 0.150984 0.113308 0.055728 -0.367622
MOTHER_bothnogain -0.143705 -0.174808 -0.172854 -0.177350 -0.185878 -0.012399 0.120604 0.169308 0.152101 0.202147 ... 0.092148 -0.047541 -0.113491 0.182409 0.016184 -0.112336 0.164656 0.032340 0.037839 0.756193
STRANGER_self2other2 0.076463 0.017294 0.141827 0.134241 0.116310 0.103559 -0.077292 -0.101797 -0.071863 -0.126868 ... 0.092959 -0.052225 0.116128 -0.047461 -0.121124 0.011901 0.011787 -0.012819 -0.073632 -0.465643
STRANGER_self0other4 0.040282 0.074219 0.049318 0.210247 0.179878 -0.072728 -0.183174 -0.191617 -0.185801 -0.102591 ... -0.066666 -0.001530 0.064483 -0.064789 -0.150689 -0.024537 -0.081585 -0.178437 0.113069 -0.297464
STRANGER_self4other0 0.018730 0.011122 0.115264 0.308393 0.284211 0.071924 -0.137166 -0.236961 -0.125406 -0.216534 ... -0.048021 -0.084036 0.170233 -0.148711 -0.023650 -0.017047 -0.005140 -0.054571 0.057275 -0.474068
STRANGER_bothnogain -0.068064 0.011930 -0.005993 -0.153839 -0.193667 -0.008217 0.068331 0.093304 0.059197 0.110626 ... -0.043249 0.055953 -0.239863 0.170714 0.080837 -0.013103 -0.028591 0.087726 0.019582 0.754694
cohesion_dim -0.111752 -0.152018 0.093608 0.037450 -0.022666 0.121426 0.255920 0.031899 0.199450 0.146491 ... 1.000000 0.006995 0.045501 0.276146 0.009556 0.005742 0.084981 -0.031496 -0.013811 -0.019665
flexibility_dim -0.022316 -0.178365 -0.142749 0.058963 0.055832 0.149180 0.193048 0.191841 0.164323 0.156390 ... 0.006995 1.000000 -0.062234 0.133074 0.112790 -0.034528 -0.022133 0.017770 -0.134562 0.006874
altruism -0.067702 0.026831 0.082416 0.126772 0.040572 0.196766 -0.153973 -0.114859 -0.033183 -0.144481 ... 0.045501 -0.062234 1.000000 -0.065864 0.138393 -0.043717 -0.130913 -0.086418 0.046342 -0.173044
honesty -0.113146 -0.138697 -0.158584 -0.071493 -0.126396 0.309862 0.196207 0.327029 0.087776 0.212599 ... 0.276146 0.133074 -0.065864 1.000000 0.190022 -0.176566 0.377734 0.262556 -0.079668 0.083776
emotionality 0.082301 -0.061631 -0.039094 0.081146 -0.066582 0.264334 0.181073 0.251438 0.153493 0.047242 ... 0.009556 0.112790 0.138393 0.190022 1.000000 -0.008548 0.057286 0.012108 0.222241 0.003218
extraversion 0.067359 0.072717 0.098596 0.013458 0.017284 -0.129736 -0.135527 0.027216 -0.124706 -0.061433 ... 0.005742 -0.034528 -0.043717 -0.176566 -0.008548 1.000000 0.179740 0.094831 0.081373 0.049010
agreeableness 0.040347 -0.125635 -0.169946 -0.037698 -0.099797 0.192761 0.032602 0.040731 0.046782 0.009764 ... 0.084981 -0.022133 -0.130913 0.377734 0.057286 0.179740 1.000000 0.209206 0.185333 0.032182
conscientiousness 0.159143 0.048293 -0.077817 0.024836 0.007509 0.270028 0.149945 0.034930 0.068792 0.110043 ... -0.031496 0.017770 -0.086418 0.262556 0.012108 0.094831 0.209206 1.000000 0.163838 0.062846
openness 0.052738 0.096417 -0.191009 -0.113234 -0.175204 0.080862 0.147579 -0.116250 0.077446 -0.040287 ... -0.013811 -0.134562 0.046342 -0.079668 0.222241 0.081373 0.185333 0.163838 1.000000 0.045113
average_nogain -0.131875 -0.059946 -0.084584 -0.194803 -0.195458 -0.024425 0.127382 0.170344 0.141331 0.216963 ... -0.019665 0.006874 -0.173044 0.083776 0.003218 0.049010 0.032182 0.062846 0.045113 1.000000

39 rows × 39 columns

In [224]:
pg.corr(df['LW_mother'],df['MOTHER_self2other2'],method='pearson')
Out[224]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 0.108757 [-0.06, 0.28] 0.011828 -0.003612 0.216267 0.233 0.236155
In [223]:
pg.corr(df['LW_mother'],df['MOTHER_self0other4'],method='pearson')
Out[223]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 0.341996 [0.18, 0.49] 0.116961 0.103164 0.000064 295.53 0.981489
In [225]:
pg.corr(df['LW_father'],df['FATHER_self2other2'],method='pearson')
Out[225]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 0.141706 [-0.03, 0.31] 0.02008 0.004769 0.106417 0.397 0.366812
In [226]:
pg.corr(df['LW_father'],df['FATHER_self0other4'],method='pearson')
Out[226]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 0.319257 [0.16, 0.47] 0.101925 0.087893 0.000202 101.101 0.963728
In [228]:
pg.corr(df['LW_stranger'],df['STRANGER_self2other2'],method='pearson')
Out[228]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 0.103559 [-0.07, 0.27] 0.010724 -0.004733 0.239159 0.217 0.218344
In [227]:
pg.corr(df['LW_stranger'],df['STRANGER_self0other4'],method='pearson')
Out[227]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 -0.072728 [-0.24, 0.1] 0.005289 -0.010253 0.40907 0.153 0.131138
In [229]:
pg.corr(df['PD_cooperations_mother'],df['MOTHER_self4other0'])
Out[229]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 95 -0.286014 [-0.46, -0.09] 0.081804 0.061843 0.004958 6.254 0.809283
In [231]:
pg.corr(df['SD_cooperations_mother'],df['MOTHER_self4other0'])
Out[231]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 95 -0.319582 [-0.49, -0.13] 0.102133 0.082614 0.001595 17.337 0.89093
In [230]:
pg.corr(df['PD_cooperations_stranger'],df['LW_stranger'])
Out[230]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 94 0.318366 [0.12, 0.49] 0.101357 0.081606 0.001765 15.885 0.885176
In [233]:
pg.corr(df['SD_cooperations_stranger'],df['LW_stranger'])
Out[233]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 94 0.220164 [0.02, 0.4] 0.048472 0.02756 0.032986 1.209 0.573432
In [232]:
pg.corr(df['SD_cooperations_stranger'],df['LW_self'])
Out[232]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 94 -0.265104 [-0.44, -0.07] 0.07028 0.049847 0.009815 3.435 0.739886

Hypothesis: 17: NAcc -> PDG

We expect a correlation between NAcc activation strength for self-no-gain, other-gain condition and participant choices during a prisoner’s dilemma paradigm outside the scanner. During the prisoner’s dilemma, we expect participants to show more cooperative behavior for each target if their NAcc activation for that target was higher during the vicarious reward task.

In [309]:
#colors_targets3 = [#2B749E','#4BB1EB','#EB8C57'] Mother, Father, Stranger

plt.figure(figsize=(10,6),dpi=200)
o = sns.regplot(data=df,x='PD_cooperations_mother',y='MOTHER_self0other4',x_jitter=0.2,label='Mother',color='#2B749E')
o = sns.regplot(data=df,x='PD_cooperations_father',y='FATHER_self0other4',x_jitter=0.2,label='Father',color='#2B749E')
o = sns.regplot(data=df,x='PD_cooperations_stranger',y='STRANGER_self0other4',x_jitter=0.2,label='Stranger',color='#EB8C57')
o.set_xlabel('Number of Cooperations in PDG')
o.set_ylabel('NAcc (ROI) Parameter estimate')
o.legend(loc='best')
sns.despine()
In [308]:
#colors_targets3 = [#2B749E','#4BB1EB','#EB8C57'] Mother, Father, Stranger

plt.figure(figsize=(10,6),dpi=200)
o = sns.regplot(data=df,x='SD_cooperations_mother',y='MOTHER_self0other4',x_jitter=0.2,label='Mother',color='#2B749E')
o = sns.regplot(data=df,x='SD_cooperations_father',y='FATHER_self0other4',x_jitter=0.2,label='Father',color='#2B749E')
o = sns.regplot(data=df,x='SD_cooperations_stranger',y='STRANGER_self0other4',x_jitter=0.2,label='Stranger',color='#EB8C57')
o.set_xlabel('Number of Cooperations in SDG')
o.set_ylabel('NAcc (ROI) Parameter estimate')
o.legend(loc='best')
sns.despine()
In [55]:
pg.corr(df['PD_cooperations_father'],df['FATHER_self0other4'],method='shepherd')
Out[55]:
n outliers r CI95% r2 adj_r2 p-val power
shepherd 96 4 -0.14504 [-0.34, 0.06] 0.021036 -0.000017 0.167754 0.293113
In [40]:
pg.corr(df['PD_cooperations_stranger'],df['STRANGER_self0other4'],method='pearson')
Out[40]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 96 -0.133305 [-0.33, 0.07] 0.01777 -0.003353 0.195392 0.291 0.25474
In [57]:
pg.corr(df['PD_cooperations_mother'],df['MOTHER_self0other4'],method='shepherd')
Out[57]:
n outliers r CI95% r2 adj_r2 p-val power
shepherd 96 4 -0.017442 [-0.22, 0.18] 0.000304 -0.021195 0.868928 0.05311
In [58]:
plt.figure(figsize=(10,6),dpi=200)
p = sns.regplot(data=df,x='SD_cooperations_mother',y='MOTHER_self0other4',x_jitter=0.2,label='Mother',color='#2B749E')
p = sns.regplot(data=df,x='SD_cooperations_father',y='FATHER_self0other4',x_jitter=0.2,label='Father',color='#4BB1EB')
p = sns.regplot(data=df,x='SD_cooperations_stranger',y='STRANGER_self0other4',x_jitter=0.2,label='Stranger',color='#EB8C57')
p.set_xlabel('Number of Cooperations in SD')
p.set_ylabel('NAcc (ROI) Parameter estimate')
p.legend(loc='1')
sns.despine()
/Users/philipb/anaconda3/lib/python3.7/site-packages/matplotlib/legend.py:497: UserWarning: Unrecognized location "1". Falling back on "best"; valid locations are
	best
	upper right
	upper left
	lower left
	lower right
	right
	center left
	center right
	lower center
	upper center
	center

  % (loc, '\n\t'.join(self.codes)))

Hypothesis 18: NAcc -> FACES

  • We expect to find a higher ROI NAcc activation for each parent if questionnaire results point to a stronger emotional relationship within the family (assessed using the FACES IV questionnaire, [Olson, 2011]
In [60]:
pg.corr(df['cohesion_dim'],df['MOTHER_self0other4'],method='shepherd')
Out[60]:
n outliers r CI95% r2 adj_r2 p-val power
shepherd 115 8 0.242141 [0.06, 0.41] 0.058632 0.041822 0.011977 0.746846
In [59]:
#colors_targets3 = [#2B749E','#4BB1EB','#EB8C57'] Mother, Father, Stranger

plt.figure(figsize=(10,6),dpi=200)
q = sns.regplot(data=df,x='cohesion_dim',y='MOTHER_self0other4',label='Mother',color='#2B749E')
q = sns.regplot(data=df,x='cohesion_dim',y='FATHER_self0other4',label='Father',color='#4BB1EB')
#q = sns.regplot(data=df,x='cohesion_dim',y='STRANGER_self0other4',label='Father')
q.legend(bbox_to_anchor=(1, 0.65), loc='best')
q.set_xlabel('Family Cohesion')
q.set_ylabel('NAcc (ROI) OtherWin')
sns.despine()
In [61]:
pg.corr(df['cohesion_dim'],df['FATHER_self0other4'],method='shepherd')
Out[61]:
n outliers r CI95% r2 adj_r2 p-val power
shepherd 115 4 -0.056617 [-0.24, 0.13] 0.003206 -0.014594 0.555041 0.092301

Hypothesis 19: NAcc -> PTM

  • We expect to see higher activation within the NAcc for the other-gain > self-no-gain contrast (for unknown other target) for participants with higher scores for pro-sociality (as measured with the Prosocial Tendencies Measurement Revised,!
In [63]:
pg.corr(df['PTM'],df['STRANGER_self0other4'],method='shepherd')
Out[63]:
n outliers r CI95% r2 adj_r2 p-val power
shepherd 122 7 -0.085272 [-0.26, 0.09] 0.007271 -0.009413 0.36488 0.154619

Hypothesis 20: NAcc -> IRI

In [84]:
plt.figure(figsize=(6,4),dpi=100)
r = sns.regplot(data=df,x='PTM',y='STRANGER_self0other4',color='#EB8C57')
r.set_xlabel('Prosocial tendencies measures (PTM)')
r.set_ylabel('NAcc parameter estimates (stranger)')
sns.despine()
  • We expect to see a higher activation for the ROI NAcc analysis for the unknown other target (within the other-gain > self-no-gain contrast) with participants who score higher on measures of perspective taking and empathy, as measured with the Interpersonal Reactivity Index!
In [65]:
pg.corr(df['IRI_PT'],df['STRANGER_self0other4'],method='pearson')
Out[65]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 122 0.009652 [-0.17, 0.19] 0.000093 -0.016712 0.915964 0.114 0.051149
In [66]:
pg.corr(df['IRI_EM'],df['STRANGER_self0other4'],method='pearson')
Out[66]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 122 -0.156934 [-0.33, 0.02] 0.024628 0.008236 0.0843 0.494 0.410014
In [80]:
plt.figure(figsize=(8,6),dpi=150)
s = sns.regplot(data=df,x='IRI_PT',y='STRANGER_self0other4',order=1, label='Perspective taking',color='#EB8C57')
s= sns.regplot(data=df,x='IRI_EM',y='STRANGER_self0other4',order=1, label='Empathy',color='#EBB044')
s.set_xlabel('Interpersonal Reactivity Index (IRI)')
s.set_ylabel('NAcc parameter estimates (stranger)')
s.legend(loc='best')
sns.despine()

Exploratory

In [67]:
plt.figure(figsize=(10,6),dpi=150)
w = sns.lmplot(data=df,x='LW_mother',y='MOTHER_self0other4',hue='gender',col='gender',height=8)
#s.set_xlabel('Interpersonal Reactivity Index (IRI)')
#s.set_ylabel('NAcc parameter estimates (stranger)')
#s.legend(loc='best')
sns.despine()
<Figure size 1500x900 with 0 Axes>
In [68]:
plt.figure(figsize=(10,6),dpi=150)
w = sns.lmplot(data=df,x='LW_father',y='FATHER_self0other4',hue='gender',col='gender',height=8)
#s.set_xlabel('Interpersonal Reactivity Index (IRI)')
#s.set_ylabel('NAcc parameter estimates (stranger)')
#s.legend(loc='best')
sns.despine()
<Figure size 1500x900 with 0 Axes>
In [99]:
plt.figure(figsize=(10,6),dpi=200)
x3 = sns.regplot(data=df,x='LW_mother',y='MOTHER_self0other4',x_jitter=0.1,label='Mother',color='#2B749E')
#x3 = sns.regplot(data=df,x='LW_father',y='FATHER_self0other4',x_jitter=0.1,label='Father',color='#4BB1EB')
#x3 = sns.regplot(data=df,x='LW_stranger',y='STRANGER_self0other4',x_jitter=0.1,label='Stranger',color='#EB8C57')
x3.set_ylabel('NAcc - OtherWin')
x3.set_xlabel('Like Winning')
x3.legend(loc='upper left')
plt.ylim(-6,9)
plt.xlim(0.5,7.5)
sns.despine()
In [87]:
pg.corr(df['LW_mother'],df['MOTHER_self0other4'],method='pearson')
Out[87]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 0.341996 [0.18, 0.49] 0.116961 0.103164 0.000064 295.53 0.981489
In [88]:
pg.corr(df['LW_father'],df['FATHER_self0other4'],method='pearson')
Out[88]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 0.319257 [0.16, 0.47] 0.101925 0.087893 0.000202 101.101 0.963728
In [94]:
pg.corr(df['LW_stranger'],df['STRANGER_self0other4'],method='pearson')
Out[94]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 131 -0.072728 [-0.24, 0.1] 0.005289 -0.010253 0.40907 0.153 0.131138
In [76]:
#colors_PDG = ['#6AC27E','#CF854C']

plt.figure(figsize=(10,6),dpi=200)
x4 = sns.regplot(data=df,x='PD_cooperations_mother',y='MOTHER_self4other0',x_jitter=0.1,label='PD',color='#6AC27E')
x4 = sns.regplot(data=df,x='SD_cooperations_mother',y='MOTHER_self4other0',x_jitter=0.1,label='SD',color='#CF854C')
x4.set_ylabel('NAcc (ROI) Mother - SelfWin')
x4.set_xlabel('Number of cooperations with Mother')
x4.legend(loc='best')
sns.despine()
In [74]:
pg.corr(df['PD_cooperations_mother'],df['MOTHER_self0other4'],method='pearson')
Out[74]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 96 -0.024786 [-0.22, 0.18] 0.000614 -0.020878 0.810558 0.131 0.056464
In [75]:
pg.corr(df['PD_cooperations_mother'],df['MOTHER_self4other0'],method='pearson')
Out[75]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 96 -0.287648 [-0.46, -0.09] 0.082742 0.063016 0.004486 6.805 0.817993
In [69]:
df.corr()
Out[69]:
age age2 LW_self LW_mother LW_father LW_stranger PD_Cooperations SD_Cooperations PD_cooperations_mother PD_cooperations_father ... cohesion_dim flexibility_dim altruism honesty emotionality extraversion agreeableness conscientiousness openness average_nogain
age 1.000000 -0.288059 -0.091526 -0.034663 -0.116611 -0.025464 0.038409 0.290055 0.110810 0.153689 ... -0.111752 -0.022316 -0.067702 -0.113146 0.082301 0.067359 0.040347 0.159143 0.052738 -0.157615
age2 -0.288059 1.000000 0.149851 0.003100 -0.001248 -0.225295 -0.131756 -0.274092 -0.059953 -0.110396 ... -0.152018 -0.178365 0.026831 -0.138697 -0.061631 0.072717 -0.125635 0.048293 0.096417 -0.019985
LW_self -0.091526 0.149851 1.000000 0.424031 0.357259 -0.230387 -0.145264 -0.270093 -0.152086 -0.117428 ... 0.093608 -0.142749 0.082416 -0.158584 -0.039094 0.098596 -0.169946 -0.077817 -0.191009 -0.102932
LW_mother -0.034663 0.003100 0.424031 1.000000 0.730257 0.115621 0.028453 -0.233536 0.003777 -0.022743 ... 0.037450 0.058963 0.126772 -0.071493 0.081146 0.013458 -0.037698 0.024836 -0.113234 -0.208588
LW_father -0.116611 -0.001248 0.357259 0.730257 1.000000 0.136867 0.082969 -0.281694 -0.019952 0.156742 ... -0.022666 0.055832 0.040572 -0.126396 -0.066582 0.017284 -0.099797 0.007509 -0.175204 -0.206321
LW_stranger -0.025464 -0.225295 -0.230387 0.115621 0.136867 1.000000 0.299719 0.126860 0.267766 0.222285 ... 0.121426 0.149180 0.196766 0.309862 0.264334 -0.129736 0.192761 0.270028 0.080862 -0.018849
PD_Cooperations 0.038409 -0.131756 -0.145264 0.028453 0.082969 0.299719 1.000000 0.219142 0.814605 0.808093 ... 0.255920 0.193048 -0.153973 0.196207 0.181073 -0.135527 0.032602 0.149945 0.147579 0.128524
SD_Cooperations 0.290055 -0.274092 -0.270093 -0.233536 -0.281694 0.126860 0.219142 1.000000 0.256658 0.131864 ... 0.031899 0.191841 -0.114859 0.327029 0.251438 0.027216 0.040731 0.034930 -0.116250 0.168959
PD_cooperations_mother 0.110810 -0.059953 -0.152086 0.003777 -0.019952 0.267766 0.814605 0.256658 1.000000 0.690540 ... 0.199450 0.164323 -0.033183 0.087776 0.153493 -0.124706 0.046782 0.068792 0.077446 0.147870
PD_cooperations_father 0.153689 -0.110396 -0.117428 -0.022743 0.156742 0.222285 0.808093 0.131864 0.690540 1.000000 ... 0.146491 0.156390 -0.144481 0.212599 0.047242 -0.061433 0.009764 0.110043 -0.040287 0.202566
PD_cooperations_stranger -0.146228 -0.125448 -0.102743 0.105149 0.063955 0.318366 0.715922 0.103956 0.327497 0.322292 ... 0.239883 0.114351 -0.109386 0.184630 0.228370 -0.156599 0.135615 0.157910 0.246609 -0.040354
SD_cooperations_mother 0.251601 -0.233354 -0.204101 -0.216984 -0.258669 0.062555 0.201106 0.897695 0.271002 0.151333 ... 0.078918 0.221933 -0.155332 0.300406 0.253824 0.154648 0.139804 0.023490 -0.157719 0.163210
SD_cooperations_father 0.313707 -0.300448 -0.219309 -0.315204 -0.228805 0.038319 0.169152 0.856870 0.225339 0.215923 ... 0.022604 0.145722 -0.093668 0.243038 0.168523 0.085931 0.032216 0.001347 -0.097918 0.143896
SD_cooperations_stranger 0.187916 -0.171761 -0.265104 -0.077418 -0.232092 0.220164 0.180150 0.802673 0.172067 -0.006085 ... -0.015502 0.126035 -0.039810 0.283398 0.211423 -0.140761 -0.039968 0.053774 -0.058630 0.127374
PTM -0.051362 -0.063468 -0.013274 0.052466 0.014486 0.259117 0.176918 -0.019081 0.184545 0.066816 ... -0.004423 -0.071627 0.329205 0.029279 0.357780 0.115424 0.182999 0.116641 0.234353 -0.041495
IRI_EM -0.104649 0.043928 -0.147068 0.022890 -0.037079 0.138036 0.255482 0.042405 0.194194 0.210275 ... 0.069990 -0.077159 0.127691 0.253779 0.590264 0.041416 0.262428 0.301229 0.263962 0.066932
IRI_PT 0.157919 0.022057 -0.299723 -0.104905 -0.100230 0.141058 0.174431 0.020170 0.169782 0.256278 ... -0.090064 0.198025 -0.118483 0.295557 0.197835 0.123306 0.379815 0.305447 0.326794 0.069014
FATHER_self2other2 0.127588 -0.041375 -0.011678 0.097564 0.131752 0.147228 -0.201887 -0.058970 -0.141508 -0.174684 ... -0.044919 0.075468 0.249172 -0.264922 -0.071557 0.047531 -0.148349 -0.068274 0.048454 -0.460836
FATHER_self0other4 0.101923 -0.087299 0.211999 0.351245 0.326535 0.099907 -0.040135 -0.028242 -0.067633 -0.107860 ... 0.044501 0.102626 0.253809 -0.068565 -0.018025 -0.004131 -0.007412 -0.124268 -0.092563 -0.455869
FATHER_self4other0 0.027735 0.037468 0.129697 0.083553 0.061637 0.011582 0.002106 -0.086026 -0.157012 -0.084982 ... -0.034060 -0.073160 0.073799 0.026180 -0.018521 -0.003578 0.059406 -0.054738 0.134331 -0.306180
FATHER_bothnogain -0.108763 0.083279 -0.024231 -0.126754 -0.076526 -0.029622 0.093499 0.111601 0.105903 0.152141 ... -0.110612 0.035718 -0.058086 -0.178145 -0.092981 0.269666 -0.085020 0.030988 0.048894 0.754267
MOTHER_self2other2 0.021517 0.091725 0.100661 0.094712 0.074049 0.192925 0.002012 -0.083304 -0.016934 -0.051045 ... 0.080878 -0.098941 0.168753 0.018328 0.018100 0.002793 0.172516 0.220868 -0.029489 -0.278589
MOTHER_self0other4 0.146020 0.067200 0.118014 0.338238 0.244271 0.051284 0.013272 -0.027516 -0.024786 -0.082576 ... 0.065173 0.051333 0.055260 -0.241274 -0.024050 -0.059695 0.012710 -0.112397 -0.101704 -0.459246
MOTHER_self4other0 -0.053411 0.122083 0.000197 -0.005109 -0.031905 -0.101083 -0.258800 -0.246860 -0.287648 -0.260073 ... -0.079579 -0.159197 0.211794 0.120410 0.046903 -0.026026 0.150984 0.113308 0.055728 -0.368196
MOTHER_bothnogain -0.162138 -0.141854 -0.185184 -0.188097 -0.194433 -0.008461 0.122049 0.168895 0.157498 0.192008 ... 0.091305 -0.036631 -0.113491 0.182409 0.016184 -0.112336 0.164656 0.032340 0.037839 0.760864
STRANGER_self2other2 0.098232 -0.013247 0.155602 0.146421 0.126378 0.098361 -0.079318 -0.102208 -0.078532 -0.117421 ... 0.091940 -0.063481 0.116128 -0.047461 -0.121124 0.011901 0.011787 -0.012819 -0.073632 -0.478585
STRANGER_self0other4 0.039497 0.072781 0.048846 0.209040 0.179155 -0.072659 -0.183361 -0.191726 -0.186165 -0.101891 ... -0.066667 -0.001060 0.064483 -0.064789 -0.150689 -0.024537 -0.081585 -0.178437 0.113069 -0.292569
STRANGER_self4other0 0.030206 -0.004131 0.122224 0.313114 0.288317 0.069668 -0.138163 -0.237102 -0.128434 -0.212229 ... -0.047855 -0.089490 0.170233 -0.148711 -0.023650 -0.017047 -0.005140 -0.054571 0.057275 -0.477859
STRANGER_bothnogain -0.081074 0.029671 -0.015656 -0.161067 -0.199321 -0.005692 0.069797 0.093911 0.063343 0.105585 ... -0.043100 0.062856 -0.239863 0.170714 0.080837 -0.013103 -0.028591 0.087726 0.019582 0.755117
cohesion_dim -0.111752 -0.152018 0.093608 0.037450 -0.022666 0.121426 0.255920 0.031899 0.199450 0.146491 ... 1.000000 0.006995 0.045501 0.276146 0.009556 0.005742 0.084981 -0.031496 -0.013811 -0.019406
flexibility_dim -0.022316 -0.178365 -0.142749 0.058963 0.055832 0.149180 0.193048 0.191841 0.164323 0.156390 ... 0.006995 1.000000 -0.062234 0.133074 0.112790 -0.034528 -0.022133 0.017770 -0.134562 0.021217
altruism -0.067702 0.026831 0.082416 0.126772 0.040572 0.196766 -0.153973 -0.114859 -0.033183 -0.144481 ... 0.045501 -0.062234 1.000000 -0.065864 0.138393 -0.043717 -0.130913 -0.086418 0.046342 -0.173044
honesty -0.113146 -0.138697 -0.158584 -0.071493 -0.126396 0.309862 0.196207 0.327029 0.087776 0.212599 ... 0.276146 0.133074 -0.065864 1.000000 0.190022 -0.176566 0.377734 0.262556 -0.079668 0.083776
emotionality 0.082301 -0.061631 -0.039094 0.081146 -0.066582 0.264334 0.181073 0.251438 0.153493 0.047242 ... 0.009556 0.112790 0.138393 0.190022 1.000000 -0.008548 0.057286 0.012108 0.222241 0.003218
extraversion 0.067359 0.072717 0.098596 0.013458 0.017284 -0.129736 -0.135527 0.027216 -0.124706 -0.061433 ... 0.005742 -0.034528 -0.043717 -0.176566 -0.008548 1.000000 0.179740 0.094831 0.081373 0.049010
agreeableness 0.040347 -0.125635 -0.169946 -0.037698 -0.099797 0.192761 0.032602 0.040731 0.046782 0.009764 ... 0.084981 -0.022133 -0.130913 0.377734 0.057286 0.179740 1.000000 0.209206 0.185333 0.032182
conscientiousness 0.159143 0.048293 -0.077817 0.024836 0.007509 0.270028 0.149945 0.034930 0.068792 0.110043 ... -0.031496 0.017770 -0.086418 0.262556 0.012108 0.094831 0.209206 1.000000 0.163838 0.062846
openness 0.052738 0.096417 -0.191009 -0.113234 -0.175204 0.080862 0.147579 -0.116250 0.077446 -0.040287 ... -0.013811 -0.134562 0.046342 -0.079668 0.222241 0.081373 0.185333 0.163838 1.000000 0.045113
average_nogain -0.157615 -0.019985 -0.102932 -0.208588 -0.206321 -0.018849 0.128524 0.168959 0.147870 0.202566 ... -0.019406 0.021217 -0.173044 0.083776 0.003218 0.049010 0.032182 0.062846 0.045113 1.000000

39 rows × 39 columns

In [76]:
pg.corr(df['SD_cooperations_mother'],df['MOTHER_self4other0'],method='pearson')
Out[76]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 96 -0.320617 [-0.49, -0.13] 0.102795 0.083501 0.001449 18.83 0.896132
In [ ]:
plt.figure(figsize=(10,6),dpi=200)
x3 = sns.regplot(data=df,x='conscientiousness',y='emotionality',color='#2B749E')
sns.despine()

Compare correlations between mother and father for NAcc + Joy of winning

In [15]:
from CorrelationStats import corrstats
In [25]:
help(corrstats)
Help on module CorrelationStats.corrstats in CorrelationStats:

NAME
    CorrelationStats.corrstats

DESCRIPTION
    Functions for calculating the statistical significant differences between two dependent or independent correlation
    coefficients.
    The Fisher and Steiger method is adopted from the R package http://personality-project.org/r/html/paired.r.html
    and is described in detail in the book 'Statistical Methods for Psychology'
    The Zou method is adopted from http://seriousstats.wordpress.com/2012/02/05/comparing-correlations/
    Credit goes to the authors of above mentioned packages!
    
    Author: Philipp Singer (www.philippsinger.info)

FUNCTIONS
    atanh(x, /)
        Return the inverse hyperbolic tangent of x.
    
    dependent_corr(xy, xz, yz, n, twotailed=True, conf_level=0.95, method='steiger')
        Calculates the statistic significance between two dependent correlation coefficients
        @param xy: correlation coefficient between x and y
        @param xz: correlation coefficient between x and z
        @param yz: correlation coefficient between y and z
        @param n: number of elements in x, y and z
        @param twotailed: whether to calculate a one or two tailed test, only works for 'steiger' method
        @param conf_level: confidence level, only works for 'zou' method
        @param method: defines the method uses, 'steiger' or 'zou'
        @return: t and p-val
    
    independent_corr(xy, ab, n, n2=None, twotailed=True, conf_level=0.95, method='fisher')
        Calculates the statistic significance between two independent correlation coefficients
        @param xy: correlation coefficient between x and y
        @param xz: correlation coefficient between a and b
        @param n: number of elements in xy
        @param n2: number of elements in ab (if distinct from n)
        @param twotailed: whether to calculate a one or two tailed test, only works for 'fisher' method
        @param conf_level: confidence level, only works for 'zou' method
        @param method: defines the method uses, 'fisher' or 'zou'
        @return: z and p-val
    
    pow(x, y, /)
        Return x**y (x to the power of y).
    
    rho_rxy_rxz(rxy, rxz, ryz)
    
    rz_ci(r, n, conf_level=0.95)

DATA
    division = _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192...
    norm = <scipy.stats._continuous_distns.norm_gen object>
    t = <scipy.stats._continuous_distns.t_gen object>
    tanh = <ufunc 'tanh'>

AUTHOR
    psinger

FILE
    /Users/philipb/surfdrive/PhD/BRAINLINKS/T1/data/CorrelationStats/corrstats.py


In [24]:
# Compare correlations between mother
corrstats.independent_corr(0.341996,0.319257,131,twotailed=True,conf_level=0.95,method='fisher')
Out[24]:
(0.2042527878996303, 0.8381559619616423)

Personality & Reward activity

In [3]:
df_master = pd.read_csv('/Users/philipb/surfdrive/PhD/BRAINLINKS/T1/T1_MASTER_2020.csv')
df_master.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 141 entries, 0 to 140
Data columns (total 60 columns):
 #   Column                         Non-Null Count  Dtype  
---  ------                         --------------  -----  
 0   PPN                            141 non-null    object 
 1   age                            140 non-null    float64
 2   sex                            140 non-null    object 
 3   oxytocin_0                     136 non-null    float64
 4   oxytocin_1                     137 non-null    float64
 5   IOS_stranger                   126 non-null    float64
 6   IOS_mother                     126 non-null    float64
 7   IOS_father                     126 non-null    float64
 8   LW_self                        139 non-null    float64
 9   LW_mother                      139 non-null    float64
 10  LW_father                      139 non-null    float64
 11  LW_stranger                    139 non-null    float64
 12  CLOSE_father                   138 non-null    float64
 13  CLOSE_mother                   138 non-null    float64
 14  CLOSE_stranger                 138 non-null    float64
 15  PTM                            131 non-null    object 
 16  RSS                            130 non-null    float64
 17  altruism                       101 non-null    float64
 18  honesty                        101 non-null    float64
 19  emotiolity                     101 non-null    float64
 20  extraversion                   101 non-null    float64
 21  agreeableness                  101 non-null    float64
 22  conscientiousness              101 non-null    float64
 23  openness                       101 non-null    float64
 24  ext_neuro                      101 non-null    float64
 25  FATHER_self2other2             127 non-null    float64
 26  FATHER_self0other4             127 non-null    float64
 27  FATHER_self4other0             127 non-null    float64
 28  FATHER_bothnogain              127 non-null    float64
 29  MOTHER_self2other2             127 non-null    float64
 30  MOTHER_self0other4             127 non-null    float64
 31  MOTHER_self4other0             127 non-null    float64
 32  MOTHER_bothnogain              127 non-null    float64
 33  STRANGER_self2other2           127 non-null    float64
 34  STRANGER_self0other4           127 non-null    float64
 35  STRANGER_self4other0           127 non-null    float64
 36  STRANGER_bothnogain            127 non-null    float64
 37  sd_total_points                92 non-null     float64
 38  NrCooperations_total_pd        92 non-null     float64
 39  NrCooperations_total_sd        92 non-null     float64
 40  NrDefections_total_pd          92 non-null     float64
 41  NrDefections_total_sd          92 non-null     float64
 42  NrCooperations_total_mother    92 non-null     float64
 43  NrCooperations_total_father    92 non-null     float64
 44  NrCooperations_total_stranger  92 non-null     float64
 45  NrDefections_total_mother      92 non-null     float64
 46  NrDefections_total_father      92 non-null     float64
 47  NrDefections_total_stranger    92 non-null     float64
 48  NrCooperationsMother_pd        92 non-null     float64
 49  NrCooperationsFather_pd        92 non-null     float64
 50  NrCooperationsStranger_pd      92 non-null     float64
 51  NrCooperationsMother_sd        92 non-null     float64
 52  NrCooperationsFather_sd        92 non-null     float64
 53  NrCooperationsStranger_sd      92 non-null     float64
 54  NrDefectionsMother_pd          92 non-null     float64
 55  NrDefectionsFather_pd          92 non-null     float64
 56  NrDefectionsStranger_pd        92 non-null     float64
 57  NrDefectionsMother_sd          92 non-null     float64
 58  NrDefectionsFather_sd          92 non-null     float64
 59  NrDefectionsStranger_sd        91 non-null     float64
dtypes: float64(57), object(3)
memory usage: 66.2+ KB
In [40]:
tidy_nacc.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1341 entries, 0 to 1340
Data columns (total 10 columns):
 #   Column        Non-Null Count  Dtype  
---  ------        --------------  -----  
 0   PPN           1341 non-null   object 
 1   gender        1341 non-null   object 
 2   age           1341 non-null   float64
 3   age2          1341 non-null   float64
 4   PTM           1233 non-null   float64
 5   IRI_EM        1197 non-null   float64
 6   IRI_PT        1197 non-null   float64
 7   NAcc_target   1341 non-null   object 
 8   NAcc_outcome  1341 non-null   object 
 9   NAcc          1197 non-null   float64
dtypes: float64(6), object(4)
memory usage: 104.9+ KB
In [6]:
plt.figure(figsize=(10,6),dpi=200)
x3 = sns.regplot(data=df_master,x='extraversion',y='STRANGER_self4other0',color='#2B749E')
sns.despine()

DCN - Revision -mPFC ROI analysis (2021)

In [36]:
q = sns.catplot(data=tidy_mpfc,x='vmPFC_target',y='vmPFC',hue='vmPFC_outcome',kind='bar',height=15,aspect=1.33,ci=95,
               palette=sns.color_palette(colors_outcomes, n_colors=3, desat=0.9))
q.set_axis_labels('Target','vmPFC parameter estimate')
sns.despine()
In [47]:
#colors_targets = ['#3A9E70','#2B749E','#4BB1EB','#EB8C57'] #Self , Mother, Father, Stranger

plt.figure(figsize=(14,10))
#q = sns.violinplot(data=tidy_nacc_other,x='NAcc_target',y='NAcc',hue='gender',split=True,
#               palette=sns.color_palette(colors_targets3_father, desat=0.9),inner=None)
q = sns.swarmplot(data=tidy_mpfc,x='mPFC_outcome',y='mPFC',hue="mPFC_target",
               palette=sns.color_palette(colors_targets3_father, n_colors=3, desat=1))
#q.set_axis_labels('Target','NAcc parameter estimate')
#q.set_legend('Target','NAcc parameter estimate')
#q.legend(loc='best')
sns.despine()
In [69]:
plt.figure(figsize=(10,8),dpi=150)
q = sns.catplot(data=tidy_mpfc,x='mPFC_outcome',y='mPFC',kind='violin',hue = 'mPFC_target', height=8,aspect=1.33,ci=99)
sns.despine()
<Figure size 1500x1200 with 0 Axes>

Stats mFPC

In [ ]:
# ANOVA for SelfWin > NoWin (page 14)
rma_mpfc_self = pg.rm_anova(data=tidy_nacc_nowin,dv='NAcc',within=['NAcc_outcome'],subject='PPN',detailed=True)
rma_mpfc_self
In [ ]:
# ANCOVA + age2 for SelfWin > NoWin (page 14)
ancova_nowin = pg.ancova(data=tidy_nacc_nowin,dv='NAcc',between='NAcc_outcome',covar='age2')
ancova_nowin
In [ ]:
# ANCOVA + age for SelfWin > NoWin (page 14)

ancova_nowin = pg.ancova(data=tidy_nacc_nowin,dv='NAcc',between='NAcc_outcome',covar='age')
ancova_nowin
In [48]:
# 3x3 RM-ANOVA: BothWin > OtherWin (page 14)
rma_mpfc = pg.rm_anova(data=tidy_mpfc,dv='mPFC',within=['mPFC_target','mPFC_outcome'],subject='PPN',detailed=True)
rma_mpfc
/Users/philipb/anaconda3/lib/python3.7/site-packages/pingouin/distribution.py:459: UserWarning: Epsilon values might be innaccurate in two-way repeated measures design where each  factor has more than 2 levels. Please  double-check your results.
  warnings.warn("Epsilon values might be innaccurate in "
Out[48]:
Source SS ddof1 ddof2 MS F p-unc p-GG-corr np2 eps
0 mPFC_target 130.380934 2 258 65.190467 2.731571 0.067001 0.072908 0.020736 0.901055
1 mPFC_outcome 49.085243 2 258 24.542621 1.220275 0.296847 0.292864 0.009371 0.854847
2 mPFC_target * mPFC_outcome 288.678294 4 516 72.169573 4.374405 0.001735 0.003937 0.032798 0.798732

Result:

  • No Target effect, No Outcome effect
  • But an Interaction effect target*Outcome
In [37]:
# ANOVA for EACH conditions separately (page 17) -- SELF
pg.rm_anova(data=tidy_mPFC_self, dv='mPFC',within='mPFC_target',subject='PPN')
Out[37]:
Source ddof1 ddof2 F p-unc np2 eps
0 mPFC_target 2 258 1.210315 0.29979 0.009295 0.975541
In [38]:
# ANOVA for EACH conditions separately (page 17) -- SELF
pg.rm_anova(data=tidy_mPFC_both, dv='mPFC',within='mPFC_target',subject='PPN')
Out[38]:
Source ddof1 ddof2 F p-unc np2 eps
0 mPFC_target 2 258 4.91127 0.008066 0.036676 0.98586
In [43]:
# ANOVA for EACH conditions separately (page 17) -- SELF
pg.rm_anova(data=tidy_mPFC_other, dv='mPFC',within='mPFC_target',subject='PPN')
Out[43]:
Source ddof1 ddof2 F p-unc p-GG-corr np2 eps sphericity W-spher p-spher
0 mPFC_target 2 258 4.914537 0.008041 0.010187 0.036699 0.906064 False 0.896325 0.000907
In [32]:
pg.pairwise_ttests(data=tidy_mPFC_both, dv='mPFC', between='mPFC_target')
Out[32]:
Contrast A B Paired Parametric T dof Tail p-unc BF10 hedges
0 mPFC_target father mother False True 2.874752 274.0 two-sided 0.004361 6.477 0.345131
1 mPFC_target father stranger False True 2.442397 274.0 two-sided 0.015222 2.214 0.293224
2 mPFC_target mother stranger False True -0.303885 274.0 two-sided 0.761446 0.138 -0.036483
In [31]:
pg.pairwise_ttests(data=tidy_mPFC_other, dv='mPFC', between='mPFC_target')
Out[31]:
Contrast A B Paired Parametric T dof Tail p-unc BF10 hedges
0 mPFC_target father mother False True 0.762967 274.0 two-sided 0.446140 0.174 0.091599
1 mPFC_target father stranger False True 2.621636 274.0 two-sided 0.009240 3.385 0.314743
2 mPFC_target mother stranger False True 1.849118 274.0 two-sided 0.065518 0.669 0.221998

Neuro-Behavioral Correlations (mPFC)

In [26]:
#colors_targets3 = [#2B749E','#4BB1EB','#EB8C57'] Mother, Father, Stranger

plt.figure(figsize=(10,6),dpi=200)
o = sns.regplot(data=df,x='PD_cooperations_mother',y='MPFC_MOTHER_self0other4',x_jitter=0.2,label='Mother',color='#2B749E')
o = sns.regplot(data=df,x='PD_cooperations_father',y='MPFC_FATHER_self0other4',x_jitter=0.2,label='Father',color='#2B749E')
o = sns.regplot(data=df,x='PD_cooperations_stranger',y='MPFC_STRANGER_self0other4',x_jitter=0.2,label='Stranger',color='#EB8C57')
o.set_xlabel('Number of Cooperations in PDG')
o.set_ylabel('MPFC_ (ROI) Parameter estimate')
o.legend(loc='best')
sns.despine()
In [53]:
plt.figure(figsize=(10,6),dpi=150)
w = sns.lmplot(data=df,x='LW_mother',y='MPFC_MOTHER_self0other4',hue='gender',col='gender',height=8)
#s.set_xlabel('Interpersonal Reactivity Index (IRI)')
#s.set_ylabel('NAcc parameter estimates (stranger)')
#s.legend(loc='best')
sns.despine()
<Figure size 1500x900 with 0 Axes>
In [57]:
plt.figure(figsize=(10,6),dpi=150)
w = sns.lmplot(data=df,x='LW_father',y='MPFC_FATHER_self0other4',hue='gender',col='gender',height=8)
#s.set_xlabel('Interpersonal Reactivity Index (IRI)')
#s.set_ylabel('NAcc parameter estimates (stranger)')
#s.legend(loc='best')
sns.despine()
<Figure size 1500x900 with 0 Axes>
In [55]:
plt.figure(figsize=(10,6),dpi=200)
x3 = sns.regplot(data=df,x='LW_mother',y='MPFC_MOTHER_self0other4',x_jitter=0.1,label='Mother',color='#2B749E')
x3 = sns.regplot(data=df,x='LW_father',y='MPFC_FATHER_self0other4',x_jitter=0.1,label='Father',color='#4BB1EB')
# x3 = sns.regplot(data=df,x='LW_stranger',y='MPFC_STRANGER_self0other4',x_jitter=0.1,label='Stranger',color='#EB8C57')
x3.set_ylabel('MPFC - OtherWin')
x3.set_xlabel('Like Winning')
x3.legend(loc='upper left')
plt.ylim(-6,9)
plt.xlim(0.5,7.5)
sns.despine()
In [40]:
plt.figure(figsize=(10,6),dpi=250)
x3 = sns.regplot(data=df,x='MOTHER_self0other4',y='MPFC_MOTHER_self0other4',x_jitter=0.1,label='Mother',color='#2B749E')
x3 = sns.regplot(data=df,x='FATHER_self0other4',y='MPFC_FATHER_self0other4',x_jitter=0.1,label='Father',color='#4BB1EB')
x3 = sns.regplot(data=df,x='STRANGER_self0other4',y='MPFC_STRANGER_self0other4',x_jitter=0.1,label='Stranger',color='#EB8C57')
x3.set_ylabel('vMPFC - OtherWin')
x3.set_xlabel('NAcc - OtherWin')
x3.legend(loc='lower right')
plt.ylim(-6,9)
plt.xlim(0.5,7.5)
sns.despine()
In [41]:
pg.corr(df['MOTHER_self0other4'],df['MPFC_MOTHER_self0other4'],method='spearman')
Out[41]:
n r CI95% r2 adj_r2 p-val power
spearman 130 0.651124 [0.54, 0.74] 0.423962 0.414891 4.991724e-17 1.0
In [60]:
pg.corr(df['FATHER_self0other4'],df['MPFC_FATHER_self0other4'],method='spearman')
Out[60]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 122 0.666193 [0.55, 0.75] 0.443813 0.434465 5.581418e-17 1.239e+14 1.0
In [61]:
pg.corr(df['STRANGER_self0other4'],df['MPFC_STRANGER_self0other4'],method='spearman')
Out[61]:
n r CI95% r2 adj_r2 p-val BF10 power
pearson 122 0.476414 [0.33, 0.6] 0.226971 0.213978 2.909616e-08 4.508e+05 0.999898
In [62]:
plt.figure(figsize=(10,6),dpi=200)
x3 = sns.regplot(data=df,x='MOTHER_self4other0',y='MPFC_MOTHER_self4other0',x_jitter=0.1,label='Mother',color='#2B749E')
x3 = sns.regplot(data=df,x='FATHER_self4other0',y='MPFC_FATHER_self4other0',x_jitter=0.1,label='Father',color='#4BB1EB')
x3 = sns.regplot(data=df,x='STRANGER_self4other0',y='MPFC_STRANGER_self4other0',x_jitter=0.1,label='Stranger',color='#EB8C57')
x3.set_ylabel('MPFC - SelfWin')
x3.set_xlabel('NAcc - SelfWin')
x3.legend(loc='upper left')
plt.ylim(-6,9)
plt.xlim(0.5,7.5)
sns.despine()
In [ ]: