By Philip Brandner September 2020
# 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
pg.__version__
sns.__version__
!git clone https://github.com/psinger/CorrelationStats.git
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')
# 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()
df_faces = pd.read_csv('/Users/philipb/surfdrive/PhD/BRAINLINKS/T1/data/T1_FACES_final.csv')
df_faces
#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)
df_hexaco = pd.read_csv('/Users/philipb/surfdrive/PhD/BRAINLINKS/T1/Vragenlijsten/T1_HEXACO_scored.csv')
df_hexaco
df = pd.merge(left=df, right=df_hexaco,how='left',left_on='PPN',right_on='PPN')
df.drop(['Unnamed: 0'],axis=1,inplace=True)
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
df['nacc_average_nogain'] = df[['MOTHER_bothnogain','FATHER_bothnogain','STRANGER_bothnogain']].mean(axis=1)
df['nacc_average_nogain'].hist()
df['mpfc_average_nogain'] = df[['MPFC_MOTHER_bothnogain','MPFC_FATHER_bothnogain','MPFC_STRANGER_bothnogain']].mean(axis=1)
df['mpfc_average_nogain'].hist()
# 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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
# 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()
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()
# 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']
df.info()
plt.figure(figsize = (10,8))
sns.kdeplot(data=df,x='age',y='PD_cooperations_stranger',hue='gender', palette='crest',fill=True)
sns.despine()
plt.figure(figsize=(14,8))
sns.distplot(df['PD_Cooperations'])
sns.distplot(df['SD_Cooperations'])
plt.ylim(0,0.1)
sns.despine()
# 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('')
test assumptions
pg.normality(tidy,dv='LW',group='LW_target')
Seems like we do not have a normal distribution for LW & LW Target
pg.homoscedasticity(tidy,dv='LW',group='LW_target')
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.
# Run the ANOVA
welch_aov_LW = pg.welch_anova(data=tidy,dv='LW',between='LW_target')
welch_aov_LW
# 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
# 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)
Let's run a 3x2 repeated-measures-ANOVA for targets(3)*context(2)
tidy.info()
# 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')
aov_PD = pg.rm_anova(data=tidy,dv='PD',within=['PD_target','PD_context'], subject='PPN')
aov_PD
pg.homoscedasticity(tidy,dv='PD',group='PD_target')
Let's test pairwise-post-hoc with Games-Howell because Lavene's test of heteroscedascity is not met
pg.pairwise_gameshowell(data=tidy, dv='PD', between='PD_target')
Interpretation:
pg.pairwise_gameshowell(data=tidy, dv='PD', between='PD_context')
Interpretation:
# 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)
pg.ancova(data=tidy, dv='PD',between='PD_target',covar='age')
# 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)
# 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)
# The way to use pps is
# pps.score(df, "feature_column", "target_column")
# https://github.com/8080labs/ppscore
#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.
plt.figure(figsize=(8,5),dpi=250)
m = sns.regplot(data=df,x='LW_mother',y='LW_father',x_jitter=0.5)
sns.despine()
pg.corr(df['LW_father'],df['LW_mother'],method='shepherd')
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()
pg.corr(df['PD_Cooperations'],df['LW_stranger'],method='shepherd')
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()
pg.corr(df['LW_self'],df['SD_Cooperations'],method='shepherd')
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()
#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()
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()
pg.homoscedasticity(tidy_nacc, dv='NAcc', group='NAcc_target')
# Let's test for equal of varaince assumption
pg.homoscedasticity(tidy_nacc_other, dv='NAcc', group='NAcc_target')
# 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
# ANCOVA + age2 for SelfWin > NoWin (page 14)
ancova_nowin = pg.ancova(data=tidy_nacc_nowin,dv='NAcc',between='NAcc_outcome',covar='age2')
ancova_nowin
# ANCOVA + age for SelfWin > NoWin (page 14)
ancova_nowin = pg.ancova(data=tidy_nacc_nowin,dv='NAcc',between='NAcc_outcome',covar='age')
ancova_nowin
# 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
Interpretation: No target effects but outcome & interaction effects
Interpretation: No differences between targets
pg.pairwise_ttests(data=tidy_nacc, dv='NAcc', between='NAcc_outcome')
# ANOVA for EACH conditions separately (page 14) -- SELF
pg.rm_anova(data=tidy_nacc_self, dv='NAcc',within='NAcc_target',subject='PPN')
# ANOVA for EACH conditions separately (page 14) -- BOTH
pg.rm_anova(data=tidy_nacc_both, dv='NAcc',within='NAcc_target',subject='PPN')
# ANOVA for EACH conditions separately (page 14) -- OTHER
pg.rm_anova(data=tidy_nacc_other, dv='NAcc',within='NAcc_target',subject='PPN')
# simple t-test to compare STRANGER OtherWin > NoWin
pg.ttest(df['STRANGER_self0other4'],df['STRANGER_bothnogain'])
sns.catplot(data=tidy_nacc_nowin_stranger,x='NAcc_outcome',y='NAcc',kind='swarm')
# Gender split
pg.mixed_anova(data=tidy_nacc_other, dv='NAcc',between='gender',within='NAcc_target',subject='PPN')
pg.ancova(data=tidy_nacc, dv='NAcc',between='NAcc_outcome',covar='age')
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))
# Correlation matrix (page 18)
df.corr()
pg.corr(df['LW_mother'],df['MOTHER_self2other2'],method='pearson')
pg.corr(df['LW_mother'],df['MOTHER_self0other4'],method='pearson')
pg.corr(df['LW_father'],df['FATHER_self2other2'],method='pearson')
pg.corr(df['LW_father'],df['FATHER_self0other4'],method='pearson')
pg.corr(df['LW_stranger'],df['STRANGER_self2other2'],method='pearson')
pg.corr(df['LW_stranger'],df['STRANGER_self0other4'],method='pearson')
pg.corr(df['PD_cooperations_mother'],df['MOTHER_self4other0'])
pg.corr(df['SD_cooperations_mother'],df['MOTHER_self4other0'])
pg.corr(df['PD_cooperations_stranger'],df['LW_stranger'])
pg.corr(df['SD_cooperations_stranger'],df['LW_stranger'])
pg.corr(df['SD_cooperations_stranger'],df['LW_self'])
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.
#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()
#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()
pg.corr(df['PD_cooperations_father'],df['FATHER_self0other4'],method='shepherd')
pg.corr(df['PD_cooperations_stranger'],df['STRANGER_self0other4'],method='pearson')
pg.corr(df['PD_cooperations_mother'],df['MOTHER_self0other4'],method='shepherd')
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()
pg.corr(df['cohesion_dim'],df['MOTHER_self0other4'],method='shepherd')
#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()
pg.corr(df['cohesion_dim'],df['FATHER_self0other4'],method='shepherd')
pg.corr(df['PTM'],df['STRANGER_self0other4'],method='shepherd')
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()
pg.corr(df['IRI_PT'],df['STRANGER_self0other4'],method='pearson')
pg.corr(df['IRI_EM'],df['STRANGER_self0other4'],method='pearson')
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()
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()
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()
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()
pg.corr(df['LW_mother'],df['MOTHER_self0other4'],method='pearson')
pg.corr(df['LW_father'],df['FATHER_self0other4'],method='pearson')
pg.corr(df['LW_stranger'],df['STRANGER_self0other4'],method='pearson')
#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()
pg.corr(df['PD_cooperations_mother'],df['MOTHER_self0other4'],method='pearson')
pg.corr(df['PD_cooperations_mother'],df['MOTHER_self4other0'],method='pearson')
df.corr()
pg.corr(df['SD_cooperations_mother'],df['MOTHER_self4other0'],method='pearson')
plt.figure(figsize=(10,6),dpi=200)
x3 = sns.regplot(data=df,x='conscientiousness',y='emotionality',color='#2B749E')
sns.despine()
from CorrelationStats import corrstats
help(corrstats)
# Compare correlations between mother
corrstats.independent_corr(0.341996,0.319257,131,twotailed=True,conf_level=0.95,method='fisher')
df_master = pd.read_csv('/Users/philipb/surfdrive/PhD/BRAINLINKS/T1/T1_MASTER_2020.csv')
df_master.info()
tidy_nacc.info()
plt.figure(figsize=(10,6),dpi=200)
x3 = sns.regplot(data=df_master,x='extraversion',y='STRANGER_self4other0',color='#2B749E')
sns.despine()
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()
#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()
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()
# 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
# ANCOVA + age2 for SelfWin > NoWin (page 14)
ancova_nowin = pg.ancova(data=tidy_nacc_nowin,dv='NAcc',between='NAcc_outcome',covar='age2')
ancova_nowin
# ANCOVA + age for SelfWin > NoWin (page 14)
ancova_nowin = pg.ancova(data=tidy_nacc_nowin,dv='NAcc',between='NAcc_outcome',covar='age')
ancova_nowin
# 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
Result:
# ANOVA for EACH conditions separately (page 17) -- SELF
pg.rm_anova(data=tidy_mPFC_self, dv='mPFC',within='mPFC_target',subject='PPN')
# ANOVA for EACH conditions separately (page 17) -- SELF
pg.rm_anova(data=tidy_mPFC_both, dv='mPFC',within='mPFC_target',subject='PPN')
# ANOVA for EACH conditions separately (page 17) -- SELF
pg.rm_anova(data=tidy_mPFC_other, dv='mPFC',within='mPFC_target',subject='PPN')
pg.pairwise_ttests(data=tidy_mPFC_both, dv='mPFC', between='mPFC_target')
pg.pairwise_ttests(data=tidy_mPFC_other, dv='mPFC', between='mPFC_target')
#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()
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()
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()
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()
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()
pg.corr(df['MOTHER_self0other4'],df['MPFC_MOTHER_self0other4'],method='spearman')
pg.corr(df['FATHER_self0other4'],df['MPFC_FATHER_self0other4'],method='spearman')
pg.corr(df['STRANGER_self0other4'],df['MPFC_STRANGER_self0other4'],method='spearman')
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()