Skip to content

Conversation

@jsicherman
Copy link
Collaborator

@jsicherman jsicherman commented Dec 10, 2024

Performs both a weighted (by score) KDE and an unweighted KDE on the cell coordinates, and computes their ratio across a grid of n_bins x n_bins. This results in much smoother score estimates across the tissue. Addresses #7

Remaining work:

  • Implement a way to evaluate the estimator at cell coordinates/neighborhoods
  • Convert to smooth image mask for region exclusion (could also be done in a follow on PR)... Are there geometric properties of these masks which could be used to estimate something about the type of failure?

Binned:
image

Using estimator:
image

Different dataset, binned:
image

Using estimator:
image

Sampled atop cells:
image

As a mask (thresholding at the 70th percentile):
image

@berl
Copy link
Collaborator

berl commented Dec 10, 2024

transcribing from our slack conversation:
pretty sure KDE on its own was the wrong idea. However, it seems like a weighted KDE divided by a non-weighted KDE would give a “kernel-mean-estimator” which is what I was envisioning: a kernel weighted mean value of nearby expression ratios

there is probably a name and package for this. note that the scikit-learn KDE has a ball tree under the hood, so (edit: speed) comparison of this to a nearest-neighbors approach may be a wash. one nice thing about the sklearn KDE is that they have few different kernels that can speed up computation

@Margery0011 Margery0011 marked this pull request as ready for review December 11, 2024 17:24
@jsicherman jsicherman changed the title [WIP]: use a KDE for smooth scores over tissue area feat: use a KDE for smooth scores over tissue area Dec 11, 2024
@berl
Copy link
Collaborator

berl commented Dec 12, 2024

I'm excited to get this in! I added back the fixed range for the z-score plot. comparing the KDE to the binned version shows some differences that I'll add another issue for figuring this out:
image

@berl berl merged commit edfe680 into main Dec 12, 2024
4 checks passed
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.

3 participants