From a5903395ae341f4bed7eb530d192337da9ea8d67 Mon Sep 17 00:00:00 2001 From: Iqra Amin <90134115+iqraAmin@users.noreply.github.com> Date: Thu, 3 Oct 2024 02:09:39 +0500 Subject: [PATCH 1/7] Update DESCRIPTION --- DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b72ab509..9c38e57e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,9 +26,9 @@ Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 Depends: - base (>= 4.4.1), - utils (>= 4.4.1), - R (>= 4.4.1), + base (>= 4.4.0), + utils (>= 4.4.0), + R (>= 4.4.0), Imports: checkmate, data.table (>= 1.12.2), From d9b5055973efe6283ba1ff9c6816a836f810f436 Mon Sep 17 00:00:00 2001 From: Iqra Amin <90134115+iqraAmin@users.noreply.github.com> Date: Thu, 3 Oct 2024 02:20:21 +0500 Subject: [PATCH 2/7] Update DESCRIPTION --- DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9c38e57e..b72ab509 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,9 +26,9 @@ Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 Depends: - base (>= 4.4.0), - utils (>= 4.4.0), - R (>= 4.4.0), + base (>= 4.4.1), + utils (>= 4.4.1), + R (>= 4.4.1), Imports: checkmate, data.table (>= 1.12.2), From 49cd813df3684cd598447dda8308a046af852568 Mon Sep 17 00:00:00 2001 From: iqraAmin Date: Mon, 11 Nov 2024 19:50:48 -0500 Subject: [PATCH 3/7] Update Seurat and Giotto Interoperability for Xenium Image --- R/interoperability.R | 122 ++++++++++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 49 deletions(-) diff --git a/R/interoperability.R b/R/interoperability.R index 14cd5941..39a62040 100644 --- a/R/interoperability.R +++ b/R/interoperability.R @@ -1465,6 +1465,7 @@ giottoToSeuratV4 <- function(gobject, #' @export giottoToSeuratV5 <- function(gobject, spat_unit = NULL, + dataType, res_type = c("hires", "lowres", "fullres"), ...) { # data.table vars @@ -1795,17 +1796,36 @@ giottoToSeuratV5 <- function(gobject, # since we allow use non-lowres images ) # see https://github.com/satijalab/seurat/issues/3595 - newV1 <- new( - Class = "VisiumV1", - image = img_array, - scale.factors = scalefactors, - coordinates = coord, - spot.radius = + if (dataType != 0){ + if(dataType == "xenium"){ + coord1 <- coord + coord$cell_id <- rownames(coord) + coord <- coord[, c("cell_id", "imagerow", "imagecol")] + segmentations.data <- list( + "centroids" = CreateCentroids(coord1), + "segmentation" = CreateSegmentation(coord) + ) + coords <- CreateFOV( + coords = segmentations.data, + type = c("segmentation", "centroids"), + assay = "rna") + fov <- "default_fov" + sobj[[fov]] <- coords + }else{ + newV1 <- new( + Class = "VisiumV1", + image = img_array, + scale.factors = scalefactors, + coordinates = coord, + spot.radius = scalef$fiducial * scalef$lowres / max(dim(img_array)), - key = paste0(key, "_") - ) - - sobj@images[[key]] <- newV1 + key = paste0(key, "_") + ) + + sobj@images[[key]] <- newV1 + } + } + } } @@ -2369,50 +2389,54 @@ seuratToGiottoV5 <- function(sobject, gpoints <- createGiottoPoints(mol_spatlocs, feat_type = "rna" ) - if ("centroids" %in% names(sobject@images[[i]])) { - centroids_coords <- - sobject@images[[i]]$centroids@coords - centroids_coords <- vect(centroids_coords) - gpolygon <- create_giotto_polygon_object( - name = "cell", spatVector = centroids_coords - ) - } - if ("segmentation" %in% names(sobject@images[[i]])) { - polygon_list <- list() - - for (j in seq(sobject@images[[ - i - ]]@boundaries$segmentation@polygons)) { - polygon_info <- sobject@images[[ - i - ]]@boundaries$segmentation@polygons[[j]] - - # Get coordinates from segmentation - seg_coords <- polygon_info@Polygons[[1]]@coords - - # Fetch cell_Id from polygon information - cell_ID <- polygon_info@ID - - # Convert it to SpatVector - seg_coords <- vect(seg_coords) - - # Create giotto_polygon_object - gpolygon <- create_giotto_polygon_object( - name = "cell", - spatVector = centroids_coords, - spatVectorCentroids = seg_coords - ) - - # Add the cell_ID to the list of polygon names - polygon_list[[cell_ID]] <- gpolygon - } - } } } + if ("centroids" %in% names(sobject@images[[i]])) { + centroids_coords <- + sobject@images[[i]]$centroids@coords + centroids_coords <- vect(centroids_coords) + gpolygon <- create_giotto_polygon_object( + name = "cell", spatVector = centroids_coords + ) + } + if ("segmentation" %in% names(sobject@images[[i]])) { + polygon_list <- list() + for (j in seq(sobject@images[[ + i + ]]@boundaries$segmentation@polygons)) { + polygon_info <- sobject@images[[ + i + ]]@boundaries$segmentation@polygons[[j]] + # Get coordinates from segmentation + + seg_coords <- polygon_info@Polygons[[1]]@coords + # Fetch cell_Id from polygon information + cell_ID <- polygon_info@ID + # Convert it to SpatVector + seg_coords <- vect(seg_coords) + # Create giotto_polygon_object + gpolygon <- create_giotto_polygon_object( + name = "cell", + spatVector = centroids_coords, + spatVectorCentroids = seg_coords + + ) + # Add the cell_ID to the list of polygon names + polygon_list[[cell_ID]] <- gpolygon + } + + } + } } } - + + + + + + + # Find SueratImages, extract them, and pass to create image image_list <- list() for (i in names(sobject@images)) { From 110c48b524b371381f2d3374376f75f06bd892dc Mon Sep 17 00:00:00 2001 From: Iqra Amin <90134115+iqraAmin@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:23:28 +0500 Subject: [PATCH 4/7] Update DESCRIPTION --- DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b72ab509..9c38e57e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,9 +26,9 @@ Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 Depends: - base (>= 4.4.1), - utils (>= 4.4.1), - R (>= 4.4.1), + base (>= 4.4.0), + utils (>= 4.4.0), + R (>= 4.4.0), Imports: checkmate, data.table (>= 1.12.2), From 39b06c71b0bdbac48b2b2325ee2fcaaafec039c0 Mon Sep 17 00:00:00 2001 From: Iqra Amin <90134115+iqraAmin@users.noreply.github.com> Date: Fri, 15 Nov 2024 02:05:10 +0500 Subject: [PATCH 5/7] Update DESCRIPTION --- DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9c38e57e..b72ab509 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,9 +26,9 @@ Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 Depends: - base (>= 4.4.0), - utils (>= 4.4.0), - R (>= 4.4.0), + base (>= 4.4.1), + utils (>= 4.4.1), + R (>= 4.4.1), Imports: checkmate, data.table (>= 1.12.2), From 2f180f840b7884a00040ed430ccec3e4e3151bb2 Mon Sep 17 00:00:00 2001 From: Iqra Amin <90134115+iqraAmin@users.noreply.github.com> Date: Thu, 21 Nov 2024 20:36:32 +0500 Subject: [PATCH 6/7] Update interoperability.R Fixed Scoping Issue --- R/interoperability.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/interoperability.R b/R/interoperability.R index 39a62040..85de6b32 100644 --- a/R/interoperability.R +++ b/R/interoperability.R @@ -1802,10 +1802,10 @@ giottoToSeuratV5 <- function(gobject, coord$cell_id <- rownames(coord) coord <- coord[, c("cell_id", "imagerow", "imagecol")] segmentations.data <- list( - "centroids" = CreateCentroids(coord1), - "segmentation" = CreateSegmentation(coord) + "centroids" = SeuratObject::CreateCentroids(coord1), + "segmentation" = SeuratObject::CreateSegmentation(coord) ) - coords <- CreateFOV( + coords <- SeuratObject::CreateFOV( coords = segmentations.data, type = c("segmentation", "centroids"), assay = "rna") From e386d71220cd016694f96df12ef87ec63e28f302 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:58:42 -0500 Subject: [PATCH 7/7] enh: allow featType and spatUnit to do nothing when unsupported --- R/methods-nesting.R | 6 ++++++ man/featType-generic.Rd | 3 +++ man/spatUnit-generic.Rd | 3 +++ 3 files changed, 12 insertions(+) diff --git a/R/methods-nesting.R b/R/methods-nesting.R index adcb0089..62d66768 100644 --- a/R/methods-nesting.R +++ b/R/methods-nesting.R @@ -85,6 +85,9 @@ setMethod("spatUnit", signature = "spatData", function(x) x@spat_unit) #' @export setMethod("spatUnit", signature("giottoPolygon"), function(x) x@name) +#' @rdname spatUnit-generic +#' @export +setMethod("spatUnit<-", signature("ANY"), function(x, value) x) #' @describeIn spatUnit-generic Set spatial unit information #' @export @@ -141,6 +144,9 @@ setMethod("featType", signature("list"), function(x) { #' @export setMethod("featType", signature = "featData", function(x) x@feat_type) +#' @rdname featType-generic +#' @export +setMethod("featType<-", signature("ANY"), function(x, value) x) #' @describeIn featType-generic Set feature type information #' @export diff --git a/man/featType-generic.Rd b/man/featType-generic.Rd index 1b31f06f..9147bb67 100644 --- a/man/featType-generic.Rd +++ b/man/featType-generic.Rd @@ -7,6 +7,7 @@ \alias{featType,ANY-method} \alias{featType,list-method} \alias{featType,featData-method} +\alias{featType<-,ANY-method} \alias{featType<-,featData-method} \alias{featType<-,list-method} \title{Feature type information} @@ -17,6 +18,8 @@ \S4method{featType}{featData}(x) +\S4method{featType}{ANY}(x) <- value + \S4method{featType}{featData}(x) <- value \S4method{featType}{list}(x) <- value diff --git a/man/spatUnit-generic.Rd b/man/spatUnit-generic.Rd index 178379de..a69d0e1a 100644 --- a/man/spatUnit-generic.Rd +++ b/man/spatUnit-generic.Rd @@ -8,6 +8,7 @@ \alias{spatUnit,list-method} \alias{spatUnit,spatData-method} \alias{spatUnit,giottoPolygon-method} +\alias{spatUnit<-,ANY-method} \alias{spatUnit<-,spatData-method} \alias{spatUnit<-,giottoPolygon-method} \alias{spatUnit<-,list-method} @@ -21,6 +22,8 @@ \S4method{spatUnit}{giottoPolygon}(x) +\S4method{spatUnit}{ANY}(x) <- value + \S4method{spatUnit}{spatData}(x) <- value \S4method{spatUnit}{giottoPolygon}(x) <- value