diff --git a/DESCRIPTION b/DESCRIPTION
index 6880f72..13bf9e1 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
Package: clustree
Type: Package
Title: Visualise Clusterings at Different Resolutions
-Version: 0.5.0
-Date: 2022-06-24
+Version: 0.5.0.9001
+Date: 2023-10-24
Authors@R:
c(person("Luke", "Zappia", role = c("aut", "cre"),
email = "luke@lazappi.id.au",
@@ -33,7 +33,7 @@ Imports: checkmate,
igraph,
dplyr,
grid,
- ggplot2,
+ ggplot2 (>= 3.4.0),
viridis,
methods,
rlang,
@@ -50,5 +50,5 @@ Suggests:
pkgdown,
spelling
Roxygen: list(markdown = TRUE)
-RoxygenNote: 7.2.0
+RoxygenNote: 7.2.3
Language: en-GB
diff --git a/NEWS.md b/NEWS.md
index a8244fc..698e895 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,15 @@
+# clustree (development version)
+
+### _clustree_ 0.5.0.9001 (2023-10-24)
+
+* Avoid warnings due to deprecated functionality in _ggplot2_ and
+ _tidyselect_. Includes increasing the _ggplot2_ requirement to >= 3.4.0.
+ (Fixes #35)
+
+### _clustree_ 0.5.0.9000 (2023-10-24)
+
+* Minor updates for compatibility with upcoming _Seurat_ v5 release (Fixes #93)
+
# _clustree_ 0.5.0 (2022-06-24)
## Minor changes
diff --git a/R/checks.R b/R/checks.R
index 928f274..9ecf134 100644
--- a/R/checks.R
+++ b/R/checks.R
@@ -9,6 +9,8 @@
#' @param node_aes value of the node aesthetic to check
#' @param node_aes_aggr aggregation function associated with the node aesthetic
#'
+#' @keywords internal
+#'
#' @importFrom utils head
assert_node_aes <- function(node_aes_name, prefix, metadata, node_aes,
node_aes_aggr) {
@@ -58,6 +60,8 @@ assert_node_aes <- function(node_aes_name, prefix, metadata, node_aes,
#' @param node_aes_aggr aggregation function associated with the node aesthetic
#' @param min minimum numeric value allowed
#' @param max maximum numeric value allowed
+#'
+#' @keywords internal
assert_numeric_node_aes <- function(node_aes_name, prefix, metadata, node_aes,
node_aes_aggr, min, max) {
@@ -87,6 +91,8 @@ assert_numeric_node_aes <- function(node_aes_name, prefix, metadata, node_aes,
#' @param min minimum numeric value allowed
#' @param max maximum numeric value allowed
#'
+#' @keywords internal
+#'
#' @importFrom grDevices col2rgb
assert_colour_node_aes <- function(node_aes_name, prefix, metadata, node_aes,
node_aes_aggr, min, max) {
@@ -120,6 +126,8 @@ assert_colour_node_aes <- function(node_aes_name, prefix, metadata, node_aes,
#'
#' @param node_aes_list List of node aesthetics
#'
+#' @keywords internal
+#'
#' @return Corrected node aesthetics list
check_node_aes_list <- function(node_aes_list) {
for (aes in names(node_aes_list)) {
diff --git a/R/clustree.R b/R/clustree.R
index 63cfcff..7d33824 100644
--- a/R/clustree.R
+++ b/R/clustree.R
@@ -284,13 +284,14 @@ clustree.matrix <- function(x, prefix,
ends = edge_arrow_ends),
end_cap = circle(circle_size_end, "points"),
start_cap = circle(circle_size_start, "points"),
- aes_(colour = ~count,
- alpha = ~in_prop,
- edge_width = ~is_core))
+ aes(colour = .data$count,
+ alpha = .data$in_prop,
+ edge_width = .data$is_core))
} else {
- gg <- gg + geom_edge_link(aes_(colour = ~count, alpha = ~in_prop,
- edge_width = ~is_core))
+ gg <- gg + geom_edge_link(aes(colour = .data$count,
+ alpha = .data$in_prop,
+ edge_width = .data$is_core))
}
if (highlight_core) {
@@ -311,17 +312,17 @@ clustree.matrix <- function(x, prefix,
# Plot node text
if (scale_node_text && !is.numeric(node_size)) {
- gg <- gg + geom_node_text(aes_(label = ~cluster,
- size = as.name(graph_attr$node_size)),
+ gg <- gg + geom_node_text(aes(label = .data$cluster,
+ size = .data[[graph_attr$node_size]]),
colour = node_text_colour,
angle = node_text_angle
)
} else {
- gg <- gg + geom_node_text(aes_(label = ~cluster),
+ gg <- gg + geom_node_text(aes(label = .data$cluster),
size = node_text_size,
colour = node_text_colour,
angle = node_text_angle
- )
+ )
}
if (!(is.null(node_label))) {
@@ -516,8 +517,13 @@ clustree.Seurat <- function(x, prefix = paste0(assay, "_snn_res."),
)
}
aes_name <- paste0(exprs, "_", node_aes_name)
- x[[aes_name]] <- Seurat::FetchData(x, vars = node_aes_value,
- slot = exprs)
+ if (packageVersion("SeuratObject") >= package_version("5.0.0")) {
+ x[[aes_name]] <- Seurat::FetchData(x, vars = node_aes_value,
+ layer = exprs)
+ } else {
+ x[[aes_name]] <- Seurat::FetchData(x, vars = node_aes_value,
+ slot = exprs)
+ }
args[[node_aes]] <- aes_name
}
}
@@ -541,6 +547,8 @@ clustree.Seurat <- function(x, prefix = paste0(assay, "_snn_res."),
#' name of a metadata column to use for node transparency
#' @param allowed vector of allowed node attributes to use as aesthetics
#'
+#' @keywords internal
+#'
#' @importFrom ggraph geom_node_point
#' @importFrom ggplot2 aes_
add_node_points <- function(node_colour, node_size, node_alpha, allowed) {
@@ -555,25 +563,25 @@ add_node_points <- function(node_colour, node_size, node_alpha, allowed) {
}
switch(aes_allowed,
- col_size_alpha = geom_node_point(aes_(colour = as.name(node_colour),
- size = as.name(node_size),
- alpha = as.name(node_alpha))),
- col_alpha = geom_node_point(aes_(colour = as.name(node_colour),
- alpha = as.name(node_alpha)),
+ col_size_alpha = geom_node_point(aes(colour = .data[[node_colour]],
+ size = .data[[node_size]],
+ alpha = .data[[node_alpha]])),
+ col_alpha = geom_node_point(aes(colour = .data[[node_colour]],
+ alpha = .data[[node_alpha]]),
size = node_size),
- col_size = geom_node_point(aes_(colour = as.name(node_colour),
- size = as.name(node_size)),
+ col_size = geom_node_point(aes(colour = .data[[node_colour]],
+ size = .data[[node_size]]),
alpha = node_alpha),
- col = geom_node_point(aes_(colour = as.name(node_colour)),
+ col = geom_node_point(aes(colour = .data[[node_colour]]),
size = node_size,
alpha = node_alpha),
- size_alpha = geom_node_point(aes_(size = as.name(node_size),
- alpha = as.name(node_alpha)),
+ size_alpha = geom_node_point(aes(size = .data[[node_size]],
+ alpha = .data[[node_alpha]]),
colour = node_colour),
- size = geom_node_point(aes_(size = as.name(node_size)),
+ size = geom_node_point(aes(size = .data[[node_size]]),
colour = node_colour,
alpha = node_alpha),
- alpha = geom_node_point(aes_(alpha = as.name(node_alpha)),
+ alpha = geom_node_point(aes(alpha = .data[[node_alpha]]),
colour = node_colour,
size = node_size),
none = geom_node_point(colour = node_colour,
@@ -597,6 +605,8 @@ add_node_points <- function(node_colour, node_size, node_alpha, allowed) {
#' labels
#' @param allowed vector of allowed node attributes to use as aesthetics
#'
+#' @keywords internal
+#'
#' @importFrom ggraph geom_node_label
#' @importFrom ggplot2 aes_
add_node_labels <- function(node_label, node_colour, node_label_size,
@@ -605,13 +615,13 @@ add_node_labels <- function(node_label, node_colour, node_label_size,
is_allowed <- c(node_colour) %in% allowed
if (is_allowed) {
- geom_node_label(aes_(label = as.name(node_label),
- fill = as.name(node_colour)),
+ geom_node_label(aes(label = .data[[node_label]],
+ fill = .data[[node_colour]]),
size = node_label_size,
colour = node_label_colour,
nudge_y = node_label_nudge)
} else {
- geom_node_label(aes_(label = as.name(node_label)),
+ geom_node_label(aes(label = .data[[node_label]]),
fill = node_colour,
size = node_label_size,
colour = node_label_colour,
diff --git a/R/clustree_overlay.R b/R/clustree_overlay.R
index 9b53f64..46a1bd4 100644
--- a/R/clustree_overlay.R
+++ b/R/clustree_overlay.R
@@ -259,12 +259,12 @@ clustree_overlay.matrix <- function(x, prefix, metadata, x_value, y_value,
levels(edges[[paste0("from_", prefix)]]) <- levels(nodes[[prefix]])
if (use_colour == "points") {
- gg <- ggplot(points, aes_(x = as.name(x_value), y = as.name(y_value))) +
- geom_point(aes_(colour = as.name(paste0(hi_res, "_cluster"))),
+ gg <- ggplot(points, aes(x = .data[[x_value]], y = .data[[y_value]])) +
+ geom_point(aes(colour = .data[[paste0(hi_res, "_cluster")]]),
size = point_size, alpha = point_alpha,
shape = point_shape)
} else {
- gg <- ggplot(points, aes_(x = as.name(x_value), y = as.name(y_value))) +
+ gg <- ggplot(points, aes(x = .data[[x_value]], y = .data[[y_value]])) +
geom_point(colour = alt_colour, size = point_size,
alpha = point_alpha, shape = point_shape)
}
@@ -283,26 +283,26 @@ clustree_overlay.matrix <- function(x, prefix, metadata, x_value, y_value,
if (use_colour == "edges") {
gg <- gg +
geom_segment(data = edges_res,
- aes_(x = as.name(paste0("from_", x_value)),
- y = as.name(paste0("from_", y_value)),
- xend = as.name(paste0("to_", x_value)),
- yend = as.name(paste0("to_", y_value)),
- alpha = ~ in_prop,
- colour = as.name(paste0("from_", prefix))),
+ aes(x = .data[[paste0("from_", x_value)]],
+ y = .data[[paste0("from_", y_value)]],
+ xend = .data[[paste0("to_", x_value)]],
+ yend = .data[[paste0("to_", y_value)]],
+ alpha = .data$in_prop,
+ colour = .data[[paste0("from_", prefix)]]),
arrow = arrow(length = unit(edge_width * 5,
"points")),
- size = edge_width)
+ linewidth = edge_width)
} else {
gg <- gg +
geom_segment(data = edges_res,
- aes_(x = as.name(paste0("from_", x_value)),
- y = as.name(paste0("from_", y_value)),
- xend = as.name(paste0("to_", x_value)),
- yend = as.name(paste0("to_", y_value)),
- alpha = ~ in_prop),
+ aes(x = .data[[paste0("from_", x_value)]],
+ y = .data[[paste0("from_", y_value)]],
+ xend = .data[[paste0("to_", x_value)]],
+ yend = .data[[paste0("to_", y_value)]],
+ alpha = .data$in_prop),
arrow = arrow(length = unit(edge_width * 5,
"points")),
- size = edge_width,
+ linewidth = edge_width,
colour = alt_colour)
}
}
@@ -310,9 +310,9 @@ clustree_overlay.matrix <- function(x, prefix, metadata, x_value, y_value,
if (label_nodes) {
gg <- gg +
ggrepel::geom_label_repel(data = nodes,
- aes_(x = as.name(x_val),
- y = as.name(y_val),
- label = ~ node),
+ aes(x = .data[[x_val]],
+ y = .data[[y_val]],
+ label = .data$node),
size = label_size)
}
@@ -604,8 +604,13 @@ clustree_overlay.Seurat <- function(x, x_value, y_value,
)
}
aes_name <- paste0(exprs, "_", node_aes_name)
- x[[aes_name]] <- Seurat::FetchData(x, vars = node_aes_value,
- slot = exprs)
+ if (packageVersion("SeuratObject") >= package_version("5.0.0")) {
+ x[[aes_name]] <- Seurat::FetchData(x, vars = node_aes_value,
+ layer = exprs)
+ } else {
+ x[[aes_name]] <- Seurat::FetchData(x, vars = node_aes_value,
+ slot = exprs)
+ }
args[[node_aes]] <- aes_name
}
}
@@ -638,6 +643,8 @@ clustree_overlay.Seurat <- function(x, x_value, y_value,
#' @param node_alpha either a numeric value giving the alpha of all nodes or the
#' name of a metadata column to use for node transparency
#'
+#' @keywords internal
+#'
#' @importFrom ggplot2 aes_ geom_point
overlay_node_points <- function(nodes, x_value, y_value, node_colour, node_size,
node_alpha) {
@@ -653,57 +660,57 @@ overlay_node_points <- function(nodes, x_value, y_value, node_colour, node_size,
switch(aes_allowed,
col_size_alpha = geom_point(data = nodes,
- aes_(x = as.name(x_value),
- y = as.name(y_value),
- fill = as.name(node_colour),
- size = as.name(node_size),
- alpha = as.name(node_alpha)),
+ aes(x = .data[[x_value]],
+ y = .data[[y_value]],
+ fill = .data[[node_colour]],
+ size = .data[[node_size]],
+ alpha = .data[[node_alpha]]),
shape = 21),
col_alpha = geom_point(data = nodes,
- aes_(x = as.name(x_value),
- y = as.name(y_value),
- fill = as.name(node_colour),
- alpha = as.name(node_alpha)),
+ aes(x = .data[[x_value]],
+ y = .data[[y_value]],
+ fill = .data[[node_colour]],
+ alpha = .data[[node_alpha]]),
size = node_size,
shape = 21),
col_size = geom_point(data = nodes,
- aes_(x = as.name(x_value),
- y = as.name(y_value),
- fill = as.name(node_colour),
- size = as.name(node_size)),
+ aes(x = .data[[x_value]],
+ y = .data[[y_value]],
+ fill = .data[[node_colour]],
+ size = .data[[node_size]]),
alpha = node_alpha,
shape = 21),
col = geom_point(data = nodes,
- aes_(x = as.name(x_value),
- y = as.name(y_value),
- fill = as.name(node_colour)),
+ aes(x = .data[[x_value]],
+ y = .data[[y_value]],
+ fill = .data[[node_colour]]),
size = node_size,
alpha = node_alpha,
shape = 21),
size_alpha = geom_point(data = nodes,
- aes_(x = as.name(x_value),
- y = as.name(y_value),
- fill = as.name(node_size),
- alpha = as.name(node_alpha)),
+ aes(x = .data[[x_value]],
+ y = .data[[y_value]],
+ fill = .data[[node_size]],
+ alpha = .data[[node_alpha]]),
colour = node_colour,
shape = 21),
size = geom_point(data = nodes,
- aes_(x = as.name(x_value),
- y = as.name(y_value),
- size = as.name(node_size)),
+ aes(x = .data[[x_value]],
+ y = .data[[y_value]],
+ size = .data[[node_size]]),
fill = node_colour,
alpha = node_alpha,
shape = 21),
alpha = geom_point(data = nodes,
- aes_(x = as.name(x_value),
- y = as.name(y_value),
- alpha = as.name(node_alpha)),
+ aes(x = .data[[x_value]],
+ y = .data[[y_value]],
+ alpha = .data[[node_alpha]]),
fill = node_colour,
size = node_size,
shape = 21),
none = geom_point(data = nodes,
- aes_(x = as.name(x_value),
- y = as.name(y_value)),
+ aes(x = .data[[x_value]],
+ y = .data[[y_value]]),
fill = node_colour,
size = node_size,
alpha = node_alpha,
@@ -746,6 +753,8 @@ overlay_node_points <- function(nodes, x_value, y_value, node_colour, node_size,
#'
#' @return ggplot object
#'
+#' @keywords internal
+#'
#' @importFrom ggplot2 scale_colour_hue geom_jitter scale_y_reverse scale_alpha
#' ylab theme
#' element_line element_blank
@@ -771,14 +780,13 @@ plot_overlay_side <- function(nodes, edges, points, prefix, side_value,
!!as.name(paste0("to_", prefix)))))
if (use_colour == "points") {
-
- gg <- ggplot(points, aes_(x = as.name(side_value), y = point_y)) +
- geom_jitter(aes_(colour = as.name(colnames(points)[3])),
+ gg <- ggplot(points, aes(x = .data[[side_value]], y = point_y)) +
+ geom_jitter(aes(colour = .data[[colnames(points)[3]]]),
height = y_jitter * median(y_diffs), width = 0,
size = point_size, alpha = point_alpha,
shape = point_shape)
} else {
- gg <- ggplot(points, aes_(x = as.name(side_value), y = point_y)) +
+ gg <- ggplot(points, aes(x = .data[[side_value]], y = point_y)) +
geom_jitter(height = y_jitter * median(y_diffs), width = 0,
colour = alt_colour, size = point_size,
alpha = point_alpha, shape = point_shape)
@@ -797,26 +805,26 @@ plot_overlay_side <- function(nodes, edges, points, prefix, side_value,
if (use_colour == "edges") {
gg <- gg +
geom_segment(data = edges_res,
- aes_(x = as.name(paste0("from_", side_value)),
- y = ~ from_y,
- xend = as.name(paste0("to_", side_value)),
- yend = ~ to_y,
- alpha = ~ in_prop,
- colour = as.name(paste0("from_", prefix))),
+ aes(x = .data[[paste0("from_", side_value)]],
+ y = .data$from_y,
+ xend = .data[[paste0("to_", side_value)]],
+ yend = .data$to_y,
+ alpha = .data$in_prop,
+ colour = .data[[paste0("from_", prefix)]]),
arrow = arrow(length = unit(edge_width * 5,
"points")),
- size = edge_width)
+ linewidth = edge_width)
} else {
gg <- gg +
geom_segment(data = edges_res,
- aes_(x = as.name(paste0("from_", side_value)),
- y = ~ from_y,
- xend = as.name(paste0("to_", side_value)),
- yend = ~ to_y,
- alpha = ~ in_prop),
+ aes(x = .data[[paste0("from_", side_value)]],
+ y = .data$from_y,
+ xend = .data[[paste0("to_", side_value)]],
+ yend = .data$to_y,
+ alpha = .data$in_prop),
arrow = arrow(length = unit(edge_width * 5,
"points")),
- size = edge_width,
+ linewidth = edge_width,
colour = alt_colour)
}
}
@@ -824,10 +832,10 @@ plot_overlay_side <- function(nodes, edges, points, prefix, side_value,
if (label_nodes) {
gg <- gg +
ggrepel::geom_label_repel(data = nodes,
- aes_(x = as.name(paste0("mean_",
- side_value)),
- y = ~ y,
- label = ~ node),
+ aes(x = .data[[paste0("mean_",
+ side_value)]],
+ y = .data$y,
+ label = .data$node),
size = label_size)
}
@@ -838,8 +846,8 @@ plot_overlay_side <- function(nodes, edges, points, prefix, side_value,
scale_colour_hue(drop = FALSE) +
ylab(prefix) +
theme_minimal() +
- theme(axis.line.x = element_line(size = 1, colour = "grey50"),
- axis.ticks.x = element_line(size = 0.6, colour = "grey50"),
+ theme(axis.line.x = element_line(linewidth = 1, colour = "grey50"),
+ axis.ticks.x = element_line(linewidth = 0.6, colour = "grey50"),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank())
diff --git a/R/graph.R b/R/graph.R
index f4aab99..f647eb6 100644
--- a/R/graph.R
+++ b/R/graph.R
@@ -16,6 +16,8 @@
#'
#' @return [tidygraph::tbl_graph] object containing the tree graph
#'
+#' @keywords internal
+#'
#' @importFrom dplyr %>%
#' @importFrom rlang .data
build_tree_graph <- function(clusterings, prefix, count_filter, prop_filter,
@@ -60,6 +62,8 @@ build_tree_graph <- function(clusterings, prefix, count_filter, prop_filter,
#' @param prefix string indicating columns containing clustering information
#' @param node_aes_list nested list containing node aesthetics
#'
+#' @keywords internal
+#'
#' @return data.frame containing node information
get_tree_nodes <- function(clusterings, prefix, metadata, node_aes_list) {
@@ -110,6 +114,8 @@ get_tree_nodes <- function(clusterings, prefix, metadata, node_aes_list) {
#'
#' @return data.frame containing edge information
#'
+#' @keywords internal
+#'
#' @importFrom dplyr %>%
#' @importFrom rlang .data :=
get_tree_edges <- function(clusterings, prefix) {
@@ -152,13 +158,13 @@ get_tree_edges <- function(clusterings, prefix) {
})
edges <- dplyr::bind_rows(edges) %>%
- dplyr::mutate(from_node = paste0(prefix, .data$from_res,
- "C", .data$from_clust)) %>%
- dplyr::mutate(to_node = paste0(prefix, .data$to_res,
- "C", .data$to_clust)) %>%
- dplyr::select(.data$from_node, .data$to_node, dplyr::everything()) %>%
- dplyr::rename(!!as.name(paste0("from_", prefix)) := .data$from_res,
- !!as.name(paste0("to_", prefix)) := .data$to_res)
+ dplyr::mutate(from_node = paste0(prefix, !!as.name("from_res"),
+ "C", !!as.name("from_clust"))) %>%
+ dplyr::mutate(to_node = paste0(prefix, !!as.name("to_res"),
+ "C", !!as.name("to_clust"))) %>%
+ dplyr::select("from_node", "to_node", dplyr::everything()) %>%
+ dplyr::rename(!!as.name(paste0("from_", prefix)) := !!as.name("from_res"),
+ !!as.name(paste0("to_", prefix)) := !!as.name("to_res"))
return(edges)
@@ -177,6 +183,8 @@ get_tree_edges <- function(clusterings, prefix) {
#' @param is_cluster logical vector indicating which rows of metadata are in the
#' node to be summarized
#'
+#' @keywords internal
+#'
#' @return data.frame with aggregated data
aggr_metadata <- function(node_data, col_name, col_aggr, metadata,
is_cluster) {
@@ -200,6 +208,8 @@ aggr_metadata <- function(node_data, col_name, col_aggr, metadata,
#' @param node_aes_list nested list containing node aesthetics
#' @param metadata data.frame containing metadata that can be used as aesthetics
#'
+#' @keywords internal
+#'
#' @return graph with additional attributes
store_node_aes <- function(graph, node_aes_list, metadata) {
diff --git a/R/stability.R b/R/stability.R
index b7038b1..300026e 100644
--- a/R/stability.R
+++ b/R/stability.R
@@ -8,6 +8,8 @@
#' @param clusterings numeric matrix containing clustering information, each
#' column contains clustering at a separate resolution
#'
+#' @keywords internal
+#'
#' @return matrix with stability score for each cluster
calc_sc3_stability <- function(clusterings) {
@@ -70,6 +72,8 @@ calc_sc3_stability <- function(clusterings) {
#' @seealso The documentation for the `calculate_stability` function in the
#' SC3 package
#'
+#' @keywords internal
+#'
#' @return SC3 stability index
calc_sc3_stability_cluster <- function(clusterings, res, cluster) {
diff --git a/_pkgdown.yml b/_pkgdown.yml
index fb4be72..1165dfc 100644
--- a/_pkgdown.yml
+++ b/_pkgdown.yml
@@ -1,15 +1,15 @@
url: https://lazappi.github.io/clustree/
template:
bootstrap: 5
- params:
- bootswatch: cosmo
- ganalytics: UA-52309538-5
-reference:
- - title: clustree functions
- contents:
- - clustree
- - clustree_overlay
- - title: Example datasets
- contents:
- - nba_clusts
- - sc_example
+ bootswatch: cosmo
+ includes:
+ in_header: |
+
+
+
diff --git a/man/add_node_labels.Rd b/man/add_node_labels.Rd
index 83539d4..1946075 100644
--- a/man/add_node_labels.Rd
+++ b/man/add_node_labels.Rd
@@ -31,3 +31,4 @@ labels}
\description{
Add node labels to a clustering tree plot with the specified aesthetics.
}
+\keyword{internal}
diff --git a/man/add_node_points.Rd b/man/add_node_points.Rd
index 72b488e..5bfd64b 100644
--- a/man/add_node_points.Rd
+++ b/man/add_node_points.Rd
@@ -21,3 +21,4 @@ name of a metadata column to use for node transparency}
\description{
Add node points to a clustering tree plot with the specified aesthetics.
}
+\keyword{internal}
diff --git a/man/aggr_metadata.Rd b/man/aggr_metadata.Rd
index be7be73..b0d6c95 100644
--- a/man/aggr_metadata.Rd
+++ b/man/aggr_metadata.Rd
@@ -25,3 +25,4 @@ data.frame with aggregated data
\description{
Aggregate a metadata column to get a summarized value for a cluster node
}
+\keyword{internal}
diff --git a/man/assert_colour_node_aes.Rd b/man/assert_colour_node_aes.Rd
index 2a59724..2d085f9 100644
--- a/man/assert_colour_node_aes.Rd
+++ b/man/assert_colour_node_aes.Rd
@@ -33,3 +33,4 @@ used as node aesthetics}
\description{
Raise error if an incorrect set of colour node parameters has been supplied.
}
+\keyword{internal}
diff --git a/man/assert_node_aes.Rd b/man/assert_node_aes.Rd
index af58058..80e1049 100644
--- a/man/assert_node_aes.Rd
+++ b/man/assert_node_aes.Rd
@@ -21,3 +21,4 @@ used as node aesthetics}
\description{
Raise error if an incorrect set of node parameters has been supplied.
}
+\keyword{internal}
diff --git a/man/assert_numeric_node_aes.Rd b/man/assert_numeric_node_aes.Rd
index 24d6403..70068f3 100644
--- a/man/assert_numeric_node_aes.Rd
+++ b/man/assert_numeric_node_aes.Rd
@@ -33,3 +33,4 @@ used as node aesthetics}
\description{
Raise error if an incorrect set of numeric node parameters has been supplied.
}
+\keyword{internal}
diff --git a/man/build_tree_graph.Rd b/man/build_tree_graph.Rd
index 0090362..318a12c 100644
--- a/man/build_tree_graph.Rd
+++ b/man/build_tree_graph.Rd
@@ -37,3 +37,4 @@ used as node aesthetics}
Build a tree graph from a set of clusterings, metadata and associated
aesthetics
}
+\keyword{internal}
diff --git a/man/calc_sc3_stability.Rd b/man/calc_sc3_stability.Rd
index da32f91..2500b5a 100644
--- a/man/calc_sc3_stability.Rd
+++ b/man/calc_sc3_stability.Rd
@@ -19,3 +19,4 @@ set of clusterings. The index varies from 0 to 1, where 1 suggests that a
cluster is more stable across resolutions. See \code{\link[=calc_sc3_stability_cluster]{calc_sc3_stability_cluster()}}
for more details.
}
+\keyword{internal}
diff --git a/man/calc_sc3_stability_cluster.Rd b/man/calc_sc3_stability_cluster.Rd
index f7f9923..453cc9e 100644
--- a/man/calc_sc3_stability_cluster.Rd
+++ b/man/calc_sc3_stability_cluster.Rd
@@ -56,3 +56,4 @@ Where:
The documentation for the \code{calculate_stability} function in the
SC3 package
}
+\keyword{internal}
diff --git a/man/check_node_aes_list.Rd b/man/check_node_aes_list.Rd
index f04e06e..965bf33 100644
--- a/man/check_node_aes_list.Rd
+++ b/man/check_node_aes_list.Rd
@@ -15,3 +15,4 @@ Corrected node aesthetics list
\description{
Warn if node aesthetic names are incorrect
}
+\keyword{internal}
diff --git a/man/get_tree_edges.Rd b/man/get_tree_edges.Rd
index 4a6ff4b..630636c 100644
--- a/man/get_tree_edges.Rd
+++ b/man/get_tree_edges.Rd
@@ -18,3 +18,4 @@ data.frame containing edge information
\description{
Extract the edges from a set of clusterings
}
+\keyword{internal}
diff --git a/man/get_tree_nodes.Rd b/man/get_tree_nodes.Rd
index 3e765ca..1dfc045 100644
--- a/man/get_tree_nodes.Rd
+++ b/man/get_tree_nodes.Rd
@@ -23,3 +23,4 @@ data.frame containing node information
\description{
Extract the nodes from a set of clusterings and add relevant attributes
}
+\keyword{internal}
diff --git a/man/overlay_node_points.Rd b/man/overlay_node_points.Rd
index 4481433..cfd4981 100644
--- a/man/overlay_node_points.Rd
+++ b/man/overlay_node_points.Rd
@@ -33,3 +33,4 @@ name of a metadata column to use for node transparency}
Overlay clustering tree nodes on a scatter plot with the specified
aesthetics.
}
+\keyword{internal}
diff --git a/man/plot_overlay_side.Rd b/man/plot_overlay_side.Rd
index 1101c9a..35cee99 100644
--- a/man/plot_overlay_side.Rd
+++ b/man/plot_overlay_side.Rd
@@ -74,3 +74,4 @@ Plot the side view of a clustree overlay plot. If the ordinary plot shows the
tree from above this plot shows it from the side, highlighting either the
x or y dimension and the clustering resolution.
}
+\keyword{internal}
diff --git a/man/store_node_aes.Rd b/man/store_node_aes.Rd
index 419002a..6deaa3d 100644
--- a/man/store_node_aes.Rd
+++ b/man/store_node_aes.Rd
@@ -19,3 +19,4 @@ graph with additional attributes
\description{
Store the names of node attributes to use as aesthetics as graph attributes
}
+\keyword{internal}
diff --git a/tests/testthat/test-clustree-overlay.R b/tests/testthat/test-clustree-overlay.R
index dfe96dd..79c6863 100644
--- a/tests/testthat/test-clustree-overlay.R
+++ b/tests/testthat/test-clustree-overlay.R
@@ -32,25 +32,37 @@ seurat_clusters2$resX <- "X"
seurat_clusters2$TSNE1 <- sc_example$tsne[, 1]
seurat_clusters2$TSNE2 <- sc_example$tsne[, 2]
-if (requireNamespace("Seurat", quietly = TRUE) &&
- packageVersion(pkg = "Seurat") < package_version(x = "3.0.0")) {
- library("Seurat")
- seurat <- CreateSeuratObject(sc_example$counts,
- meta.data = sc_example$seurat_clusters)
- seurat <- SetDimReduction(seurat, "TSNE", "cell.embeddings",
- sc_example$tsne)
-}
-
-if (requireNamespace("Seurat", quietly = TRUE) &&
- packageVersion(pkg = "Seurat") >= package_version(x = "3.0.0")) {
- library("Seurat")
- seurat <- CreateSeuratObject(counts = sc_example$counts,
- meta.data = sc_example$seurat_clusters)
- seurat[["TSNE"]] <- suppressWarnings(CreateDimReducObject(
- embeddings = sc_example$tsne,
- key = "tSNE_",
- assay = DefaultAssay(seurat)
- ))
+if (requireNamespace("Seurat", quietly = TRUE)) {
+
+ library(Seurat)
+
+ seurat_version <- packageVersion("Seurat")
+
+ if (seurat_version >= package_version("5.0.0")) {
+ seurat <- CreateSeuratObject(
+ counts = as(sc_example$counts, "sparseMatrix"),
+ data = as(sc_example$logcounts, "sparseMatrix"),
+ meta.data = sc_example$seurat_clusters
+ )
+ seurat[["TSNE"]] <- suppressWarnings(CreateDimReducObject(
+ embeddings = sc_example$tsne,
+ key = "tSNE_",
+ assay = DefaultAssay(seurat)
+ ))
+ } else if (seurat_version >= package_version("3.0.0")) {
+ seurat <- CreateSeuratObject(counts = sc_example$counts,
+ meta.data = sc_example$seurat_clusters)
+ seurat[["TSNE"]] <- suppressWarnings(CreateDimReducObject(
+ embeddings = sc_example$tsne,
+ key = "tSNE_",
+ assay = DefaultAssay(seurat)
+ ))
+ } else {
+ seurat <- CreateSeuratObject(sc_example$counts,
+ meta.data = sc_example$seurat_clusters)
+ seurat <- SetDimReduction(seurat, "TSNE", "cell.embeddings",
+ sc_example$tsne)
+ }
}
if (requireNamespace("SingleCellExperiment", quietly = TRUE)) {
diff --git a/tests/testthat/test-clustree.R b/tests/testthat/test-clustree.R
index e8cbd8f..aac41a2 100644
--- a/tests/testthat/test-clustree.R
+++ b/tests/testthat/test-clustree.R
@@ -25,25 +25,37 @@ nba_tibble <- dplyr::as_tibble(nba_clusts)
seurat_clusters2 <- sc_example$seurat_clusters
seurat_clusters2$resX <- "X"
-if (requireNamespace("Seurat", quietly = TRUE) &&
- packageVersion(pkg = "Seurat") < package_version(x = "3.0.0")) {
- library("Seurat")
- seurat <- CreateSeuratObject(sc_example$counts,
- meta.data = sc_example$seurat_clusters)
- seurat <- SetDimReduction(seurat, "TSNE", "cell.embeddings",
- sc_example$tsne)
-}
-
-if (requireNamespace("Seurat", quietly = TRUE) &&
- packageVersion(pkg = "Seurat") >= package_version(x = "3.0.0")) {
- library("Seurat")
- seurat <- CreateSeuratObject(counts = sc_example$counts,
- meta.data = sc_example$seurat_clusters)
- seurat[["TSNE"]] <- suppressWarnings(CreateDimReducObject(
- embeddings = sc_example$tsne,
- key = "tSNE_",
- assay = DefaultAssay(seurat)
- ))
+if (requireNamespace("Seurat", quietly = TRUE)) {
+
+ library(Seurat)
+
+ seurat_version <- packageVersion("Seurat")
+
+ if (seurat_version >= package_version("5.0.0")) {
+ seurat <- CreateSeuratObject(
+ counts = as(sc_example$counts, "sparseMatrix"),
+ data = as(sc_example$logcounts, "sparseMatrix"),
+ meta.data = sc_example$seurat_clusters
+ )
+ seurat[["TSNE"]] <- suppressWarnings(CreateDimReducObject(
+ embeddings = sc_example$tsne,
+ key = "tSNE_",
+ assay = DefaultAssay(seurat)
+ ))
+ } else if (seurat_version >= package_version("3.0.0")) {
+ seurat <- CreateSeuratObject(counts = sc_example$counts,
+ meta.data = sc_example$seurat_clusters)
+ seurat[["TSNE"]] <- suppressWarnings(CreateDimReducObject(
+ embeddings = sc_example$tsne,
+ key = "tSNE_",
+ assay = DefaultAssay(seurat)
+ ))
+ } else {
+ seurat <- CreateSeuratObject(sc_example$counts,
+ meta.data = sc_example$seurat_clusters)
+ seurat <- SetDimReduction(seurat, "TSNE", "cell.embeddings",
+ sc_example$tsne)
+ }
}
if (requireNamespace("SingleCellExperiment", quietly = TRUE)) {
diff --git a/vignettes/clustree.Rmd b/vignettes/clustree.Rmd
index bab4c5b..859af90 100644
--- a/vignettes/clustree.Rmd
+++ b/vignettes/clustree.Rmd
@@ -244,11 +244,11 @@ clustree(sce, prefix = "sc3_", suffix = "_clusters")
```{r seurat-present, echo = FALSE}
seurat_present <- requireNamespace("Seurat", quietly = TRUE) &&
- packageVersion("Seurat") >= package_version(x = "3.0.0")
+ packageVersion("Seurat") >= package_version(x = "5.0.0")
```
```{r seurat-not, echo = FALSE, results = 'asis', eval = !seurat_present}
-cat("> **NOTE:** This section requires the Seurat package (>= 3.0.0).",
+cat("> **NOTE:** This section requires the Seurat package (>= 5.0.0).",
"This package isn't installed so the results won't be shown.")
```
@@ -258,8 +258,9 @@ convert our `SingleCellExperiment` to `Seurat` format:
```{r seurat, eval = seurat_present}
suppressPackageStartupMessages(library("Seurat"))
-# Create the Seurat object
-seurat <- CreateSeuratObject(counts = sc_example$counts,
+# Create the Seurat object, Seurat >= expects a sparse matrix
+seurat <- CreateSeuratObject(counts = as(sc_example$counts, "sparseMatrix"),
+ data = as(sc_example$logcounts, "sparseMatrix"),
meta.data = sc_example$seurat_clusters)
# Add the t-SNE embedding