Skip to content

Commit 59d55ba

Browse files
improved the check on raw counts in input
1 parent 68b68aa commit 59d55ba

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/mintflow/interface/module_setup_data.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ def _func_doeshave_isolated_nodes_inneighgraph(adata_input:anndata.AnnData):
129129

130130
return number_of_isolated_nodes > 0, number_of_isolated_nodes
131131

132+
def _check_raw_counts(X):
133+
assert sparse.issparse(X)
134+
return np.allclose(
135+
X.data,
136+
np.floor(X.data)
137+
)
138+
132139
def setup_data(
133140
dict_all4_configs,
134141
flag_verbose=True,
@@ -165,9 +172,9 @@ def setup_data(
165172
)
166173
)
167174

168-
if not sc._utils.check_nonnegative_integers(adata_temp.X): # grabbed from https://github.com/scverse/scanpy/blob/0cfd0224f8b0a90317b0f1a61562f62eea2c2927/src/scanpy/preprocessing/_highly_variable_genes.py#L74
175+
if not _check_raw_counts(adata_temp.X): #sc._utils.check_nonnegative_integers(adata_temp.X): # grabbed from https://github.com/scverse/scanpy/blob/0cfd0224f8b0a90317b0f1a61562f62eea2c2927/src/scanpy/preprocessing/_highly_variable_genes.py#L74
169176
raise Exception(
170-
"Inflow requires count data, but the anndata in {} seems to have non-count values in adata.X".format(
177+
"MintFlow requires that `adata.X` contains raw counts, but the anndata in {} seems to have non-count values in `adata.X`".format(
171178
fname_adata_temp
172179
)
173180
)

0 commit comments

Comments
 (0)