Fix division-by-zero in filter.points & as.vector regression in multi-traits#153
Open
lyangfan wants to merge 2 commits intoYinLiLin:masterfrom
Open
Fix division-by-zero in filter.points & as.vector regression in multi-traits#153lyangfan wants to merge 2 commits intoYinLiLin:masterfrom
lyangfan wants to merge 2 commits intoYinLiLin:masterfrom
Conversation
In the density plot, filter.points is called with a constant y value (per-chromosome band position), making y_max - y_min = 0. This causes 0/0 = NaN, collapsing all keys to NaN and making duplicated() keep only the first point per group. The result is severe point loss in density plots. Fix: check for zero range before division; assign 0L to scaled values when range is 0, preserving correct point filtering behavior.
as.vector() on a multi-column data.frame does not flatten it to a numeric vector, causing min() to fail with "invalid type (list)". Use unlist() first. Bug existed since upstream (2023-06-28). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
1. Fix division-by-zero in
filter.pointscausing density plot point lossfilter.pointsis called with constant y values in density rendering. Wheny_range == 0,(y - y_min) / (y_max - y_min)produces0/0 = NaN. R'sduplicated()treats the firstNaNas unique and all subsequent as duplicates, collapsing the entire density bar to a single pixel.Reproduce:
2. Fix
as.vectorregression in multi-traits modeThe optimization commit (23905fc) removed
Pmap <- as.matrix(Pmap)to keep Pmap as data.frame for performance. However,as.vector(Pmap[,3:(R+2)])in the multi-traits section relies on Pmap being a matrix —as.vector()on a data.frame (which is a list) returns it unchanged. Subsequentmin_no_na(pvalue)→min(list, na.rm=TRUE)crashes.Reproduce:
🤖 Generated with Claude Code