{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Life Science ontologies and Knowledge Graphs, HANDS-ON\n", "*HANDS-ON session given as part of ETBII 2024*\n", "\n", "At the end of this hands-on session, you will be able to\n", " - explore and search publicly available biomedical ontologies, combine knowledge provided by multiple ontologies,\n", " - computationally exploit these ontologies: explore node neighborhood, navigate class hierarchies, retrieve synonyms,\n", " - understand how biochemical regulations are modeled in BioPAX,\n", " - assemble/summarize new graphs based on graph patterns." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 1. Querying gene regulation resources \n", "\n", "\n", "We are interesed in regulators for SCN5A, a gene involved in cardiac arrhythmias. We would like build a diagram like : \n", "\n", "![:scale 50%](fig/viz.png)\n", "\n", "We will now use PathwayCommons (http://www.pathwaycommons.org), an RDF dataset used to integrated biological signaling pathways (5,772 pathways, 2,424,055 interactions) from 22 regulation data sources. We will use this SPARQL endpoint: https://abromics.gcp.glicid.fr/sparql \n", "\n", "PathwayCommons uses the BioPAX ontology to represent regulation and signaling knowledge. Have a look on Figure 3 and Figure 4 of the BioPAX paper (https://www.researchgate.net/publication/46191859_BioPAX_-_A_community_standard_for_pathway_data_sharing) to have a quick overview of BioPAX. \n", "\n", "We are interested in **activation** or **inhibition** gene regulations. The following *turtle* syntax shows how they can be represented in BioPAX. \n", "\n", "```\n", "@prefix rdf:\t .\n", "@prefix pc:\t .\n", "@prefix bp:\t .\n", "@prefix xsd:\t .\n", "\n", "pc:TemplateReactionRegulation_3906f4646d89f7cf2b1316601aa946d4\n", "\trdf:type\tbp:TemplateReactionRegulation ;\n", "\tbp:comment\t\"REPLACED http://pathwaycommons.org/pc12/TemplateReactionRegulation_3906f4646d89f7cf2b1316601aa946d4\"^^xsd:string ;\n", "\tbp:controlType\t\"ACTIVATION\"^^xsd:string ;\n", "\tbp:controlled\tpc:TemplateReaction_8baa2a60259c4221da8a2304b1d9f1fd ;\n", "\tbp:controller\tpc:SmallMolecule_59bf598d207e0612414e22fd11aa3ccb ;\n", "\tbp:dataSource\tpc:Provenance_b3c525b2c0027b58914b1a79ecc37320 ;\n", "\tbp:displayName\t\"Phenobarbital results in increased expression of CYP2B6 protein\"^^xsd:string ;\n", "\tbp:xref\t ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " .\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 1\n", "On a piece of paper, draw the corresponding directed labelled graph. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 2\n", "1. Test the `DESCRIBE pc:TemplateReactionRegulation_3906f4646d89f7cf2b1316601aa946d4` query directly at \n", "2. Test the same query directly in this notebook: \n", "```python\n", "query = \"YOUR QUERY\"\n", "sparql = SPARQLWrapper(\"https://abromics.gcp.glicid.fr/sparql\")\n", "sparql.setQuery(query)\n", "results = sparql.queryAndConvert()\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from SPARQLWrapper import SPARQLWrapper\n", "\n", "query = \"\"\"\n", "...\n", "\"\"\"\n", "#sparql = SPARQLWrapper(\"https://abromics.gcp.glicid.fr/sparql\")\n", "#sparql.setQuery(query)\n", "#results = sparql.queryAndConvert()\n", "#print(results.serialize(format=\"turtle\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**In the remainder of the question we will use the SPARQL endpoint web interface ().**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 3\n", "Based on this description, write a query to show the names of all genes that regulate (activation or inhibition) SCN5A. We will proceed in multiple progressive steps. \n", "\n", "1. identify regulation reactions with resources of type `bp:TemplateReactionRegulation` (don’t forget to use a LIMIT 10 to get fast results)\n", "2. show their control type (`bp:controlType` property) and filter only “activation” or “inhibition”.\n", "3. show the associated scientific publication with the `bp:xref` property. Make sure that “pubmed” is contained in its URI (you can use a FILTER fonction: `FILTER (regex(?publi, \"pubmed\"))`).\n", "4. identify the source of the regulation (`bp:controller`) and its display name (`bp:displayName`).\n", "5. identify the target of the regulation (`bp:controlled`) and its display name (`bp:displayName`). Make sure (FILTER) that the display name is our target gene: SCN5A." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Question 3.1\n", "Identify regulation reactions with resources of type `bp:TemplateReactionRegulation` (don’t forget to use a LIMIT 10 to get fast results)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "query = \"\"\"\n", "PREFIX bp: \n", "\n", "SELECT * WHERE {\n", " ...\n", "} \n", "LIMIT 10\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# SOLUTION:\n", "!echo \"ClBSRUZJWCBicDogPGh0dHA6Ly93d3cuYmlvcGF4Lm9yZy9yZWxlYXNlL2Jpb3BheC1sZXZlbDMub3dsIz4KClNFTEVDVCAqIFdIRVJFIHsKICAgID9yZWd1bCByZGY6dHlwZSBicDpUZW1wbGF0ZVJlYWN0aW9uUmVndWxhdGlvbiAuIAp9IApMSU1JVCAxMAo=\" | base64 --decode" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Question 9.2\n", "Show their control type (`bp:controlType` property). You can filter only “ACTIVATION” or “INHIBITION”. \n", "Use a FILTER clause, the or `||` operator and `regex(variable,\"pattern\")` function. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "query = \"\"\"\n", "...\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# SOLUTION:\n", "!echo \"UFJFRklYIGJwOiA8aHR0cDovL3d3dy5iaW9wYXgub3JnL3JlbGVhc2UvYmlvcGF4LWxldmVsMy5vd2wjPgoKU0VMRUNUICogV0hFUkUgewogICAgP3JlZ3VsIHJkZjp0eXBlIGJwOlRlbXBsYXRlUmVhY3Rpb25SZWd1bGF0aW9uIDsgCiAgICAgICAgICAgICAgICBicDpjb250cm9sVHlwZSA/dCAuCiAgICBGSUxURVIgKHJlZ2V4KD90LCBBQ1RJVikpCn0gCkxJTUlUIDEw\" | base64 --decode" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Question 3.3\n", "Show the associated scientific publication with the `bp:xref` property. Make sure that “pubmed” is contained in its URI. Use a FILTER clause, and a `regex(variable,\"pattern\")` function. We want to get reaction, even if no publication isassociated, for that we will enclose the triple pattern within an `OPTIONAL {}` clause." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "query = \"\"\"\n", "...\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# SOLUTION:\n", "!echo \"ClBSRUZJWCBicDogPGh0dHA6Ly93d3cuYmlvcGF4Lm9yZy9yZWxlYXNlL2Jpb3BheC1sZXZlbDMub3dsIz4KClNFTEVDVCAqIFdIRVJFIHsKICAgID9yZWd1bCByZGY6dHlwZSBicDpUZW1wbGF0ZVJlYWN0aW9uUmVndWxhdGlvbiA7IAogICAgICAgICAgICAgICAgYnA6Y29udHJvbFR5cGUgP3QgLgogICAgRklMVEVSIChyZWdleCg/dCwgQUNUSVYpKQoKICAgID9yZWd1bCBicDp4cmVmID9wdWJsaSAuIAogICAgRklMVEVSIChyZWdleCg/cHVibGksIHB1Ym1lZCkpCn0gCg==\" | base64 --decode" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### Question 3.4\n", "Identify the source of the regulation (`bp:controller`) and its display name (`bp:displayName`)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "query = \"\"\"\n", "...\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# SOLUTION:\n", "!echo \"UFJFRklYIGJwOiA8aHR0cDovL3d3dy5iaW9wYXgub3JnL3JlbGVhc2UvYmlvcGF4LWxldmVsMy5vd2wjPgoKU0VMRUNUICogV0hFUkUgewogICAgP3JlZ3VsIHJkZjp0eXBlIGJwOlRlbXBsYXRlUmVhY3Rpb25SZWd1bGF0aW9uIDsgCiAgICAgICAgICAgICAgICBicDpjb250cm9sVHlwZSA/dCAuCiAgICBGSUxURVIgKHJlZ2V4KD90LCBBQ1RJVikpCgogICAgP3JlZ3VsIGJwOnhyZWYgP3B1YmxpIC4gCiAgICBGSUxURVIgKHJlZ2V4KD9wdWJsaSwgcHVibWVkKSkKCiAgICA/cmVndWwgYnA6Y29udHJvbGxlciA/c291cmNlIC4gCiAgICA/c291cmNlIGJwOmRpc3BsYXlOYW1lID9zb3VyY2VfbmFtZSAuIAp9IApMSU1JVCAxMA==\" | base64 --decode" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### Question 3.5\n", "Identify the target of the regulation (`bp:controlled`) and its display name (`bp:displayName`). Make sure (FILTER) that the display name is our target gene: SCN5A." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "query = \"\"\"\n", "...\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# SOLUTION:\n", "!echo \"UFJFRklYIGJwOiA8aHR0cDovL3d3dy5iaW9wYXgub3JnL3JlbGVhc2UvYmlvcGF4LWxldmVsMy5vd2wjPgoKU0VMRUNUICogV0hFUkUgewogICAgP3JlZ3VsIHJkZjp0eXBlIGJwOlRlbXBsYXRlUmVhY3Rpb25SZWd1bGF0aW9uIC4gCiAgICA/cmVndWwgYnA6ZGF0YVNvdXJjZSA/ZHMgLiAKICAgID9yZWd1bCBicDpjb250cm9sVHlwZSA/dHlwZSAuCiAgICBGSUxURVIgKHJlZ2V4KD90eXBlLCBBQ1RJViwgaSkgfHwgcmVnZXgoP3R5cGUsIElOSElCLCBpKSkKCiAgICA/cmVndWwgYnA6eHJlZiA/cHVibGkgLiAKICAgIEZJTFRFUiAocmVnZXgoP3B1YmxpLCBwdWJtZWQpKQoKICAgID9yZWd1bCBicDpjb250cm9sbGVyID9zb3VyY2UgLiAKICAgID9zb3VyY2UgYnA6ZGlzcGxheU5hbWUgP3NvdXJjZV9uYW1lIC4gCiAgICA/cmVndWwgYnA6Y29udHJvbGxlZCA/dGFyZ2V0IC4gCiAgICA/dGFyZ2V0IGJwOmRpc3BsYXlOYW1lID90YXJnZXRfbmFtZSAuIAogICAgRklMVEVSIChyZWdleCg/dGFyZ2V0X25hbWUsIFNDTjVBKSkKfSA=\" | base64 --decode" ] }, { "cell_type": "markdown", "metadata": { "jp-MarkdownHeadingCollapsed": true }, "source": [ "## Question 4\n", "From the previous query, retrieve a tabular file (CSV) with 3 columns for the source name, the regulation type, and the target name. Use the http://app.rawgraphs.io web tool to generate an alluvial flow chart which displays the relations between the source and target nodes. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2. Exploring Life Science ontologies\n", "\n", "BioPortal (https://bioportal.bioontology.org) is a large repository of biomedical ontologies gathering 600+ ontologies and 8+ million classes. We will use this web resource to navigate and retrieve biomedical knowledge." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 5\n", "Search for two definitions of “mitral valve prolapse”, coming from two different ontologies." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 6\n", "In the human phenotype ontology, search for all sub-classes of “mitral stenosis”. You will use the “jump to” search box to directly display the corresponding class." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 7\n", "Still from the Human Phenotype Ontology, list “mitral valve prolapse” class mappings. Based on its corresponding class in the OMIM ontology (Online Mendelian Inheritance in Man), retrieve possibly involved genes. You will need to navigate through “manifestation of” and “gene symbol” properties." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.14" } }, "nbformat": 4, "nbformat_minor": 4 }