Use the Scatterwidget with AnnData from Notebook

Use the Scatterwidget with AnnData from Notebook#

This tutorial is an example of how to use the Napari-Spatialdata ScatterWidget from a notebook.

Import packages and data#

There are two options to install napari-spatialdata:

(1) Run pip install napari-spatialdata

or,

(2) Clone this repo and run pip install -e .

from napari_spatialdata import QtAdataScatterWidget
import squidpy as sq
import matplotlib.pyplot as plt

Load in the AnnData:

adata = sq.datasets.visium_hne_adata()

The following line is needed to initialize a widget without a QApplication:

%gui qt5

Open the ScatterWidget:

widget = QtAdataScatterWidget(adata)
widget.show()

The widget:

plt.imshow(widget.screenshot())
plt.axis('off')
(-0.5, 861.5, 719.5, -0.5)
../_images/85178625422eefc64a123ba33cd0eef2e13ec9bb02544087b8ddb551143b0801.png

Some examples of scatterplots:

plt.imshow(widget.screenshot())
plt.axis('off')
(-0.5, 861.5, 719.5, -0.5)
../_images/a7fcaa2332eebbe3e6cdf9048719c9f13c3d1afb9f73fb930886e5c4b1852bd9.png
plt.imshow(widget.screenshot())
plt.axis('off')
(-0.5, 861.5, 719.5, -0.5)
../_images/2250f7f4f09bf218e0c1e477d6d6dc1c77197fa140cc6d40fb0567045930a142.png