Automatically sort index.use in apply
authorPaul Hoffman <phoffman@nygenome.org>
Tue, 27 Mar 2018 15:12:58 +0000 (11:12 -0400)
committerPaul Hoffman <phoffman@nygenome.org>
Tue, 27 Mar 2018 15:12:58 +0000 (11:12 -0400)
R/loom.R

index e15ac77311d198e90ee9b92a595b0c8925d9ee07..355b7c0b22c4eeecea08dc6732104aabb1f21ddc 100644 (file)
--- a/R/loom.R
+++ b/R/loom.R
@@ -720,6 +720,7 @@ loom <- R6Class(
         index.use <- 1:self$shape[MARGIN]
       } else {
         # Filter index.use to values between 1 and self$shape[MARGIN]
+        index.use <- sort(x = index.use)
         index.use <- as.integer(x = index.use)
         index.use[index.use >= 1 & index.use <= self$shape[MARGIN]]
         index.use <- as.vector(x = na.omit(object = index.use))
@@ -728,7 +729,7 @@ loom <- R6Class(
 
         } else {
           warning("No values passed to 'index.use' fall within the data, using all values")
-          index.use <- NULL
+          index.use <- 1:self$shape[MARGIN]
         }
       }
       # Trial to get class of new dataset