Skip to content
Merged

Dev #18

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -645,15 +645,15 @@ 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 (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()
x_means <- lapply(split(reducedDim(obj, reduced_dim)[, 1], obj[[group_var]]), median) %>% unlist()
y_means <- lapply(split(reducedDim(obj, reduced_dim)[, 2], obj[[group_var]]), median) %>% unlist()
centers <- data.frame(x = x_means, y = y_means)
centers[[group_var]] <- rownames(centers)
}

if ("Seurat" %in% class(obj)) {
x_means <- lapply(split(Seurat::Embeddings(obj, reduced_dim)[, 1], obj[[group_var]]), mean) %>% unlist()
y_means <- lapply(split(Seurat::Embeddings(obj, reduced_dim)[, 2], obj[[group_var]]), mean) %>% unlist()
x_means <- lapply(split(Seurat::Embeddings(obj, reduced_dim)[, 1], obj[[group_var]]), median) %>% unlist()
y_means <- lapply(split(Seurat::Embeddings(obj, reduced_dim)[, 2], obj[[group_var]]), median) %>% unlist()
centers <- data.frame(x = x_means, y = y_means)
centers[[group_var]] <- rownames(centers)
}
Expand Down
17 changes: 5 additions & 12 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3026,18 +3026,11 @@
},
"renv": {
"Package": "renv",
"Version": "1.0.7.9000",
"Source": "GitHub",
"RemoteType": "github",
"RemoteUsername": "rstudio",
"RemoteRepo": "renv",
"RemoteRef": "main",
"RemoteSha": "8c2379948cb5667f47047b0e709c889fd2188feb",
"RemoteHost": "api.github.com",
"Requirements": [
"utils"
],
"Hash": "73e0d7fbfb3035ae18fa10a9a923a40a"
"Version": "1.0.9",
"OS_type": null,
"NeedsCompilation": "no",
"Repository": "CRAN",
"Source": "Repository"
},
"reshape2": {
"Package": "reshape2",
Expand Down
69 changes: 66 additions & 3 deletions renv/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
local({

# the requested version of renv
version <- "1.0.7.9000"
attr(version, "sha") <- "8c2379948cb5667f47047b0e709c889fd2188feb"
version <- "1.0.9"
attr(version, "sha") <- NULL

# the project directory
project <- Sys.getenv("RENV_PROJECT")
Expand Down Expand Up @@ -98,6 +98,66 @@ local({
unloadNamespace("renv")

# load bootstrap tools
ansify <- function(text) {
if (renv_ansify_enabled())
renv_ansify_enhanced(text)
else
renv_ansify_default(text)
}

renv_ansify_enabled <- function() {

override <- Sys.getenv("RENV_ANSIFY_ENABLED", unset = NA)
if (!is.na(override))
return(as.logical(override))

pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE", unset = NA)
if (identical(pane, "build"))
return(FALSE)

testthat <- Sys.getenv("TESTTHAT", unset = "false")
if (tolower(testthat) %in% "true")
return(FALSE)

iderun <- Sys.getenv("R_CLI_HAS_HYPERLINK_IDE_RUN", unset = "false")
if (tolower(iderun) %in% "false")
return(FALSE)

TRUE

}

renv_ansify_default <- function(text) {
text
}

renv_ansify_enhanced <- function(text) {

# R help links
pattern <- "`\\?(renv::(?:[^`])+)`"
replacement <- "`\033]8;;ide:help:\\1\a?\\1\033]8;;\a`"
text <- gsub(pattern, replacement, text, perl = TRUE)

# runnable code
pattern <- "`(renv::(?:[^`])+)`"
replacement <- "`\033]8;;ide:run:\\1\a\\1\033]8;;\a`"
text <- gsub(pattern, replacement, text, perl = TRUE)

# return ansified text
text

}

renv_ansify_init <- function() {

envir <- renv_envir_self()
if (renv_ansify_enabled())
assign("ansify", renv_ansify_enhanced, envir = envir)
else
assign("ansify", renv_ansify_default, envir = envir)

}

`%||%` <- function(x, y) {
if (is.null(x)) y else x
}
Expand Down Expand Up @@ -142,7 +202,10 @@ local({
# compute common indent
indent <- regexpr("[^[:space:]]", lines)
common <- min(setdiff(indent, -1L)) - leave
paste(substring(lines, common), collapse = "\n")
text <- paste(substring(lines, common), collapse = "\n")

# substitute in ANSI links for executable renv code
ansify(text)

}

Expand Down
Loading