In [1]:
import numpy as np
import nsaba.nsaba as na

from copy import deepcopy

In [2]:
datdir = '../../data_dir'
na.Nsaba.aba_load(datdir)
na.Nsaba.ns_load(datdir)
na.Nsaba.ns_load_id_dict()


This may take a minute or two ...
SampleAnnot.csv loaded.
MicroarrayExpression.csv loaded.
Probes.csv loaded.
Nsaba.aba['mni_coords'] initialized.

This may take a minute or two ...
database.txt loaded.
features.txt loaded.
Nsaba.ns['mni_coords'] initialized.

This may take a minute or two ...

In [3]:
ei = na.Nsaba()

In [4]:
ei.load_ge_pickle('Nsaba_ABA_ge.pkl', datdir)


This may take a minute or two ...
'ge' dictionary successfully loaded

In [5]:
# Reference table

ei_table = {}
for i, key in enumerate(ei.ge.keys()):
    ei_table[key] = i

In [ ]:


In [6]:
# Params

keys = ei.ge.keys()

mat_size = len(keys)
coord_num = len(ei.ge[1])

keys2 = deepcopy(keys)

In [7]:
%%time
# Test Run
n = 4000
keys_T = keys[:n]
key2T = keys2[:n]

p = np.zeros([n,n, coord_num])
for i, key_row in enumerate(keys_T):
    for j, key_col in enumerate(key2T):
        p[i][i+j] = ei.ge[key_row]/ei.ge[key_col]
    key2T = key2T[1:]


CPU times: user 54.5 s, sys: 25.1 s, total: 1min 19s
Wall time: 3min 11s

In [ ]:
del p

In [ ]:
def make_ei_mat(EI):
    for i, key_row in enumerate(keys):
        for j, key_col in enumerate(keys2):
            EI[i][j] = ei.ge[key_row]/ei.ge[key_col]
        keys2 = key2[1:]
    return EI

In [ ]:


In [ ]:
%%time
EI = np.zeros((mat_size, mat_size, coord_num))
EI = make_ei_mat(EI)