def plot(self, grid=None, width=None, height=None, title=None, axis_font_size=None, palette=None, points=None, points_colors=None, **kwargs): if title is None: title = "Phenotypic Phase Plane" if len(self.variable_ids) == 1: variable = self.variable_ids[0] x_axis_label = self.nice_variable_ids[0] y_axis_label = self.nice_objective_id dataframe = pandas.DataFrame(columns=["ub", "lb", "value", "strain"]) for _, row in self.iterrows(): _df = pandas.DataFrame([[row['objective_upper_bound'], row['objective_lower_bound'], row[variable], "WT"]], columns=dataframe.columns) dataframe = dataframe.append(_df) plot = plotter.production_envelope(dataframe, grid=grid, width=width, height=height, title=title, y_axis_label=y_axis_label, x_axis_label=x_axis_label, palette=palette, points=points, points_colors=points_colors) elif len(self.variable_ids) == 2: var_1 = self.variable_ids[0] var_2 = self.variable_ids[1] x_axis_label = self.nice_variable_ids[0] y_axis_label = self.nice_variable_ids[1] z_axis_label = self.nice_objective_id dataframe = pandas.DataFrame(columns=["ub", "lb", "value1", "value2", "strain"]) for _, row in self.iterrows(): _df = pandas.DataFrame([[row['objective_upper_bound'], row['objective_lower_bound'], row[var_1], row[var_2], "WT"]], columns=dataframe.columns) dataframe = dataframe.append(_df) plot = plotter.production_envelope_3d(dataframe, grid=grid, width=width, height=height, title=title, y_axis_label=y_axis_label, x_axis_label=x_axis_label, z_axis_label=z_axis_label, palette=palette, points=points, points_colors=points_colors) else: notice("Multi-dimensional plotting is not supported") return if grid is None: plotter.display(plot)
def plot(self, grid=None, width=None, height=None, title=None, axis_font_size=None, palette=None, points=None, points_colors=None, estimate='flux', **kwargs): """plot phenotypic phase plane result create a plot of a phenotypic phase plane analysis Parameters ---------- grid: plotting grid the grid for plotting width: int the width of the plot height: int the height of the plot title: string the height of the plot axis_font_size: int the font sizes for the axis palette: string name of color palette to use, e.g. RdYlBlu points: iterable of points additional points to plot as x, y iterable points_colors: iterable of strings iterable with colors for the points estimate: string either flux, mass_yield (g output / g output) or c_yield (mol carbon output / mol carbon input) """ possible_estimates = { 'flux': ('objective_upper_bound', 'objective_lower_bound', 'flux', '[mmol gDW^-1 h^-1]'), 'mass_yield': ('mass_yield_upper_bound', 'mass_yield_lower_bound', 'mass yield, src={}'.format(self.source_reaction), '[g/g(src) h^-1]'), 'c_yield': ('c_yield_upper_bound', 'c_yield_lower_bound', 'carbon yield, src={}'.format(self.source_reaction), '[mmol(C)/mmol(C(src)) h^-1]') } if estimate not in possible_estimates: raise Exception('estimate must be one of %s' % ', '.join(possible_estimates.keys())) upper, lower, description, unit = possible_estimates[estimate] if title is None: title = "Phenotypic Phase Plane ({})".format(description) if len(self.variable_ids) == 1: variable = self.variable_ids[0] y_axis_label = self._axis_label(self.objective, self.nice_objective_id, unit) x_axis_label = self._axis_label(variable, self.nice_variable_ids[0], '[mmol gDW^-1 h^-1]') dataframe = pandas.DataFrame( columns=["ub", "lb", "value", "strain"]) for _, row in self.iterrows(): _df = pandas.DataFrame( [[row[upper], row[lower], row[variable], "WT"]], columns=dataframe.columns) dataframe = dataframe.append(_df) plot = plotter.production_envelope(dataframe, grid=grid, width=width, height=height, title=title, y_axis_label=y_axis_label, x_axis_label=x_axis_label, palette=palette, points=points, points_colors=points_colors) elif len(self.variable_ids) == 2: var_1 = self.variable_ids[0] var_2 = self.variable_ids[1] x_axis_label = self._axis_label(var_1, self.nice_variable_ids[0], '[mmol gDW^-1 h^-1]') y_axis_label = self._axis_label(var_2, self.nice_variable_ids[1], '[mmol gDW^-1 h^-1]') z_axis_label = self._axis_label(self.objective, self.nice_objective_id, unit) dataframe = pandas.DataFrame( columns=["ub", "lb", "value1", "value2", "strain"]) for _, row in self.iterrows(): _df = pandas.DataFrame( [[row[upper], row[lower], row[var_1], row[var_2], "WT"]], columns=dataframe.columns) dataframe = dataframe.append(_df) plot = plotter.production_envelope_3d(dataframe, grid=grid, width=width, height=height, title=title, y_axis_label=y_axis_label, x_axis_label=x_axis_label, z_axis_label=z_axis_label, palette=palette, points=points, points_colors=points_colors) else: notice("Multi-dimensional plotting is not supported") return if grid is None: plotter.display(plot)