troutpy.tl.image_intensities_per_transcript#
- troutpy.tl.image_intensities_per_transcript(sdata, image_key, scale, transcript_key, extracellular=False, copy=True, gene_key='gene')#
Extract image intensities at transcript locations and store them as a new table.
For each transcript, the pixel value of every channel (and z-slice, if present) of
sdata.images[image_key][scale]nearest to its rescaled coordinates is extracted into anAnnDatastored atsdata["image_intensity_per_transcript"].- Parameters:
sdata (spatialdata.SpatialData) – The input SpatialData object.
image_key (str) – Key of the image layer in
sdata.images.scale (str) – Scale of the image to use (e.g.
"scale0").transcript_key (str) – Key of the transcript points layer in
sdata.points.extracellular (bool, optional) – If
True, only transcripts whereextracellularisTrueare used. Otherwise all transcripts are used. Defaults toFalse.copy (bool, optional) – If
True, return the modified SpatialData object. Otherwise modifysdatain place and returnNone. Defaults toTrue.gene_key (str, optional) – Column holding the gene assigned to each transcript. Defaults to
"gene".
- Return type:
- Returns:
spatialdata.SpatialData or None SpatialData with the added
"image_intensity_per_transcript"table ifcopy=True; otherwiseNone.- Raises:
KeyError – If
image_keyortranscript_keyis not found insdata.