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

Don't fail when KDE bandwidth is 0 #3

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

daemontus
Copy link

@daemontus daemontus commented Jan 7, 2025

Hi! This is the other error I was running into (the one due to which I originally decided to split the computation to individual genes, which lead me to discover the first reported error).

This one is pretty straightforward: when the data is "too simple", the KDE estimator is failing because the automatically selected bandwidth is zero. These genes are otherwise uninteresting (they get binarized to NaN anyway as ZeroInf; maybe Discareded would be even more appropriate here), but it's hard to filter them out beforehand. I originally used a "at least X non-zero samples" criterion to avoid this issue, but here X should ideally depend on the number and variance of observations overall and I couldn't figure out a formula that was reliable enough to always remove all problematic genes.

Hence, in this PR, I try to compute the bandwidth (using the same method) before using the KDE estimator itself. If it fails, I print a warning and return NaN, otherwise everything works as usual. Hopefully this should only impact very low-quality genes anyway. The main reason for fixing this is to avoid failing a large computation when only one or two genes are problematic (and having to search for these genes through other means).

(Also: I am branching off of PR #2, since I need the single-gene bug fixed in order for my test to work, but otherwise these should be two separate things)

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

Successfully merging this pull request may close these issues.

1 participant