diff --git a/DESCRIPTION b/DESCRIPTION index e4cd68d0b..f5414b57f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Giotto Title: Spatial Single-Cell Transcriptomics Toolbox -Version: 4.0.4 +Version: 4.0.5 Authors@R: c( person("Ruben", "Dries", email = "rubendries@gmail.com", role = c("aut", "cre")), diff --git a/NEWS.md b/NEWS.md index 5c4175b95..5c4db1554 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,12 @@ +# Giotto 4.0.5 (2024/03/12) -# Giotto 4.0.4 +## Bug fixes +* Fix Error "cannot coerce class ‘structure("spatLocsObj", package = "Giotto")’ to a data.frame" in `spatialDE()` + +## Enhancements +* `readPolygonVizgenParquet()` now has `calc_centroids = TRUE` by default + +# Giotto 4.0.4 (2024/02/28) ## Breaking changes * Remove `do_manual_adj` and image adjustment params from `createGiottoVisiumObject()` diff --git a/R/general_help.R b/R/general_help.R index 2d34ffe1f..0463fe6da 100644 --- a/R/general_help.R +++ b/R/general_help.R @@ -1149,12 +1149,15 @@ readPolygonFilesVizgenHDF5 = function(boundaries_path, #' can be selected. #' @param file parquet file to load #' @param z_index either 'all' or a numeric vector of z_indices to get polygons for +#' @param calc_centroids calculate centroids for the polygons (default = TRUE) #' @param verbose be verbose -#' @keywords internal #' @export -readPolygonVizgenParquet = function(file, - z_index = 'all', - verbose = TRUE) { +readPolygonVizgenParquet = function( + file, + z_index = 'all', + calc_centroids = TRUE, + verbose = TRUE +) { # package checks package_check('arrow') @@ -1223,6 +1226,12 @@ readPolygonVizgenParquet = function(file, spatVector = sv, unique_ID_cache = poly_table$EntityID ) + + if(isTRUE(calc_centroids)) { + # NOTE: will not recalculate if centroids are already attached + gpoly = GiottoClass::centroids(x = gpoly, append_gpolygon = TRUE) + } + }) return(out) diff --git a/R/spatial_genes.R b/R/spatial_genes.R index 63bb6d916..144c6c5aa 100644 --- a/R/spatial_genes.R +++ b/R/spatial_genes.R @@ -2026,10 +2026,11 @@ spatialDE <- function(gobject = NULL, # expression values = match.arg(expression_values, c('raw', 'normalized', 'scaled', 'custom')) - expr_values = get_expression_values(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - values = values) + expr_values = getExpression(gobject = gobject, + spat_unit = spat_unit, + feat_type = feat_type, + values = values, + output = "matrix") ## python path if(is.null(python_path)) { @@ -2042,9 +2043,10 @@ spatialDE <- function(gobject = NULL, reticulate::source_python(file = reader_path) ## get spatial locations - spatial_locs = get_spatial_locations(gobject, - spat_unit = spat_unit, - spat_loc_name = spat_loc_name) + spatial_locs = getSpatialLocations(gobject, + spat_unit = spat_unit, + name = spat_loc_name, + output = "data.table") spatial_locs <- as.data.frame(spatial_locs) rownames(spatial_locs) <- spatial_locs$cell_ID spatial_locs <- subset(spatial_locs, select = -cell_ID) @@ -3810,6 +3812,9 @@ heatmSpatialCorFeats = function(gobject, stop('\n spatCorObject needs to be the output from detectSpatialCorFeats() \n') } + ## package check for ComplexHeatmap + package_check(pkg_name = 'ComplexHeatmap', repository = 'CRAN') + ## create correlation matrix cor_DT = spatCorObject[['cor_DT']] cor_DT_dc = data.table::dcast.data.table(cor_DT, formula = feat_ID~variable, value.var = 'spat_cor') diff --git a/man/readPolygonVizgenParquet.Rd b/man/readPolygonVizgenParquet.Rd index b47b2c45d..37c33ccee 100644 --- a/man/readPolygonVizgenParquet.Rd +++ b/man/readPolygonVizgenParquet.Rd @@ -4,17 +4,23 @@ \alias{readPolygonVizgenParquet} \title{Read MERSCOPE polygons from parquet} \usage{ -readPolygonVizgenParquet(file, z_index = "all", verbose = TRUE) +readPolygonVizgenParquet( + file, + z_index = "all", + calc_centroids = TRUE, + verbose = TRUE +) } \arguments{ \item{file}{parquet file to load} \item{z_index}{either 'all' or a numeric vector of z_indices to get polygons for} +\item{calc_centroids}{calculate centroids for the polygons (default = TRUE)} + \item{verbose}{be verbose} } \description{ Read Vizgen exported cell boundary parquet files as giottoPolyons. The z level can be selected. } -\keyword{internal}