Skip to content

Commit

Permalink
Hard code np.log1p(10000)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuanXu1 committed Sep 22, 2023
1 parent dd7e6a5 commit 0fbf8d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions celltypist/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def __init__(self, filename: Union[AnnData,str] = "", model: Union[Model,str] =
elif isinstance(filename, AnnData) or (isinstance(filename, str) and filename.endswith('.h5ad')):
self.adata = sc.read(filename) if isinstance(filename, str) else filename
self.adata.var_names_make_unique()
if (self.adata.X[:1000].min() < 0) or (self.adata.X[:1000].max() > np.log1p(10000)):
if (self.adata.X[:1000].min() < 0) or (self.adata.X[:1000].max() > 9.22):
logger.info("👀 Invalid expression matrix in `.X`, expect log1p normalized expression to 10000 counts per cell; will try the `.raw` attribute")
try:
self.indata = self.adata.raw.X
Expand All @@ -310,7 +310,7 @@ def __init__(self, filename: Union[AnnData,str] = "", model: Union[Model,str] =
except Exception as e:
raise Exception(
f"🛑 Fail to use the `.raw` attribute in the input object. {e}")
if (self.indata[:1000].min() < 0) or (self.indata[:1000].max() > np.log1p(10000)):
if (self.indata[:1000].min() < 0) or (self.indata[:1000].max() > 9.22):
raise ValueError(
"🛑 Invalid expression matrix in both `.X` and `.raw.X`, expect log1p normalized expression to 10000 counts per cell")
else:
Expand Down

0 comments on commit 0fbf8d9

Please sign in to comment.