FlowSOM::MetaClustering() throws an error for every method that isn't "metaClustering_consensus"
Closed this issue · 2 comments
In the current version, the FlowSOM::MetaClustering()
function throws an error unless the method
argument is set to "metaClustering_consensus". Here is a minimal reproducible example:
toy_data <-
data.frame(
marker_1 = runif(n = 100),
marker_2 = runif(n = 100),
marker_3 = runif(n = 100)
)
# this runs
FlowSOM::MetaClustering(
data = as.matrix(toy_data),
method = "metaClustering_consensus"
)
#> [1] 1 2 3 4 1 3 2 2 3 5 3 2 1 3 3 1 3 2 1 2 2 4 1 4 4 3 2 3 4 1 1 2 3 2 2 2 3
#> [38] 1 2 2 1 3 1 1 4 4 2 1 3 3 4 2 4 2 3 1 4 1 3 3 4 4 2 1 1 4 3 4 2 2 3 2 1 2
#> [75] 1 3 3 5 3 2 2 2 2 4 2 2 2 1 2 4 1 2 2 3 1 2 2 2 3 4
# this does not run
FlowSOM::MetaClustering(
data = as.matrix(toy_data),
method = "metaClustering_hclust"
)
#> Error in method(data, k = res, seed = seed): unused argument (seed = seed)
# this does not run
FlowSOM::MetaClustering(
data = as.matrix(toy_data),
method = "metaClustering_som"
)
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#>
#> Mapping data to SOM
#> Error in method(data, k = res, seed = seed): unused argument (seed = seed)
# this does not run
FlowSOM::MetaClustering(
data = as.matrix(toy_data),
method = "metaClustering_kmeans"
)
#> Error in method(data, k = res, seed = seed): unused argument (seed = seed)
To my eye, the reason for this issue is that the third line of the MetaClustering()
function calls the subroutines metaClustering_hclust
, metaClustering_kmeans
, and metaClustering_som
with the argument seed
, which is not included in any of their function definitions. The following change (or something like it) would fix the problem, though I don't think setting the seed for hierarchical clustering is strictly necessary because it does not involve randomness (I think...!):
metaClustering_hclust <-
function(data, k = 7, seed) {
set.seed(seed)
d <- stats::dist(data, method = "minkowski")
fit <- stats::hclust(d, method = "ward.D2")
stats::cutree(fit, k = k)
}
metaClustering_kmeans <-
function(data, k = 7, seed) {
set.seed(seed)
stats::kmeans(data, centers = k)$cluster
}
metaClustering_som <-
function(data, k = 7, seed) {
set.seed(seed)
s <- SOM(data ,xdim = k, ydim = 1, rlen = 100)
s$unit.classif
}
Hi,
We addressed this issue in the latest commit. Thank you for bringing this to our attention.
Let us know if you encounter any other issues.
Kind regards
The FlowSOM team
Awesome! Best of luck with future versions!