spateo.io.nanostring#

IO functions for NanoString CosMx technology.

Module Contents#

Functions#

read_nanostring_as_dataframe(→ pandas.DataFrame)

Read a NanoString CSV tx or metadata file as pandas DataFrame.

stitch_images(→ numpy.ndarray)

Stitch multiple FOVs into a single image using position information.

read_nanostring(→ anndata.AnnData)

Read NanoString CosMx data as AnnData.

Attributes#

spateo.io.nanostring.VERSIONS[source]#
spateo.io.nanostring.FOV_PARSER[source]#
spateo.io.nanostring.read_nanostring_as_dataframe(path: str, label_columns: List[str] | None = None) pandas.DataFrame[source]#

Read a NanoString CSV tx or metadata file as pandas DataFrame.

Parameters:
path

Path to file.

label_columns

Column names, the combination of which indicates unique cells.

Returns:

Pandas Dataframe with the following standardized column names.
  • gene: Gene name/ID (whatever was used in the original file)

  • x, y: X and Y coordinates

spateo.io.nanostring.stitch_images(stain_dir: str, positions_path: str, labels: bool = False) numpy.ndarray[source]#

Stitch multiple FOVs into a single image using position information.

Parameters:
stain_dir

Directory containing JPEG or TIFF files with filenames ending in ‘_FXXX’ where XXX indicates the FOV index.

positions_path

Path to CSV file containing FOV positions.

labels

Whether these are labels (and therefore should be made unique).

Returns:

A numpy array containing the stitched image. May contain multiple channels,

which is the last dimension of the array.

spateo.io.nanostring.read_nanostring(path: str, meta_path: str | None = None, binsize: int | None = None, label_columns: str | List[str] | None = None, add_props: bool = True, version: typing_extensions.Literal[cosmx] = 'cosmx') anndata.AnnData[source]#

Read NanoString CosMx data as AnnData.

Parameters:
path

Path to transcript detection CSV file.

meta_path

Path to cell metadata CSV file.

scale

Physical length per coordinate. For visualization only.

scale_unit

Scale unit.

binsize

Size of pixel bins

label_columns

Columns that contain already-segmented cell labels. Each unique combination is considered a unique cell.

add_props

Whether or not to compute label properties, such as area, bounding box, centroid, etc.

version

NanoString technology version. Currently only used to set the scale and scale units of each unit coordinate. This may change in the future.

Returns:

Bins x genes or labels x genes AnnData.