Precily

Precily Model

Precily model for drug response prediction.

Contains Precily, a pathway-based deep learning model for drug response prediction. A deep neural network that predicts LN(IC50) by combining GSVA pathway-activity scores with SMILESVec drug embeddings.

Original authors: Chawla et al. (2022, 10.1038/s41467-022-33291-z) Reference code: https://github.com/SmritiChawla/Precily

class drevalpy.models.Precily.precily.PrecilyModel

Bases: DRPModel

Precily model for drug response prediction.

build_model(hyperparameters)

Store hyperparameters.

The network is built in train() once the input dimension (n_pathways + n_drug_features) is known.

Parameters:

hyperparameters (dict[str, Any]) – dropout, learning_rate, epochs, batch_size, seed

Return type:

None

cell_line_views = ['pathways']
drug_views = ['smilesvec']
early_stopping = False
classmethod get_model_name()

Get the model name.

Return type:

str

Returns:

Precily

classmethod load(directory)

Load a Precily model saved with save method.

Expects in directory:

  • “precily_model.pt”: network state_dict

  • “hyperparameters.json”: hyperparameters incl. “input_dim”

Parameters:

directory (str) – directory containing the saved files

Return type:

PrecilyModel

Returns:

a restored PrecilyModel

load_cell_line_features(data_path, dataset_name)

Load precomputed GSVA pathway scores.

Generate it with the Precily pathway featurizer:
python -m drevalpy.datasets.featurizer.create_precily_pathway_features <dataset_name> \

–gene_sets <path_to/c2.cp.v6.1.symbols.gmt>

Parameters:
  • data_path (str) – path to the data

  • dataset_name (str) – dataset name

Return type:

FeatureDataset

Returns:

cell line FeatureDataset with the “pathways” view

Raises:

FileNotFoundError – if the pathway feature CSV is missing

load_drug_features(data_path, dataset_name)

Load precomputed SMILESVec drug embeddings.

Generate it with the Precily drug featurizer:
python -m drevalpy.datasets.featurizer.create_precily_drug_embeddings <dataset_name> \

–smilesvec_model <path_to/drug.l8.pubchem.canon.ws20.txt>

Parameters:
  • data_path (str) – path to the data

  • dataset_name (str) – dataset name

Return type:

FeatureDataset

Returns:

drug FeatureDataset with the “smilesvec” view

Raises:

FileNotFoundError – if the drug feature CSV is missing

predict(cell_line_ids, drug_ids, cell_line_input, drug_input=None)

Predict LN(IC50) for the given cell line / drug pairs.

Parameters:
Return type:

ndarray

Returns:

predicted response values

Raises:

ValueError – if drug_input is None or the model is not built

save(directory)

Save the Precily model using PyTorch conventions.

Stores:

  • “precily_model.pt”: PyTorch state_dict of the network

  • “hyperparameters.json”: all hyperparameters plus the resolved input_dim (so the network can be rebuilt with the right shape)

Parameters:

directory (str) – target directory

Raises:

ValueError – if the model is not built

Return type:

None

train(output, cell_line_input, drug_input=None, output_earlystopping=None, model_checkpoint_dir='checkpoints')

Train the Precily model.

Parameters:
Raises:

ValueError – if drug_input is None

Return type:

None

Model utils

Neural network components for the Precily model.

Exact port of the Keras architecture from Chawla et al. (Nat Commun 2022),

Input(input_dim)

-> Dense(1429) -> ReLU -> Dense(512) -> ReLU -> Dropout(p) -> Dense(140) -> ReLU -> Dropout(p) -> Dense(200) -> ReLU -> Dropout(p) -> Dense(1)

input_dim = n_pathways (GSVA) + n_drug_features (Morgan/SMILESVec). With Morgan fingerprints the drug dimension differs and input_dim is set accordingly at build time.

class drevalpy.models.Precily.model_utils.PrecilyNetwork(input_dim, dropout=0.1)

Bases: Module

Feed-forward regressor predicting LN(IC50) from pathway + drug features.

Parameters:
forward(x)

Perform forward pass.

Parameters:

x (Tensor) – [batch, input_dim] feature tensor

Return type:

Tensor

Returns:

[batch] predicted LN(IC50)