{"id":20307874,"url":"https://github.com/benedekrozemberczki/tigerlily","last_synced_at":"2025-04-11T15:12:52.528Z","repository":{"id":62559736,"uuid":"464654950","full_name":"benedekrozemberczki/tigerlily","owner":"benedekrozemberczki","description":"TigerLily: Finding drug interactions in silico with the Graph.","archived":false,"fork":false,"pushed_at":"2022-12-17T16:11:50.000Z","size":14993,"stargazers_count":99,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T11:21:35.020Z","etag":null,"topics":["biology","ddi","deep-learning","drug-drug-interaction","embedding","gradient-boosting","graph","graph-database","graph-embedding","graph-machine-learning","heterogeneous-graph","knowledge-graph","machine-learning","network-science","node","node-embedding","pharmaceuticals","tigergraph","unsupervised-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benedekrozemberczki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-28T21:48:19.000Z","updated_at":"2025-01-05T20:35:14.000Z","dependencies_parsed_at":"2023-01-29T17:31:10.356Z","dependency_job_id":null,"html_url":"https://github.com/benedekrozemberczki/tigerlily","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Ftigerlily","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Ftigerlily/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Ftigerlily/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2Ftigerlily/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benedekrozemberczki","download_url":"https://codeload.github.com/benedekrozemberczki/tigerlily/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248429119,"owners_count":21101785,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["biology","ddi","deep-learning","drug-drug-interaction","embedding","gradient-boosting","graph","graph-database","graph-embedding","graph-machine-learning","heterogeneous-graph","knowledge-graph","machine-learning","network-science","node","node-embedding","pharmaceuticals","tigergraph","unsupervised-learning"],"created_at":"2024-11-14T17:19:26.157Z","updated_at":"2025-04-11T15:12:52.507Z","avatar_url":"https://github.com/benedekrozemberczki.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[pypi-image]: https://badge.fury.io/py/tigerlily.svg\n[pypi-url]: https://pypi.python.org/pypi/tigerlily\n[size-image]: https://img.shields.io/github/repo-size/benedekrozemberczki/tigerlily.svg\n[size-url]: https://github.com/benedekrozemberczki/tigerlily/archive/main.zip\n[build-image]: https://github.com/benedekrozemberczki/tigerlily/workflows/CI/badge.svg\n[build-url]: https://github.com/benedekrozemberczki/tigerlily/actions?query=workflow%3ACI\n[docs-image]: https://readthedocs.org/projects/tigerlily/badge/?version=latest\n[docs-url]: https://tigerlily.readthedocs.io/en/latest/?badge=latest\n[coverage-image]: https://codecov.io/gh/benedekrozemberczki/tigerlily/branch/main/graph/badge.svg?token=30XLVBUIEH\n[coverage-url]: https://codecov.io/github/benedekrozemberczki/tigerlily?branch=main\n\n\n[![PyPI Version][pypi-image]][pypi-url]\n[![Docs Status][docs-image]][docs-url]\n[![Code Coverage][coverage-image]][coverage-url]\n[![Build Status][build-image]][build-url]\n[![Arxiv](https://img.shields.io/badge/ArXiv-2204.08206-orange.svg)](https://arxiv.org/abs/2204.08206)\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"100%\" src=\"https://github.com/benedekrozemberczki/tigerlily/blob/main/images/tigerlily_logo.jpg?sanitize=true\" /\u003e\n\u003c/p\u003e\n\n\n\n\n\n----------------------------------------------------------------------\n\n### **Drug Interaction Prediction with Tigerlily**\n\n**[Documentation](https://tigerlily.readthedocs.io)** | **[Example Notebook](https://github.com/benedekrozemberczki/tigerlily/blob/main/example_notebook.ipynb)** |  **[Youtube Video](https://www.youtube.com/watch?v=fEWcor96tt8)** |  **[Project Report](http://arxiv.org/abs/2204.08206)** \n\n\n\n**Tigerlily** is a [TigerGraph](https://www.tigergraph.com/) based system designed to solve the [drug interaction prediction task](https://arxiv.org/abs/2111.02916). In this machine learning task, we want to predict whether two drugs have an adverse interaction. Our framework allows us to solve this **[highly relevant real-world problem](https://www.newscientist.com/article/2143486-side-effects-kill-thousands-but-our-data-on-them-is-flawed/)** using graph mining techniques in these steps: \n\n- **(a)** Using [PyTigergraph](https://github.com/pyTigerGraph/pyTigerGraph) we create a heterogeneous biological graph of drugs and proteins.\n- **(b)** We calculate the [personalized PageRank](https://github.com/tigergraph/gsql-graph-algorithms/blob/master/algorithms/Centrality/pagerank/personalized/multi_source/tg_pagerank_pers.gsql) scores of drug nodes in the [TigerGraph Cloud](https://tgcloud.io/).\n- **(c)** We embed the nodes using [sparse non-negative matrix factorization](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.NMF.html) of the personalized PageRank matrix.\n- **(d)** Using the node embeddings we train a [gradient boosting](https://lightgbm.readthedocs.io/en/latest/) based drug interaction predictor.\n\n--------------------------------------------------------------------------------\n\n\n### (A) **Creating and populating a Graph**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"90%\" src=\"https://github.com/benedekrozemberczki/tigerlily/blob/main/images/pair_scoring_A.jpg?sanitize=true\" /\u003e\n\u003c/p\u003e\n\n\nAs a first step, the basic **TigerLily** tools are imported, and we load the example dataset that integrated DrugBankDDI and the BioSNAP datasets. We create a ``PersonalizedPageRankMachine`` and connect to the host with the ``Graph``. The settings of this machine should be the appropriate user credentials and details; a secret is obtained in the **TigerGraph Graph Studio**. We install the default Personalized PageRank query and upload the edges of the example dataset used in our demonstrations. This graph has **drug** and **protein** nodes, **drug-protein** and **protein-protein** interactions. Our goal is to predict the **drug-drug** interactions.\n\n```python\nfrom tigerlily.dataset import ExampleDataset\nfrom tigerlily.embedding import EmbeddingMachine\nfrom tigerlily.operator import hadamard_operator\nfrom tigerlily.pagerank import PersonalizedPageRankMachine\n\ndataset = ExampleDataset()\n\nedges = dataset.read_edges()\ntarget = dataset.read_target()\n\nmachine = PersonalizedPageRankMachine(host=\"host_name\",\n                                      graphname=\"graph_name\",\n                                      username=\"username_value\",\n                                      secret=\"secret_value\",\n                                      password=\"password_value\")\n                           \nmachine.connect()\nmachine.install_query()\n\nmachine.upload_graph(new_graph=True, edges=edges)\n```\n\n\n### (B) **Computing the Approximate Personalized PageRank vectors**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"90%\" src=\"https://github.com/benedekrozemberczki/tigerlily/blob/main/images/pair_scoring_B.jpg?sanitize=true\" /\u003e\n\u003c/p\u003e\n\n\nWe are only interested in describing the neighbourhood of drug nodes in the biological graph. Because of this, we only retrieve the neighbourhood of the drugs - for each drug we retrieve those nodes (top-k closest neighbors) which are the closest based on the Personalized PageRank scores. We are going to learn the drug embeddings based on these scores.  \n\n```python\ndrug_node_ids = machine.connection.getVertices(\"drug\")\n\npagerank_scores = machine.get_personalized_pagerank(drug_node_ids)\n```\n### (C) Learning the Drug Embeddings and Drug Pair Feature Generation\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"90%\" src=\"https://github.com/benedekrozemberczki/tigerlily/blob/main/images/pair_scoring_C.jpg?sanitize=true\" /\u003e\n\u003c/p\u003e\n\n\nWe create an embedding machine that creates drug node representations. The embedding machine instance has a random seed, a dimensions hyperparameter (this sets the number of factors), and a maximal iteration count for the factorization. An embedding is learned from the Personalized PageRank scores and using the drug features we create drug pair features with the operator function.\n\n```python\nembedding_machine = EmbeddingMachine(seed=42,\n                                     dimensions=32,\n                                     max_iter=100)\n\nembedding = embedding_machine.fit(pagerank_scores)\n\ndrug_pair_features = embedding_machine.create_features(target, hadamard_operator)\n```\n### (D) Predicting Drug Interactions and Inference\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"90%\" src=\"https://github.com/benedekrozemberczki/tigerlily/blob/main/images/pair_scoring_D.jpg?sanitize=true\" /\u003e\n\u003c/p\u003e\n\n\nWe load a gradient boosting-based classifier, an evaluation metric for binary classification, and a function to create train-test splits. We create a train and test portion of the drug pairs using 80% of the pairs for training. A gradient boosted tree model is trained, score the model on the test set. We compute an AUROC score on the test portion of the dataset and print it out.\n\n```python\nfrom lightgbm import LGBMClassifier\nfrom sklearn.metrics import roc_auc_score\nfrom sklearn.model_selection import train_test_split\n\nX_train, X_test, y_train, y_test = train_test_split(drug_pair_features,\n                                                    target,\n                                                    train_size=0.8,\n                                                    random_state=42)\n\nmodel = LGBMClassifier(learning_rate=0.01,\n                       n_estimators=100)\n\nmodel.fit(X_train,y_train[\"label\"])\n\npredicted_label = model.predict_proba(X_test)\n\nauroc_score_value = roc_auc_score(y_test[\"label\"], predicted_label[:,1])\n\nprint(f'AUROC score: {auroc_score_value :.4f}')\n```\n\nHead over to the [documentation](https://tigerlily.readthedocs.io) to find out more about installation and a full API reference.\nFor a quick start, check out the [example notebook](https://github.com/benedekrozemberczki/tigerlily/blob/main/example_notebook.ipynb). If you notice anything unexpected, please open an [issue](github.com/benedekrozemberczki/tigerlily/issues).\n\n\n--------------------------------------------------------------------------------\n\n**Citing**\n\n\nIf you find *Tigerlily* useful in your research, please consider adding the following citation:\n\n```bibtex\n@misc{tigerlily2022,\n  author = {Benedek Rozemberczki},\n  title = {TigerLily: Finding drug interactions in silico with the Graph},\n  year = {2022},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/benedekrozemberczki/tigerlily}},\n}\n```\n\n--------------------------------------------------------------------------------\n\n**Installation**\n\nTo install tigerlily, simply run:\n\n```sh\npip install tigerlily\n```\n\n**Running tests**\n\nRunning tests requires that you run:\n\n```\n$ tox -e py\n```\n--------------------------------------------------------------------------------\n\n**License**\n\n- [Apache 2.0 License](https://github.com/benedekrozemberczki/tigerlily/blob/main/LICENSE)\n\n--------------------------------------------------------------------------------\n\n**Credit**\n\nThe **TigerLily** logo and the high level machine learning workflow image are based on:\n\n- [Kubos Origami Font](https://www.fontspace.com/kubos-origami-font-f29538)\n- [Noun Project Icons](https://thenounproject.com/)\n\nBenedek Rozemberczki has a yearly subscription to the Noun Project that allows the customization and commercial use of the icons.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedekrozemberczki%2Ftigerlily","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenedekrozemberczki%2Ftigerlily","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedekrozemberczki%2Ftigerlily/lists"}