-
Notifications
You must be signed in to change notification settings - Fork 2
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
Bug in squidpy metrics computation #197
Comments
This will happen if the both the phenotypes you pass have identical values for all cells in the sample. I've updated SPT/spatialprofilingtoolbox/db/squidpy_metrics.py Lines 50 to 61 in 06a0f85
Note that the db function skips uploading a record when no co_occurence value is returned. We should consider replacing it with something like a NaN value to indicate that this value cannot be computed. Either way, this will need to be handled on the frontend. |
This bug was happening with neighborhood enrichment, not co-occurrence, and it happened when 2 distinct phenotypes were used. |
Also I would like to check that the production instance no longer exhibits this issue before we close. |
This was part way resolved by changes made since the original issue (the warning does appear) , but the current behavior is still pretty much the same. If this 1-cluster issue is encountered during computation of a feature, the error causes no further computations to proceed, and the feature is permanently in a pending computation state. |
Fixed by Now when this issue is encountered it is logged, ...
11-16 21:52:00 [ DEBUG ] ondemand.providers.squidpy_provider:172: Computed feature value of 2: Mold_61_0, 0.08425675935957183
11-16 21:52:01 [ DEBUG ] ondemand.providers.squidpy_provider:172: Computed feature value of 2: Mold_62_0, 0.9999999999983203
11-16 21:52:01 [ DEBUG ] ondemand.providers.squidpy_provider:172: Computed feature value of 2: Mold_63_0, 1.9636129412073801e-90
/usr/local/lib/python3.11/site-packages/spatialprofilingtoolbox/workflow/common/squidpy.py:158: UserWarning: All phenotypes provided had identical values. Only one cluster could be made.
warn('All phenotypes provided had identical values. Only one cluster could be made.')
11-16 21:52:01 [ ERROR ] workflow.common.squidpy:57: Got 1 cluster, need 2 to compute neighborhood enrichment. Presuming null.
11-16 21:52:01 [ DEBUG ] ondemand.providers.squidpy_provider:172: Computed feature value of 2: Mold_64_0, None
11-16 21:52:01 [ DEBUG ] ondemand.providers.squidpy_provider:172: Computed feature value of 2: Mold_65_0, 0.9993631557868359
11-16 21:52:01 [ DEBUG ] ondemand.providers.squidpy_provider:172: Computed feature value of 2: Mold_66_0, 0.9282621463508228
... |
There is a possibility that the number of "clusters" in the AnnData object we create and pass to squidpy functions is sometimes 1 and not 2, as expected. Here is a relevant error log:
The usage that triggered this was a request for the neighborhood enrichment metric with a certain pair of phenotypes on the Moldoveanu dataset. Here is the HTTP request:
The text was updated successfully, but these errors were encountered: