From 3691bc9bece0bd6c55e0c98aef0f819fee05b4be Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Tue, 2 Dec 2025 10:38:24 +0100 Subject: [PATCH 1/2] Set chrX median counts to NA if gender is unknown NULL doesn't have a dimension, while NA is a vector of length 1 If this is not done, building a PoN with data missing sex chromosomes will fail, because the code will try to bind NA (with dimensions) with NULL (no dimension), leading to a hard-to-debug-message --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 318e589..bf64931 100644 --- a/R/utils.R +++ b/R/utils.R @@ -251,7 +251,7 @@ getGender <- function(rawReads, normReads, gc, map, fracReadsInChrYForMale = 0.0 }else{ gender <- "unknown" # chrX is not provided chrYCov <- NA - chrXMedian <- NULL + chrXMedian <- NA } return(list(gender=gender, chrYCovRatio=chrYCov, chrXMedian=chrXMedian)) } From 54e5fd9c5a22b4ba4239c295c08eff6419e70e83 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Tue, 2 Dec 2025 10:44:36 +0100 Subject: [PATCH 2/2] Adjust uses of counts so that they can take account also being NA --- R/output.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/output.R b/R/output.R index ed50670..f142bd7 100644 --- a/R/output.R +++ b/R/output.R @@ -108,11 +108,11 @@ outputParametersToFile <- function(hmmResults, file){ write.table(paste0("Coverage:\t", coverage), file = fc, col.names = FALSE, row.names = FALSE, quote = FALSE, sep = "\t") - if (!is.null(x$chrYCov)){ + if (!is.null(x$chrYCov) || !is.na(x$chrYCov)){ write.table(paste0("ChrY coverage fraction:\t", signif(x$chrYCov[s], digits = 4)), file = fc, col.names = FALSE, row.names = FALSE, quote = FALSE, sep = "\t") } - if (!is.null(x$chrXMedian)){ + if (!is.null(x$chrXMedian) || !is.na(x$chrXMedian)){ write.table(paste0("ChrX median log ratio:\t", signif(x$chrXMedian[s], digits = 4)), file = fc, col.names = FALSE, row.names = FALSE, quote = FALSE, sep = "\t") }