Connectivity between three-nodes motifs

``````

In [1]:

import numpy as np
np.random.seed(0)

%matplotlib inline

from __future__ import division

``````
``````

In [2]:

from inet.motifs import iiconcounter

from inet.utils import II_slice
print('Inet version {}'.format(__version__))

``````
``````

Inet version 0.0.12

``````
``````

In [3]:

# use the dataset to create the null hypothesis

``````
``````

``````

Collect number of experiments containing three PV(+) cells

``````

In [4]:

# for the moment, we only count experiments with 3 PVs
# later we use mydataset.PV[2:]|
PV3 = sum(mydataset.IN[3].values())
PV3

``````
``````

Out[4]:

8

``````
``````

In [5]:

# select experiments with only 3 PVs
pvlist =  list()
for i in range(len(mydataset)):
if '3_1' in mydataset.experiment[i]['fname']:
pvlist.append(i)
print('{:3d} --> {}'.format(i, mydataset.experiment[i]['fname']))

``````
``````

3 --> 3_170824_01.syn
42 --> 3_170822_01.syn
45 --> 3_170829_01.syn
59 --> 3_170830_02.syn
118 --> 3_170622_03.syn
131 --> 3_170412_01.syn
156 --> 3_170830_01.syn
183 --> 3_171016_01.syn

``````
``````

In [6]:

#check that experiment
II_slice(mydataset.experiment[56]['matrix'],3)

``````
``````

Out[6]:

array([[0, 1, 1],
[0, 0, 0],
[0, 0, 0]])

``````
``````

In [7]:

matrix = II_slice(mydataset.experiment[56]['matrix'],3)
matrix

``````
``````

Out[7]:

array([[0, 0, 0],
[1, 0, 3],
[3, 1, 0]])

``````
``````

In [8]:

mymatrix = matrix.copy()
mymatrix[mymatrix==2]=0
mymatrix

``````
``````

Out[8]:

array([[0, 0, 0],
[1, 0, 3],
[3, 1, 0]])

``````
``````

In [9]:

iiconcounter(matrix)

``````
``````

Out[9]:

{'ii_con_c1e': {'found': 0, 'tested': 0},
'ii_con_c2': {'found': 0, 'tested': 0},
'ii_con_c2e': {'found': 0, 'tested': 0},
'ii_con_chem': {'found': 0, 'tested': 0},
'ii_con_elec': {'found': 0, 'tested': 10}}

``````
``````

In [12]:

np.nonzero(mymatrix)

``````
``````

Out[12]:

(array([1, 1, 2, 2]), array([0, 2, 0, 1]))

``````
``````

In [24]:

pre, post = np.nonzero(mymatrix)
np.unique(post, return_index=1, return_counts=1)

``````
``````

Out[24]:

(array([0, 1, 2]), array([0, 3, 1]), array([2, 1, 1]))

``````

Convergent Motifs

``````

In [10]:

# count number of total convergent motifs
mydataset.motif['ii_con']

``````
``````

Out[10]:

{'found': 1, 'tested': 21}

``````
``````

In [11]:

# select recording of the only convergent motifs
for i in pvlist:
if mydataset.experiment[i]['motif']['ii_con'] ['found']:
print(i)

``````
``````

56

``````

Divergent motifs

``````

In [12]:

# count number of total convergent motifs
mydataset.motif['ii_div']

``````
``````

Out[12]:

{'found': 2, 'tested': 21}

``````
``````

In [13]:

# select recording of the only convergent motifs
for i in pvlist:
if mydataset.experiment[i]['motif']['ii_div']['found']:
print(i)

``````
``````

56

``````

Linear chains

``````

In [14]:

# count number of total convergent motifs++
mydataset.motif['ii_lin']

``````
``````

Out[14]:

{'found': 2, 'tested': 21}

``````
``````

In [15]:

# select recording of the only convergent motifs
for i in pvlist:
if mydataset.experiment[i]['motif']['ii_lin']['found']:
print(i)

``````
``````

56

``````
``````

In [16]:

matrix = II_slice(mydataset.experiment[56]['matrix'],3)

``````
``````

In [17]:

matrix[1,1]=2

``````
``````

In [18]:

for i in range(3):
print(matrix[:,i])

``````
``````

[0 1 3]
[0 2 1]
[0 3 0]

``````
``````

In [19]:

np.nonzero(matrix[:,0])

``````
``````

Out[19]:

(array([1, 2]),)

``````
``````

In [38]:

from itertools import permutations

``````
``````

In [79]:

permutations?

``````
``````

In [82]:

for i,j in permutations(np.array([1,2,3]), 2):
print(i,j)

``````
``````

(1, 2)
(1, 3)
(2, 1)
(2, 3)
(3, 1)
(3, 2)

``````
``````

In [86]:

permutations(3, 2)

``````
``````

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-86-9d47d0673c7d> in <module>()
----> 1 permutations(3, 2)

TypeError: 'int' object is not iterable

``````
``````

In [77]:

matrix

``````
``````

Out[77]:

array([[0, 0, 0],
[1, 2, 3],
[3, 1, 0]])

``````
``````

In [ ]:

``````