Skip to content

Commit a45c0c0

Browse files
committed
Bugfix to FindClustersAndDimRedux
1 parent 16e9682 commit a45c0c0

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

singlecell/resources/chunks/FindClustersAndDimRedux.R

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,26 @@ if (!reticulate::py_module_available(module = 'leidenalg')) {
1515
}
1616
}
1717

18+
if (all(is.null(clusterResolutions)) || clusterResolutions == '') {
19+
clusterResolutions <- c(0.2, 0.4, 0.6, 0.8, 1.2)
20+
} else if (is.character(clusterResolutions)) {
21+
clusterResolutionsOrig <- clusterResolutions
22+
clusterResolutions <- gsub(clusterResolutions, pattern = ' ', replacement = '')
23+
clusterResolutions <- unlist(strsplit(clusterResolutions, split = ','))
24+
clusterResolutions <- as.numeric(clusterResolutions)
25+
if (any(is.na(clusterResolutions))) {
26+
stop(paste0('Some values for clusterResolutions were not numeric: ', clusterResolutionsOrig))
27+
}
28+
else if (is.numeric(clusterResolutions)) {
29+
# No action needed
30+
} else {
31+
stop('Must provide a value for clusterResolutions')
32+
}
33+
1834
for (datasetId in names(seuratObjects)) {
1935
printName(datasetId)
2036
seuratObj <- readSeuratRDS(seuratObjects[[datasetId]])
2137

22-
if (all(is.null(clusterResolutions)) || clusterResolutions == '') {
23-
clusterResolutions <- c(0.2, 0.4, 0.6, 0.8, 1.2)
24-
} else if (is.character(clusterResolutions)) {
25-
clusterResolutionsOrig <- clusterResolutions
26-
clusterResolutions <- gsub(clusterResolutions, pattern = ' ', replacement = '')
27-
clusterResolutions <- unlist(strsplit(clusterResolutions, split = ','))
28-
clusterResolutions <- as.numeric(clusterResolutions)
29-
if (any(is.na(clusterResolutions))) {
30-
stop(paste0('Some values for clusterResolutions were not numeric: ', clusterResolutionsOrig))
31-
}
32-
} else {
33-
stop('Must provide a value for clusterResolutions')
34-
}
35-
3638
seuratObj <- CellMembrane::FindClustersAndDimRedux(seuratObj, minDimsToUse = minDimsToUse, useLeiden = useLeiden, clusterResolutions = clusterResolutions)
3739

3840
saveData(seuratObj, datasetId)

0 commit comments

Comments
 (0)