Skip to content

Commit

Permalink
Merge pull request #40 from TheJacksonLaboratory/G3-235-create-docume…
Browse files Browse the repository at this point in the history
…ntation-on-how-to-search-for-genesets-with-a-disease-name-via-the-g-3-api

Adding first pass at finding genesets document
  • Loading branch information
bergsalex authored May 29, 2024
2 parents 38d5fa2 + 94c821d commit e7caf4f
Show file tree
Hide file tree
Showing 3 changed files with 320 additions and 1 deletion.
318 changes: 318 additions & 0 deletions docs/tutorial/finding-genesets.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
{
"cells": [
{
"metadata": {},
"cell_type": "markdown",
"source": "## Dependencies and Set Up",
"id": "d6d91fc15ac330d8"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "!pip install geneweaver-client",
"id": "d932df03b02fc0e8"
},
{
"cell_type": "code",
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-05-28T13:24:21.132102Z",
"start_time": "2024-05-28T13:24:20.315733Z"
}
},
"source": "from geneweaver.client.auth import login",
"outputs": [],
"execution_count": 1
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:15:34.037708Z",
"start_time": "2024-05-28T14:15:14.743965Z"
}
},
"cell_type": "code",
"source": "login()",
"id": "6a4553c34d73a6c7",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1. On your computer or mobile device navigate to: https://geneweaver.auth0.com/activate?user_code=VPPC-FWSQ\n",
"2. Enter the following code: VPPC-FWSQ\n",
"Authenticated!\n",
"- Id Token: eyJhbGciOi...\n"
]
}
],
"execution_count": 2
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:18:35.250326Z",
"start_time": "2024-05-28T14:18:35.224788Z"
}
},
"cell_type": "code",
"source": "from geneweaver.client.auth import get_access_token",
"id": "9a222f2e97f34647",
"outputs": [],
"execution_count": 4
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## Finding Cancer Related Genesets",
"id": "15f75595e4344685"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:19:16.611744Z",
"start_time": "2024-05-28T14:19:16.598106Z"
}
},
"cell_type": "code",
"source": "import requests",
"id": "5fed1b8b6ec94259",
"outputs": [],
"execution_count": 6
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:27:23.944721Z",
"start_time": "2024-05-28T14:27:22.740834Z"
}
},
"cell_type": "code",
"source": [
"result = requests.get(\n",
" \"https://geneweaver.jax.org/api/genesets\",\n",
" params={\n",
" \"search_text\": \"cancer\",\n",
" \"curation_tier\": \"Tier I\",\n",
" \"limit\": 10\n",
" },\n",
" headers={\"Authorization\": f\"Bearer {get_access_token()}\"}\n",
")\n",
"result.ok"
],
"id": "868214fa2ab3f9cd",
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 56
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:27:24.698625Z",
"start_time": "2024-05-28T14:27:24.696627Z"
}
},
"cell_type": "code",
"source": "cancer_genesets = result.json()[\"data\"]",
"id": "8a0a7ef040973dfe",
"outputs": [],
"execution_count": 57
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:27:25.889802Z",
"start_time": "2024-05-28T14:27:25.887410Z"
}
},
"cell_type": "code",
"source": [
"for i in cancer_genesets:\n",
" print(i[\"name\"])"
],
"id": "b40c7fce9c826e32",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"MP:0010337 increased chronic lymphocytic leukemia incidence\n",
"MSigDB Geneset - MORF_ZNF10\n",
"MSigDB Geneset - KRAS.LUNG.BREAST_UP.V1_UP\n",
"MSigDB Geneset - MORF_HDAC2\n",
"MSigDB Geneset - GCM_PTPRD\n",
"GWAS Catalog Data for breast carcinoma in 10,052 European ancestry cases, 12,575 European ancestry controls\n",
"MSigDB Geneset - MORF_TFDP2\n",
"GWAS Catalog Data for response to platinum based chemotherapy, non-small cell lung carcinoma in 327 European ancestry individuals\n",
"MSigDB Geneset - MORF_PML\n",
"MSigDB Geneset - GCM_ERCC4\n"
]
}
],
"execution_count": 58
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## Finding GWAS Cancer Related Genesets",
"id": "1c8f32c85d7e2e24"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:28:38.858820Z",
"start_time": "2024-05-28T14:28:37.607796Z"
}
},
"cell_type": "code",
"source": [
"result = requests.get(\n",
" \"https://geneweaver.jax.org/api/genesets\",\n",
" params={\n",
" \"search_text\": \"gwas & cancer\",\n",
" \"curation_tier\": \"Tier I\",\n",
" \"limit\": 10\n",
" },\n",
" headers={\"Authorization\": f\"Bearer {get_access_token()}\"}\n",
")\n",
"result.ok"
],
"id": "e9ba2ac7c4b68831",
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 60
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:28:38.861832Z",
"start_time": "2024-05-28T14:28:38.859816Z"
}
},
"cell_type": "code",
"source": "gwas_cancer_genesets = result.json()[\"data\"]",
"id": "b173bc8938da9893",
"outputs": [],
"execution_count": 61
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:28:38.864681Z",
"start_time": "2024-05-28T14:28:38.862696Z"
}
},
"cell_type": "code",
"source": [
"for i in gwas_cancer_genesets:\n",
" print(i[\"name\"])"
],
"id": "f4396390d053338b",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"GWAS Catalog Data for breast carcinoma in 10,052 European ancestry cases, 12,575 European ancestry controls\n",
"GWAS Catalog Data for response to platinum based chemotherapy, non-small cell lung carcinoma in 327 European ancestry individuals\n",
"GWAS Catalog Data for lung carcinoma in 2,331 Han Chinese ancestry lung cancer cases, 1,006 Han Chinese ancestry non-cardia gastric cancer cases, 2,031 Han Chinese ancestry esophageal squamous-cell carcinoma cases, 4,006 Han Chinese ancestry controls\n",
"GWAS Catalog Data for lung carcinoma, squamous cell carcinoma, gastric carcinoma in 2,331 Han Chinese ancestry lung cancer cases, 1,006 Han Chinese ancestry non-cardia gastric cancer cases, 2,031 Han Chinese ancestry esophageal squamous-cell carcinoma cases, 4,006 Han Chinese ancestry controls\n",
"GWAS Catalog Data for estrogen-receptor negative breast cancer in 4,939 European ancestry cases, 14,352 European ancestry controls\n",
"GWAS Catalog Data for breast carcinoma in 899 European ancestry cases, 804 European ancestry controls\n",
"GWAS Catalog Data for breast carcinoma in 1,426 European ancestry cases, 1,301 European ancestry controls\n",
"GWAS Catalog Data for ovarian carcinoma in 1,817 European ancestry cases, 2,353 European ancestry controls\n",
"GWAS Catalog Data for breast carcinoma in 1,367 Sardinian cases, 1,658 Sardinian controls\n",
"GWAS Catalog Data for endometrial carcinoma in 4,907 European ancestry cases, 11,945 European ancestry controls\n"
]
}
],
"execution_count": 62
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-05-28T14:29:22.658230Z",
"start_time": "2024-05-28T14:29:22.655886Z"
}
},
"cell_type": "code",
"source": [
"for i in gwas_cancer_genesets:\n",
" print(f\"GS{i['id']} has {i['count']} genes\")"
],
"id": "30e29e4ca07bfa24",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"GS267835 has 98 genes\n",
"GS270261 has 1 genes\n",
"GS268187 has 3 genes\n",
"GS268186 has 3 genes\n",
"GS271027 has 30 genes\n",
"GS269914 has 1 genes\n",
"GS270401 has 7 genes\n",
"GS270122 has 2 genes\n",
"GS267760 has 2 genes\n",
"GS268492 has 8 genes\n"
]
}
],
"execution_count": 66
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "",
"id": "eeb496d3d034ca3a"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ nav:
- tutorial/index.md
- Client Login: tutorial/geneweaver_client_login.ipynb
- Map Gene IDs: tutorial/map-gene-ids.ipynb
- Finding Genesets: tutorial/finding-genesets.ipynb
- NCI-60 Example Workflow: tutorial/nci_60_example_01.ipynb
# - Geneweaver Command Line Interface:
# - tutorial/geneweaver_command_line.md
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "geneweaver-docs"
version = "0.0.1a0"
version = "0.0.2a0"
description = ""
authors = ["Alexander Berger <alexander.berger@jax.org>"]
readme = "README.md"
Expand Down

0 comments on commit e7caf4f

Please sign in to comment.