In [ ]:
%matplotlib inline

Extract histogram features

This example shows how to extract histogram features from tissue image.

Histogram features give a more detailed view than summary features ( by computing a histogram of each image channel and returning bin-counts for each Visium spot.

In addition to feature_name and channels we can specify the following features_kwargs:

  • bins - number of bins of the histogram, default is 10.
  • v_range - range on which values are binned, default is the whole image range.

::: seealso See for general usage of :::

In [ ]:
import squidpy as sq

Lets load the fluorescence Visium dataset and calculate bin-counts (3 bins) of channels 0 and 1.

In [ ]:
# get spatial dataset including high-resolution tissue image
img = sq.datasets.visium_fluo_image_crop()
adata = sq.datasets.visium_fluo_adata_crop()

# calculate histogram features and save in key "histogram_features"
    features_kwargs={"histogram": {"bins": 3, "channels": [0, 1]}},

The result is stored in adata.obsm['histogram_features'].

In [ ]:

Use to plot the histogram features on the tissue image or have a look at our interactive visualisation tutorial to learn how to use our interactive napari plugin. With these features we can e.g. appreciate the detailed distribution of intensity values of channel 0 (DAPI stain) on the different bins.

In [ ]:, "histogram_features"),
    color=[None, "histogram_ch-0_bin-0", "histogram_ch-0_bin-1", "histogram_ch-0_bin-2"],