harpy.im.transcript_density

harpy.im.transcript_density#

harpy.im.transcript_density(sdata, image_name='raw_image', points_name='transcripts', n_sample=15000000, name_x='x', name_y='y', name_z=None, z_index=None, chunks=1024, crd=None, to_coordinate_system='global', scale_factors=None, output_image_name='transcript_density', overwrite=False)#

Calculate the transcript density using a Gaussian filter and add it to the provided spatialdata.SpatialData object.

This function computes the density of transcripts in the spatialdata.SpatialData object, scales and smooths it, and then adds the resulting density image to the same spatialdata.SpatialData object.

Parameters:
  • sdata (SpatialData) – spatialdata.SpatialData object containing spatial information.

  • image_name (str (default: 'raw_image')) – The image element of the SpatialData object used for determining image boundary. image_name and points_name should be registered in coordinate system to_coordinate_system.

  • points_name (str (default: 'transcripts')) – The name of the points element containing transcript data, by default “transcripts”.

  • n_sample (int | None (default: 15000000)) – The number of transcripts to sample for calculation of transcript density.

  • name_x (str (default: 'x')) – Column name for x-coordinates of the transcripts in the points element, by default “x”.

  • name_y (str (default: 'y')) – Column name for y-coordinates of the transcripts in the points element, by default “y”.

  • name_z (str | None (default: None)) – Column name for z-coordinates of the transcripts in the points element, by default None.

  • z_index (int | None (default: None)) – The z index in the points element for which to calculate transcript density. If set to None for a 3D points element (and name_z is not equal to None), an y-x transcript density projection will be calculated.

  • chunks (int (default: 1024)) – Chunksize for calculation of density using gaussian filter.

  • crd (tuple[int, int, int, int] | None (default: None)) – The coordinates for a region of interest in the format (xmin, xmax, ymin, ymax). If provided, the density is computed only for this region, by default None.

  • to_coordinate_system (str (default: 'global')) – The coordinate system that holds image_name and points_name. This coordinate system should be the intrinsic coordinate system in pixels.

  • scale_factors (Sequence[dict[str, int] | int] | None (default: None)) – Scale factors to apply for multiscale.

  • output_image_name (str (default: 'transcript_density')) – The name of the output image element in the spatialdata.SpatialData object where the transcript density will be added, by default “transcript_density”.

  • overwrite (bool (default: False)) – If True overwrites the element if it already exists.

Return type:

SpatialData

Returns:

: Updated spatialdata.SpatialData object with the added transcript density image element.

Examples

>>> sdata = SpatialData(...)
>>> sdata = transcript_density(sdata, points_name="transcripts", crd=(2000, 4000, 2000, 4000))