epistasis.models package¶
See subpackages for specific models.
epistasis.models.base module¶
-
class
epistasis.models.base.
AbstractModel
¶ Bases:
abc.ABC
Abstract Base Class for all epistasis models.
This class sets all docstrings not given in subclasses.
-
static
__new__
(self, *args, **kwargs)¶ Replace the docstrings of a subclass with docstrings in this base class.
-
add_X
(X=None, key=None)¶ Add X to Xbuilt
Keyword arguments for X:
- None :
- Uses
gpm.binary
to construct X. If genotypes are missing they will not be included in fit. At the end of fitting, an epistasis map attribute is attached to the model class.
Parameters: - X – see above for details.
- key (str) – name for storing the matrix.
Returns: Xbuilt – newly built 2d array matrix
Return type: numpy.ndarray
-
add_gpm
(gpm)¶ Add a GenotypePhenotypeMap object to the epistasis model.
-
fit
(X=None, y=None, **kwargs)¶ Fit model to data.
Parameters: - X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model.
- y (None or ndarray (default=None)) – array of phenotypes. If None, the phenotypes in the attached genotype-phenotype map is used.
Returns: The model is returned. Allows chaining methods.
Return type: self
-
fit_transform
(X=None, y=None, **kwargs)¶ Fit model to data and transform output according to model.
Parameters: - X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model.
- y (None or ndarray (default=None)) – array of phenotypes. If None, the phenotypes in the attached genotype-phenotype map is used.
Returns: gpm – The genotype-phenotype map object with transformed genotypes.
Return type: GenotypePhenotypeMap
-
gpm
¶ Data stored in a GenotypePhenotypeMap object.
-
hypothesis
(X=None, thetas=None)¶ Compute phenotypes from given model parameters.
Parameters: - X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model.
- thetas (ndarray) – array of model parameters. See thetas property for specifics.
Returns: y – array of phenotypes predicted by model parameters.
Return type: ndarray
-
hypothesis_transform
(X=None, y=None, thetas=None)¶ Transform phenotypes with given model parameters.
Parameters: - X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model.
- y (ndarray) – An array of phenotypes to transform.
- thetas (ndarray) – array of model parameters. See thetas property for specifics.
Returns: y – array of phenotypes predicted by model parameters.
Return type: ndarray
-
lnlike_of_data
(X=None, y=None, yerr=None, thetas=None)¶ Compute the individUal log-likelihoods for each datapoint from a set of model parameters.
Parameters: - X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model.
- y (ndarray) – An array of phenotypes to transform.
- yerr (ndarray) – An array of the measured phenotypes standard deviations.
- thetas (ndarray) – array of model parameters. See thetas property for specifics.
Returns: y – array of phenotypes predicted by model parameters.
Return type: ndarray
-
lnlike_transform
(X=None, y=None, yerr=None, lnprior=None, thetas=None)¶ Compute the individual log-likelihoods for each datapoint from a set of model parameters and a prior.
Parameters: - X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model.
- y (ndarray) – An array of phenotypes to transform.
- yerr (ndarray) – An array of the measured phenotypes standard deviations.
- lnprior (ndarray) – An array of priors for a given datapoint.
- thetas (ndarray) – array of model parameters. See thetas property for specifics.
Returns: y – array of phenotypes predicted by model parameters.
Return type: ndarray
-
lnlikelihood
(X=None, y=None, yerr=None, thetas=None)¶ Compute the individal log-likelihoods for each datapoint from a set of model parameters.
Parameters: - X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model.
- y (ndarray) – An array of phenotypes to transform.
- yerr (ndarray) – An array of the measured phenotypes standard deviations.
- thetas (ndarray) – array of model parameters. See thetas property for specifics.
Returns: lnlike – log-likelihood of the model parameters.
Return type: float
-
num_of_params
¶ Number of parameters in model.
-
predict
(X=None)¶ Use model to predict phenotypes for a given list of genotypes.
Parameters: X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model. Returns: y – array of phenotypes. Return type: ndarray
-
predict_transform
(X=None, y=None, **kwargs)¶ Transform a set of phenotypes according to the model.
Parameters: - X (None, ndarray, or list of genotypes. (default=None)) – data used to construct X matrix that maps genotypes to model coefficients. If None, the model uses genotypes in the attached genotype-phenotype map. If a list of strings, the strings are genotypes that will be converted to an X matrix. If ndarray, the function assumes X is the X matrix used by the epistasis model.
- y (ndarray) – An array of phenotypes to transform.
Returns: y_transform – array of phenotypes.
Return type: ndarray
-
static
-
class
epistasis.models.base.
BaseModel
¶ Bases:
epistasis.models.base.AbstractModel
,sklearn.base.RegressorMixin
,sklearn.base.BaseEstimator
Base model for defining an epistasis model.
-
exception
epistasis.models.base.
SubclassException
¶ Bases:
Exception
Subclass Exception for parent classes.
-
epistasis.models.base.
use_sklearn
(sklearn_class)¶ Swap out last class in the inherited stack (Assuming its the BaseModel) with the AbstractModel below. Then, sandwiches the Sklearn class with all other base classes first, followed by the Sklearn class and the AbstractModel.
epistasis.models.classifiers module¶
epistasis.models.ensemble module¶
epistasis.models.pipeline module¶
epistasis.models.utils module¶
-
exception
epistasis.models.utils.
FittingError
¶ Bases:
Exception
Exception Subclass for X matrix errors.
-
exception
epistasis.models.utils.
XMatrixException
¶ Bases:
Exception
Exception Subclass for X matrix errors.
-
epistasis.models.utils.
arghandler
(method)¶ Points methods to argument handlers. Assumes each argument has a corresponding method attached to the object named “_{argument}”. These methods given default values to arguments.
Ignores self and kwargs