Exemple #1
0
def update_btn_single():
    genotype = genotypes_selection_single_genotype.v_model
    if genotype:
        vids = get_vid_of_genotype(misc.all_mtg, [genotype])
        df = extract_at_module_scale(misc.all_mtg, vids=vids)
        geno_frequency = occurence_module_order_along_time(
            data=df, frequency_type="cdf")
    update_btn_export(link_export_t11, geno_frequency)

    if genotype:
        vids = get_vid_of_genotype(misc.all_mtg, [genotype])
        df = extract_at_module_scale(misc.all_mtg, vids=vids)
        res = pd.crosstab(index=df["order"],
                          columns=df["complete_module"],
                          normalize="index")
        res.columns = ["incomplete", "complete"]
    update_btn_export(link_export_t12, res)

    if genotype:
        vids = get_vid_of_genotype(misc.all_mtg, [genotype])
        df = extract_at_module_scale(misc.all_mtg, vids=vids)
        res = pd.crosstab(index=df["date"],
                          columns=df["complete_module"],
                          normalize="index")
        res.columns = ["incomplete", "complete"]
    update_btn_export(link_export_t13, res)
Exemple #2
0
def on_change_node_waffle_parameter(widget, event, data):
    if not date_selection_waffle.v_model:
        pass
    else:
        with waffle:
            waffle.clear_output()
            genotype = genotypes_selection_waffle.v_model
            vids = get_vid_of_genotype(misc.all_mtg, [genotype])
            df = extract_at_node_scale(misc.all_mtg, vids=vids)
            tmp = df2waffle(df,
                            index='rank',
                            date=date_selection_waffle.v_model,
                            variable=data,
                            order=order_selection_waffle.v_model)

            # TODO: remove the legend here (which only apply to branching_type)
            l_names = {
                "1": "Stolon",
                "2": "Vegetative bud",
                "3": "Initiated bud",
                "4": "Aborted bud",
                "5": "Floral bud",
                "6": "Branch crown"
            }

            fig = plot_waffle(
                tmp,
                #                             layout=layout,
                legend_name=l_names,
                plot_func=plot_type_waffle.v_model)
            display(fig)
def on_change_geno_2d(widget, event, data):
    id_selection_2d.items = list(
        range(len(get_vid_of_genotype(misc.all_mtg, [data]))))
    id_selection_2d.v_model = 1

    print_2d_median(misc.all_mtg, data)
    print_2d_single_p(misc.all_mtg, data, vid=id_selection_2d.v_model)
Exemple #4
0
def on_change_module_plot_type(widget, event, data):
    if date_selection_waffle.v_model and parameter_selection_waffle.v_model:
        with waffle:
            waffle.clear_output()
            genotype = genotypes_selection_waffle.v_model
            vids = get_vid_of_genotype(misc.all_mtg, [genotype])
            df = extract_at_module_scale(misc.all_mtg, vids=vids)

            if aggfunc_selection_waffle.v_model == 'concat_string':
                tmp = df2waffle(df,
                                index='order',
                                date=date_selection_waffle.v_model,
                                variable=parameter_selection_waffle.v_model,
                                aggfunc=lambda x: ' '.join(x),
                                crosstab=False)
            else:
                tmp = df2waffle(df,
                                index='order',
                                date=date_selection_waffle.v_model,
                                variable=parameter_selection_waffle.v_model,
                                aggfunc=aggfunc_selection_waffle.v_model,
                                crosstab=False)

            fig = plot_waffle(
                tmp,
                #                               layout=layout,
                plot_func=data)

            display(fig)
def print_2d_single_p(g, genotype, vid):
    with plot2d_single_p:
        plot2d_single_p.clear_output()
        vids_selected = get_vid_of_genotype(g, genotypes=[genotype])
        g.properties()['order'] = orders(g)
        scene = visu2d.plot2d(g, [vids_selected[vid]],
                              dist=[3] * 3,
                              display=False)
        display3d(scene)
Exemple #6
0
def on_change_genotype_p3_t2(widget, event, data):
    genotype = genotypes_selection_analyze.v_model
    vids = get_vid_of_genotype(misc.all_mtg, [genotype])
    df = extract_at_plant_scale(misc.all_mtg, vids=vids)
    param = list(df.columns)
    param.remove("Genotype")
    param.remove('date')
    date_selection_analyze.items = list(df.date.unique())
    date_selection_analyze.v_model = ""
    variable_selection_analyze.items = param
def print_2d_median(g, genotype):
    with plot2d_most_central:
        plot2d_most_central.clear_output()
        vids_selected = get_vid_of_genotype(g, genotypes=[genotype])
        g.properties()['order'] = orders(g)
        df = extract_at_plant_scale(g, vids=vids_selected)
        df_median = median_individuals(df, )
        # selection of vid of median individuals
        pids = list(df_median.vid)
        n = len(pids)
        scene = visu2d.plot2d(g, pids, dist=[6] * n, display=False)
        display3d(scene)
Exemple #8
0
def on_change_genotype_p3_t1(widget, event, data):
    # update table
    df = pd.DataFrame()
    if misc.all_mtg:
        vids = get_vid_of_genotype(misc.all_mtg, genotypes=data)
        df = extract_at_plant_scale(misc.all_mtg, vids=vids)
    update_grid(df, df_plantscale)

    # update descriptors
    update_grid(df.describe(), df_description)

    update_btn_extract()
Exemple #9
0
def on_change_module_waffle_genotype(widget, event, data):
    genotype = genotypes_selection_waffle.v_model
    vids = get_vid_of_genotype(misc.all_mtg, [genotype])
    df = extract_at_module_scale(misc.all_mtg, vids=vids)
    param = list(df.columns)
    param.remove("Genotype")
    param.remove('date')
    param.remove('order')
    param.remove('plant')
    date_selection_waffle.items = list(df.date.unique())
    date_selection_waffle.v_model = ""
    parameter_selection_waffle.items = param
Exemple #10
0
def on_change_node_waffle_genotype(widget, event, data):
    genotype = genotypes_selection_waffle.v_model
    vids = get_vid_of_genotype(misc.all_mtg, [genotype])
    df = extract_at_node_scale(misc.all_mtg, vids=vids)
    param = list(df.columns)
    param.remove("Genotype")
    param.remove('date')
    date_selection_waffle.items = list(df.date.unique())
    date_selection_waffle.v_model = ""
    variable_selection_waffle.items = param
    order = list(df.order.unique())
    order.append({'text': 'All', 'value': None})
    order_selection_waffle.items = order
Exemple #11
0
def print_files_description():
    with files_description:
        files_description.clear_output()
        # nb of files selected
        nb_files = len(files_selection.v_model)

        # experiments names:
        exp_names = set(misc.all_mtg.property('Experiment_name').values())

        # genotypes:
        genotype_names = get_genotypes(misc.all_mtg)

        # mtg.properties: + list of possible values
        properties = [(p, set(misc.all_mtg.property(p).values()))
                      for p in misc.all_mtg.property_names() if p not in [
                          'edge_type', 'index', 'label', 'Experiment_name',
                          'Genotype', '_line', 'DBI'
                      ]]
        print('Number of files selected:', nb_files)
        print('Experiment names:', exp_names)
        print('List of genotypes:', genotype_names)
        for genotype in genotype_names:
            print(genotype, ':',
                  len(get_vid_of_genotype(misc.all_mtg, [genotype])),
                  ' plants')
        print('List of properties:', misc.all_mtg.property_names())
        print('\n')
        print('List of properties values:')

        for p in properties:
            if p[1]:
                if isinstance(next(iter(p[1])), float):
                    print(
                        p[0],
                        ' min:',
                        min(p[1]),
                        'max:',
                        max(p[1]),
                        'mean:',
                        np.mean(list(p[1])),
                        'std:',
                        np.std(list(p[1])),
                        'Q1:',
                        np.quantile(list(p[1]), 0.25),
                        'Q2:',
                        np.quantile(list(p[1]), 0.50),
                        'Q3:',
                        np.quantile(list(p[1]), 0.75),
                    )
                else:
                    print(p[0], ': ', p[1])
