def predict(filen, min_dic, leng, resc):
    dfo =\
    pd.read_csv('/scicore/home/nimwegen/rocasu25/Documents/Projects/biozentrum/MoM_constitExpr/20190612_forAthos/'+filen+'/'+filen+'.csv')
    dfo = dfo.groupby('cell').filter(lambda x: x.values.shape[0] > 1)
    df, in_dic = rl.build_data_strucutre(dfo, leng, resc)
    pred_mat = rl.predict(min_dic, in_dic)
    return rl.merge_df_pred(df, pred_mat)
def find_param(filen, leng, resc, rsq, const=False):
    dfo = pd.read_csv(
        '/scicore/home/nimwegen/rocasu25/Documents/Projects/biozentrum/MoM_constitExpr/20190612_forAthos/'
        + filen + '/' + filen + '.csv')
    dfo = dfo.groupby('cell').filter(lambda x: x.values.shape[0] > 1)
    #filter out bad cells
    dfo = dfo.groupby('cell').filter(lambda x:\
                                     linregress(x.time_sec,np.log(x['{}'.format(leng)]))[2]>rsq)
    df, in_dic = rl.build_data_strucutre(dfo, leng, resc)
    # Set sl2 such taht cv2=0.25
    mod = \
    mn.minimize_lengths(free={'gamma':0.0125,'sl2':0.012*2*in_dic['s'][1,0]**2*0.25,'m_lam':in_dic['s'][1,0]},fixed={'sm2':20.})
    mod.boundary[1] = (1e-13, 1.)
    if const:
        mod.boundary[1] = (1e-13, 1. / 40)
    return mod.minimize(in_dic=in_dic)
Beispiel #3
0
def predict(df, x):
    """Predict length and growht rate using inferred parameters"""
    ml, g, sl2, sm2, sd2 = x
    _, in_dic = rl.build_data_strucutre(df, 'length_box_um', 1)
    pred_mat = rl.prediction_total(ml,
                                   g,
                                   sl2,
                                   sm2,
                                   in_dic['reind_v'],
                                   in_dic['dat_v'],
                                   in_dic['s'],
                                   in_dic['S'],
                                   in_dic['dt'],
                                   in_dic['lane_ID_v'],
                                   in_dic['val_v'],
                                   1,
                                   sd2,
                                   nproc=10)
    df = rl.merge_df_pred(df, pred_mat)
    return df
Beispiel #4
0
#file_to_analy ='/Users/fiori/DoubleAdderArticle/PreProcessed/20180706_GW296_glycerol37_r095_div.csv'
#file_to_analy\
#='/Users/fiori/DoubleAdderArticle/PreProcessed/20180709_GW296_glucose8aa_r095_div.csv'
#file_to_analy='/Users/fiori/DoubleAdderArticle/PreProcessed/20180711_GW296_glucose_r095_div.csv'
file_to_analy='/Users/fiori/DoubleAdderArticle/PreProcessed/20180711_GW296_glucose_r098_div.csv'
#sys.argv[1]
step = int(sys.argv[1])
#step=8
# minimal cell length
fil = 15#int(sys.argv[3])
#fil=24
leng = 'length_box_um'#sys.argv[4]
dglu = pd.read_csv(file_to_analy)
dglu = rl.give_good_structure(dglu)
dft = rl.give_unique_dataset(dglu,step,fil)
_,in_dic = rl.build_data_strucutre(dft,leng,1)
boundary = [(1e-10,None),(1e-5,None),(1e-10,None),(1e-10,None)]
m,g,s,e,a =[in_dic['s'][1,0],0.01,2.3630e-07,in_dic['sm2'],in_dic['sd2']]
r = np.random.rand(5)*np.random.choice((-1,1),5)*0.5 #50% max var 
mod=mn.minimize_lengths(free={'sl2':s+s*r[0],'gamma':g+g*r[1],'sm2':e+e*r[2],'mlam':m+m*r[3]},fixed={'sd2':a},boundary=boundary)
bestpar =\
    mod.minimize(in_dic=in_dic,numerical=False,fun=rl.grad_obj_wrap)
mb = mod.errorbars(in_dic)
mb['log_lik']= bestpar['log_lik']
mb['step']=step
mb['filt']=fil
f = open("{}.pkl".format('gluc_pap_fix{}'.format(step)),"wb")
pickle.dump(mb,f)
f.close()
#mbp = mb['param']
#mbe = mb['error']
import minimize_lengths as mn
import recursive_lengths as rl
import pandas as pd
import numpy as np
from numba import jit,prange
@jit(parallel=True)
def compute_different_tau(in_dic):
    ret = []
    taus =  [tau for tau in range(3,180,18)]
    for i in prange(len(taus)):
        tau = taus[i]
        mod = mn.minimize_lengths(free={'sm2':sms,'sl2':0.27},fixed={'gamma':1./tau,'m_lam':s[1,0]})
        tmp = mod.minimize(in_dic = in_dic)
        print(tmp[-1])
    return 
if __name__=="__main__":
    df = pd.read_csv('/scicore/home/nimwegen/rocasu25/Documents/Projects/biozentrum/MoM_constitExpr/20190612_forAthos/myframes_chr_rpmB_glucose_20190515/myframes_chr_rpmB_glucose_20190515.csv')
    df['res_log_length_um'] = np.log(df['length_um'])*1e02
    in_dic = rl.build_data_strucutre(df,'res_log_length_um')
    s,S,_,sms = rl.build_intial_mat(df,'res_log_length_um')
    compute_different_tau(in_dic)