From 89f00738caa58ed2cfc8a2f4a06d6293b1227c0d Mon Sep 17 00:00:00 2001 From: Vincent LAVILLE <vincent.laville@pasteur.fr> Date: Fri, 11 Jan 2019 12:38:03 +0100 Subject: [PATCH] Update correlationMatrix.R - Handling NAs --- R/correlationMatrix.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/R/correlationMatrix.R b/R/correlationMatrix.R index f58a981..fd6a9cd 100644 --- a/R/correlationMatrix.R +++ b/R/correlationMatrix.R @@ -147,6 +147,18 @@ getGenoCorMatrix <- function(lrsid, lchr, lpos, lrefall, pop, path = NULL, web = testMat <- testMat[-to_remove, ] genoMap <- genoMap[-to_remove,] } + to_remove <- NULL + for (i in 1:length(lrsid)) { + if (!(lrsid[i] %in% rownames(testMat))) { + to_remove <- c(to_remove, i) + } + } + if (!is.null(to_remove)) { + lrsid <- lrsid[-to_remove] + lpos <- lpos[-to_remove] + lchr <- lchr[-to_remove] + lrefall <- lrefall[-to_remove] + } testMat <- changeCoding(testMat, as.character(lrefall) == genoMap$REF) colnames(testMat) <- lind cormat = stats::cor(t(testMat)) -- GitLab