Exemplo n.º 1
0
    def plot(self,
             index=None,
             grid=None,
             width=None,
             height=None,
             title=None,
             palette=None,
             **kwargs):
        if index is None:
            index = self.data_frame.index[0:10]
        fva_result = self.data_frame.loc[index]
        if title is None:
            title = "Flux Variability Analysis"

        dataframe = pandas.DataFrame(
            columns=["lb", "ub", "strain", "reaction"])
        for reaction_id, row in fva_result.iterrows():
            _df = pandas.DataFrame(
                [[row['lower_bound'], row['upper_bound'], "WT", reaction_id]],
                columns=dataframe.columns)
            dataframe = dataframe.append(_df)

        plot = plotter.flux_variability_analysis(dataframe,
                                                 grid=grid,
                                                 width=width,
                                                 height=height,
                                                 title=title,
                                                 y_axis_label="Reactions",
                                                 x_axis_label="Flux limits",
                                                 palette=palette)
        if grid is None:
            plotter.display(plot)
Exemplo n.º 2
0
    def _plot_flux_variability_analysis(self, index, variables=None, title=None,
                                        width=None, height=None, palette=None, grid=None):
        if variables is None:
            variables = self.reference_fva.index[0:10]

        title = "Compare WT solution %i" % index if title is None else title

        wt_fva_res = self.reference_fva.loc[variables]
        strain_fva_res = self.nth_panel(index).loc[variables]
        dataframe = pandas.DataFrame(columns=["lb", "ub", "strain", "reaction"])
        for reaction_id, row in wt_fva_res.iterrows():
            _df = pandas.DataFrame([[row['lower_bound'], row['upper_bound'], "WT", reaction_id]],
                                   columns=dataframe.columns)
            dataframe = dataframe.append(_df)

        for reaction_id, row in strain_fva_res.iterrows():
            _df = pandas.DataFrame([[row['lower_bound'], row['upper_bound'], "Strain %i" % index, reaction_id]],
                                   columns=dataframe.columns)
            dataframe = dataframe.append(_df)

        plot = plotter.flux_variability_analysis(dataframe, grid=grid, width=width, height=height,
                                                 title=title, x_axis_label="Reactions", y_axis_label="Flux limits",
                                                 palette=palette)

        plotter.display(plot)
Exemplo n.º 3
0
    def _plot_flux_variability_analysis(self, index, variables=None, title=None,
                                        width=None, height=None, palette=None, grid=None):
        if variables is None:
            variables = self.reference_fva.index[0:10]

        title = "Compare WT solution %i" % index if title is None else title

        wt_fva_res = self.reference_fva.loc[variables]
        strain_fva_res = self.nth_panel(index).loc[variables]
        dataframe = pandas.DataFrame(columns=["lb", "ub", "strain", "reaction"])
        for reaction_id, row in wt_fva_res.iterrows():
            _df = pandas.DataFrame([[row['lower_bound'], row['upper_bound'], "WT", reaction_id]],
                                   columns=dataframe.columns)
            dataframe = dataframe.append(_df)

        for reaction_id, row in strain_fva_res.iterrows():
            _df = pandas.DataFrame([[row['lower_bound'], row['upper_bound'], "Strain %i" % index, reaction_id]],
                                   columns=dataframe.columns)
            dataframe = dataframe.append(_df)

        plot = plotter.flux_variability_analysis(dataframe, grid=grid, width=width, height=height,
                                                 title=title, x_axis_label="Reactions", y_axis_label="Flux limits",
                                                 palette=palette)

        plotter.display(plot)
Exemplo n.º 4
0
    def plot(self, grid=None, width=None, height=None, title=None, *args, **kwargs):
        if title is None:
            title = "FSEOF fluxes"

        plot = plotter.line(self.data_frame, grid=grid, width=width, height=height, title=title, **kwargs)

        if grid is None:
            plotter.display(plot)
