Fixed issues with chunking and iterating
authorPaul Hoffman <phoffman@nygenome.org>
Thu, 9 Nov 2017 18:27:23 +0000 (13:27 -0500)
committerPaul Hoffman <phoffman@nygenome.org>
Thu, 9 Nov 2017 18:27:23 +0000 (13:27 -0500)
R/loom.R

index 224434622874a8965825843f84176042cef6f478..8bbbca98afb7e0d9fc694de76caed272268eadfd 100644 (file)
--- a/R/loom.R
+++ b/R/loom.R
@@ -414,8 +414,8 @@ loom <- R6Class(
         chunk.data <- if (dataset.matrix) {
           switch(
             EXPR = MARGIN,
-            '1' = self[[dataset.use]][, chunk.indices],
-            '2' = self[[dataset.use]][chunk.indices, ]
+            '1' = self[[dataset.use]][, chunk.indices], # Chunk genes
+            '2' = self[[dataset.use]][chunk.indices, ] # Chunk cells
           )
         } else {
           self[[private$iter.datset]][chunk.indices]
@@ -522,8 +522,8 @@ loom <- R6Class(
         chunk.data <- if (dataset.matrix) {
           switch(
             EXPR = MARGIN,
-            '1' = self[[dataset.use]][chunk.indices, ],
-            '2' = self[[dataset.use]][, chunk.indices]
+            '1' = self[[dataset.use]][, chunk.indices], # Chunk genes
+            '2' = self[[dataset.use]][chunk.indices, ] # Chunk cells
           )
         } else {
           self[[dataset.use]][chunk.indices]
@@ -645,7 +645,7 @@ loom <- R6Class(
       }
       # Ensure the indices provided fit within the range of the dataset
       index.use[1] <- max(1, index.use[1])
-      index.use[2] <- min(index.use[2], self$shape[private$iter.margin])
+      index.use[2] <- min(index.use[2], rev(x = self$shape)[private$iter.margin])
       # Ensure that index.use[1] is greater than index.use[2]
       if (index.use[1] > index.use[2]) {
         stop(paste0(