Skip to content

Commit 43baac1

Browse files
committed
fix bug about CompressedCharacterList (revert)
1 parent 69d2bf8 commit 43baac1

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

R/bambu.R

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -264,27 +264,34 @@ bambu <- function(reads, annotations = NULL, genome = NULL, NDR = NULL,
264264
ColNames <- c()
265265
for(i in seq_along(quantData)){
266266
quantData_i <- quantData[[i]]
267+
#load in the barcode clustering from file if provided
268+
iter <- seq_len(ncol(metadata(quantData_i)$countMatrix)) # iter is integer
267269
if(!is.null(clusters)){
268-
if(class(clusters[[i]])!="CompressedCharacterList"){ # !is.list(clusters) is FALSE for CompressedCharacterList
269-
clusterMaps <- NULL
270-
for(j in seq_along(metadata(quantData_i)$sampleNames)){ #load in a file per sample name provided
271-
clusterMap <- fread(clusters[[j]], header = FALSE,
272-
data.table = FALSE)
273-
# read.table(clusters[[j]],
274-
# sep = ifelse(grepl(".tsv$",clusters[[j]]), "\t", ","),
275-
# header = FALSE)
276-
clusterMap[,1] <- paste0(metadata(quantData_i)$sampleNames[j],
277-
"_",clusterMap[,1])
278-
clusterMaps <- rbind(clusterMaps, clusterMap)
279-
}
280-
clustering <- splitAsList(clusterMaps[,1], clusterMaps[,2])
281-
rm(clusterMaps)
282-
rm(clusterMap)
283-
iter <- clustering
284-
285-
} else{
286-
iter <- clusters[[i]]
270+
if(class(clusters[[i]])!="CompressedCharacterList"){ # !is.list(clusters) is FALSE for CompressedCharacterList
271+
clusterMaps <- NULL
272+
for(j in seq_along(metadata(quantData_i)$sampleNames)){ #load in a file per sample name provided
273+
clusterMap <- fread(clusters[[j]], header = FALSE,
274+
data.table = FALSE)
275+
# read.table(clusters[[j]],
276+
# sep = ifelse(grepl(".tsv$",clusters[[j]]), "\t", ","),
277+
# header = FALSE)
278+
clusterMap[,1] <- paste0(metadata(quantData_i)$sampleNames[j],
279+
"_",clusterMap[,1])
280+
clusterMaps <- rbind(clusterMaps, clusterMap)
281+
}
282+
clustering <- splitAsList(clusterMaps[,1], clusterMaps[,2])
283+
rm(clusterMaps)
284+
rm(clusterMap)
285+
iter <- clustering
286+
287+
} else{ #if clusters is a list
288+
if(length(quantData)>1){
289+
iter <- clusters[[i]] #lowMemory mode
290+
}else{
291+
iter <- clusters#do.call(c,clusters)
287292
}
293+
}
294+
}
288295
countsSeCompressed <- bplapply(iter, FUN = function(j){ # previous i changed to j to avoid duplicated assignment
289296
#i = iter[i %in% colnames(metadata(quantData_i)$countMatrix)] #bug, after assignment, i become emptyprint(i)
290297
countMatrix <- unname(metadata(quantData_i)$countMatrix[,j]) # same here
@@ -324,5 +331,4 @@ bambu <- function(reads, annotations = NULL, genome = NULL, NDR = NULL,
324331
colnames(countsSe) <- ColData[,1]
325332
return(countsSe)
326333
}
327-
}
328-
}
334+
}

0 commit comments

Comments
 (0)