Ken Furudate

In [ ]:
import scanpy as sc
import anndata as ad
import squidpy as sq

import numpy as np
import pandas as pd

import matplotlib as mpl
from matplotlib import pyplot as plt
%matplotlib inline
import matplotlib.font_manager
plt.rcParams['font.sans-serif'] = ['Arial'] + plt.rcParams['font.sans-serif']
plt.rcParams["font.size"] = 20

import os
import seaborn as sns
from pathlib import Path

from IPython.core.display import display, HTML
display(HTML("<style>.container { width:80% !important; }</style>"))

import warnings
warnings.filterwarnings('ignore')

sc.logging.print_header()
print(f"squidpy=={sq.__version__}")

import skimage
/usr/local/lib/python3.7/dist-packages/distributed/config.py:20: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  defaults = yaml.load(f)
scanpy==1.9.1 anndata==0.8.0 umap==0.5.3 numpy==1.21.6 scipy==1.4.1 pandas==1.3.5 scikit-learn==1.0.2 statsmodels==0.13.2 python-igraph==0.9.11 pynndescent==0.5.7
squidpy==1.2.2
In [ ]:
datadir="/data/spatial/"
in_f = "integrated_data.h5ad"

data = sc.read_h5ad(datadir + in_f)
In [ ]:
set(data.obs['sample'])
Out[ ]:
{'A', 'B', 'C', 'D'}
In [ ]:
adata = data[data.obs['sample']=="A"]
bdata = data[data.obs['sample']=="B"]
cdata = data[data.obs['sample']=="C"]
ddata = data[data.obs['sample']=="D"]

data_lst = (adata, bdata, cdata, ddata)
In [51]:
interested_genes = [
 # Exhausted T cell marker
 "NR4A2", "TOX", "BACH2",
 
 # Cytotoxic T cell marker                    
 "CD8A", "CD28"
]

vmax_ = [1.6, 0.8, 0.1, 0.4, 0.1]

idx = 1
sc.pl.spatial(adata=data_lst[idx], 
              color=interested_genes,
              color_map="viridis",
              vmax=vmax_,
              ncols=3,
              na_in_legend=False,
              )
In [54]:
interested_genes = [
  # Regulatory T cell marker
  "CD4", "FOXP3", "IL2RA",
  
  # M2 like TAM markers 
  "CD163", "MSR1",  "MRC1"
]

vmax_ = [0.7, 0.1, 0.2, 0.7, 0.2, 0.2]

idx = 1
sc.pl.spatial(adata=data_lst[idx], 
              color=interested_genes,
              color_map="viridis",
              vmax=vmax_,
              ncols=3,
              na_in_legend=False,
              )
In [55]: