Skip to content

Commit

Permalink
Bugfix to MergeSeurat
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber committed Jan 31, 2025
1 parent d8a8d9a commit cde358a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions singlecell/resources/chunks/MergeSeurat.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ mergeBatch <- function(seuratObjects, outerBatchIdx, maxBatchSize = 20, maxInput

# Phase 1: group into batches:
batchList <- list()
activeBatch <- c()
activeBatch <- list()
sizeOfBatch <- 0
batchIdx <- 1
for (datasetId in names(seuratObjects)) {
activeBatch <- c(activeBatch, seuratObjects[[datasetId]])
activeBatch[[datasetId]] <- seuratObjects[[datasetId]]
sizeInMb <- (file.size(seuratObjects[[datasetId]]) / 1024^2)
sizeOfBatch <- sizeOfBatch + sizeInMb

if (length(activeBatch) >= maxBatchSize || (sizeOfBatch >= maxInputFileSizeMb && length(activeBatch) > 1)) {
logger::log_info(paste0('adding to batch with ', length(activeBatch), ' files and ', sizeOfBatch, 'MB'))
batchList[batchIdx] <- activeBatch
activeBatch <- c()
logger::log_info(paste0('adding to batch with ', length(activeBatch), ' files and ', sizeOfBatch, ' MB'))
batchList[[batchIdx]] <- activeBatch
activeBatch <- list()
sizeOfBatch <- 0
batchIdx <- batchIdx + 1
next
Expand All @@ -76,8 +76,8 @@ mergeBatch <- function(seuratObjects, outerBatchIdx, maxBatchSize = 20, maxInput

# Account for final files:
if (length(activeBatch) > 0) {
logger::log_info(paste0('finalizing batch with ', length(activeBatch), ' files and ', sizeOfBatch, 'MB'))
batchList[batchIdx] <- activeBatch
logger::log_info(paste0('finalizing batch with ', length(activeBatch), ' files and ', sizeOfBatch, ' MB'))
batchList[[batchIdx]] <- activeBatch
}

if (length(batchList) == 0){
Expand Down

0 comments on commit cde358a

Please sign in to comment.