{ "cells": [ { "cell_type": "markdown", "id": "b3b0dbee", "metadata": {}, "source": [ "# NCIT tutorial\n", "\n", "* author: Chris Mungall\n", "* created: 2022-11-11\n", "\n", "This tutorial walks through NCIT-OBO, the goals are:\n", "\n", "- to help understand the structure of ncit\n", "- to show how to do advanced OAK queries (CLI and programmatic) on NCIT\n" ] }, { "cell_type": "markdown", "id": "9aced0d9", "metadata": {}, "source": [ "## Create an alias\n", "\n", "For convenience we will set a bash alias.\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "44bd10cd", "metadata": {}, "outputs": [], "source": [ "%alias ncit runoak -i sqlite:obo:ncit" ] }, { "cell_type": "markdown", "id": "09595dfc", "metadata": {}, "source": [ "### Basic lookup queries\n", "\n", "Let's check it's working:" ] }, { "cell_type": "code", "execution_count": 8, "id": "81399308", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NCIT:C4872 ! Breast Carcinoma\r\n" ] } ], "source": [ "ncit info NCIT:C4872" ] }, { "cell_type": "code", "execution_count": 9, "id": "fb640127", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NCIT:C4872 ! Breast Carcinoma\r\n" ] } ], "source": [ "ncit info \"Breast Carcinoma\"" ] }, { "cell_type": "markdown", "id": "f8b16045", "metadata": {}, "source": [ "## Exploring the structure of NCIT" ] }, { "cell_type": "code", "execution_count": 12, "id": "1e122ab2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "subject\tsubject_label\tpredicate\tpredicate_label\tobject\tobject_label\n", "NCIT:C4872\tBreast Carcinoma\tNCIT:R101\tDisease_Has_Primary_Anatomic_Site\tNCIT:C12971\tBreast\n", "NCIT:C4872\tBreast Carcinoma\tNCIT:R103\tDisease_Has_Normal_Tissue_Origin\tNCIT:C12937\tMammary Epithelium\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C2916\tCarcinoma\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C9335\tMalignant Breast Neoplasm\n", "NCIT:C4872\tBreast Carcinoma\towl:equivalentClass\tNone\t_:riog00972235\tNone\n" ] } ], "source": [ "phenio relationships NCIT:C4872" ] }, { "cell_type": "code", "execution_count": 11, "id": "0162323e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "subject\tsubject_label\tpredicate\tpredicate_label\tobject\tobject_label\n", "NCIT:C4872\tBreast Carcinoma\tNCIT:R100\tDisease_Has_Associated_Anatomic_Site\tNCIT:C12219\tAnatomic Structure, System, or Substance\n", "NCIT:C4872\tBreast Carcinoma\tNCIT:R100\tDisease_Has_Associated_Anatomic_Site\tNCIT:C12971\tBreast\n", "NCIT:C4872\tBreast Carcinoma\tNCIT:R100\tDisease_Has_Associated_Anatomic_Site\tNCIT:C13018\tOrgan\n", "NCIT:C4872\tBreast Carcinoma\tNCIT:R105\tDisease_Has_Abnormal_Cell\tNCIT:C12913\tAbnormal Cell\n", "NCIT:C4872\tBreast Carcinoma\tNCIT:R105\tDisease_Has_Abnormal_Cell\tNCIT:C12922\tNeoplastic Cell\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C26709\tBreast Disorder\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C27551\tDisorder by Site\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C2910\tBreast Neoplasm\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C2916\tCarcinoma\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C2991\tDisease or Disorder\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C3262\tNeoplasm\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C3263\tNeoplasm by Site\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C3709\tEpithelial Neoplasm\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C4741\tNeoplasm by Morphology\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C4872\tBreast Carcinoma\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C7057\tDisease, Disorder or Finding\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C7062\tNeoplasm by Special Category\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C9305\tMalignant Neoplasm\n", "NCIT:C4872\tBreast Carcinoma\trdfs:subClassOf\tNone\tNCIT:C9335\tMalignant Breast Neoplasm\n", "NCIT:C4872\tBreast Carcinoma\towl:equivalentClass\tNone\t_:riog00922295\tNone\n" ] } ], "source": [ "phenio relationships --include-entailed NCIT:C4872" ] }, { "cell_type": "markdown", "id": "b79f675d", "metadata": {}, "source": [ "Here we can see linkages to external ontologies using two relations\n", "\n", "### Querying ancestors\n", "\n", "We will try finding all ancestors of NCIT:C4872\n", "\n", "__IMPORTANT__ in OAK, all graph commands are parameterized by predicate lists. Consult the OAK docs if you\n", "don't understand what this means!\n", "\n", "To find all is-a ancestors (i.e. ancestors following SubClassOf between named classes) we use `-p i`:" ] }, { "cell_type": "code", "execution_count": 13, "id": "90d3806c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NCIT:C26709 ! Breast Disorder\n", "NCIT:C27551 ! Disorder by Site\n", "NCIT:C2910 ! Breast Neoplasm\n", "NCIT:C2916 ! Carcinoma\n", "NCIT:C2991 ! Disease or Disorder\n", "NCIT:C3262 ! Neoplasm\n", "NCIT:C3263 ! Neoplasm by Site\n", "NCIT:C3709 ! Epithelial Neoplasm\n", "NCIT:C4741 ! Neoplasm by Morphology\n", "NCIT:C4872 ! Breast Carcinoma\n", "NCIT:C7057 ! Disease, Disorder or Finding\n", "NCIT:C7062 ! Neoplasm by Special Category\n", "NCIT:C9305 ! Malignant Neoplasm\n", "NCIT:C9335 ! Malignant Breast Neoplasm\n" ] } ], "source": [ "ncit ancestors -p i NCIT:C4872" ] }, { "cell_type": "markdown", "id": "58f23581", "metadata": {}, "source": [ "Next we will generate a visualization from this using the `viz` command:" ] }, { "cell_type": "code", "execution_count": 14, "id": "c10dc41f", "metadata": {}, "outputs": [], "source": [ "ncit viz -p i NCIT:C4872 -o output/NCIT_C4872.png" ] }, { "cell_type": "markdown", "id": "a354b6da", "metadata": {}, "source": [ "![img](output/NCIT_C4872.png)" ] }, { "cell_type": "code", "execution_count": 18, "id": "93d7083e", "metadata": {}, "outputs": [], "source": [ "ncit viz -p i,NCIT:R101,NCIT:R103,NCIT:R82 NCIT:C4872 -o output/NCIT_C4872_multirel.png" ] }, { "cell_type": "markdown", "id": "7e69abe3", "metadata": {}, "source": [ "![img](output/NCIT_C4872_multirel.png)" ] } ], "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.9.5" } }, "nbformat": 4, "nbformat_minor": 5 }