feat_df, meta_df, idx, gene_list = select_strains([candidate_gene],
                                                              CONTROL_STRAIN,
                                                              feat_df=feat,
                                                              meta_df=meta)
            # filter features
            feat_df, meta_df, featsets = filter_features(feat_df,
                                                         meta_df)

            # strain_numbers.append(meta_df.groupby('worm_strain')['file_id_prestim'].describe()['count'])


            strain_lut, stim_lut, feat_lut = make_colormaps(gene_list,
                                                            featlist=featsets['all'],
                                                            idx=idx,
                                                            candidate_gene=[candidate_gene],
                                                            )

            # colorbars to map colors to strains
            plot_colormap(strain_lut)
            plt.savefig(saveto / 'strain_cmap.png')
            plot_cmap_text(strain_lut)
            plt.savefig(saveto / 'strain_cmap_text.png')

            plot_colormap(stim_lut, orientation='horizontal')
            plt.savefig(saveto / 'stim_cmap.png')
            plot_cmap_text(stim_lut)
            plt.savefig(saveto / 'stim_cmap_text.png')

            plt.close('all')
Ejemplo n.º 2
0
    genes = [g for g in genes if 'myo' not in g and 'unc-54' not in g]

    #%%

    for g in genes:
        print('making ts stimuli plots for {}'.format(g))
        candidate_gene = g
        timeseries_fname = RAW_DATA_DIR / 'Results' / '{}_timeseries.hdf5'.format(
            candidate_gene)
        (saveto / candidate_gene).mkdir(exist_ok=True)

        # only select strains of interest
        meta, idx, gene_list = select_strains(candidate_gene,
                                              CONTROL_STRAIN,
                                              meta_df=meta_ts)
        strain_lut, stim_lut = make_colormaps(gene_list, [], idx,
                                              candidate_gene)

        if g == 'figo-1':
            strain_lut['C43B7.2'] = strain_lut['figo-1']

        timeseries_df = pd.read_hdf(timeseries_fname, 'timeseries_df')
        # hires_df = pd.read_hdf(timeseries_fname, 'hires_df')

        # test_feats = [f for f in timeseries_df.columns if 'radial_velocity' in f]

        # t = ['d_relative_to_neck_radial_velocity_head_tip',
        #      'relative_to_neck_radial_velocity_head_tip']

        for k in strain_lut.keys():

            _ts_df = timeseries_df.query('@k in worm_gene')
Ejemplo n.º 3
0
                subset=['worm_gene'],
                inplace=True)   
    # remove data from dates to exclude
    good_date = meta.query('@DATES_TO_DROP not in imaging_date_yyyymmdd').index
    # bad wells
    good_wells_from_gui = meta.query('is_bad_well == False').index
    meta = meta.loc[good_wells_from_gui & good_date,:]
    
    # only select strains of interest
    meta, idx, gene_list = select_strains(CANDIDATE_GENE,
                                          CONTROL_STRAIN,
                                          meta_df=meta,
                                          feat_df=None)        
    strain_lut, stim_lut = make_colormaps(gene_list,
                                            idx,
                                            CANDIDATE_GENE,
                                            CONTROL_STRAIN,
                                            featlist=[])
    #strain to gene dictionary
    strain_dict = strain_gene_dict(meta)
    gene_dict = {v:k for k,v in strain_dict.items()}

    meta = align_bluelight_meta(meta)
    
    if is_reload_timeseries_from_results:
        # this uses tierpytools under the hood
        timeseries_df, hires_df  = load_bluelight_timeseries_from_results(
                            meta,
                            RAW_DATA_DIR / 'Results')
                            # save to disk
        timeseries_df.to_hdf(timeseries_fname, 'timeseries_df', format='table')
            for f in list(zip(window_feat_files, window_fname_files)))

    genes = [g for g in meta.worm_gene.unique() if g != CONTROL_STRAIN]
    # genes = [g.replace('C43B7.2', 'figo-1') for g in genes]
    genes = [g for g in genes if 'myo' not in g and 'unc-54' not in g]

    #%%
    feat_df, meta_df, idx, gene_list = select_strains(STRAINS,
                                                      CONTROL_STRAIN,
                                                      feat_df=feat,
                                                      meta_df=meta)
    # filter features
    feat_df, meta_df, featsets = filter_features(feat_df, meta_df)

    strain_lut, stim_lut, feat_lut = make_colormaps(gene_list,
                                                    featlist=featsets['all'],
                                                    idx=idx,
                                                    candidate_gene=STRAINS)

    # colorbars to map colors to strains
    plot_colormap(strain_lut)
    plt.savefig(saveto / 'strain_cmap.png')
    plot_cmap_text(strain_lut)
    plt.savefig(saveto / 'strain_cmap_text.png')

    plot_colormap(stim_lut, orientation='horizontal')
    plt.savefig(saveto / 'stim_cmap.png')
    plot_cmap_text(stim_lut)
    plt.savefig(saveto / 'stim_cmap_text.png')

    plt.close('all')
Ejemplo n.º 5
0
 # strain_numbers = []
 
 #%%
 for count,g in enumerate(genes):
     print('Analysing {} {}/{}'.format(g, count+1, len(genes)))
     candidate_gene = g
     
     (saveto / candidate_gene).mkdir(exist_ok=True)
     
     meta_df, idx, gene_list = select_strains(candidate_gene,
                                                     CONTROL_STRAIN,
                                                     meta_df=meta)
     
     strain_lut, stim_lut = make_colormaps(gene_list,
                                         featlist=[],
                                         idx=idx,
                                         candidate_gene=candidate_gene,
                                         )
     
     subsample = meta_df.groupby('worm_gene').sample(n_subsample,
                                                     random_state=seed)
     
     
     for k,v in strain_lut.items():
         _meta = subsample.query('@k in `worm_gene`')
         
         for i,r in _meta.iterrows():
             _imgstore = RAW_DATA_DIR / 'Results' / r['imgstore_name'] / 'metadata_featuresN.hdf5'
             
             with pd.HDFStore(_imgstore) as fid:
                 ts = fid['/timeseries_data'].query("`well_name` == @r.well_name")