-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from mvapontes/samples
Add sort examples and logo
- Loading branch information
Showing
6 changed files
with
620 additions
and
2,912 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": null, | ||
"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": null, | ||
"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 | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.