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)
def update_btn_multiple(): if misc.all_mtg: df = extract_at_module_scale(misc.all_mtg) Mean = df.groupby(["Genotype", "order"]).mean() update_btn_export(link_export_t21, Mean) if misc.all_mtg: df = extract_at_module_scale(misc.all_mtg) Mean = df.groupby(["Genotype", "order"]).mean() update_btn_export(link_export_t22, Mean) if misc.all_mtg: df = extract_at_module_scale(misc.all_mtg) Mean = df.groupby(["Genotype", "order"]).mean() update_btn_export(link_export_t23, Mean) if misc.all_mtg: df = extract_at_module_scale(misc.all_mtg) ctd = crowntype_distribution(data=df, crown_type="branch_crown") ctd = ctd[ctd.index.get_level_values('order') != 0] update_btn_export(link_export_t24, ctd) if misc.all_mtg: df = extract_at_module_scale(misc.all_mtg) ctd = crowntype_distribution(data=df, crown_type="extension_crown") ctd = ctd[ctd.index.get_level_values('order') != 0] update_btn_export(link_export_t25, ctd)
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 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
def on_change_genotype_p4(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_module_scale(misc.all_mtg, vids=vids) update_grid(df, df_modulescale) # update descriptors update_grid(df.describe(), df_description) # update the extraction button update_btn_extract()
def test_extract_at_module_scale(): files = shared_data(openalea.strawberry).glob('*.mtg') mtg_path = dict((name(f), f) for f in files) gariguette = read_mtg_file(mtg_path['Gariguette']) gariguette_extraction_at_module_scale = extract_at_module_scale(gariguette) assert len(gariguette_extraction_at_module_scale) == 241 gariguette_frequency = occurence_module_order_along_time(data= gariguette_extraction_at_module_scale,frequency_type= "cdf") assert len(gariguette_frequency) == 6 mean= gariguette_extraction_at_module_scale.groupby(["Genotype", "order"]).mean() sd= gariguette_extraction_at_module_scale.groupby(["Genotype", "order"]).std() assert len(mean) == 6 assert len(sd) == 6
def print_multiple_genotypes_plots(): if misc.all_mtg.property('Genotype'): df = extract_at_module_scale(misc.all_mtg) # plot pointwisemean leaves fig = plot_module_pointwisemean(df, "nb_total_leaves") transfert_figure(fig, plot_pointwisemean_leaves) # plot pointwisemean flowers fig = plot_module_pointwisemean(df, "nb_total_flowers") transfert_figure(fig, plot_pointwisemean_flowers) # plot pointwisemean stolons fig = plot_module_pointwisemean(df, "nb_stolons") transfert_figure(fig, plot_pointwisemean_stolons) # crowntype branch fig = plot_module_crown(df, "branch_crown") transfert_figure(fig, plot_branch_crown) # crowntype extension fig = plot_module_crown(df, "extension_crown") transfert_figure(fig, plot_extension_crown)
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')
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
def test_df2waffle(): files = shared_data(openalea.strawberry).glob('*.mtg') mtg_path = dict((name(f), f) for f in files) mtg = read_mtg_file(mtg_path['Capriss']) df = extract_at_node_scale(mtg) node_scale = df2waffle(df, index='rank', date='2015/03/02', variable='branching_type') assert node_scale.shape == (20, 9) df = extract_at_module_scale(mtg) module_scale = df2waffle(df, index='order', date='2015/03/02', variable='crown_status', aggfunc='median') assert module_scale.shape == (3, 9)
def test_extract_at_module_scale(): files = shared_data(openalea.strawberry).glob('*.mtg') mtg_path = dict((name(f), f) for f in files) mtg = MTG() for k, genotype in enumerate(mtg_path): if (genotype=="Sicile") or (genotype=="Nils") or (genotype=='origine_stolon_gariguetteDV_6novembre2018') \ or (genotype=='friendlyfruit_varieties'): pass else: mtg = union(mtg, read_mtg_file(mtg_path[genotype])) genotypes = mtg.property('Genotype') for geno in set(genotypes.values()): vids = [ vid for vid in mtg.vertices(scale=1) if genotypes.get(vid) == geno ] df = extract_at_module_scale(mtg, vids) assert not df.empty assert set(df['Genotype']) == {geno}
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)