Strawberry analysis function

Function to analyse strawberry mtg: Data extraction and plot

openalea.strawberry.analysis.apparent_axis(g, vid)[source]

Return apparent axis if module are visible

Parameters
  • g (MTG) – MTG

  • vid (int) – vid selected

Yield

generator of axis

Return type

int

openalea.strawberry.analysis.branching_type(vid, g)[source]

Returns the type of branching

Algorithms

if module is visible:
  • branch crown (complex ramification):6

  • inflorescence : 7

if module is invisible:
  • stolon (s): 1,

  • vegetative bud(bt, at stage None, 17,18,19):2,

  • initiated bud, (bt, at stage A):3,

  • aborted or roten or dried bud: 4

  • floral bud(ht):5

Parameters
  • vid (int) – vid selected

  • g (MTG) – MTG

Returns

The branching type

Return type

int

openalea.strawberry.analysis.complete(vid, g)[source]

Add property complete or not on mtg

Parameters
  • vid (int) – vid selected

  • g (MTG) – MTG

Returns

The ‘complete’ state of the vid

Return type

boolean

openalea.strawberry.analysis.complete_module(g, vids=[])[source]

Return properties incomplete or complete module Algorithm: module are complete: if module are visible and terminated by an Inflorescence (HT) (propertie=True) else module are incomplete (all module terminated by ht or bt) (property=False)

Parameters
  • g (MTG) – the MTG module

  • vids (list, optional) – list of vids, defaults to []

openalea.strawberry.analysis.compute_leaf_area(g, vids=[])[source]

Compute the leaf area of the selected MTG

Parameters
  • g (MTG) – MTG

  • vids (list, optional) – list of vids at scale 3, defaults to []

Returns

A dict of leaf area (key is vid)

Return type

dict

openalea.strawberry.analysis.crown_status(vid, g)[source]

Returns the type of inflorescence

Algorithms

if label is bt then
  • if stage is 17, 18, 19 or None, => vegetative (1)

  • if stage is A => initiated (2)

  • if stage is other => non defined (pourri, avorte, coupe) (-1)

  • Terminal vegetative bud (1): label==bt g.property(Stade)== none or 17 or 18 or 19

  • Terminal initiated bud (2): label== bt if g.property(Stade) == A

  • Terminal Floral bud (3): label==ht

  • Inflorescence Terminal (4): label== HT

  • runner (5): label = s

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The crown status

Return type

int

openalea.strawberry.analysis.crowntype_distribution(data, varieties, crown_type, plot=True, expand=0)[source]

Create a dataframe containing relative frequency values by genotype and order for extension and branch crown and a relative frequency distribution plot

Parameters
  • data (pd.DataFrame) – panda dataframe issue from extraction of data at module scale

  • varieties (list of string) – names of varieties which are plot

  • crown_type (str) – type of branch crown (extension_crown or branch_crown)

  • plot (bool, optional) – is ploted, defaults to True

  • expand (int, optional) – allows to change xlim, defaults to 0

Returns

the dataframe

Return type

pd.DataFrame

openalea.strawberry.analysis.date(vid, g)[source]

Return the date of the selected vid in the mtg

Parameters
  • vid (int) – vid selected

  • g (MTG) – MTG

Returns

The date

Return type

string

openalea.strawberry.analysis.df2waffle(df, date, index, variable, order=None, aggfunc=None, crosstab=None, *args, **kwargs)[source]

Transpose dataframe by variable with plant in columns and rank or order in index This function are available for extraction at node scale (index=’rank’) and extraction at module scale (index= ‘order’)

Parameters
  • df (pd.DataFrame) – dataframe from extract function at differente scale (modules and nodes scale)

  • date (str) – date which must be processed

  • index (str) – scale of the representation (node > ‘rank’, module > ‘order’)

  • variable (str) – variable which must be processed

  • order (int, optional) – at module scale, give a specific module to be processed , defaults to None

  • aggfunc (str, optional) – required if the data need to be grouped quantitative: “mean”, “median” | qualitative: lambda x: ‘ ‘.join(x), defaults to None

  • crosstab (boolean, optional) – make a crosstab selection of the input data, defaults to None

Returns