Exemplo n.º 5
0
    def plot(self, grid=None, width=None, height=None, title=None, *args, **kwargs):
        if title is None:
            title = "FSEOF fluxes"

        plot = plotter.line(self.data_frame, grid=grid, width=width, height=height, title=title, **kwargs)

        if grid is None:
            plotter.display(plot)
Exemplo n.º 6
0
    def plot(self,
             index=0,
             grid=None,
             width=None,
             height=None,
             title=None,
             palette=None,
             **kwargs):
        wt_production = phenotypic_phase_plane(self._model,
                                               objective=self._target,
                                               variables=[self._biomass])
        with TimeMachine() as tm:
            for ko in self.data_frame.loc[index, "reactions"]:
                self._model.reactions.get_by_id(ko).swap_cofactors(
                    self._swap_pairs, tm)
            mt_production = phenotypic_phase_plane(self._model,
                                                   objective=self._target,
                                                   variables=[self._biomass])

        if title is None:
            title = "Production Envelope"

        dataframe = DataFrame(columns=["ub", "lb", "value", "strain"])
        for _, row in wt_production.iterrows():
            _df = DataFrame([[
                row['objective_upper_bound'], row['objective_lower_bound'],
                row[self._biomass.id], "WT"
            ]],
                            columns=dataframe.columns)
            dataframe = dataframe.append(_df)
        for _, row in mt_production.iterrows():
            _df = DataFrame([[
                row['objective_upper_bound'], row['objective_lower_bound'],
                row[self._biomass.id], "MT"
            ]],
                            columns=dataframe.columns)
            dataframe = dataframe.append(_df)

        plot = plotter.production_envelope(dataframe,
                                           grid=grid,
                                           width=width,
                                           height=height,
                                           title=title,
                                           x_axis_label=self._biomass.id,
                                           y_axis_label=self._target.id,
                                           palette=palette)
        plotter.display(plot)
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    def plot(self, index=None, grid=None, width=None, height=None, title=None, palette=None, **kwargs):
        if index is None:
            index = self.data_frame.index[0:10]
        fva_result = self.data_frame.loc[index]
        if title is None:
            title = "Flux Variability Analysis"

        dataframe = pandas.DataFrame(columns=["lb", "ub", "strain", "reaction"])
        for reaction_id, row in fva_result.iterrows():
            _df = pandas.DataFrame([[row['lower_bound'], row['upper_bound'], "WT", reaction_id]],
                                   columns=dataframe.columns)
            dataframe = dataframe.append(_df)

        plot = plotter.flux_variability_analysis(dataframe, grid=grid, width=width, height=height,
                                                 title=title, y_axis_label="Reactions", x_axis_label="Flux limits",
                                                 palette=palette)
        if grid is None:
            plotter.display(plot)
Exemplo n.º 9
0
    def plot(self, index=0, grid=None, width=None, height=None, title=None, palette=None, **kwargs):
        wt_production = phenotypic_phase_plane(self._model, objective=self._target, variables=[self._biomass.id])
        with TimeMachine() as tm:
            for ko in self.data_frame.loc[index, "reactions"]:
                self._model.reactions.get_by_id(ko).knock_out(tm)

            mt_production = phenotypic_phase_plane(self._model, objective=self._target, variables=[self._biomass.id])
        if title is None:
            title = "Production Envelope"

        dataframe = DataFrame(columns=["ub", "lb", "value", "strain"])
        for _, row in wt_production.iterrows():
            _df = DataFrame([[row['objective_upper_bound'], row['objective_lower_bound'], row[self._biomass.id], "WT"]],
                            columns=dataframe.columns)
            dataframe = dataframe.append(_df)
        for _, row in mt_production.iterrows():
            _df = DataFrame([[row['objective_upper_bound'], row['objective_lower_bound'], row[self._biomass.id], "MT"]],
                            columns=dataframe.columns)
            dataframe = dataframe.append(_df)

        plot = plotter.production_envelope(dataframe, grid=grid, width=width, height=height, title=title,
                                           x_axis_label=self._biomass.id, y_axis_label=self._target, palette=palette)
        plotter.display(plot)
Exemplo n.º 10
0
    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)