Skip to content

Commit 4cf414a

Browse files
authored
Merge pull request #18 from mjz1/dev
Dev
2 parents 112b5db + b800212 commit 4cf414a

File tree

3 files changed

+75
-19
lines changed

3 files changed

+75
-19
lines changed

R/plotting.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,15 @@ get_label_centers <- function(obj, group_var = "clusters", reduced_dim = "UMAP")
645645
# To any scatter of a umap can add + geom_label_repel(data = get_label_centers(sce), aes(x = x, y = y, label = clusters))
646646

647647
if (class(obj) %in% c("SingleCellExperiment", "Milo")) {
648-
x_means <- lapply(split(reducedDim(obj, reduced_dim)[, 1], obj[[group_var]]), mean) %>% unlist()
649-
y_means <- lapply(split(reducedDim(obj, reduced_dim)[, 2], obj[[group_var]]), mean) %>% unlist()
648+
x_means <- lapply(split(reducedDim(obj, reduced_dim)[, 1], obj[[group_var]]), median) %>% unlist()
649+
y_means <- lapply(split(reducedDim(obj, reduced_dim)[, 2], obj[[group_var]]), median) %>% unlist()
650650
centers <- data.frame(x = x_means, y = y_means)
651651
centers[[group_var]] <- rownames(centers)
652652
}
653653

654654
if ("Seurat" %in% class(obj)) {
655-
x_means <- lapply(split(Seurat::Embeddings(obj, reduced_dim)[, 1], obj[[group_var]]), mean) %>% unlist()
656-
y_means <- lapply(split(Seurat::Embeddings(obj, reduced_dim)[, 2], obj[[group_var]]), mean) %>% unlist()
655+
x_means <- lapply(split(Seurat::Embeddings(obj, reduced_dim)[, 1], obj[[group_var]]), median) %>% unlist()
656+
y_means <- lapply(split(Seurat::Embeddings(obj, reduced_dim)[, 2], obj[[group_var]]), median) %>% unlist()
657657
centers <- data.frame(x = x_means, y = y_means)
658658
centers[[group_var]] <- rownames(centers)
659659
}

renv.lock

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,18 +3026,11 @@
30263026
},
30273027
"renv": {
30283028
"Package": "renv",
3029-
"Version": "1.0.7.9000",
3030-
"Source": "GitHub",
3031-
"RemoteType": "github",
3032-
"RemoteUsername": "rstudio",
3033-
"RemoteRepo": "renv",
3034-
"RemoteRef": "main",
3035-
"RemoteSha": "8c2379948cb5667f47047b0e709c889fd2188feb",
3036-
"RemoteHost": "api.github.com",
3037-
"Requirements": [
3038-
"utils"
3039-
],
3040-
"Hash": "73e0d7fbfb3035ae18fa10a9a923a40a"
3029+
"Version": "1.0.9",
3030+
"OS_type": null,
3031+
"NeedsCompilation": "no",
3032+
"Repository": "CRAN",
3033+
"Source": "Repository"
30413034
},
30423035
"reshape2": {
30433036
"Package": "reshape2",

renv/activate.R

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
local({
33

44
# the requested version of renv
5-
version <- "1.0.7.9000"
6-
attr(version, "sha") <- "8c2379948cb5667f47047b0e709c889fd2188feb"
5+
version <- "1.0.9"
6+
attr(version, "sha") <- NULL
77

88
# the project directory
99
project <- Sys.getenv("RENV_PROJECT")
@@ -98,6 +98,66 @@ local({
9898
unloadNamespace("renv")
9999

100100
# load bootstrap tools
101+
ansify <- function(text) {
102+
if (renv_ansify_enabled())
103+
renv_ansify_enhanced(text)
104+
else
105+
renv_ansify_default(text)
106+
}
107+
108+
renv_ansify_enabled <- function() {
109+
110+
override <- Sys.getenv("RENV_ANSIFY_ENABLED", unset = NA)
111+
if (!is.na(override))
112+
return(as.logical(override))
113+
114+
pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE", unset = NA)
115+
if (identical(pane, "build"))
116+
return(FALSE)
117+
118+
testthat <- Sys.getenv("TESTTHAT", unset = "false")
119+
if (tolower(testthat) %in% "true")
120+
return(FALSE)
121+
122+
iderun <- Sys.getenv("R_CLI_HAS_HYPERLINK_IDE_RUN", unset = "false")
123+
if (tolower(iderun) %in% "false")
124+
return(FALSE)
125+
126+
TRUE
127+
128+
}
129+
130+
renv_ansify_default <- function(text) {
131+
text
132+
}
133+
134+
renv_ansify_enhanced <- function(text) {
135+
136+
# R help links
137+
pattern <- "`\\?(renv::(?:[^`])+)`"
138+
replacement <- "`\033]8;;ide:help:\\1\a?\\1\033]8;;\a`"
139+
text <- gsub(pattern, replacement, text, perl = TRUE)
140+
141+
# runnable code
142+
pattern <- "`(renv::(?:[^`])+)`"
143+
replacement <- "`\033]8;;ide:run:\\1\a\\1\033]8;;\a`"
144+
text <- gsub(pattern, replacement, text, perl = TRUE)
145+
146+
# return ansified text
147+
text
148+
149+
}
150+
151+
renv_ansify_init <- function() {
152+
153+
envir <- renv_envir_self()
154+
if (renv_ansify_enabled())
155+
assign("ansify", renv_ansify_enhanced, envir = envir)
156+
else
157+
assign("ansify", renv_ansify_default, envir = envir)
158+
159+
}
160+
101161
`%||%` <- function(x, y) {
102162
if (is.null(x)) y else x
103163
}
@@ -142,7 +202,10 @@ local({
142202
# compute common indent
143203
indent <- regexpr("[^[:space:]]", lines)
144204
common <- min(setdiff(indent, -1L)) - leave
145-
paste(substring(lines, common), collapse = "\n")
205+
text <- paste(substring(lines, common), collapse = "\n")
206+
207+
# substitute in ANSI links for executable renv code
208+
ansify(text)
146209

147210
}
148211

0 commit comments

Comments
 (0)