Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potentially misleading error when counts are not in expected range #89

Closed
padix-key opened this issue Oct 4, 2023 · 3 comments
Closed

Comments

@padix-key
Copy link

If the count matrix is not log1p normalized to a maximum of 10000, Celltypist resorts to adata.raw.X instead of adata.X.

In my case adata.raw is not populated at all, so instead of hinting to the the unexpected counts, Celltypist raises

Exception: 🛑 Fail to use the `.raw` attribute in the input object. 'NoneType' object has no attribute 'X'

I would suggest adding an optional parameter, e.g. enforce_x, allow_raw_counts or something like that,
that converts the log message

"👀 Invalid expression matrix in `.X`, expect log1p normalized expression to 10000 counts per cell; will try the `.raw` attribute")

into an exception.

@padix-key padix-key changed the title Misleading error when counts are not in expected range Potentially misleading error when counts are not in expected range Oct 4, 2023
@ChuanXu1
Copy link
Collaborator

ChuanXu1 commented Oct 6, 2023

@padix-key, CellTypist first tries adata.X and if its format is met, it will predict cell types accordingly. If adata.X does not suffice, CellTypist will resort to adata.raw.X to see whether adata.raw.X works. If both do not work, an error will be raised. Please let me know whether it is clear to you.

@padix-key
Copy link
Author

padix-key commented Oct 23, 2023

Sorry for the late response. After source code inspection I also found this behavior and I think it is generally fine. However, in my opinion the error message does not convey the actual problem: If I have an AnnData with X but without raw, the problem is that X is not properly normalized, not that AnnData.raw is None.

ChuanXu1 added a commit that referenced this issue Oct 29, 2023
@ChuanXu1
Copy link
Collaborator

@padix-key, error messages have been redesigned 42c2c1c
These new error messages will be available in the next version.
I will close the issue and please reopen it if you have further questions or suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants