%matplotlib inline

Visualize input data of different spatial technologies

There are great numbers of emerging technologies of image-based spatial technologies. They mainly include three branches. First one is in-situ hybridization based technologies, such as MERFISH and SeqFISH. Second one is in-situ sequencing based technologies, such as STARMap and FISSeq. Third one is sequencing-bead based technologies, such as Stereo-seq, which reach subcellular-resolution spatial data due to small bead sizes.

This tutorial shows how the input data of different spatial technologies look like.

Import packages & data

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt 

import Bering as br

Define the visualization function

def visualize_spots(df_spots_all):
    df_spots_seg = df_spots_all[df_spots_all['labels'] != 'background'] # foreground nodes
    df_spots_unseg = df_spots_all[df_spots_all['labels'] == 'background'] # background nodes

    # visualize the spots
    x, y = df_spots_seg['x'].values, df_spots_seg['y'].values
    cell_types = df_spots_seg['labels'].values

    fig, ax = plt.subplots(figsize = (6, 6))
    for idx, cell_type in enumerate(np.unique(cell_types)):
        
        xc = x[np.where(cell_types == cell_type)[0]]
        yc = y[np.where(cell_types == cell_type)[0]]

        ax.scatter(xc, yc, s = 0.03, label = cell_type, color = np.random.rand(3,))

    xb, yb = df_spots_unseg['x'].values, df_spots_unseg['y'].values
    ax.scatter(xb, yb, color = '#DCDCDC', alpha = 0.2, s = 0.015, label = 'background')

    h, l = ax.get_legend_handles_labels()
    plt.legend(h, l, loc = 'upper right', fontsize = 8, markerscale = 15)

1. MERFISH Cortex data

This MERFISH data is from [Zhang et al., 2021]. Gray dots are unsegmented spots from original paper.

df_spots_all = br.datasets.merfish_cortex_zhang()
visualize_spots(df_spots_all)
Downloading dataset `merfish_cortex_zhang` from `https://figshare.com/ndownloader/files/41409090` as `None.tsv`
../../../_images/ef0a6a806266dc4b91da34e325de08dda2225698e6b805dd4861ab3d8e598a90.png

2. Nanostring CoxMx Non-small-cell Lung Cancer data

This Nanostring CosMx data is from [He et al., 2022]

df_spots_all = br.datasets.cosmx_nsclc_he()
visualize_spots(df_spots_all)
Downloading dataset `cosmx_nsclc_he` from `https://figshare.com/ndownloader/files/41409093` as `None.tsv`
../../../_images/f2f3b664c9d7b19889508b1cbd1fc9130505c64629da98ec78fdb5cfce7fada8.png

3. pciSeq Hippocampus data

This pciSeq data is from [Qian et al., 2020]

df_spots_all = br.datasets.iss_ca1_qian()
visualize_spots(df_spots_all)
Downloading dataset `iss_ca1_qian` from `https://figshare.com/ndownloader/files/41409096` as `None.tsv`
../../../_images/e0875ceee57c765122b68835e9c7c0b21405c3b2fe416e15b849b87af5b97019.png

4. Stereo-seq Embryo Brain data

This Stereo-seq data is from [Chen et al., 2022]

df_spots_all = br.datasets.stereoseq_embryobrain_chen()
visualize_spots(df_spots_all)
Downloading dataset `stereoseq_embryobrain_chen` from `https://figshare.com/ndownloader/files/41409105` as `None.tsv`
../../../_images/f7666321f41ce8bcad795cc6fab94e68f16f5e8ac5a64d2d6d4bf910f2b560cc.png

5. 10x Xenium Ductal Carcinoma In Situ data

This 10x Xenium data is from [Janesick et al., 2022]

df_spots_all = br.datasets.xenium_dcis_janesick()
visualize_spots(df_spots_all)
Downloading dataset `xenium_dcis_janesick` from `https://figshare.com/ndownloader/files/41409108` as `None.tsv`
../../../_images/94dab19a258f19c768130f8aa4d8135b32287ad4ef5144eccc2abceb3fc16062.png

6. MERFISH Ileum data

This MERFISH data is from [Petukhov et al., 2022]

df_spots_all = br.datasets.merfish_ileum_petukhov()
visualize_spots(df_spots_all)
Downloading dataset `merfish_ileum_petukhov` from `https://figshare.com/ndownloader/files/41409102` as `None.tsv`
../../../_images/cfe60d3cf3ebc2dcf64c03882d641ca2f974af8794e3af095e21d9e76de29a54.png