From 31d9c116e59f068f6b0783f9e9d970701ec162d0 Mon Sep 17 00:00:00 2001 From: Owen Chapman Date: Tue, 1 Oct 2019 20:34:54 -0700 Subject: [PATCH] Bugfix for control set of 1 sample cor returns numeric if 1x1, matrix otherwise. Numeric is not indexable, get `Error in cor(query@intensity[p, ], ref@intensity[p, ])[1, ] : incorrect number of dimensions` --- R/process.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/process.R b/R/process.R index b19aac3..6f60f75 100644 --- a/R/process.R +++ b/R/process.R @@ -72,7 +72,13 @@ setMethod("CNV.fit", signature(query = "CNV.data", ref = "CNV.data", anno = "CNV } object@anno <- anno - r <- cor(query@intensity[p, ], ref@intensity[p, ])[1, ] < 0.99 + r <- cor(query@intensity[p, ], ref@intensity[p, ]) + # cor returns numeric if 1x1, matrix otherwise... + if (!is.matrix(r)){ + r <- as.matrix(r) + colnames(r) <- colnames(ref@intensity) + } + r <- r[1, ] < 0.99 if (any(!r)) message("query sample seems to also be in the reference set. not used for fit.") if (intercept) { ref.fit <- lm(y ~ ., data = data.frame(y = query@intensity[p,