terra.datasets.read_xenium_10x

terra.datasets.read_xenium_10x#

terra.datasets.read_xenium_10x(base_url, out_dir)#

Download a 10x Genomics Xenium sample and load it as an AnnData.

Fetches the two small standalone output files ({base_url}_cell_feature_matrix.h5 and {base_url}_cells.parquet — tens of MB, not the multi-GB output bundle), caches them in out_dir, and returns an AnnData with raw counts in .X (gene-expression features only) and single-cell spatial coordinates in .obsm['spatial'].

Parameters:
  • base_url (str) – Common prefix of the sample’s files on the 10x CDN, e.g. "https://cf.10xgenomics.com/samples/xenium/3.0.0/" "Xenium_Prime_Human_Skin_FFPE/Xenium_Prime_Human_Skin_FFPE".

  • out_dir (str) – Local directory used to cache the downloaded files. Existing files are reused rather than re-downloaded.

Returns:

  • adata (AnnData) – Cells x genes, with .obsm['spatial'] holding the [x_centroid, y_centroid] coordinates.