{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Getting your data ready" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# scona\n", "\n", "scona is a tool to perform network analysis over correlation networks of brain regions. \n", "This tutorial will go through the basic functionality of scona, taking us from our inputs (a matrix of structural regional measures over subjects) to a report of local network measures for each brain region, and network level comparisons to a cohort of random graphs of the same degree. " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import networkx as nx\n", "import scona as scn\n", "import scona.datasets as datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Importing data\n", "\n", "A scona analysis starts with four inputs.\n", "* __regional_measures__\n", " A pandas DataFrame with subjects as rows. The columns should include structural measures for each brain region, as well as any subject-wise covariates. \n", "* __names__\n", " A list of names of the brain regions. This will be used to specify which columns of the __regional_measures__ matrix to want to correlate over.\n", "* __covars__ _(optional)_ \n", " A list of your covariates. This will be used to specify which columns of __regional_measure__ you wish to correct for. \n", "* __centroids__\n", " A list of tuples representing the cartesian coordinates of brain regions. This list should be in the same order as the list of brain regions to accurately assign coordinates to regions. The coordinates are expected to obey the convention the the x=0 plane is the same plane that separates the left and right hemispheres of the brain. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0nspn_idocccentrestudy_primaryage_scansexmaleage_binmri_centre...rh_supramarginal_part5rh_supramarginal_part6rh_supramarginal_part7rh_frontalpole_part1rh_temporalpole_part1rh_transversetemporal_part1rh_insula_part1rh_insula_part2rh_insula_part3rh_insula_part4
00103560Cambridge2K_Cohort20.761Female0.04WBIC...2.5922.8412.3182.4863.5262.6383.3082.5833.1883.089
11107020Cambridge2K_Cohort16.055Male1.02WBIC...3.4483.2832.7403.2254.0443.0403.8672.9433.4783.609
22107360Cambridge2K_Cohort14.897Female0.01WBIC...3.5263.2693.0763.1333.9002.9143.8942.8983.7203.580
33107780Cambridge2K_Cohort20.022Female0.04WBIC...2.8302.9172.6472.7963.4013.0453.1382.7392.8333.349
44107940Cambridge2K_Cohort14.656Female0.01WBIC...2.6893.2942.8202.5392.1512.7342.7912.9353.5383.403
\n", "

5 rows × 324 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 nspn_id occ centre study_primary age_scan sex male \\\n", "0 0 10356 0 Cambridge 2K_Cohort 20.761 Female 0.0 \n", "1 1 10702 0 Cambridge 2K_Cohort 16.055 Male 1.0 \n", "2 2 10736 0 Cambridge 2K_Cohort 14.897 Female 0.0 \n", "3 3 10778 0 Cambridge 2K_Cohort 20.022 Female 0.0 \n", "4 4 10794 0 Cambridge 2K_Cohort 14.656 Female 0.0 \n", "\n", " age_bin mri_centre ... rh_supramarginal_part5 \\\n", "0 4 WBIC ... 2.592 \n", "1 2 WBIC ... 3.448 \n", "2 1 WBIC ... 3.526 \n", "3 4 WBIC ... 2.830 \n", "4 1 WBIC ... 2.689 \n", "\n", " rh_supramarginal_part6 rh_supramarginal_part7 rh_frontalpole_part1 \\\n", "0 2.841 2.318 2.486 \n", "1 3.283 2.740 3.225 \n", "2 3.269 3.076 3.133 \n", "3 2.917 2.647 2.796 \n", "4 3.294 2.820 2.539 \n", "\n", " rh_temporalpole_part1 rh_transversetemporal_part1 rh_insula_part1 \\\n", "0 3.526 2.638 3.308 \n", "1 4.044 3.040 3.867 \n", "2 3.900 2.914 3.894 \n", "3 3.401 3.045 3.138 \n", "4 2.151 2.734 2.791 \n", "\n", " rh_insula_part2 rh_insula_part3 rh_insula_part4 \n", "0 2.583 3.188 3.089 \n", "1 2.943 3.478 3.609 \n", "2 2.898 3.720 3.580 \n", "3 2.739 2.833 3.349 \n", "4 2.935 3.538 3.403 \n", "\n", "[5 rows x 324 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df, *a = datasets.NSPN_WhitakerVertes_PNAS2016.import_data()\n", "df.head()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }