{ "cells": [ { "cell_type": "markdown", "id": "quick_start-0", "metadata": {}, "source": "# Quick start\n\n[](https://colab.research.google.com/github/Abel-ai-lab/andrey/blob/main/examples/quick_start.ipynb) {download}`Download this notebook <../../../examples/quick_start.ipynb>`\n\nYou call every method in Andrey the same way: pass it your data, and read the result it returns.\nThis notebook loads the protein measurements of Sachs et al. (2005), learns a graph from them\nwith four classic methods, PC, GES, FCI, and DirectLiNGAM, reads each result, and draws each\ngraph." }, { "cell_type": "markdown", "id": "quick_start-1", "metadata": {}, "source": [ "## Start\n", "\n", "Choose a CPU runtime and run this cell first. In Colab it installs `andrey-core==0.17.1` from PyPI;\n", "local kernels use the installed environment." ] }, { "cell_type": "code", "execution_count": 1, "id": "quick_start-2", "metadata": { "tags": [ "colab-setup" ] }, "outputs": [], "source": [ "import os\n", "import sys\n", "\n", "IN_COLAB = \"google.colab\" in sys.modules\n", "\n", "if IN_COLAB:\n", " os.environ[\"ANDREY_DEVICE\"] = \"cpu\"\n", " !pip install --quiet \"andrey-core[viz]==0.17.1\" pandas" ] }, { "cell_type": "code", "execution_count": 2, "id": "quick_start-3", "metadata": {}, "outputs": [], "source": [ "import andrey\n", "import andrey.viz\n", "from andrey.data import load_dataset" ] }, { "cell_type": "markdown", "id": "quick_start-4", "metadata": {}, "source": [ "## The data\n", "\n", "Sachs and colleagues (2005) measured 11 proteins and phospholipids in 853 single human immune\n", "cells. Biologists had already mapped how these molecules signal to one another, so a graph\n", "learned from the measurements can be checked against a known network of 17 links.\n", "`load_dataset` downloads the measurements on first use and caches them.\n", "\n", "Each row is one cell and each column one molecule. For your own data, pass a pandas DataFrame\n", "or a NumPy array of the same shape: one row per sample, one column per variable." ] }, { "cell_type": "code", "execution_count": 3, "id": "quick_start-5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | raf | \n", "mek | \n", "plc | \n", "pip2 | \n", "pip3 | \n", "erk | \n", "akt | \n", "pka | \n", "pkc | \n", "p38 | \n", "jnk | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "26.4 | \n", "13.2 | \n", "8.82 | \n", "18.30 | \n", "58.80 | \n", "6.61 | \n", "17.0 | \n", "414.0 | \n", "17.00 | \n", "44.9 | \n", "40.0 | \n", "
| 1 | \n", "35.9 | \n", "16.5 | \n", "12.30 | \n", "16.80 | \n", "8.13 | \n", "18.60 | \n", "32.5 | \n", "352.0 | \n", "3.37 | \n", "16.5 | \n", "61.5 | \n", "
| 2 | \n", "59.4 | \n", "44.1 | \n", "14.60 | \n", "10.20 | \n", "13.00 | \n", "14.90 | \n", "32.5 | \n", "403.0 | \n", "11.40 | \n", "31.9 | \n", "19.5 | \n", "
| 3 | \n", "73.0 | \n", "82.8 | \n", "23.10 | \n", "13.50 | \n", "1.29 | \n", "5.83 | \n", "11.8 | \n", "528.0 | \n", "13.70 | \n", "28.6 | \n", "23.1 | \n", "
| 4 | \n", "33.7 | \n", "19.8 | \n", "5.19 | \n", "9.73 | \n", "24.80 | \n", "21.10 | \n", "46.1 | \n", "305.0 | \n", "4.66 | \n", "25.7 | \n", "81.3 | \n", "