From 0fd3b4c8125102c3e4f090f1eac94b9705a5f8b3 Mon Sep 17 00:00:00 2001 From: Arsham Mikaeili Namini <92790984+Arshammik@users.noreply.github.com> Date: Sun, 16 Nov 2025 04:18:14 -0500 Subject: [PATCH] Fix integer overflow in sigma2 initialization for large datasets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert N and J to numeric before multiplication to prevent overflow when N * J exceeds 2^31-1 (e.g., 4M cells × 20K genes = 80B). --- DESCRIPTION | 4 ++-- R/gedi_class.R | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4ce9ea0..acfcff5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: gedi Type: Package Title: Gene Expression Data Integration -Version: 2.2.8 -Date: 2025-10-13 +Version: 2.2.9 +Date: 2025-11-16 Authors@R: c( person("Arsham", "Mikaeili Namini", email = "arsham.mikaeilinamini@mail.mcgill.ca", role = c("aut", "cre")), person("Hamed", "S.Najafabadi", email = "hamed.najafabadi@mcgill.ca", role = c("aut")) diff --git a/R/gedi_class.R b/R/gedi_class.R index ec4a53f..27a568b 100644 --- a/R/gedi_class.R +++ b/R/gedi_class.R @@ -297,7 +297,8 @@ GEDI <- R6Class( # Initialize sigma2_0 if (obs_type != "X") { Yp_full <- Y_log_dense - VecVecProduct(J_vec, s_0) - o_0 - sigma2_0 <- sum(Yp_full^2) / (N * J + 1) + # Fix integer overflow: convert N and J to numeric before multiplication + sigma2_0 <- sum(Yp_full^2) / (as.numeric(N) * as.numeric(J) + 1) } else { sigma2_0 <- 1 }