Skip to content

Commit

Permalink
Merge pull request drieslab#1060 from drieslab/suite_dev
Browse files Browse the repository at this point in the history
Giotto 4.1.4 - hotix visium spot polygon sizing
  • Loading branch information
jiajic authored Oct 30, 2024
2 parents cb82d37 + 661ae09 commit 2b0e652
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7650-7754")),
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@

# Giotto 4.1.4 (2024/10/30)

## Changes
* `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)

## New
Expand Down
16 changes: 13 additions & 3 deletions R/clustering.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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]]
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion R/convenience_general.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -782,9 +785,12 @@ 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,
npoints = 100
)

GiottoClass::polyStamp(
Expand Down
7 changes: 5 additions & 2 deletions man/doLeidenClusterIgraph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2b0e652

Please sign in to comment.