Repository navigation
Keep genes whose positive counts are all 1 in poscounts size factors - #494
Open
MMatinGerami wants to merge 1 commit into
Open
MMatinGerami wants to merge 1 commit into
MMatinGerami wants to merge 1 commit into
Conversation
The poscounts filter kept genes with logmeans > 0, where logmeans is the mean of log counts over all samples with zeros contributing 0. A gene whose positive counts are all 1 has logmeans exactly 0 and was dropped, although the docstring says only all-zero genes are excluded and DESeq2's geoMeanNZ keeps it. Filter on genes with at least one positive count instead. Add a test on a small count matrix whose expected size factors come from DESeq2 1.52.0 estimateSizeFactors(type = "poscounts"). Refs scverse#491 (bug 6).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issue or PRs
Refs #491 (bug 6 only: "poscounts size factors leave out genes whose positive counts are all 1").
What does your PR implement? Be specific.
DeseqDataSet.fit_size_factors("poscounts")filtered usable genes with(~np.isinf(logmeans)) & (logmeans > 0).logmeansis the mean oflog(count)over all samples with zeros contributing 0, so a gene whose positive counts are all 1 haslogmeans == 0and was dropped from the median. The docstring says the method "will only exclude genes which have all-0 values", and DESeq2'sgeoMeanNZkeeps such genes (estimateSizeFactorsForMatrixfilters onis.finite(loggeomeans) & cnts > 0). These genes are common in the sparse single-cell and metagenomic data that poscounts is meant for, and their omission shifts every size factor.The filter is now
(self.X > 0).any(axis=0), which keeps every gene with at least one positive count. All-zero genes are still excluded, and the values on the existingr_test_size_factors_poscount.csvfixture are unchanged.A test on a 4 x 6 count matrix with one such gene checks the size factors against DESeq2 1.52.0
estimateSizeFactors(type = "poscounts"), with and without that gene; it fails onmainand passes with this change.pytest testspasses (66 tests), ruff and mypy are clean.LLM usage: Claude Code (Anthropic) helped draft the patch and test; I reviewed, ran and verified every changed line locally.