Example #1
0
def load_and_filer(pwd, rval=0.95):
    """load csv filter div and 0.95 r value and at least 2 clls"""
    df = pd.read_csv(pwd)
    df = rl.give_good_structure(df)
    df = df.loc[(df['end_type'] == 'DIVISION') | (df['end_type'] == 'DIV') |
                (df['end_type'] == 'div')]
    if 'length_box' in df.columns:  #guillaume data
        df['time_sec'] = df['frame'] * 60 * 3
        df['length_box_um'] = df['length_box'] * 0.065
    else:
        df['length_box_um'] = (df['vertical_bottom'] -
                               df['vertical_top']) * 0.065
    df = df.groupby('cell').filter(lambda x: True
                                   if len(x['length_box_um']) > 2 else False)
    df = df.groupby('cell').filter(lambda x: linregress(
        x['time_sec'], np.log(x['length_box_um'])).rvalue > rval)
    #df = rl.give_unique_dataset(df,6,18)
    df = df[[
        'length_box_um', 'time_sec', 'parent_id', 'id', 'gl', 'date', 'pos',
        'cell', 'lane_ID', 'end_type'
    ]]
    return df
Example #2
0
import pickle
from scipy.stats import linregress 
#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()