From a41d019f309e00b1e4a3128803ae10ea94fe7159 Mon Sep 17 00:00:00 2001 From: josschavezf Date: Fri, 8 Mar 2024 12:29:58 -0500 Subject: [PATCH 1/6] =?UTF-8?q?fix=20Error:=20cannot=20coerce=20class=20?= =?UTF-8?q?=E2=80=98structure("spatLocsObj",=20package=20=3D=20"Giotto")?= =?UTF-8?q?=E2=80=99=20to=20a=20data.frame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/spatial_genes.R | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/R/spatial_genes.R b/R/spatial_genes.R index 63bb6d916..10a29eeeb 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) From 7243c289580c7f9b6a4f6aeb9fba2a9e4f74304b Mon Sep 17 00:00:00 2001 From: josschavezf Date: Fri, 8 Mar 2024 12:32:10 -0500 Subject: [PATCH 2/6] update news --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 5c4175b95..728ce56da 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Giotto TBD + +## Bug fixes +* Fix Error "cannot coerce class ‘structure("spatLocsObj", package = "Giotto")’ to a data.frame" in `spatialDE()` # Giotto 4.0.4 From 3828f8fde64e697be5218495f0044e1efb4b83aa Mon Sep 17 00:00:00 2001 From: RubD Date: Mon, 11 Mar 2024 22:39:02 -0400 Subject: [PATCH 3/6] add centroids to parquet polygon reader --- R/general_help.R | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/R/general_help.R b/R/general_help.R index 2d34ffe1f..243def437 100644 --- a/R/general_help.R +++ b/R/general_help.R @@ -1149,11 +1149,13 @@ 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', + calc_centroids = TRUE, verbose = TRUE) { # package checks @@ -1223,6 +1225,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 = .calculate_centroids_polygons(gpolygon = gpoly, append_gpolygon = TRUE) + } + }) return(out) From c0680fd3659047a5da9113eee486643957ba82a3 Mon Sep 17 00:00:00 2001 From: RubD Date: Tue, 12 Mar 2024 14:44:19 -0400 Subject: [PATCH 4/6] add package check for complexheatmap in heatmSpatialCorFeats --- R/spatial_genes.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/spatial_genes.R b/R/spatial_genes.R index 10a29eeeb..144c6c5aa 100644 --- a/R/spatial_genes.R +++ b/R/spatial_genes.R @@ -3812,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') From f0c888993c4c6706449fbfb02b9628a71ba55166 Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:51:52 -0400 Subject: [PATCH 5/6] chore: bump version for dev --- DESCRIPTION | 2 +- NEWS.md | 7 +++++-- R/general_help.R | 2 +- man/readPolygonVizgenParquet.Rd | 9 ++++++++- 4 files changed, 15 insertions(+), 5 deletions(-) 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 728ce56da..5c4db1554 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,12 @@ -# Giotto TBD +# Giotto 4.0.5 (2024/03/12) ## Bug fixes * Fix Error "cannot coerce class ‘structure("spatLocsObj", package = "Giotto")’ to a data.frame" in `spatialDE()` -# Giotto 4.0.4 +## 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 243def437..18a8025b7 100644 --- a/R/general_help.R +++ b/R/general_help.R @@ -1228,7 +1228,7 @@ readPolygonVizgenParquet = function(file, if(isTRUE(calc_centroids)) { # NOTE: will not recalculate if centroids are already attached - gpoly = .calculate_centroids_polygons(gpolygon = gpoly, append_gpolygon = TRUE) + gpoly = GiottoClass::centroids(x = gpoly, append_gpolygon = TRUE) } }) diff --git a/man/readPolygonVizgenParquet.Rd b/man/readPolygonVizgenParquet.Rd index b47b2c45d..49673064a 100644 --- a/man/readPolygonVizgenParquet.Rd +++ b/man/readPolygonVizgenParquet.Rd @@ -4,13 +4,20 @@ \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{ From 67a4d08fab8c0b9efe0452808c10daaeb25c5f3d Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:07:57 -0400 Subject: [PATCH 6/6] chore: make `readPolygonVizgenParquet()` non-internal --- R/general_help.R | 11 ++++++----- man/readPolygonVizgenParquet.Rd | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/general_help.R b/R/general_help.R index 18a8025b7..0463fe6da 100644 --- a/R/general_help.R +++ b/R/general_help.R @@ -1151,12 +1151,13 @@ readPolygonFilesVizgenHDF5 = function(boundaries_path, #' @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', - calc_centroids = TRUE, - verbose = TRUE) { +readPolygonVizgenParquet = function( + file, + z_index = 'all', + calc_centroids = TRUE, + verbose = TRUE +) { # package checks package_check('arrow') diff --git a/man/readPolygonVizgenParquet.Rd b/man/readPolygonVizgenParquet.Rd index 49673064a..37c33ccee 100644 --- a/man/readPolygonVizgenParquet.Rd +++ b/man/readPolygonVizgenParquet.Rd @@ -24,4 +24,3 @@ readPolygonVizgenParquet( Read Vizgen exported cell boundary parquet files as giottoPolyons. The z level can be selected. } -\keyword{internal}