pachterlab / SpatialFeatureExperiment

Extension of SpatialExperiment with sf
https://pachterlab.github.io/SpatialFeatureExperiment
Artistic License 2.0
36 stars 7 forks source link

Get and set the primary `colGeometry` #24

Open lambdamoses opened 7 months ago

lambdamoses commented 7 months ago

In practice there usually is a primary colGeometry, and we can reorder the colGeometries so the first one is the primary one, like cell segmentation in MERFISH and Visium spots (or you can change it to the centroids). Maybe we can have a convenience function to do such reordering since many functions default to the first one.

lambdamoses commented 7 months ago

Assigned to @mingqizh

lambdamoses commented 7 months ago

Inspect internals:

library(SingleCellExperiment)
devtools::load_all()
# Inspect the internals
int_colData(sfe)

You should see that int_colData(sfe) is a DataFrame (S4 data frame), with columns that include reducedDims, spatialCoords, and colGeometries. The columns themselves can be DataFrames. Next run int_colData(sfe)$colGeometries to see the internals of colGeometries. It should be a DataFrame whose columns are sf data frames. Then simply reorder the columns of int_colData(sfe)$colGeometries so the first column is the primary colGeometry.