{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# In-silico perturbation for customized drug(compound) databases\n", "As long as the target genes of drugs are known, UNAGI allows users to use their own drug (compound) databases or systematically perturb some drugs (compounds) of their interests. Here is the guidance to show the format of drug (compound) database that UNAGI can recognize." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Customize drug (compound) databases\n", "A dictionary or a json file that contains following information: drug/compound: target genes with the indication of perutrbation direciton\n", "\n", "e.g. Drug_C: ['COL1A1:-', 'ROBO2:+']: Drug C down-regulates COL1A1 and up-regulates ROBO2." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "customized_drug_database = {}\n", "customized_drug_database['Drug_A'] = ['TACR1:-', 'MAPK4:+', 'DUSP10:-', 'EGFR:+']\n", "customized_drug_database['Drug_B'] = ['C3:-', 'KDR:+', 'INSR:-','PLA2G2A:-']\n", "customized_drug_database['Drug_C'] = ['COL1A1:-', 'ROBO2:+']\n", "np.save('PATH_TO/customized_drug_database.npy',customized_drug_database)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Perform in-silico drug perturbation on the customized drug database\n", "Genes that are not overlapped with the input single data will be ignored." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/yumin/anaconda3/envs/test_unagi/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Start perturbation....\n", "10\n", "11\n", "0\n", "1\n", "4\n", "8\n", "9\n", "3\n", "5\n", "6\n", "2\n", "7\n", "drug perturabtion done\n", "random background done\n", "Finish results analysis\n" ] } ], "source": [ "from UNAGI import UNAGI\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "unagi = UNAGI()\n", "data_path = 'PATH_TO_TARGET/dataset.h5ad'\n", "iteration = 0 #which iteration of the model to use\n", "change_level = 0.5 #reduce the expression to 50% of the original value\n", "customized_drug = 'PATH_TO/customized_drug_database.npy'\n", "results = unagi.customize_drug_perturbation(data_path,iteration,customized_drug,change_level,target_dir='PATH_TO_TARGET',device='cuda:0')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | compound | \n", "perturbation score | \n", "pval_adjusted | \n", "drug_regulation | \n", "idrem_suggestion | \n", "
|---|---|---|---|---|---|
| 0 | \n", "Drug_C | \n", "0.383395 | \n", "0.011888 | \n", "[COL1A1:-, ROBO2:+] | \n", "[COL1A1:-, ROBO2:+] | \n", "