API - adapters#

found.adapters.step_fn(*out_names)[source]#

decorator for functions that return tuples, returns a copy which “annotates” individual output values with names for use in Pipeline.

returned function behaves identically to the original un-decorated function, the only modification is the addition of a private attribute to the function object.

Parameters:

out_names (str) – desired “names” of return values, in the same order as they are in the returned tuple.

Returns:

Callable[[TypeVar(Fn, bound= Callable[..., tuple])], TypeVar(Fn, bound= Callable[..., tuple])] – named return value annotated function

class found.adapters.Pipeline(dimr_fn, regr_fn, binr_fn, cachable_dimr=False, strict=True)[source]#

class which when provided with individual pipeline components (see fields), creates a pipeline for detecting and re-classifying cells affected/unaffected by the case condition.

functions are run in the following order: dimr_fn → regr_fn → binr_fn

Parameters:
  • dimr_fn (Callable) – dimensionality reduction function (output accessible to further functions via a parameter named Z unless explicitly wrapped by step_fn())

  • regr_fn (Callable) – regression function (output accessible to further functions via a parameter named Y unless explicitly wrapped by step_fn())

  • binr_fn (Callable) – binarization function (output accessible to further functions via a parameter named W unless explicitly wrapped by step_fn())

  • cachable_dimr (bool) – boolean indicating if the first k dimensions of the output of dimr_fn stable when requesting larger dimensions (e.g. is dimr_fn(X, k) = dimr_fn(X, k+n)[:, :k]) caution with setting this without care as it can lead to incorrect results when conducting hyperparameter optimization via Tuner. as a rule of thumb, this property is generally only true for truncated PCA.

  • strict (bool) – boolean indicating if the pipeline should conduct strict type checking, disable with caution if getting spurious {py:exc}`~TypeError` failures

check(w)[source]#

convenience function, given a set of provided arguments, validates if the pipeline can run returns if yes, raises ValueError if no

Parameters:

w (dict[str, object]) – dictionary of initial pipeline variables

update(dimr_fn=None, regr_fn=None, binr_fn=None, cachable_dimr=None, strict=None)[source]#

convenience constructor for creating a new Pipeline from an existing one (does not mutate original object).

Parameters:
  • dimr_fn (Callable | None) – dimensionality reduction function (output accessible to further functions via a parameter named Z)

  • regr_fn (Callable | None) – regression function (output accessible to further functions via a parameter named Y)

  • binr_fn (Callable | None) – binarization function (output accessible to further functions via a parameter named W)

  • cachable_dimr (bool | None) – boolean indicating if the first k dimensions of the output of dimr_fn stable when requesting larger dimensions (e.g. is dimr_fn(X, k) = dimr_fn(X, k+n)[:, :k]) caution with setting this without care as it can lead to incorrect results when conducting hyperparameter optimization via Tuner. as a rule of thumb, this property is generally only true for truncated PCA.

  • strict (bool | None) – boolean indicating if the pipeline should conduct strict type checking, disable with caution if getting spurious TypeError failures

Return type:

Self

classmethod from_proc_ad(dimr_key, regr_fn, binr_fn, strict=None)[source]#

convenience constructor for creating a Pipeline where the dimr_fn step fetches data from a specified AnnData obsm slot.

resulting Pipeline must be called with a named argument adata providing an AnnData object.

resulting Pipeline can optionally be called with a named argument k specifying the desired dimensionality of the dimensionality reduction space, otherwise the full provided space will be used.

Parameters:
  • dimr_key (str) – key for obsm slot specifying dimensionality reduction matrix

  • regr_fn (Callable) – regression function (output accessible to further functions via a parameter named Y)

  • binr_fn (Callable) – binarization function (output accessible to further functions via a parameter named W)

  • strict (bool | None) – boolean indicating if the pipeline should conduct strict type checking, disable with caution if getting spurious TypeError failures

Return type:

Self