a dataframe in “waffle” shape: index=date, & columns=variable

Return type

pd.DataFrame

openalea.strawberry.analysis.extract_at_module_scale(g, vids=[], convert={'Fleurs_avorte': 'FLWRNUMBER_ABORTED', 'Fleurs_ouverte': 'FLWRNUMBER_OPEN', 'Fleurs_total': 'FLWRNUMBER', 'Plante': 'Plant_ID', 'Stade': 'Stade', 'date': 'Sample_date'})[source]

Compute the properties at module scale of a MTG.

Parameters
  • g (MTG) – The MTG

  • vids (list, optional) – list of vids that are included in the extraction at scale 1, defaults to []

  • convert (dict, optional) – Dictionary of equivalence of data name from fr to eng , defaults to convert

Returns

A dataframe of computed properties at module scale

Return type

DataFrame

openalea.strawberry.analysis.extract_at_node_scale(g, vids=[], convert={'Fleurs_avorte': 'FLWRNUMBER_ABORTED', 'Fleurs_ouverte': 'FLWRNUMBER_OPEN', 'Fleurs_total': 'FLWRNUMBER', 'Plante': 'Plant_ID', 'Stade': 'Stade', 'date': 'Sample_date'})[source]

Compute the properties at node scale of a MTG.

Parameters
  • g (MTG) – The MTG

  • vids (list, optional) – list of vids that are included in the extraction at scale 1, defaults to []

  • convert (dict, optional) – Dictionary of equivalence of data name from fr to eng , defaults to convert

Returns

A dataframe of computed properties at node scale

Return type

DataFrame

openalea.strawberry.analysis.extract_at_plant_scale(g, vids=[], convert={'Fleurs_avorte': 'FLWRNUMBER_ABORTED', 'Fleurs_ouverte': 'FLWRNUMBER_OPEN', 'Fleurs_total': 'FLWRNUMBER', 'Plante': 'Plant_ID', 'Stade': 'Stade', 'date': 'Sample_date'})[source]

Compute the properties at plant scale of a MTG.

Parameters
  • g (MTG) – The MTG

  • vids (list, optional) – list of vids that are included in the extraction at scale 1, defaults to []

  • convert (dict, optional) – Dictionary of equivalence of data name from fr to eng , defaults to convert

Returns

A dataframe of computed properties at plant scale

Return type

DataFrame

openalea.strawberry.analysis.genotype(vid, g)[source]

Return the genotype of the selected vids in the mtg

Parameters
  • vid (int) – vid selected

  • g (MTG) – MTG

Returns

The genotype

Return type

string

openalea.strawberry.analysis.is_axis_root(g, vid)[source]

Checks if axis is root

Parameters
  • g (MTG) – MTG

  • vid (int) – vid selected

Returns

Is the axis a root

Return type

boolean

openalea.strawberry.analysis.mean_leaf_area(vid, g)[source]

Compute the mean leaf area

Parameters
  • vid (int) – selected vids

  • g (MTG) – MTG

Returns

the mean leaf area of the selected vid

Return type

float

openalea.strawberry.analysis.median_individuals(df)[source]

Generate a median individual from a group of genotype, date, modality

Parameters

df (DataFrame) – A dataframe extracted from the MTG at a specific scale (order, plant, or node)

Returns

A reduced dataframe with the median individual

Return type

DataFrame

openalea.strawberry.analysis.missing_leaves(vid, g)[source]

Return the number of missing leaves

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of missing leaves

Return type

int

openalea.strawberry.analysis.modality(vid, g)[source]

Return the modality of the selected vid in the mtg

Parameters
  • vid (int) – vid selected

  • g (MTG) – MTG

Returns

The modality

Return type

string

openalea.strawberry.analysis.module_tree(v, g)[source]

Return the list of vid of module tree

Parameters
  • v (int) – selected vid

  • g (MTG) – MTG

Returns

List of module tree

Return type

list

openalea.strawberry.analysis.my_bt(vid, g)[source]

Return branching type on parent if branch crown correspond to Son vertex

Parameters
  • vid (int) – vid selected

  • g (MTG) – MTG

Returns

the branching type on parent

Return type

string

openalea.strawberry.analysis.my_complete(vid, g)[source]

