{
"cells": [
{
"cell_type": "markdown",
"id": "cfda1a55-732b-4dba-9e91-1fb65f49e2d5",
"metadata": {},
"source": [
"Tutorial 3: Automated Annotation of Cell Identities in mIHC Data\n",
"================================================================\n",
"\n",
"In this tutorial, we demonstrate how to use ImmunoPheno to annotate cell identities in a multiplexed IHC dataset using reference data stored in the ImmunoPhenoDB database. Specifically, we consider a human tonsil tissue section that has been profiled with PhenoCycler using a panel of 26 antibodies. For illustration purposes, we will only consider a small portion of the tissue section containing ~118k cells. The data can be found in this [link](https://www.dropbox.com/scl/fi/d03airv7b1bimyy8n99jz/codex_small.zip?rlkey=4php5lnz5a7r096kopb3h4b01&dl=0)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fcc162b4-e104-478a-a346-6b56aa013049",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import pickle\n",
"import numpy as np\n",
"import plotly.express as px\n",
"import seaborn as sns\n",
"from immunopheno.data_processing import ImmunoPhenoData\n",
"from immunopheno.connect import ImmunoPhenoDB_Connect\n",
"from immunopheno.plots import plot_filter_metrics\n",
"from sklearn.metrics.pairwise import euclidean_distances"
]
},
{
"cell_type": "markdown",
"id": "36eb1665-903b-47b2-b471-ca43479a6aa0",
"metadata": {},
"source": [
"We can visualize the spatial location of the cells in the tissue:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "50616464-512b-4df5-95fa-9ea56aa7a1fa",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "x=%{x}
y=%{y}
| \n", " | idExperiment | \n", "nameExp | \n", "typeExp | \n", "pmid | \n", "doi | \n", "idBTO | \n", "tissue | \n", "
|---|---|---|---|---|---|---|---|
| 0 | \n", "4 | \n", "Childhood Hematopoiesis and Immune Development... | \n", "CITE | \n", "0 | \n", "https://doi.org | \n", "BTO:0001387 | \n", "tonsil | \n", "
| 1 | \n", "5 | \n", "Childhood Hematopoiesis and Immune Development... | \n", "CITE | \n", "0 | \n", "https://doi.org | \n", "BTO:0001387 | \n", "tonsil | \n", "
| 2 | \n", "6 | \n", "Childhood Hematopoiesis and Immune Development... | \n", "CITE | \n", "0 | \n", "https://doi.org | \n", "BTO:0001387 | \n", "tonsil | \n", "