sparrow.io.read_transcripts#
- sparrow.io.read_transcripts(sdata, path_count_matrix, transform_matrix=None, pixelSize=None, output_layer='transcripts', overwrite=False, debug=False, column_x=0, column_y=1, column_z=None, column_gene=3, column_midcount=None, delimiter=',', header=None, comment=None, crd=None, to_coordinate_system='global', filter_gene_names=None, blocksize='64MB')#
Reads transcript information from a file with each row listing the x and y coordinates, along with the gene name.
If a transform matrix is provided an affine transformation is applied to the coordinates of the transcripts. The transformation is applied to the dask dataframe before adding it to
sdata. The SpatialData object is augmented with a points layer namedoutput_layerthat contains the transcripts.- Parameters:
sdata (
SpatialData) – The SpatialData object to which the transcripts will be added.path_count_matrix (
str|Path) – Path to a.parquetfile or.csvfile containing the transcripts information. Each row should contain anx(column_x),y(column_y) coordinate and a gene name (column_gene). Optional a count column (seecolumn_midcount) is provided.transform_matrix (
str|Path|ndarray[Any,dtype[TypeVar(_ScalarType_co, bound=generic, covariant=True)]] |None(default:None)) – Thisnumpyarray should contain a 3x3 transformation matrix for the affine transformation. The matrix defines the linear transformation to be applied to the coordinates of the transcripts before adding it as a points layer tosdata. E.g.: | Sx 0 Tx | | 0 Sy Ty | | 0 0 1 | If no transform matrix is specified, the identity matrix will be used. Iftransform_matrixis specified as a path to a file, it will be read vianumpy.loadtext.output_layer (
str(default:'transcripts')) – Name of the points layer of the SpatialData object to which the transcripts will be added.overwrite (
bool(default:False)) – If True overwrites theoutput_layer(a points layer) if it already exists.debug (
bool(default:False)) – If True, a sample of the data is processed for debugging purposes.pixelSize (float | None) – Pixel size in microns. If provided, a scaling transformation matrix is created based on this value. Ignored if
path_transform_matrixis provided.column_x (
int(default:0)) – Column index of the X coordinate in the count matrix.column_y (
int(default:1)) – Column index of the Y coordinate in the count matrix.column_z (
int|None(default:None)) – Column index of the Z coordinate in the count matrix.column_gene (
int(default:3)) – Column index of the gene information in the count matrix.column_midcount (
int|None(default:None)) – Specifies the column index that contains the count of how many times the gene is detected at that particular location. Ignored when set to None.delimiter (
str(default:',')) – Delimiter used to separate values in the.csvfile. Ignored ifpath_count_matrixis a.parquetfile.header (
int|None(default:None)) – Row number to use as the header in the.csvfile. IfNone, no header is used. Ignored ifpath_count_matrixis a.parquetfile.comment (
str|None(default:None)) – Character indicating that the remainder of line should not be parsed. If found at the beginning of a line, the line will be ignored altogether. This parameter must be a single character. Ignored ifpath_count_matrixis a.parquetfile.crd (
tuple[int,int,int,int] |None(default:None)) – The coordinates (in pixels) for the region of interest in the format (xmin, xmax, ymin, ymax). If None, all transcripts are considered.to_coordinate_system (
str(default:'global')) – Coordinate system to whichoutput_layerwill be added.filter_gene_names (
str|list[str] |None(default:None)) – Gene names that need to be filtered out (viastr.contains), mostly control genes that were added, and which you don’t want to use. Filtering is case insensitive.blocksize (
str(default:'64MB')) – Block size of the partions of the dask dataframe stored aspoints_layerinsdata.
- Return type:
SpatialData- Returns:
: The updated SpatialData object containing the transcripts.