scanpy.read_visium

Contents

scanpy.read_visium#

scanpy.read_visium(path, genome=None, *, count_file='filtered_feature_bc_matrix.h5', library_id=None, load_images=True, source_image_path=None)[source]#

Read 10x-Genomics-formatted visum dataset.

Deprecated: The function read_visium is deprecated and will be removed in the future. Use :func:`squidpy.read.visium` instead.

In addition to reading regular 10x output, this looks for the spatial folder and loads images, coordinates and scale factors. Based on the Space Ranger output docs.

See spatial() for a compatible plotting function.

Parameters:
path PathLike[str] | str

Path to directory for visium datafiles.

genome str | None (default: None)

Filter expression to genes within this genome.

count_file str (default: 'filtered_feature_bc_matrix.h5')

Which file in the passed directory to use as the count file. Typically would be one of: ‘filtered_feature_bc_matrix.h5’ or ‘raw_feature_bc_matrix.h5’.

library_id str | None (default: None)

Identifier for the visium library. Can be modified when concatenating multiple adata objects.

source_image_path PathLike[str] | str | None (default: None)

Path to the high-resolution tissue image. Path will be included in .uns["spatial"][library_id]["metadata"]["source_image_path"].

Return type:

AnnData

Returns:

Annotated data matrix, where observations/cells are named by their barcode and variables/genes by gene name. Stores the following information:

X

The data matrix is stored

obs_names

Cell names

var_names

Gene names for a feature barcode matrix, probe names for a probe bc matrix

var['gene_ids']

Gene IDs

var['feature_types']

Feature types

obs[filtered_barcodes]

filtered barcodes if present in the matrix

var

Any additional metadata present in /matrix/features is read in.

uns['spatial']

Dict of spaceranger output files with ‘library_id’ as key

uns['spatial'][library_id]['images']

Dict of images ('hires' and 'lowres')

uns['spatial'][library_id]['scalefactors']

Scale factors for the spots

uns['spatial'][library_id]['metadata']

Files metadata: ‘chemistry_description’, ‘software_version’, ‘source_image_path’

obsm['spatial']

Spatial spot coordinates, usable as basis by embedding().