<jupyter_start><jupyter_text>Pair-rule gene mutant simulations<jupyter_code>import sys
sys.path.insert(0, '../functions/')

from imputation import *
from data_prep import *<jupyter_output><empty_output><jupyter_text>Load (x,y,z)-coordinates<jupyter_code>raw_data = np.loadtxt('../data/dmel_data.txt').T
xyz = raw_data[:,:3]
def make_quad(X):
    quad = np.zeros((int(X.shape[0]), int(X.shape[1] + (X.shape[1]*(X.shape[1]-1))/2)))
    quad[:, :X.shape[1]] = np.copy(X)
    col = 99
    for i in range(X.shape[1]-1):
        for j in range(i+1, X.shape[1]):
            quad[:,col] = (X[:,i]*X[:,j])
            col += 1
    return quad<jupyter_output><empty_output><jupyter_text>Load gene name pickle and create a dictionary<jupyter_code>with open('../pickles/names.pkl', 'rb') as f:
    names = pickle.load(f)
    
name_dic = {}
for (i,name) in enumerate(names):
    name_dic[name] = i<jupyter_output><empty_output><jupyter_text>Load complete data with imputated valuesThis data set is not uploaded in the repository as the file size exceeds the limit. Before running the cells below, be sure to run the notebook 1. Data preparation to obtain a complete data set.  Simulations<jupyter_code>data = np.loadtxt('../data/data_complete.txt')
init = np.vstack((np.vsplit(data, 6)[0]))

w = res['w'][-1]
bias = res['bias'][-1]

genes = [name_dic['h'], name_dic['eve'], name_dic['ftz'], name_dic['odd'], name_dic['prd'], name_dic['slp1']]
fig = plt.figure(figsize=(6,4.5), dpi=300)
fig.subplots_adjust(wspace=0.15, hspace=0.5)
for (e_s, source) in enumerate(genes):
    prop = 1
    if e_s == 0:
        true = np.vstack((np.vsplit(data, 6)[prop+1]))
        quad = make_quad(init)
        f = init + quad.dot(w) + bias
        f[f<0] = 0
        
        for i in range(prop):
            quad = make_quad(f)
            f = f + quad.dot(w) + bias
            f[f<0] = 0
        
        for (e,target) in enumerate(genes):
            norm = plt.Normalize(np.min(data[:,target]), np.max(data[:,target]))
            ax = fig.add_subplot(8,6,e+1)
            ax.axis('off')
            ax.scatter(xyz[:,0][xyz[:,1] > 0], xyz[:,2][xyz[:,1] > 0],
                      c=true[:,target][xyz[:,1] > 0], s=0.5, norm=norm,
                      cmap=plt.cm.Blues)
            ax.text(0,120,names[target],ha='center', fontsize=10)
            ax1 = fig.add_subplot(8,6,e+7)
            ax1.axis('off')
            ax1.scatter(xyz[:,0][xyz[:,1] > 0], xyz[:,2][xyz[:,1] > 0],
                      c=f[:,target][xyz[:,1] > 0], s=0.5, norm=norm,
                      cmap=plt.cm.Blues)
            if e == 0:
                ax.text(-420,0,'WT \n Obs.',ha='left',va='center', rotation=90, fontsize=10)
                ax1.text(-420,0,'WT'+ '\n' + 'Sim.',ha='left',va='center', rotation=90, fontsize=10)

    init_p = np.copy(init)
    init_p[:,source] = init_p[:,source]*0

    quad = make_quad(init_p)
    f_p = init_p + quad.dot(w) + bias
    f_p[f_p<0] = 0
    f_p[:,source] = f_p[:,source]*0

    for i in range(prop):
        quad = make_quad(f_p)
        f_p = f_p + quad.dot(w) + bias
        f_p[f_p<0] = 0
        f_p[:,source] = f_p[:,source]*0
    
    position=13 + e_s*6
    for (e,target) in enumerate(genes):
        norm = plt.Normalize(np.min(data[:,target]), np.max(data[:,target]))
        ax = fig.add_subplot(8,6,position)
        ax.axis('off')
        xy = ax.scatter(xyz[:,0][xyz[:,1] > 0], xyz[:,2][xyz[:,1] > 0],
                  c=f_p[:,target][xyz[:,1] > 0], s=0.5, norm=norm,
                  cmap=plt.cm.Blues)
        if e == 0:
            ax.text(-340,0,names[source] + '-', ha='left', va='center', rotation=90, fontsize=10)
        position += 1
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19427954668105774, 'fraction_numerical': 0.033998920669185105, 'mean_word_length': 2.6812313803376364, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '614836', 'license': 'MIT', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1445, 'n_words': 265, 'path': 'notebooks/6. Mutant simulations.ipynb', 'repo_name': 'nihcompmed/erf-LAD', 'size': '3706'}