Skip to content

Include functions to work on SpatialData objects #19

Description

@sgunz

Following up on what was started during the Venice Bioc hackathon.

library("duckspatial")
library("SpatialData")

sostaPolygonShape <- function(x, # SD class
                              shapeName, # name of the shape layer
                              marks, # mark column of interest
                              markSelect, # selected mark for reconstruction
                              dim = 500, # reconstruction dim
                              ... # other sosta parameters
                              ){
 # would be good to find a better method select centroids 
 # plus rest of the data, lazy not possible due to CRS
 crd <- st_centroid(shape(x, shapeName)$geometry) |>
  st_coordinates() 
 
 # md <- shape(x, shapeName)@data |>
 #  ddbs_drop_geometry() |>
 #  as.data.frame()
 
 # now I just get in colData everything, maybe make this slimmer 
 # to reduce memory overhead
 cd <- getTable(x, shapeName) |>
  colData()
 #where is the cell_id in `md` and `cd`: int_colData
 pp <- .df2ppp(cbind(crd, cd),
               xName = colnames(crd)[[1]],
               yName = colnames(crd)[[2]],
               marks = marks)
 poly <- reconstructShapeDensity(pp, markSelect, dim = dim, ...)
 return(poly)
}

res <- sostaPolygonShape(
 x = sd,
 shapeName = "cell_boundaries",
 marks = "transferred_celltype_plot",
 markSelect = "DCIS2",
 dim = 500
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions