Utils¶
Helpful utility functions for the multidms package
- multidms.utils.explode_params_dict(params_dict)¶
Given a dictionary of model parameters, of which any of the values can be a list of values, compute all combinations of model parameter sets and returns a list of dictionaries representing each of the parameter sets.
- multidms.utils.my_concat(dfs_list, axis=0)¶
simple pd.concat wrapper for bug with vscode pylance See https://github.com/matsengrp/multidms/issues/156 for more details
- multidms.utils.split_sub(sub_string)¶
A very simplistic function to split a mutations string into its constituent parts. This function is only designed to work with simple mutation strings of the form A123B, where A is the wildtype amino acid, 123 is the site, and B is the mutant amino acid.
Note
It is favorable to use the polyclonal.utils.MutationParser class instead, as that provides the ability to parse more complex mutation strings using allowed alphabets.
- multidms.utils.split_subs(subs_string, parser=<function split_sub>)¶
Given a mutation parsing function, split a string of mutations into three lists containing the wildtype amino acids, sites, and mutant amino acids.
- Parameters:
subs_string (str) – A string containing multiple mutations
parser (function) – A function that can parse a single mutation string and returns a tuple containing the wildtype amino acid, site, and mutant amino acid
- Returns:
A tuple containing the wildtype amino acids, sites, and mutant amino acids as lists
- Return type:
- multidms.utils.difference_matrix(n, ref_index=0)¶
Given some number of conditions, return the difference matrix for computing shifts between adjacent conditional beta parameters.
- multidms.utils.transform(params, bundle_idxs)¶
Transforms the beta coefficient parameters of a multidms model to be negative for the bundles specified in bundle_idxs, and the updated beta0 parameters based on the new beta coefficients. See issue #156 for more on scaling parameters for training.
- Parameters:
- Returns:
A dictionary containing the transformed model parameters “beta”, and “beta0”.
- Return type:
- multidms.utils.rereference(X, bundle_idxs)¶
Given a binary matrix X and bundle indices, re-reference the matrix to flip the bit signs for the bundles specified in bundle_idxs. This function is used to scale the data matrix for training a model. See issue #156 for more on scaling parameters for training.
- Parameters:
X (jax.experimental.sparse.BCOO) – A binary matrix
bundle_idxs (jnp.ndarray) – An boolean array indicating the bundle indices in the binarymap matrix.
- Returns:
A re-referenced binary matrix
- Return type: