From 0485aef5a3ebe5a93c05f2fcac33c3d968886987 Mon Sep 17 00:00:00 2001 From: Alexei Martsinkovskiy Date: Thu, 22 Feb 2024 04:25:53 -0800 Subject: [PATCH] fixed reading 10x formatted visium mtx files (#803) * fixed reading 10x formatted visium mtx files solves #802 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update notes-dev.rst added release notes * Update _utils.py fixed counts file suffix to match 10x spec * Update docs/release/notes-dev.rst --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Giovanni Palla <25887487+giovp@users.noreply.github.com> --- docs/release/notes-dev.rst | 2 ++ src/squidpy/read/_utils.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/release/notes-dev.rst b/docs/release/notes-dev.rst index 86ce6e4c..76a5b52d 100644 --- a/docs/release/notes-dev.rst +++ b/docs/release/notes-dev.rst @@ -1,2 +1,4 @@ Squidpy dev (the-future) ======================== +- Fixed the reading of 10x formatted mtx files `@LinearParadox `__ + `#803 `__ diff --git a/src/squidpy/read/_utils.py b/src/squidpy/read/_utils.py index 921458bb..c5c82097 100644 --- a/src/squidpy/read/_utils.py +++ b/src/squidpy/read/_utils.py @@ -4,10 +4,10 @@ from typing import Any, Optional, Tuple import numpy as np -from anndata import AnnData, read_mtx, read_text +from anndata import AnnData, read_text from h5py import File from PIL import Image -from scanpy import read_10x_h5 +from scanpy import read_10x_h5, read_10x_mtx from squidpy._constants._pkg_constants import Key from squidpy._utils import NDArrayA @@ -48,8 +48,8 @@ def _read_counts( if count_file.endswith((".csv", ".txt")): adata = read_text(path / count_file, **kwargs) - elif count_file.endswith(".mtx"): - adata = read_mtx(path / count_file, **kwargs) + elif count_file.endswith(".mtx.gz"): + adata = read_10x_mtx(path, **kwargs) else: raise NotImplementedError("TODO")