Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updata cases and logo #16

Closed
wants to merge 13 commits into from
1,022 changes: 43 additions & 979 deletions examples/Case1.ipynb

Large diffs are not rendered by default.

1,044 changes: 117 additions & 927 deletions examples/Case2.ipynb

Large diffs are not rendered by default.

1,121 changes: 115 additions & 1,006 deletions examples/Case3.ipynb

Large diffs are not rendered by default.

345 changes: 345 additions & 0 deletions examples/Case4.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,345 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "dn69glsQDgDA"
},
"source": [
"# <img src=\"https://github.com/JuliaLang/julia-logo-graphics/raw/master/images/julia-logo-color.png\" height=\"100\" /> _Colab Notebook Template_\n",
"\n",
"## Instructions\n",
"1. Work on a copy of this notebook: _File_ > _Save a copy in Drive_ (you will need a Google account). Alternatively, you can download the notebook using _File_ > _Download .ipynb_, then upload it to [Colab](https://colab.research.google.com/).\n",
"2. If you need a GPU: _Runtime_ > _Change runtime type_ > _Hardware accelerator_ = _GPU_.\n",
"3. Execute the following cell (click on it and press Ctrl+Enter) to install Julia, IJulia and other packages (if needed, update `JULIA_VERSION` and the other parameters). This takes a couple of minutes.\n",
"4. Reload this page (press Ctrl+R, or ⌘+R, or the F5 key) and continue to the next section.\n",
"\n",
"_Notes_:\n",
"* If your Colab Runtime gets reset (e.g., due to inactivity), repeat steps 2, 3 and 4.\n",
"* After installation, if you want to change the Julia version or activate/deactivate the GPU, you will need to reset the Runtime: _Runtime_ > _Factory reset runtime_ and repeat steps 3 and 4."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "k-JYaoEJDZqG"
},
"outputs": [],
"source": [
"%%shell\n",
"set -e\n",
"\n",
"#---------------------------------------------------#\n",
"JULIA_VERSION=\"1.8.2\" # any version ≥ 0.7.0\n",
"JULIA_PACKAGES=\"IJulia BenchmarkTools\"\n",
"JULIA_PACKAGES_IF_GPU=\"CUDA\" # or CuArrays for older Julia versions\n",
"JULIA_NUM_THREADS=2\n",
"#---------------------------------------------------#\n",
"\n",
"if [ -z `which julia` ]; then\n",
" # Install Julia\n",
" JULIA_VER=`cut -d '.' -f -2 <<< \"$JULIA_VERSION\"`\n",
" echo \"Installing Julia $JULIA_VERSION on the current Colab Runtime...\"\n",
" BASE_URL=\"https://julialang-s3.julialang.org/bin/linux/x64\"\n",
" URL=\"$BASE_URL/$JULIA_VER/julia-$JULIA_VERSION-linux-x86_64.tar.gz\"\n",
" wget -nv $URL -O /tmp/julia.tar.gz # -nv means \"not verbose\"\n",
" tar -x -f /tmp/julia.tar.gz -C /usr/local --strip-components 1\n",
" rm /tmp/julia.tar.gz\n",
"\n",
" # Install Packages\n",
" nvidia-smi -L &> /dev/null && export GPU=1 || export GPU=0\n",
" if [ $GPU -eq 1 ]; then\n",
" JULIA_PACKAGES=\"$JULIA_PACKAGES $JULIA_PACKAGES_IF_GPU\"\n",
" fi\n",
" for PKG in `echo $JULIA_PACKAGES`; do\n",
" echo \"Installing Julia package $PKG...\"\n",
" julia -e 'using Pkg; pkg\"add '$PKG'; precompile;\"' &> /dev/null\n",
" done\n",
"\n",
" # Install kernel and rename it to \"julia\"\n",
" echo \"Installing IJulia kernel...\"\n",
" julia -e 'using IJulia; IJulia.installkernel(\"julia\", env=Dict(\n",
" \"JULIA_NUM_THREADS\"=>\"'\"$JULIA_NUM_THREADS\"'\"))'\n",
" KERNEL_DIR=`julia -e \"using IJulia; print(IJulia.kerneldir())\"`\n",
" KERNEL_NAME=`ls -d \"$KERNEL_DIR\"/julia*`\n",
" mv -f $KERNEL_NAME \"$KERNEL_DIR\"/julia\n",
"\n",
" echo ''\n",
" echo \"Successfully installed `julia -v`!\"\n",
" echo \"Please reload this page (press Ctrl+R, ⌘+R, or the F5 key) then\"\n",
" echo \"jump to the 'Checking the Installation' section.\"\n",
"fi"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "J5ER7bHPELHf"
},
"outputs": [],
"source": [
"versioninfo()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"id": "_hJw2NRSDtZ3"
},
"outputs": [],
"source": [
"using Pkg"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0Btoe8xRDuHr"
},
"outputs": [],
"source": [
"Pkg.add(\"Revise\")\n",
"Pkg.add(\"DataFrames\")\n",
"Pkg.add(\"BenchmarkTools\")\n",
"Pkg.add(url=\"https://github.com/bwbioinfo/KEGGAPI.jl\")\n",
"Pkg.add(\"TestImages\")\n",
"Pkg.add(\"Images\")\n",
"Pkg.add(\"FileIO\")\n",
"Pkg.add(\"Colors\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"id": "bYixR5WhD0cw"
},
"outputs": [],
"source": [
"using Revise\n",
"using DataFrames\n",
"using BenchmarkTools\n",
"using KEGGAPI\n",
"using Images\n",
"using TestImages\n",
"using Colors"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "6NJZS9B7D9H9"
},
"source": [
"# Case 4: Target molecules information at KEGG\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "hsBidRhEGBua"
},
"source": [
"### 1. Get gene id from KEGG Database\n",
"\n",
"To determine if a molecule is included in KEGG database and identify the encoding gene in the species of interest, the function find takes as input the string \"genes\" and the name of the target molecule"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "uqpyI-hmGLYX"
},
"outputs": [],
"source": [
"@time kegg_genes = KEGGAPI.find(\"genes\", \"CD19\")\n",
"DataFrame(\n",
" kegg_genes.data,\n",
" kegg_genes.colnames\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "p8eMlfOKJXfU"
},
"source": [
"#### 1.1 Get gene information"
]
},
{
"cell_type": "code",
"source": [
"@time kegg_genes_info = KEGGAPI.kegg_get([\"hsa:930\"])\n",
"split(kegg_genes_info[2][1], \"\\n\")"
],
"metadata": {
"id": "-TtFhLKJHNh_"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"#### 1.2 Get KEGG ortholog group"
],
"metadata": {
"id": "KVd3ZileJzJw"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "hwuH4jWiI59z"
},
"outputs": [],
"source": [
"@time kegg_ko = KEGGAPI.link(\"ko\", \"hsa:930\")\n",
"DataFrame(\n",
" kegg_ko.data,\n",
" kegg_ko.colnames\n",
")"
]
},
{
"cell_type": "markdown",
"source": [
"### 2. Pathway(s) including the molecule of interest\n",
"\n",
"To obtain pathways associated to a gene the input of the \"link\" function are the string \"pathway\", and KEGG gene identifier."
],
"metadata": {
"id": "yJ8zErF-KG7I"
}
},
{
"cell_type": "code",
"source": [
"@time kegg_pathway = KEGGAPI.link(\"pathway\", \"hsa:930\")\n",
"DataFrame(\n",
" kegg_pathway.data,\n",
" kegg_pathway.colnames\n",
")"
],
"metadata": {
"id": "RddXLaO2Pjcz"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"### 3. Drug(s) associated with molecule of interest\n",
"\n",
"To obtain the drugs associated to a molecule the input of the \"link\" function is the string \"drug\", and KEGG gene identifier."
],
"metadata": {
"id": "XxRLMWXsK1G1"
}
},
{
"cell_type": "code",
"source": [
"@time kegg_drug= KEGGAPI.link(\"drug\", \"hsa:930\")\n",
"DataFrame(\n",
" kegg_drug.data,\n",
" kegg_drug.colnames\n",
")"
],
"metadata": {
"id": "BE9akXjoSm87"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"### 4. Get drug(s) information from Kegg Database\n",
"\n",
"To get information on the identified drugs included in KEGG database, the function kegg_get takes as input an array of drug KEGG identifier as \"dr:DXXXXX"
],
"metadata": {
"id": "MqEPiv8FMucl"
}
},
{
"cell_type": "code",
"source": [
"@time kegg_drug_info = KEGGAPI.kegg_get(kegg_drug.data[2]);\n",
"split(kegg_drug_info[2][1], \"\\n\")"
],
"metadata": {
"id": "Pdd9ndB7S0AB"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "8EhaCFJzojif"
},
"source": [
"### 5. Get image of the pathway of interest\n",
"\n",
"The get_image function is to download a any image, the imput is the compound number as \"path:XXXXXXXX\"\n",
"\n",
"The save_image function is to save the figure in a png file. The input is a string with the name of the file and the extension \".png\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "eg44UlyITj4O"
},
"outputs": [],
"source": [
"@time kegg_pathway_image = KEGGAPI.get_image(\"path:hsa04151\")\n",
"@time KEGGAPI.save_image(kegg_pathway_image, \"pathway.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "o2u0wbKYp__O"
},
"source": [
"### 6. Visualize download compound"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ol4vHRnnUEhd"
},
"outputs": [],
"source": [
"img = load(\"pathway.png\")"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "julia 1.8.2",
"name": "julia"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Binary file added logo/keggapi-dots.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo/keggapi-logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading