diff --git a/R/get_qsvs.R b/R/get_qsvs.R index 42088d5..aa28efa 100644 --- a/R/get_qsvs.R +++ b/R/get_qsvs.R @@ -15,16 +15,17 @@ #' qsv <- list(x = matrix(seq_len(9), ncol = 3)) #' get_qsvs(qsv, 2) get_qsvs <- function(qsvPCs, k) { - # check that k isn't zero - if (k <= 0 | k > ncol(qsvPCs$x)) { - stop(paste("k must between 1 and",ncol(qsvPCs$x))) - } # Validate qsvPCs is a prcomp object if (!is(qsvPCs, "prcomp")) { stop("qsvPCs must be a prcomp object.", call. = FALSE) } + # check that k isn't zero + if (k <= 0 | k > ncol(qsvPCs$x)) { + stop(paste("k must between 1 and",ncol(qsvPCs$x))) + } + qSVs <- qsvPCs$x[, seq_len(k), drop = FALSE] colnames(qSVs) <- paste0("qSV", seq_len(k)) return(qSVs)