Skip to content

Commit f1bf398

Browse files
committed
Allow use to specify clusterResolutions
1 parent a9fb5b0 commit f1bf398

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

singlecell/resources/chunks/FindClustersAndDimRedux.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@ for (datasetId in names(seuratObjects)) {
1919
printName(datasetId)
2020
seuratObj <- readSeuratRDS(seuratObjects[[datasetId]])
2121

22-
seuratObj <- CellMembrane::FindClustersAndDimRedux(seuratObj, minDimsToUse = minDimsToUse, useLeiden = useLeiden)
22+
if (all(is.null(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+
36+
seuratObj <- CellMembrane::FindClustersAndDimRedux(seuratObj, minDimsToUse = minDimsToUse, useLeiden = useLeiden, clusterResolutions = clusterResolutions)
2337

2438
saveData(seuratObj, datasetId)
2539

singlecell/src/org/labkey/singlecell/pipeline/singlecell/FindClustersAndDimRedux.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ public Provider()
2727
}}, 15),
2828
SeuratToolParameter.create("useLeiden", "Use Leiden Clustering", "If true, FindClusters() will use algorith=4 (leiden), as opposed to the default (louvain)", "checkbox", new JSONObject(){{
2929

30-
}}, false)
31-
), null, null);
30+
}}, false),
31+
SeuratToolParameter.create("clusterResolutions", "Cluster Resolutions", "A comma-separated list of resolution. If blank, it will default to 0.2, 0.4, 0.6, 0.8, 1.2", "textfield", null, null)
32+
), null, "0.2,0.4,0.6,0.8,1.2");
3233
}
3334

3435

0 commit comments

Comments
 (0)