DecodedIntensityTable

class starfish.core.intensity_table.decoded_intensity_table.DecodedIntensityTable(data=<NA>, coords=None, dims=None, name=None, attrs=None, indexes=None, fastpath=False)[source]

DecodedIntensityTable is a container for spot or pixel features extracted from image data that have been decoded. It is the primary output from starfish Decode methods.

An IntensityTable records the numeric intensity of a set of features in each (round, channel) tile in which the feature is identified. The IntensityTable has shape (n_feature, n_channel, n_round).

Some SpotFinder methods identify a position and search for Gaussian blobs in a small radius, only recording intensities if they are found in a given tile. Other :py:class:SpotFinder: approaches find blobs in a max-projection and measure them everywhere. As a result, some IntensityTables will be dense, and others will contain np.nan entries where no feature was detected.

Examples

Create an IntensityTable using the synthetic_intensities method:

>>> from starfish.core.test.factories import SyntheticData
>>> sd = SyntheticData(n_ch=3, n_round=4, n_codes=2)
>>> codes = sd.codebook()
>>> sd.intensities(codebook=codes)
<xarray.IntensityTable (features: 2, c: 3, h: 4)>
array([[[    0.,     0.,     0.,     0.],
        [    0.,     0.,  8022., 12412.],
        [11160.,  9546.,     0.,     0.]],

       [[    0.,     0.,     0.,     0.],
        [    0.,     0., 10506., 10830.],
        [11172., 12331.,     0.,     0.]]])
Coordinates:
* features   (features) MultiIndex
- z          (features) int64 7 3
- y          (features) int64 14 32
- x          (features) int64 32 15
- r          (features) float64 nan nan
* c          (c) int64 0 1 2
* h          (h) int64 0 1 2 3
 target     (features) object 08b1a822-a1b4-4e06-81ea-8a4bd2b004a9 ...

Methods

from_intensity_table(intensities, targets[, …])

Assign target values to intensities.

to_decoded_dataframe()

Generates a dataframe containing decoded spot information.

to_expression_matrix()

Generates a cell x gene count matrix where each cell is annotated with spatial metadata.

to_mermaid(filename)

Writes a .csv.gz file in columnar format that is readable by MERMAID visualization software.

classmethod from_intensity_table(intensities, targets, distances=None, passes_threshold=None)[source]

Assign target values to intensities.

Parameters
intensitiesIntensityTable

intensity_table to assign target values to

targetsTuple[str, np.ndarray]

Target values to assign

distancesOptional[Tuple[str, np.ndarray]]

Corresponding array of distances from target for each feature

passes_thresholdOptional[Tuple[str, np.ndarray]]

Corresponding array of boolean values indicating if each itensity passed given thresholds.

Returns
DecodedIntensityTable
to_decoded_dataframe()[source]

Generates a dataframe containing decoded spot information. Guaranteed to contain physical spot coordinates (z, y, x) and gene target. Does not contain pixel coordinates.

Return type

DecodedSpots

to_expression_matrix()[source]

Generates a cell x gene count matrix where each cell is annotated with spatial metadata.

Requires that spots in the IntensityTable have been assigned to cells.

Returns
ExpressionMatrix :

cell x gene expression table

Return type

ExpressionMatrix

to_mermaid(filename)[source]

Writes a .csv.gz file in columnar format that is readable by MERMAID visualization software.

To run MERMAID, follow the installation instructions for that repository and simply replace the data.csv.gz file with the output of this function.

Parameters
filenamestr

Name for compressed-gzipped MERMAID data file. Should end in ‘.csv.gz’.

Notes

See also https://github.com/JEFworks/MERmaid

Return type

DataFrame