Return complete module, incomplete module or other (if not branch crown)

Parameters
  • vid (int) – vid selected

  • g (MTG) – MTG

Returns

‘Complete’ state

Return type

string

openalea.strawberry.analysis.nb_aborted_flowers(vid, g)[source]

Return the number of aborted flowers

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of aborted flowers

Return type

int

openalea.strawberry.analysis.nb_branching_tree(v, g)[source]

Compute the number of branching tree

Parameters
  • v (int) – selected vid

  • g (MTG) – MTG

Returns

number of branching tree

Return type

int

openalea.strawberry.analysis.nb_branching_tree_weight(v, g)[source]

Compute the number of branching tree weight

Parameters
  • v (int) – selected vid

  • g (MTG) – MTG

Returns

number of branching tree weight

Return type

int

openalea.strawberry.analysis.nb_close_flowers(vid, g)[source]

Return the number of aborted flowers

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of aborted flowers

Return type

int

openalea.strawberry.analysis.nb_extension_tree(v, g)[source]

Compute the number of extension tree

Parameters
  • v (int) – selected vid

  • g (MTG) – MTG

Returns

number of extension tree

Return type

int

openalea.strawberry.analysis.nb_floral_buds(vid, g)[source]

Return the number of floral buds

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of floral buds

Return type

int

openalea.strawberry.analysis.nb_foliar_primordia(vid, g)[source]

Return the number of foliar primordia (f)

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of foliar primordia

Return type

int

openalea.strawberry.analysis.nb_inflorescence(Vid, g)[source]

Return the number of inflorescence

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of inflorescence

Return type

int

openalea.strawberry.analysis.nb_initiated_buds(vid, g)[source]

Return the number of initiated buds

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of initiated buds

Return type

int

openalea.strawberry.analysis.nb_open_flowers(vid, g)[source]

Return the number of open flowers

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of open flowers

Return type

int

openalea.strawberry.analysis.nb_stolons(v, g)[source]

Return the number of stolons

