GPR Reference

API Documentation for the gpr submodule

Gene-Protein-Reaction Rules

metworkpy.gpr.gpr_functions.eval_gpr(gpr: GPR | Expression | list | BoolOp | Name | None, gene_weights: Series | dict, fn_dict: dict, fill_val: Any = 0) Any

Evaluate a cobra GPR with specified functions for the Boolean operations

Parameters:
  • gpr (GPR or Expression or list or BoolOp or Name optional) – The GPR to evaluate

  • gene_weights (pd.Series or dict) – Weights to assign to each gene

  • fn_dict (dict) – Dict of ‘AND’ and ‘OR’ (strings) to functions which can take two gene weights and return a single value

  • fill_val (Any) – Value to replace any missing weights with

metworkpy.gpr.gpr_functions.gene_to_rxn_weights(model: Model, gene_weights: Series, fn_dict: dict | None = None, fill_val: Any = 0) Series

Convert a gene weights series to a reaction weights series using the provided function dictionary.

Parameters:
  • model (cobra.Model) – cobra.Model: A cobra model

  • gene_weights (pd.Series or dict of str to Value) – pd.Series: A series of gene weights

  • fn_dict (dict) – dict: A dictionary of functions to use for each operator

  • fill_val (Any) – Any: The value to fill missing values with

Returns:

A series of reaction weights

Return type:

pd.Series

Notes

The fill value is applied to fill NaN values after the GPR rules have been applied. If there are genes missing from the expression data, they will silently be assigned a value of 0 before the GPR processing is performed.