This code is attached to the paper "Microbiome-metabolome interactions predict host phenotype".
Project description
LOCATE (Latent Of miCrobiome And meTabolites rElations)
This code is attached to the paper "Microbiome-metabolome interactions predict host phenotype". We propuse a machine learning (ML) tool based on latent representation which predicts the log normalized metabolites composition based on the log normalized microbiome composition. LOCATE has a higher overall accuracy than all current state-of-the-art predictors in both 16S and shotgun sequencing. We propose an intermediate representation between the microbiome and the metabolite concentrations and show that this representation can be used to predict the host phenotype better than either the microbiome or the metabolome.
How to apply LOCATE
LOCATE's code is avaliable at this GitHub as well as a pypi.
LOCATE's GitHub
LOCATE_model
This code consists of LOCATE's model class with the following functions:
-
init - with all model parametes as will be further explained.
-
find_transformer - finds the approximated A* to relate the intermediate representation of the microbiome to the training metabolites (for more details see paper's Methods).
-
forward - with LOCATE forward function.
-
configure_optimizers - controls the model's optimizers.
-
loss_g - representation network loss function.
-
training_step - with LOCATE training step.
-
validation_step - with LOCATE validation step.
-
backward - with the special backwards of LOCATE.
LOCATE_functions
Consists of two functions:
-
LOCATE_training
Input
-
X_train: Log normalized and with column z-score dataframe (for more details about normalization, see paper Methods) of training microbiome features (dataframe).
-
Y_train: Log normalized and with column z-score dataframe (for more details about normalization, see paper Methods) of training metabolites fearures (datframe).
-
X_val: Log normalized and with column z-score dataframe (for more details about normalization, see paper Methods) of validation microbiome features (dataframe).
-
Y_val: Log normalized and with column z-score dataframe (for more details about normalization, see paper Methods)
of validation metabolites fearures (datframe) - for early stopping. -
representation_size: Dimension of the intermediate representation (int).
-
weight_decay_rep: L2 regularization coefficient of the representation network (float).
-
weight_decay_dis: L2 regularization of the optional discriminator, is not used in the paper (float).
-
lr_rep: Leaning rate of the representation network (float).
-
lr_dis: Learning rate of the optional discriminator network, is not used in the paper (float).
-
rep_coef: Weight of the loss upgrades of the representation network, is set to 1, when no discriminator is used (float).
-
dis_coef: Weight of the loss upgrades of the discriminator network, is set to 0, when no discriminator is used (float).
-
activation_rep: Activation function of the representation network, one of: {relu,elu,tanh}.
-
activation_dis: Activation function of the discriminator network, one of: {relu,elu,tanh}.
-
neurons: Number of neurons in the first layer of the representation network (int).
-
neurons2: Number of neurons in the second layer of the representation network (int).
-
dropout: Dropout parameter (float).
Output
Returns a trained model.
- LOCATE_predict
Input
- model: Trained model (the output of LOCATE_training).
- X_val: Log normalized and with column z-score dataframe (for more details about normalization, see paper Methods) of validation microbiome features (dataframe).
- metab_names: List of metabolites names.
Output
Returns Z_val = intermediate representation, metabolites predictions dataframe.
- usage_example
Example of using the code on randomized data with its defaltive parameters:
model = LOCATE_training(X_train, Y_train, X_val, Y_val) Z_val, n_pred = LOCATE_predict(model, X_val, Y_val.columns)
-
LOCATE's pypi
This package contains 2 different elements:
-
LOCATE training
-
LOCATE predict
Installing LOCATE
pip install LOCATE-model
Using LOCATE
import LOCATE
model = LOCATE.LOCATE_training(X_train, Y_train, X_val, Y_val)
Z_val, n_pred = LOCATE.LOCATE_predict(model, X_val, Y_val.columns)
Contributors
Oshrit Shtossel
Contact
If you want to contact me you can reach me at oshritvig@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for LOCATE_model-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e10541a79beb3d7fa951fa6dbfd91fef27c5d147efb856f82c696cf68f41664d |
|
MD5 | c9e13e53b8bc35df249cf05d7d6c334a |
|
BLAKE2b-256 | 91932e5c8e382b1140ef42ad20141f108f4cd5cf2957c26f1e90af03db51c362 |