vitessce / vitessceR

R API and htmlwidget for Vitessce
https://r-docs.vitessce.io
Other
38 stars 9 forks source link

OmeZarrWrapper instead of OmeTiffWrapper ? #86

Open Artur-man opened 3 months ago

Artur-man commented 3 months ago

Hey there,

I would like to create this issue, also discussed in https://imagesc.zulipchat.com. It seems OmeTiffWrapper objects behave well with AnnDataWrapper with no problem, but are there any plans for implementing an OmeZarrWrapper functioning similar to OmeTiffWrapper ?

Sharing an example below:

library(vitessceR)
vc <- VitessceConfig$new(schema_version = "1.0.15", name='MBrain Example', description='mBrain')
dataset <- vc$add_dataset("MBrain")$add_object(
  MultiImageWrapper$new(
    image_wrappers = list(
      OmeTiffWrapper$new(name="Test", img_path="data/p01_x01_y01_wx0_wy0_c1.ome.tif")
    )
  )
)$add_object(
  AnnDataWrapper$new(
    adata_path="data/mbrain.zarr/",
    obs_set_paths = c("obs/clusters"),
    obs_set_names = c("Clusters"),
    obs_locations_path = "obsm/spatial",
    obs_segmentations_path="obsm/segmentation",
    obs_embedding_paths=c("obsm/umap")
  )
)
umap <- vc$add_view(dataset = dataset, Component$SCATTERPLOT, mapping = "umap")
cell_sets <- vc$add_view(dataset, Component$OBS_SETS)
spatial <- vc$add_view(dataset, Component$SPATIAL)
spatial_layers <- vc$add_view(dataset, Component$LAYER_CONTROLLER)
spatial_segmentation_layer_value <- list(opacity = 1, radius = 0, visible = TRUE, stroked = FALSE)
vc$link_views(views = c(spatial),
              c_types = c(CoordinationType$SPATIAL_ZOOM, "spatialSegmentationLayer"),
              c_values = c(0, spatial_segmentation_layer_value))

vc$layout(
  hconcat(spatial, vconcat(umap, hconcat(cell_sets, spatial_layers)))
)
vc$widget()

Screenshot 2024-07-16 at 22 35 37

ashishjain1988 commented 3 months ago

Hey @Artur-man,

I am getting an error while adding the MultiImageWrapper object to the VitessceConfig object. Did you also encountered the same issue while running your code?

vc <- VitessceConfig$new(schema_version = "1.0.15", name = "My config") vc$add_dataset("T604")$add_object( MultiImageWrapper$new( image_wrappers = list( OmeTiffWrapper$new(name="Test", img_path="data/cytassist_image.tiff") ) ) )

Error in obj$convert_and_save(self$dataset$uid, length(private$objs), : unused argument (base_dir = self$base_dir)

Regards, Ashish Jain

Artur-man commented 3 months ago

Ah ok, I think I have corrected this in my fork as well. You have to pass the self$base_dir from MultiImageWrapper's convert_and_save to OmeTiffWrapper's convert_and_save, like in here: https://github.com/vitessce/vitessceR/commit/a6dd34fcf83cf1f120e8b9206681b5c7665a3740.