Skip to content

Conversation

@ilia-kats
Copy link
Collaborator

  • make it match the R reference implementation
  • implement some options that are present in the R reference implementations but were missing here

@ilia-kats ilia-kats requested a review from gtca August 15, 2025 14:36
@ilia-kats ilia-kats requested a review from ilan-gold October 9, 2025 16:09
Copy link
Contributor

@ilan-gold ilan-gold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small things, but nice1


if denoise_counts:
bgmeans = np.empty(cells_scaled.shape[0], np.float32)
bgmeans = np.empty(cells_scaled.shape[0], cells_scaled.dtype)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we making the bgmeans the same dtype as the input? It looks like bgmeans is filled in with mean values - why not just set it to float64? It seems like you'd have the same type-loss problem as with ints then

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At that point, cells_scaled will always be a float. If it's float32, then the GaussianMixture results will also be float32, so no need to waste memory by using a dtype that is too large.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, I can move the castback to the very bottom of the function, so we do all our calculations in float64 and only cast back the result if the input was float32.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, ok you're right!


if denoise_counts:
bgmeans = np.empty(cells_scaled.shape[0], np.float32)
bgmeans = np.empty(cells_scaled.shape[0], cells_scaled.dtype)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, ok you're right!

@ilia-kats ilia-kats merged commit f03eb69 into scverse:main Oct 22, 2025
3 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.

2 participants