{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Get phenotypes associated with a list of genes from high content screens\n", "\n", "This notebook takes a list of gene symbols and queries the IDR for phenotypes associated with the genes in high content screens." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import json\n", "import csv\n", "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set up where to query and session" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import requests\n", "\n", "INDEX_PAGE = \"https://idr.openmicroscopy.org/webclient/?experimenter=-1\"\n", "\n", "# create http session\n", "with requests.Session() as session:\n", " request = requests.Request('GET', INDEX_PAGE)\n", " prepped = session.prepare_request(request)\n", " response = session.send(prepped)\n", " if response.status_code != 200:\n", " response.raise_for_status()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get list of genes to query either from file (one gene symbol per line) or enter directly in list in notebook" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['ASH2L', 'ash2', '85441']" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# uncomment the next two lines if you'd rather read gene list in from a file \n", "# with open('./includes/FiveExampleGenes.txt') as f:\n", "# genes = f.read().splitlines()\n", "\n", "# comment out the next line if you've read in the gene list from a file\n", "genes = ['ASH2L', 'ash2', '85441' ]\n", "\n", "# check the gene list has been read in\n", "genes[:5]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set up base URLS so can use shorter variable names later on" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "SCREENS_PROJECTS_URL = \"https://idr.openmicroscopy.org/mapr/api/{key}/?value={value}\"\n", "PLATES_URL = \"https://idr.openmicroscopy.org/mapr/api/{key}/plates/?value={value}&id={screen_id}\"\n", "IMAGES_URL = \"https://idr.openmicroscopy.org/mapr/api/{key}/images/?value={value}&node={parent_type}&id={parent_id}\"\n", "ATTRIBUTES_URL = \"https://idr.openmicroscopy.org/webclient/api/annotations/?type=map&image={image_id}\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### For each in gene in the list fetch the screens, plates, images and then phenotypes associated with the images\n", "\n", "The results are both printed to the screen and saved in a .csv file" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Gene | \n", "Screen | \n", "Plate | \n", "Image | \n", "Phenotype | \n", "Phenotype Term Name | \n", "Phenotype Term Accession | \n", "Phenotype Term Accession URL | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "ASH2L | \n", "idr0012-fuchs-cellmorph/screenA (2) | \n", "HT28 | \n", "1830141 | \n", "elongated cells | \n", "elongated cell phenotype | \n", "CMPO_0000077 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000077 | \n", "
1 | \n", "ASH2L | \n", "idr0012-fuchs-cellmorph/screenA (2) | \n", "HT28 | \n", "1830140 | \n", "elongated cells | \n", "elongated cell phenotype | \n", "CMPO_0000077 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000077 | \n", "
2 | \n", "ash2 | \n", "idr0001-graml-sysgro/screenA (60) | \n", "JL_120809_S14B | \n", "1239832 | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "CMPO_0000438 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000438 | \n", "
3 | \n", "ash2 | \n", "idr0001-graml-sysgro/screenA (60) | \n", "JL_120809_S14B | \n", "1239830 | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "CMPO_0000438 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000438 | \n", "
4 | \n", "ash2 | \n", "idr0001-graml-sysgro/screenA (60) | \n", "JL_120809_S14B | \n", "1239833 | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "CMPO_0000438 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000438 | \n", "
5 | \n", "ash2 | \n", "idr0001-graml-sysgro/screenA (60) | \n", "JL_120809_S14B | \n", "1239834 | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "CMPO_0000438 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000438 | \n", "
6 | \n", "ash2 | \n", "idr0001-graml-sysgro/screenA (60) | \n", "JL_120809_S14B | \n", "1239831 | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "CMPO_0000438 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000438 | \n", "
7 | \n", "ash2 | \n", "idr0001-graml-sysgro/screenA (60) | \n", "JL_120809_S14B | \n", "1239835 | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "CMPO_0000438 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000438 | \n", "
8 | \n", "ash2 | \n", "idr0001-graml-sysgro/screenA (60) | \n", "JL_121215_J4_1 | \n", "1269432 | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "CMPO_0000438 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000438 | \n", "
9 | \n", "ash2 | \n", "idr0001-graml-sysgro/screenA (60) | \n", "JL_121215_J4_1 | \n", "1269435 | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "abnormal microtubule cytoskeleton morphology d... | \n", "CMPO_0000438 | \n", "http://www.ebi.ac.uk/cmpo/CMPO_0000438 | \n", "