Parameters
  • v (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of stolon

Return type

int

openalea.strawberry.analysis.nb_total_flowers(vid, g)[source]

Return the number of total flowers

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of total flowers

Return type

int

openalea.strawberry.analysis.nb_total_leaves(vid, g)[source]

Return the total number of leaves (f+F)

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of total leaves

Return type

int

openalea.strawberry.analysis.nb_total_module_tree(v, g)[source]

Compute the number of total module tree

Parameters
  • v (int) – selected vid

  • g (MTG) – MTG

Returns

total number of module tree

Return type

int

openalea.strawberry.analysis.nb_vegetative_buds(vid, g)[source]

Return the number of vegetative buds Algorithm: if label is bt then stage is 17,18,19 or None count number of bt and attach at the parent order

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of vegetative buds

Return type

int

openalea.strawberry.analysis.nb_visible_leaves(vid, g)[source]

Return the number of visible leaves

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of visible leaves

Return type

int

openalea.strawberry.analysis.nb_visible_leaves_tree(v, g)[source]

Compute the number of visible leaves tree

Parameters
  • v (int) – selected vid

  • g (MTG) – MTG

Returns

number of visible leaves tree

Return type

int

openalea.strawberry.analysis.no_fruits(vid, g)[source]

Return the number of fruits

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The number of fruits

Return type

int

openalea.strawberry.analysis.occurence_module_order_along_time(data, frequency_type)[source]

Compute the occurence module order along time

Parameters
  • data (pd.DataFrame) – data extracted at module scale

  • frequency_type (str) – type of distribution frequency distribution (freq), probability distribution frequency (pbf) or cumulative frequency distribution (cdf)

Returns

A dataframe with frequency, probability or cumulative frequency distribution for each module order along time

Return type

pd.DataFrame

openalea.strawberry.analysis.plant(vid, g)[source]

Return the plant id of the selected vid in the mtg

Parameters
  • vid (int) – vid selected

  • g (MTG) – MTG

Returns

The plant id

Return type

string

openalea.strawberry.analysis.plot_pie(df)[source]
openalea.strawberry.analysis.plot_waffle(df, layout={}, legend_name={}, savepath=None, plot_func='matplotlib')[source]

Plot a dataframe in “waffle” shape

layout: dict of layout parameters:

height/width: size of the picture in inch x/ylabel: label of the x/y axis x/yticks: ticks of the x/y axis x/yticks_labels: labels of the ticks on the x/y axis title: title

plot_func: library used for the ploting:

matplotlib: matplotlib.pyplot.subplot.imshow plotly.imshow: plotly.express.imshow plotly.heatmap: plotly.graph_objs.heatmap

openalea.strawberry.analysis.plot_waffle_matplotlib(df, layout={}, legend_name={})[source]
openalea.strawberry.analysis.plot_waffle_plotly_heatmap(df, layout={}, legend_name={})[source]
openalea.strawberry.analysis.plot_waffle_plotly_imshow(df, layout={}, legend_name={})[source]
openalea.strawberry.analysis.pointwisemean_plot(data_mean, data_sd, varieties, variable, title, ylab, expand=0)[source]

Plot a pointwise mean of variables.

Parameters
  • data_mean (DataFrame) – panda dataframe containg mean values

  • data_sd (DataFrame) – panda dataframe containing standars error values

  • varieties (list of string) – names of varieties which are plot

  • variable (string) – The variable to plot

  • title (string) – plot title

  • ylab (string) – y axis label

  • expand (int, optional) – allows to change xlim, defaults to 0

openalea.strawberry.analysis.prob_axillary_production(g, order=None, vids=[], frequency=False)[source]

Probability of axillary production as function of node rank

Parameters
  • g (MTG) – mtg

  • order (str, optional) – order selected (order= None all module orders are selected), defaults to None

  • vids (list, optional) – vid selected, defaults to []

  • frequency (bool, optional) – frequency selected, defaults to False

Returns

A dataframe with the probability of axillary production for each node

Return type

pd.DataFrame

openalea.strawberry.analysis.property(g, name)[source]

Change the name of the MTG properties without changing the code

Parameters
  • g (MTG) – The MTG to modify

  • name (string) – The property name

Returns

A MTG with the name of the property changed

Return type

MTG

openalea.strawberry.analysis.stage(vid, g)[source]
openalea.strawberry.analysis.stage_tree(vid, g)[source]
openalea.strawberry.analysis.strawberry_dataframe(g)[source]

Convert a strawberry MTG into a dataframe

Parameters

g (MTG) – the strawberry MTG

Returns

A dataframe

Return type

DataFrame

openalea.strawberry.analysis.to_dataframe(g, vertices=[], f=None)[source]

Convert an MTG into a full dataframe.

Parameters
  • g (MTG) – MTG graph

  • vertices (list, optional) – define the vertices you want to export, defaults to []

  • f (function, optional) – v -> dict : function that returns a set of properties for any vertex, defaults to None

Returns

A dataframe that include all the MTG properties

Return type

DataFrame

openalea.strawberry.analysis.type_of_crown(vid, g)[source]

Returns the type of crown.

Definition of type of crown (1, 2, 3):
  • principal crown (1): label == T

  • branch_crown (3)

    parent(component_roots()[0]) : if successor() == F

  • extension_crown (2): contains(HT, ht, bt)

  • error (4)

Parameters
  • vid (int) – vid for which the function is applied

  • g (MTG) – MTG

Returns

The type of crown

Return type

int

openalea.strawberry.analysis.visible_modules(g, vids=[])[source]

Give “visible” property to module

Parameters
  • g (MTG) – The MTG

  • vids (list, optional) – List of vids whose property will be “visible”, defaults to []

openalea.strawberry.analysis.write_sequences(seqs, variables, VertexIdentifiers)[source]

Write Sequences into a txt file.

Example: VertexIdentifiers = [[‘-‘.join(str(orders[j]) for j in seq[0:i+1]) for i, vid in enumerate(seq)] for seq in seqs] seqs = [ list(apparent_axis(g, vid)) for vid in vids]

Parameters
  • seqs (list) – A MTG in vector format (=sequence)

  • variables (OrderedDict) – dict of variables to extract as keys & their function as var

  • VertexIdentifiers (list) – index or order succession

Returns

A string with variable information extacted from MTG

Return type

string