immunogenomics / symphony

Efficient and precise single-cell reference atlas mapping with Symphony
GNU General Public License v3.0
95 stars 22 forks source link

calcPerClusterMappingMetric fails with singleton query_cluster_labels #39

Closed amcdavid closed 1 year ago

amcdavid commented 1 year ago
library(symphony)
# For the sake of an easy to get a `query` object
rmarkdown::render('vignettes/quickstart_tutorial.Rmd')
labels = sample(1:5, size = nrow(query$meta_data), replace = TRUE)
calcPerClusterMappingMetric(reference, query, query_cluster_labels = labels)

Calculating mapping confidence for 5 query clusters query_cluster distance_score 1 5 12.908458 2 3 2.888485 3 2 3.209513 4 1 36.630791 5 4 7.808481

calcPerClusterMappingMetric works with typical data.

labels_singleton = labels
labels_singleton[1] = 6
calcPerClusterMappingMetric(reference, query, query_cluster_labels = labels_singleton)

Calculating mapping confidence for 6 query clusters Error in base::rowMeans(x, na.rm = na.rm, dims = dims, ...) : 'x' must be an array of at least two dimensions

The PCA matrix is subset with an arbitrary index, and if the index has length one, R "helpfully" coerces it to a vector. Issue arises regardless of the value of u.

https://github.com/immunogenomics/symphony/blob/d9d50dc041e423bc175b9d48301d2b9121e423ab/R/confidenceScores.R#L83