Skip to content

Commit

Permalink
get label centers for milo
Browse files Browse the repository at this point in the history
  • Loading branch information
mjz1 committed Jul 2, 2024
1 parent ef7cc7e commit bd8df13
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Replace `add_gc_cor`, `segment_cnv`, and `merge_segments` parallel backend to use `BiocParallel`
* Added `segment=FALSE` as default
* `get_label_centers` works with `Milo` objects
* Minor bugfixes


Expand Down
2 changes: 1 addition & 1 deletion R/plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ my_dens <- function(data, mapping, center_point = 0, ...) {
get_label_centers <- function(obj, group_var = "clusters", reduced_dim = "UMAP") {
# To any scatter of a umap can add + geom_label_repel(data = get_label_centers(sce), aes(x = x, y = y, label = clusters))

if ("SingleCellExperiment" %in% class(obj)) {
if (class(obj) %in% c("SingleCellExperiment", "Milo")) {
x_means <- lapply(split(reducedDim(obj, reduced_dim)[, 1], obj[[group_var]]), mean) %>% unlist()
y_means <- lapply(split(reducedDim(obj, reduced_dim)[, 2], obj[[group_var]]), mean) %>% unlist()
centers <- data.frame(x = x_means, y = y_means)
Expand Down

0 comments on commit bd8df13

Please sign in to comment.