From b66fbc27d0ad7b807f07e2f9c68af34bc9daf506 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Sun, 27 Oct 2024 21:58:30 -0400 Subject: [PATCH 1/6] chore: bump version for dev and remove remotes --- DESCRIPTION | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 63bbf99a5..3902c7c70 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Giotto Title: Spatial Single-Cell Transcriptomics Toolbox -Version: 4.1.3 +Version: 4.1.4 Authors@R: c( person("Ruben", "Dries", email = "rubendries@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7650-7754")), @@ -108,10 +108,6 @@ Suggests: trendsceek, testthat (>= 3.0.0), rmarkdown -Remotes: - drieslab/GiottoUtils, - drieslab/GiottoClass, - drieslab/GiottoVisuals Collate: 'ONTraC_wrapper.R' 'auxiliary_giotto.R' From 37e81149f572b961c00bbe8a0f6ad258bba79b8d Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:21:10 -0400 Subject: [PATCH 2/6] fix: vis spot poly sizing --- NEWS.md | 6 ++++++ R/convenience_general.R | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index a1bf83a28..697a40264 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ + +# Giotto 4.1.4 + +## Changes +* apply a modifier of 0.8461538 to visium spot diameter to reflect actual spot size + # Giotto 4.1.3 (2024/10/27) ## New diff --git a/R/convenience_general.R b/R/convenience_general.R index 86cc63493..a38530b0a 100644 --- a/R/convenience_general.R +++ b/R/convenience_general.R @@ -782,9 +782,11 @@ addVisiumPolygons <- function( if (inherits(spatlocs, "spatLocsObj")) { spatlocs <- spatlocs[] } + + spot_adj <- 55 / 65 vis_spot_poly <- GiottoClass::circleVertices( - radius = json_scalefactors$spot_diameter_fullres / 2 + radius = json_scalefactors$spot_diameter_fullres / 2 * spot_adj ) GiottoClass::polyStamp( From 6c1bca29f5db02a428dc5fadf08321b35ba78545 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:21:32 -0400 Subject: [PATCH 3/6] chore: deprecate param for harmonization --- NEWS.md | 1 + R/clustering.R | 16 +++++++++++++--- man/doLeidenClusterIgraph.Rd | 7 +++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 697a40264..0ca25996c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ ## Changes * apply a modifier of 0.8461538 to visium spot diameter to reflect actual spot size +* deprecate param `resolution_parameter` in favor of `resolution` for `doLeidenClusterIgraph()` # Giotto 4.1.3 (2024/10/27) diff --git a/R/clustering.R b/R/clustering.R index fe858c0f4..7b11dcfa9 100644 --- a/R/clustering.R +++ b/R/clustering.R @@ -237,7 +237,8 @@ doLeidenCluster <- function(gobject, #' @param network_name name of NN network to use, default to "sNN.pca" #' @param objective_function objective function for the leiden algo #' @param weights weights of edges -#' @param resolution_parameter resolution, default = 1 +#' @param resolution resolution, default = 1 +#' @param resolution_parameter deprecated. Use `resolution` instead #' @param beta leiden randomness #' @param initial_membership initial membership of cells for the partition #' @param n_iterations number of interations to run the Leiden algorithm. @@ -246,6 +247,7 @@ doLeidenCluster <- function(gobject, #' @param seed_number number for seed #' @inheritDotParams igraph::cluster_leiden -graph -objective_function #' -resolution_parameter -beta -weights -initial_membership -n_iterations +#' -resolution #' @returns giotto object with new clusters appended to cell metadata #' @details #' This function is a wrapper for the Leiden algorithm implemented in igraph, @@ -270,7 +272,8 @@ doLeidenClusterIgraph <- function(gobject, network_name = "sNN.pca", objective_function = c("modularity", "CPM"), weights = NULL, - resolution_parameter = 1, + resolution = 1, + resolution_parameter = deprecated(), beta = 0.01, initial_membership = NULL, n_iterations = 1000, @@ -288,6 +291,13 @@ doLeidenClusterIgraph <- function(gobject, spat_unit = spat_unit, feat_type = feat_type ) + + resolution <- deprecate_param( + x = resolution_parameter, + y = resolution, + fun = "doLeidenClusterIgraph", + when = "4.1.4" + ) ## get cell IDs ## cell_ID_vec <- gobject@cell_ID[[spat_unit]] @@ -321,7 +331,7 @@ doLeidenClusterIgraph <- function(gobject, leiden_clusters <- igraph::cluster_leiden( graph = graph_object_undirected, objective_function = objective_function, - resolution_parameter = resolution_parameter, + resolution = resolution, beta = beta, weights = weights, initial_membership = initial_membership, diff --git a/man/doLeidenClusterIgraph.Rd b/man/doLeidenClusterIgraph.Rd index 2ef5f9c6b..4037b9afb 100644 --- a/man/doLeidenClusterIgraph.Rd +++ b/man/doLeidenClusterIgraph.Rd @@ -13,7 +13,8 @@ doLeidenClusterIgraph( network_name = "sNN.pca", objective_function = c("modularity", "CPM"), weights = NULL, - resolution_parameter = 1, + resolution = 1, + resolution_parameter = deprecated(), beta = 0.01, initial_membership = NULL, n_iterations = 1000, @@ -41,7 +42,9 @@ doLeidenClusterIgraph( \item{weights}{weights of edges} -\item{resolution_parameter}{resolution, default = 1} +\item{resolution}{resolution, default = 1} + +\item{resolution_parameter}{deprecated. Use `resolution` instead} \item{beta}{leiden randomness} From e27c851bbe179a4a03efab16acc456acf5ac413d Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:12:37 -0400 Subject: [PATCH 4/6] enh: append scalefactor during visium creation - also increase number of vertices used in the spots --- R/convenience_general.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/convenience_general.R b/R/convenience_general.R index a38530b0a..ba0cacd58 100644 --- a/R/convenience_general.R +++ b/R/convenience_general.R @@ -511,6 +511,9 @@ createGiottoVisiumObject <- function( verbose = FALSE, initialize = TRUE ) + + ms <- 65 / json_info$spot_diameter_fullres + instructions(giotto_object, "micron_scale") <- ms } return(giotto_object) @@ -786,7 +789,8 @@ addVisiumPolygons <- function( spot_adj <- 55 / 65 vis_spot_poly <- GiottoClass::circleVertices( - radius = json_scalefactors$spot_diameter_fullres / 2 * spot_adj + radius = json_scalefactors$spot_diameter_fullres / 2 * spot_adj, + npoints = 100 ) GiottoClass::polyStamp( From 6bcbcb2e9f8c2fb1328c24971a57c6a52b1daca3 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:12:43 -0400 Subject: [PATCH 5/6] Update NEWS.md --- NEWS.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0ca25996c..9ecdd4e72 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,14 @@ -# Giotto 4.1.4 +# Giotto 4.1.4 (2024/10/30) ## Changes -* apply a modifier of 0.8461538 to visium spot diameter to reflect actual spot size -* deprecate param `resolution_parameter` in favor of `resolution` for `doLeidenClusterIgraph()` +* `createGiottoVisiumObject()` apply a modifier of 0.8461538 to visium spot diameter to reflect actual spot size +* `doLeidenClusterIgraph()` deprecate param `resolution_parameter` in favor of `resolution` + +## Enhancements +* `createGiottoVisiumObject()` append multiplicative scalefactor to get micron + values from the current coordinate units during Visium object creation. + Accessible through `instructions(gobject, "micron_scale")` # Giotto 4.1.3 (2024/10/27) From 7e3b298078104dfc6442480ba7a10682684b1fac Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:12:40 -0400 Subject: [PATCH 6/6] chore: add back remotes --- DESCRIPTION | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 3902c7c70..2f88d432a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -108,6 +108,10 @@ Suggests: trendsceek, testthat (>= 3.0.0), rmarkdown +Remotes: + drieslab/GiottoUtils, + drieslab/GiottoClass, + drieslab/GiottoVisuals Collate: 'ONTraC_wrapper.R' 'auxiliary_giotto.R'