Exemple #12
0
def on_change_genotype(widget, event, data):
    # update plant selection
    slider_n_plant.disabled = False
    box_n_plant.disabled = False
    cb_allplants.disabled = False
    slider_n_plant.max = len(get_vid_of_genotype(misc.all_mtg, [data]))
    slider_n_plant.v_model = 1

    # update mtg preview
    print_preview(misc.all_mtg,
                  genotype=data,
                  p_nb=slider_n_plant.v_model,
                  width="500px",
                  height="800px")
def print_3d_growth_developement(g, genotype):
    if g:
        with plot3d_growth_developement:
            plot3d_growth_developement.clear_output()
            print('3d growth developement')
            vids_selected = get_vid_of_genotype(g, genotypes=[genotype])
            g.properties()['order'] = orders(g)
            scene = visu3d.plot3d(g,
                                  by=["Sample_date"],
                                  hide_leaves=False,
                                  display=False,
                                  vids=vids_selected)
            display3d(scene)
    else:
        with plot3d_growth_developement:
            plot3d_growth_developement.clear_output()
            print('Select a Genotype')
def print_3d_floral_intensity(g, genotype):
    if g:
        with plot3d_floral_intensity:
            plot3d_floral_intensity.clear_output()
            print('3d floral_intensity ')
            vids_selected = get_vid_of_genotype(g, genotypes=[genotype])
            g.properties()['order'] = orders(g)
            scene = visu3d.plot3d(g,
                                  by=["Sample_date"],
                                  hide_leaves=True,
                                  display=False,
                                  vids=vids_selected)
            display3d(scene)
    else:
        with plot3d_floral_intensity:
            plot3d_floral_intensity.clear_output()
            print('Select a Genotype')
Exemple #15
0
def on_change_parameter_p3(widget, event, data):
    #     if date ...
    genotype = genotypes_selection_analyze.v_model
    vids = get_vid_of_genotype(misc.all_mtg, [genotype])
    df = extract_at_plant_scale(misc.all_mtg, vids=vids)

    res = df.groupby('date').mean()

    p = res.iplot(
        kind="line",
        mode='lines+markers',
        y=data,
        xTitle="Dates",
        yTitle=data,
        #               yTitle="Probability",
        #               title="Relative distribution of complete (True) and incomplete (False) module as function of date for {}".format(genotype),
        asFigure=True)
    transfert_figure(p, plot_plantscale)
Exemple #16
0
def print_single_genotype_plots():
    genotype = genotypes_selection_single_genotype.v_model
    vids = get_vid_of_genotype(misc.all_mtg, [genotype])
    df = extract_at_module_scale(misc.all_mtg, vids=vids)
    if genotype:
        # plot occurence module order
        fig = plot_module_occurence_module_order_along_time(df, genotype)
        transfert_figure(fig, plot_occurence)
        # plot occurence module order
        fig = plot_module_distribution_complete_incomplete_module_order(
            df, genotype)
        transfert_figure(fig, plot_distribution_module_order)
        # plot occurence module order
        fig = plot_module_distribution_complete_incomplete_date(df, genotype)
        transfert_figure(fig, plot_distribution_date)
    else:
        with plot_occurence:
            plot_occurence.clear_output()
            print('Select a Genotype')
Exemple #17
0
def on_change_date_p3(widget, event, data):

    genotype = genotypes_selection_analyze.v_model
    vids = get_vid_of_genotype(misc.all_mtg, [genotype])
    df = extract_at_module_scale(misc.all_mtg, vids=vids)

    tmp = df2waffle(df,
                    index='order',
                    date=data,
                    variable='stage',
                    crosstab=True)

    try:
        fig = plot_pie(tmp)
        fig.update_layout(
            title="Percentage representation of each stage at one date")
        transfert_figure_pie(fig, pie_plantscale)
    except ValueError:
        pass
Exemple #18
0
def update_btn_extract():
    genotype = genotypes_selection_extraction.v_model
    if genotype:
        vids = get_vid_of_genotype(misc.all_mtg, genotype)
        df = extract_at_module_scale(misc.all_mtg, vids=vids)
        update_btn_export(export_extraction, df)