From 145b0f6224dff31ff2916bc44ca2354ec44e5b60 Mon Sep 17 00:00:00 2001 From: lyangfan Date: Thu, 7 May 2026 16:51:00 +0800 Subject: [PATCH 1/2] Fix division-by-zero in filter.points causing density plot point loss 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. --- R/CMplot.r | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/CMplot.r b/R/CMplot.r index 20ad2c4..5826776 100644 --- a/R/CMplot.r +++ b/R/CMplot.r @@ -373,8 +373,10 @@ CMplot <- function( x_max <- max(x, na.rm=TRUE) y_min <- min(y, na.rm=TRUE) y_max <- max(y, na.rm=TRUE) - x_scaled <- ceiling((x - x_min) / (x_max - x_min) * w * dpi / scale) - y_scaled <- ceiling((y - y_min) / (y_max - y_min) * h * dpi / scale) + x_range <- x_max - x_min + y_range <- y_max - y_min + if(x_range == 0) x_scaled <- rep(0L, length(x)) else x_scaled <- ceiling((x - x_min) / x_range * w * dpi / scale) + if(y_range == 0) y_scaled <- rep(0L, length(y)) else y_scaled <- ceiling((y - y_min) / y_range * h * dpi / scale) key <- x_scaled * 1000000L + y_scaled !duplicated(key) } From cacb61a17b73cee053c42b6a8eaa0c49998baad3 Mon Sep 17 00:00:00 2001 From: lyangfan Date: Fri, 8 May 2026 04:16:31 +0800 Subject: [PATCH 2/2] Fix as.vector bug causing multi-traits mode to crash 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 --- R/CMplot.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/CMplot.r b/R/CMplot.r index 5826776..91b4869 100644 --- a/R/CMplot.r +++ b/R/CMplot.r @@ -1657,7 +1657,7 @@ CMplot <- function( # par(xpd=TRUE) } - pvalue <- as.vector(Pmap[,3:(R+2)]) + pvalue <- as.vector(unlist(Pmap[,3:(R+2)])) if(is.null(ylim)){ if(!is.null(threshold)){ if(LOG10){