diff --git a/R/correlationMatrix.R b/R/correlationMatrix.R
index f58a981e60ee9768cfa7a7cedff10be0afd1ff59..fd6a9cd486357af1fcc097c1ad92f06d97073422 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))