@@ -33,7 +33,10 @@ def _filter_genes(df: pd.DataFrame, remove_features: Collection[str]) -> pd.Data
3333
3434
3535def read_Xenium (
36- filepath : str | os .PathLike , * , remove_features : Collection [str ] = XENIUM_CTRLS
36+ filepath : str | os .PathLike ,
37+ * ,
38+ min_qv : float | None = None ,
39+ remove_features : Collection [str ] = XENIUM_CTRLS ,
3740) -> pd .DataFrame :
3841 """
3942 Read a Xenium transcripts file.
@@ -42,6 +45,9 @@ def read_Xenium(
4245 ----------
4346 filepath : os.PathLike or str
4447 Path to the Xenium transcripts file. Both, .csv.gz and .parquet files, are supported.
48+ min_qv : float | None, optional
49+ Minimum Phred-scaled quality value (Q-Score) of a transcript to be included.
50+ If `None` no filtering is performed.
4551 remove_features : collections.abc.Collection[str], optional
4652 List of regex patterns to filter the 'feature_name' column,
4753 :py:attr:`ovrlpy.io.XENIUM_CTRLS` by default.
@@ -53,6 +59,9 @@ def read_Xenium(
5359 filepath = Path (filepath )
5460 columns = list (_XENIUM_COLUMNS .keys ())
5561
62+ if min_qv is not None :
63+ columns .append ("qv" )
64+
5665 if filepath .suffix == ".parquet" :
5766 transcripts = pd .read_parquet (filepath , columns = columns )
5867 transcripts ["feature_name" ] = transcripts ["feature_name" ].astype ("category" )
@@ -72,6 +81,9 @@ def read_Xenium(
7281 else :
7382 transcripts = pd .read_csv (filepath , usecols = columns , dtype = {"gene" : "category" })
7483
84+ if min_qv is not None :
85+ transcripts = transcripts .loc [transcripts ["qv" ] >= min_qv ].drop (columns = "qv" )
86+
7587 transcripts = transcripts .rename (columns = _XENIUM_COLUMNS )
7688 transcripts = _filter_genes (transcripts , remove_features )
7789
0 commit comments