diff --git a/.BBSoptions b/.BBSoptions
deleted file mode 100644
index 7a13ab8..0000000
--- a/.BBSoptions
+++ /dev/null
@@ -1 +0,0 @@
-UnsupportedPlatforms: win32
diff --git a/.gitignore b/.gitignore
index 1a0b733..36bd750 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,5 @@ data/
check/
vignettes/data/
*.Rproj
-.RData
\ No newline at end of file
+.RData
+my_vitessce_files/
\ No newline at end of file
diff --git a/DESCRIPTION b/DESCRIPTION
index d8f7cb7..af7aab4 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -14,11 +14,10 @@ Authors@R: c(
Description:
R API and htmlwidget facilitating interactive visualization
of spatial single-cell data with Vitessce. The R API contains
- classes and functions for loading single-cell data stored as
- SingleCellExperiment, SpatialExperiment, and Seurat objects.
- The htmlwidget is a wrapper around the Vitessce JavaScript
- library and can be used in the Viewer tab of RStudio or Shiny
- apps.
+ classes and functions for loading single-cell data stored in
+ compatible on-disk formats. The htmlwidget is a wrapper around
+ the Vitessce JavaScript library and can be used in the Viewer tab
+ of RStudio or Shiny apps.
biocViews: SingleCell, Spatial, Visualization, ShinyApps
License: MIT + file LICENSE
BugReports: https://github.com/vitessce/vitessceR/issues
@@ -37,21 +36,16 @@ Imports:
jsonlite,
R6,
plumber,
+ mime,
future,
httpuv,
stringr,
- reticulate,
- varhandle,
+ stringi,
tools,
stats,
methods,
S4Vectors,
- grDevices,
- basilisk,
- zellkonverter,
- SummarizedExperiment,
- SingleCellExperiment,
- SpatialExperiment
+ grDevices
Suggests:
testthat,
knitr,
@@ -60,7 +54,4 @@ Suggests:
pkgdown,
rmarkdown,
purrr,
- rjson,
- Seurat,
- SeuratDisk,
- Giotto
+ rjson
diff --git a/LICENSE b/LICENSE
index fe7fcba..7de4da0 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,2 +1,2 @@
YEAR: 2020
-COPYRIGHT HOLDER: Gehlenborg Lab
+COPYRIGHT HOLDER: HIDIVE Lab
diff --git a/LICENSE.md b/LICENSE.md
index 43627c9..e149ba7 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
# MIT License
-Copyright (c) 2020 Gehlenborg Lab
+Copyright (c) 2020 HIDIVE Lab
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/NAMESPACE b/NAMESPACE
index 709fe20..52db099 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,44 +1,20 @@
# Generated by roxygen2: do not edit by hand
export(AbstractWrapper)
+export(AnnDataWrapper)
export(Component)
export(CoordinationType)
+export(CsvWrapper)
export(DataType)
export(FileType)
-export(GiottoWrapper)
export(MultiImageWrapper)
export(OmeTiffWrapper)
-export(SCEWrapper)
-export(SPEWrapper)
-export(SeuratWrapper)
export(VitessceConfig)
-export(get_giotto_obj)
-export(get_sce_obj)
-export(get_seurat_obj)
-export(get_spe_obj)
-export(giotto_to_anndata_zarr)
export(hconcat)
export(obj_list)
export(render_vitessce)
-export(sce_to_anndata_zarr)
-export(seurat_to_anndata_zarr)
-export(spe_to_anndata_zarr)
-export(spe_to_ome_zarr)
export(vconcat)
export(vitessce_output)
export(vitessce_widget)
import(R6)
import(plumber)
-importFrom(SingleCellExperiment,"reducedDims<-")
-importFrom(SingleCellExperiment,int_colData)
-importFrom(SingleCellExperiment,reducedDims)
-importFrom(SpatialExperiment,"colData<-")
-importFrom(SpatialExperiment,getImg)
-importFrom(SummarizedExperiment,colData)
-importFrom(grDevices,as.raster)
-importFrom(grDevices,col2rgb)
-importFrom(methods,new)
-importFrom(methods,slot)
-importFrom(stats,rnorm)
-importFrom(stats,rpois)
-importFrom(stats,runif)
diff --git a/R/basilisk.R b/R/basilisk.R
deleted file mode 100644
index a704283..0000000
--- a/R/basilisk.R
+++ /dev/null
@@ -1,28 +0,0 @@
-#' The Python environment
-#'
-#' Defines a conda environment via Basilisk, which is used
-#' to convert R objects to Zarr stores.
-#' This environment has been adapted from zellkonverter::.AnnDataDependencies.
-#' Reference: https://bioconductor.org/packages/release/bioc/vignettes/basilisk/inst/doc/motivation.html
-#'
-#' @keywords internal
-py_env <- basilisk::BasiliskEnvironment(
- envname="vitessce_basilisk_env",
- pkgname="vitessceR",
- packages=c(
- "numpy==1.*",
- "pandas==1.*",
- "anndata==0.7.*",
- "h5py==3.*",
- "hdf5==1.*",
- "natsort==7.*",
- "packaging==20.*",
- "scipy==1.*",
- "sqlite==3.*",
- "zarr==2.*",
- "numcodecs==0.*"
- ),
- pip=c(
- "ome-zarr==0.2.1"
- )
-)
diff --git a/R/config.R b/R/config.R
index 5757edd..5d43046 100644
--- a/R/config.R
+++ b/R/config.R
@@ -60,17 +60,20 @@ VitessceConfigDatasetFile <- R6::R6Class("VitessceConfigDatasetFile",
#' @param data_type A data type for the file.
#' @param file_type A file type for the file.
#' @param options A list of options to include for the file.
+ #' @param coordination_values A list of coordination values to include in the file definition.
#' @return A new `VitessceConfigDatasetFile` object.
- initialize = function(url = NA, data_type = NA, file_type = NA, options = NA) {
+ initialize = function(url = NA, file_type = NA, options = NA, coordination_values = NA, data_type = NA) {
private$file <- obj_list()
+ private$file[['fileType']] = file_type
if(!is_na(url)) {
private$file[['url']] = url
}
- private$file[['type']] = data_type
- private$file[['fileType']] = file_type
if(!is_na(options)) {
private$file[['options']] = options
}
+ if(!is_na(coordination_values)) {
+ private$file[['coordinationValues']] = coordination_values
+ }
},
#' @description
#' Convert the object to an R list. Helpful when converting the config to JSON.
@@ -95,18 +98,34 @@ VitessceConfigDataset <- R6::R6Class("VitessceConfigDataset",
public = list(
#' @field dataset The dataset as a list.
dataset = NULL,
+ #' @field base_dir The base directory for the config.
+ base_dir = NULL,
#' @description
#' Create a new dataset object.
#' @param uid A unique identifier string for the dataset.
#' @param name A name for the dataset
+ #' @param base_dir A directory which local files are configured relative to.
#' @return A new `VitessceConfigDataset` object.
- initialize = function(uid, name) {
+ initialize = function(uid, name, base_dir = NA) {
self$dataset <- list(
uid = uid,
name = name,
files = list()
)
private$objs <- list()
+ self$base_dir <- base_dir
+ },
+ #' @description
+ #' Get the dataset name.
+ #' @return The name as a string.
+ get_name = function() {
+ return(self$dataset[['name']])
+ },
+ #' @description
+ #' Get the dataset UID.
+ #' @return The uid as a string.
+ get_uid = function() {
+ return(self$dataset[['uid']])
},
#' @description
#' Add a file to this dataset.
@@ -117,14 +136,14 @@ VitessceConfigDataset <- R6::R6Class("VitessceConfigDataset",
#' @return Invisible self, to allow chaining.
#' @examples
#' base_url <- "http://localhost:8000/"
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' dataset <- vc$add_dataset("My dataset")$add_file(
#' url = paste0(base_url, "cells.json"),
#' data_type = DataType$CELLS,
#' file_type = FileType$CELLS_JSON
#' )
- add_file = function(url = NA, data_type = NA, file_type = NA, options = NA) {
- new_file <- VitessceConfigDatasetFile$new(url = url, data_type = data_type, file_type = file_type, options = options)
+ add_file = function(url = NA, file_type = NA, options = NA, coordination_values = NA, data_type = NA) {
+ new_file <- VitessceConfigDatasetFile$new(url = url, file_type = file_type, options = options, coordination_values = coordination_values)
self$dataset$files <- append(self$dataset$files, new_file)
invisible(self)
},
@@ -133,7 +152,7 @@ VitessceConfigDataset <- R6::R6Class("VitessceConfigDataset",
#' @param obj The data object to add.
#' @return Invisible self, to allow chaining.
add_object = function(obj) {
- obj$convert_and_save(self$dataset$uid, length(private$objs))
+ obj$convert_and_save(self$dataset$uid, length(private$objs), base_dir = self$base_dir)
private$objs <- append(private$objs, obj)
invisible(self)
},
@@ -172,11 +191,35 @@ VitessceConfigDataset <- R6::R6Class("VitessceConfigDataset",
retval <- self$dataset
retval$files <- obj_file_defs
- retval
+ return(retval)
+ }
+ )
+)
+
+CoordinationLevel <- R6::R6Class("CoordinationLevel",
+ public = list(
+ value = NULL,
+ cached_value = NULL,
+ initialize = function(value) {
+ self$value <- value
+ self$cached_value <- NA
+ },
+ set_cached = function(processed_level) {
+ self$cached_value <- processed_level
+ },
+ get_cached = function() {
+ return(self$cached_value)
+ },
+ is_cached = function() {
+ return(!is.na(self$cached_value))
}
)
)
+CL <- function(value) {
+ return(CoordinationLevel$new(value))
+}
+
#' Coordination scope in a VitessceConfig
#' @title VitessceConfigCoordinationScope Class
#' @docType class
@@ -196,11 +239,12 @@ VitessceConfigCoordinationScope <- R6::R6Class("VitessceConfigCoordinationScope"
#' Create a new coordination scope object.
#' @param c_type A coordination type name.
#' @param c_scope A coordination scope name.
+ #' @param c_value An initial value for the coordination scope.
#' @return A new `VitessceConfigCoordinationScope` object.
- initialize = function(c_type, c_scope) {
+ initialize = function(c_type, c_scope, c_value = NA) {
self$c_type <- c_type
self$c_scope <- c_scope
- self$c_value <- NA
+ self$c_value <- c_value
},
#' @description
#' Set the coordination value of this coordination scope object.
@@ -225,6 +269,35 @@ VitessceConfigCoordinationScope <- R6::R6Class("VitessceConfigCoordinationScope"
)
)
+VitessceConfigMetaCoordinationScope <- R6::R6Class("VitessceConfigMetaCoordinationScope",
+ public = list(
+ #' @field meta_scope The name of the coordination scope for metaCoordinationScopes.
+ meta_scope = NULL,
+ #' @field meta_by_scope The name of the coordination scope for metaCoordinationScopesBy.
+ meta_by_scope = NULL,
+ initialize = function(meta_scope, meta_by_scope) {
+ self$meta_scope = VitessceConfigCoordinationScope$new(CoordinationType$META_COORDINATION_SCOPES, meta_scope)
+ self$meta_by_scope = VitessceConfigCoordinationScope$new(CoordinationType$META_COORDINATION_SCOPES_BY, meta_by_scope)
+ },
+ use_coordination = function(c_scopes) {
+ if(is.na(self$meta_scope4c_value)) {
+ self$meta_scope$set_value(obj_list())
+ }
+
+ meta_scopes_val <- self$meta_scope$c_value
+ for(c_scope in c_scopes) {
+ meta_scopes_val[[c_scope$c_type]] <- c_scope$c_scope
+ }
+ self$meta_scope$set_value(meta_scopes_val)
+ invisible(self)
+ },
+ use_coordination_by_dict = function(scopes) {
+ # TODO
+ invisible(self)
+ }
+ )
+)
+
#' Horizontal view concatenation in a VitessceConfig
#' @title VitessceConfigViewHConcat Class
#' @docType class
@@ -310,6 +383,14 @@ VitessceConfigView <- R6::R6Class("VitessceConfigView",
}
invisible(self)
},
+ use_coordination_by_dict = function(scopes) {
+ # TODO
+ invisible(self)
+ },
+ use_meta_coordination = function(meta_scope) {
+ # TODO
+ invisible(self)
+ },
#' @description
#' Set the dimensions of the view.
#' @param x The x-coordinate of the view in the layout.
@@ -353,14 +434,17 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
public = list(
#' @field config The internal representation of the view config.
config = NULL,
+ #' @field base_dir The base directory for the config.
+ base_dir = NULL,
#' @description
#' Create a new config object.
+ #' @param schema_version The Vitessce config schema version to use.
#' @param name A name for the config.
#' @param description A description for the config.
#' @return A new `VitessceConfig` object.
- initialize = function(name = NA, description = NA) {
+ initialize = function(schema_version, name = NA, description = NA, base_dir = NA) {
self$config <- list(
- version = "1.0.9",
+ version = schema_version,
name = ifelse(is_na(name), "", name),
description = ifelse(is_na(description), "", description),
datasets = list(),
@@ -368,6 +452,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
layout = list(),
initStrategy = "auto"
)
+ self$base_dir <- base_dir
},
#' @description
#' Add a dataset to the config.
@@ -375,7 +460,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
#' @param uid A unique ID for the dataset. Optional. Created automatically if not provided.
#' @return A new `VitessceConfigDataset` object.
#' @examples
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ds <- vc$add_dataset("My dataset")
add_dataset = function(name, uid = NA) {
prev_dataset_uids <- c()
@@ -383,7 +468,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
prev_dataset_uids <- c(prev_dataset_uids, d$dataset$uid)
}
uid <- ifelse(is_na(uid), get_next_scope(prev_dataset_uids), uid)
- new_dataset <- VitessceConfigDataset$new(uid, name)
+ new_dataset <- VitessceConfigDataset$new(uid, name, base_dir = self$base_dir)
self$config$datasets <- append(self$config$datasets, new_dataset)
new_scopes <- self$add_coordination(CoordinationType$DATASET)
@@ -401,7 +486,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
#' @param mapping An optional convenience parameter for setting the `CoordinationType$EMBEDDING_TYPE` coordination value if the component is`Component$SCATTERPLOT`.
#' @return A new `VitessceConfigView` object.
#' @examples
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ds <- vc$add_dataset("My dataset")
#' spatial <- vc$add_view(ds, "spatial")
add_view = function(dataset, component, x = NA, y = NA, w = NA, h = NA, mapping = NA) {
@@ -436,7 +521,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
#' @param c_types The coordination types for which to create new coordination scopes.
#' @return A list of new `VitessceConfigCoordinationScope` objects.
#' @examples
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ds <- vc$add_dataset("My dataset")
#' spatial <- vc$add_view(ds, "spatial")
#' c_scopes <- vc$add_coordination(c("spatialZoom", "spatialTargetX"))
@@ -471,12 +556,21 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
}
result
},
+ add_meta_coordination = function() {
+ # TODO
+ },
+ add_coordination_by_dict = function(input_val) {
+ # TODO
+ },
+ link_views_by_dict = function(views, input_val, meta = TRUE) {
+ # TODO
+ },
#' @description
#' Define the layout of views.
#' @param view_concat A concatenation of views.
#' @return Self, to allow chaining.
#' @examples
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ds <- vc$add_dataset("My dataset")
#' spatial <- vc$add_view(ds, "spatial")
#' scatterplot <- vc$add_view(ds, "scatterplot")
@@ -535,7 +629,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
#' when setting lists or similar more complex values.
#' @return Self, to allow chaining.
#' @examples
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ref_dataset <- vc$add_dataset("Reference")
#' qry_dataset <- vc$add_dataset("Query")
#' ref_plot <- vc$add_view(ref_dataset, Component$SCATTERPLOT, mapping = "umap")
@@ -569,7 +663,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
#' @param base_url An base URL to prepend to file paths.
#' @return A `list` that can be serialized to JSON.
#' @examples
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ds <- vc$add_dataset("My dataset")
#' vc_list <- vc$to_list(base_url = "http://localhost:8000")
to_list = function(base_url = NA) {
@@ -629,7 +723,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
#' @param ... Passes extra keyword arguments to the `vitessce_widget` function.
#' @return The Vitessce htmlwidget.
#' @examples
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' dataset <- vc$add_dataset("My dataset")
#' description <- vc$add_view(dataset, Component$DESCRIPTION)
#' vc$layout(description)
@@ -645,7 +739,7 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
#' @param ... Extra parameters to pass through to the export function.
#' @return The Vitessce configuration as a list, with the `base_url` filled in.
#' @examples
- #' vc <- VitessceConfig$new("My config")
+ #' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' dataset <- vc$add_dataset("My dataset")
#' description <- vc$add_view(dataset, Component$DESCRIPTION)
#' vc$layout(description)
@@ -665,20 +759,22 @@ VitessceConfig <- R6::R6Class("VitessceConfig",
#' @name VitessceConfig$from_list
#' @title Create a new Vitessce Config from a list
+#' @description
#'
#' A helper function to construct a new `VitessceConfig` object based on an existing config in a list format.
#'
#' @param config A list containing a valid config.
#' @return A `VitessceConfig` object reflecting the list-based configuration values.
VitessceConfig$from_list <- function(config) {
- vc <- VitessceConfig$new(config$name, config$description)
+ vc <- VitessceConfig$new(config$version, name = config$name, description = config$description)
for(d in config$datasets) {
new_dataset <- vc$add_dataset(d$name, uid = d$uid)
for(f in d$files) {
new_dataset$add_file(
- f$url,
- f$type,
- f$fileType
+ url = f$url,
+ file_type = ifelse(!is.null(f$fileType), f$fileType, NA),
+ coordination_values = ifelse(!is.null(f$coordinationValues), f$coordinationValues, NA),
+ options = ifelse(!is.null(f$options), f$options, NA)
)
}
}
@@ -703,6 +799,7 @@ VitessceConfig$from_list <- function(config) {
#' @name VitessceConfig$from_object
#' @title Create a new Vitessce Config from a data object
+#' @description
#'
#' A helper function to construct a new `VitessceConfig` object based on an object containing single-cell or imaging data.
#'
@@ -710,8 +807,8 @@ VitessceConfig$from_list <- function(config) {
#' @param name A name for the view config.
#' @param description A description for the view config.
#' @return A `VitessceConfig` object containing the object as a member of the datasets list, with some automatically-configured views.
-VitessceConfig$from_object <- function(obj, name = NA, description = NA) {
- vc <- VitessceConfig$new(name, description)
+VitessceConfig$from_object <- function(obj, schema_version, name = NA, description = NA) {
+ vc <- VitessceConfig$new(schema_version, name = name, description = description)
obj$auto_view_config(vc)
return(vc)
}
diff --git a/R/constants.R b/R/constants.R
index a3fb5d2..6e2229a 100644
--- a/R/constants.R
+++ b/R/constants.R
@@ -40,7 +40,7 @@
#'
#' @export
#' @examples
-#' vc <- VitessceConfig$new("My config")
+#' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ref_dataset <- vc$add_dataset("Reference")
#' qry_dataset <- vc$add_dataset("Query")
#' ref_plot <- vc$add_view(ref_dataset, Component$SCATTERPLOT, mapping = "umap")
@@ -51,6 +51,8 @@
#' c_values = c(0, 0)
#' )
CoordinationType <- list(
+ META_COORDINATION_SCOPES = "metaCoordinationScopes",
+ META_COORDINATION_SCOPES_BY = "metaCoordinationScopesBy",
DATASET = "dataset",
EMBEDDING_TYPE = "embeddingType",
EMBEDDING_ZOOM = "embeddingZoom",
@@ -77,6 +79,7 @@ CoordinationType <- list(
GENE_SELECTION = "geneSelection",
GENE_EXPRESSION_COLORMAP = "geneExpressionColormap",
GENE_EXPRESSION_COLORMAP_RANGE = "geneExpressionColormapRange",
+ FEATURE_VALUE_COLORMAP_RANGE = "featureValueColormapRange",
CELL_COLOR_ENCODING = "cellColorEncoding",
SPATIAL_LAYERS = "spatialLayers",
GENOMIC_ZOOM = "genomicZoom",
@@ -102,7 +105,7 @@ CoordinationType <- list(
#' @export
#' @examples
#' base_url <- "http://localhost:8000/"
-#' vc <- VitessceConfig$new("My config")
+#' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' dataset <- vc$add_dataset("My dataset")$add_file(
#' url = paste0(base_url, "cells.json"),
#' data_type = DataType$CELLS,
@@ -135,10 +138,9 @@ DataType <- list(
#' @export
#' @examples
#' base_url <- "http://localhost:8000/"
-#' vc <- VitessceConfig$new("My config")
+#' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' dataset <- vc$add_dataset("My dataset")$add_file(
#' url = paste0(base_url, "cells.json"),
-#' data_type = DataType$CELLS,
#' file_type = FileType$CELLS_JSON
#' )
FileType <- list(
@@ -150,6 +152,7 @@ FileType <- list(
CELL_SETS_JSON = "cell-sets.json",
CLUSTERS_JSON = "clusters.json",
EXPRESSION_MATRIX_ZARR = "expression-matrix.zarr",
+ ANNDATA_ZARR = "anndata.zarr",
ANNDATA_CELLS_ZARR = "anndata-cells.zarr",
ANNDATA_CELL_SETS_ZARR = "anndata-cell-sets.zarr",
ANNDATA_EXPRESSION_MATRIX_ZARR = "anndata-expression-matrix.zarr"
@@ -174,7 +177,7 @@ FileType <- list(
#'
#' @export
#' @examples
-#' vc <- VitessceConfig$new("My config")
+#' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' dataset <- vc$add_dataset("My dataset")
#' description <- vc$add_view(dataset, Component$DESCRIPTION)
#' vc$layout(description)
@@ -185,9 +188,11 @@ Component <- list(
DESCRIPTION = "description",
STATUS = "status",
CELL_SETS = "cellSets",
+ OBS_SETS = "obsSets",
HEATMAP = "heatmap",
LAYER_CONTROLLER = "layerController",
HIGLASS = "higlass",
CELL_SET_SIZES = "cellSetSizes",
- GENES = "genes"
+ GENES = "genes",
+ FEATURE_LIST = "featureList"
)
diff --git a/R/content-types.R b/R/content-types.R
new file mode 100644
index 0000000..00a637d
--- /dev/null
+++ b/R/content-types.R
@@ -0,0 +1,69 @@
+# Reference: https://github.com/rstudio/plumber/blob/e829af6a94380cb897441c1c56129504afb9564f/R/content-types.R#L55
+
+# FROM Shiny
+# @author Shiny package authors
+knownContentTypes <- c(
+ html = "text/html; charset=UTF-8",
+ htm = "text/html; charset=UTF-8",
+ js = "text/javascript",
+ css = "text/css",
+ png = "image/png",
+ jpg = "image/jpeg",
+ jpeg = "image/jpeg",
+ gif = "image/gif",
+ svg = "image/svg+xml",
+ txt = "text/plain",
+ pdf = "application/pdf",
+ ps = "application/postscript",
+ xml = "application/xml",
+ m3u = "audio/x-mpegurl",
+ m4a = "audio/mp4a-latm",
+ m4b = "audio/mp4a-latm",
+ m4p = "audio/mp4a-latm",
+ mp3 = "audio/mpeg",
+ wav = "audio/x-wav",
+ m4u = "video/vnd.mpegurl",
+ m4v = "video/x-m4v",
+ mp4 = "video/mp4",
+ mpeg = "video/mpeg",
+ mpg = "video/mpeg",
+ avi = "video/x-msvideo",
+ mov = "video/quicktime",
+ ogg = "application/ogg",
+ swf = "application/x-shockwave-flash",
+ doc = "application/msword",
+ xls = "application/vnd.ms-excel",
+ ppt = "application/vnd.ms-powerpoint",
+ xlsx = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ xltx = "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
+ potx = "application/vnd.openxmlformats-officedocument.presentationml.template",
+ ppsx = "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
+ pptx = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
+ sldx = "application/vnd.openxmlformats-officedocument.presentationml.slide",
+ docx = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+ dotx = "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
+ xlam = "application/vnd.ms-excel.addin.macroEnabled.12",
+ xlsb = "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
+ feather = "application/vnd.apache.arrow.file",
+ parquet = "application/vnd.apache.parquet",
+ rds = "application/rds",
+ tsv = "application/tab-separated-values",
+ csv = "application/csv",
+ json = "application/json",
+ yml = "application/yaml",
+ yaml = "application/yaml"
+)
+
+get_content_type <- function(ext, defaultType = 'application/octet-stream') {
+ ext <- tolower(ext)
+
+ if(!is.null(knownContentTypes[ext])) {
+ ret <- knownContentTypes[ext]
+ } else if(!is.null(mime::mimemap[ext])) {
+ ret <- mime::mimemap[ext]
+ } else {
+ ret <- defaultType
+ }
+
+ ret[[1]]
+}
diff --git a/R/data_to_zarr.R b/R/data_to_zarr.R
deleted file mode 100644
index 1e89a40..0000000
--- a/R/data_to_zarr.R
+++ /dev/null
@@ -1,274 +0,0 @@
-
-#' Save a Seurat object to an AnnData-Zarr store.
-#'
-#' @keywords internal
-#' @param seurat_obj The object to save.
-#' @param out_path A path to the output Zarr store.
-#' @param assay The name of the assay to save.
-#' @return TRUE if the conversion succeeds.
-#'
-#' @export
-#' @examples
-#' obj <- get_seurat_obj()
-#' seurat_to_anndata_zarr(obj, out_path = "data/seurat.zarr", assay = "RNA")
-seurat_to_anndata_zarr <- function(seurat_obj, out_path, assay) {
- if(!requireNamespace("SeuratDisk", quietly = TRUE)) {
- stop("Install 'SeuratDisk' to enable conversion of Seurat objects to AnnData objects.")
- }
-
- h5seurat_path <- paste0(out_path, ".h5Seurat")
- h5ad_path <- paste0(out_path, ".h5ad")
-
- # Convert factor columns to string/numeric.
- seurat_obj@meta.data <- varhandle::unfactor(seurat_obj@meta.data)
-
- SeuratDisk::SaveH5Seurat(seurat_obj, filename = h5seurat_path, overwrite = TRUE)
- SeuratDisk::Convert(h5seurat_path, dest = "h5ad", overwrite = TRUE, assay = assay)
-
- # Use basilisk
- proc <- basilisk::basiliskStart(py_env)
- on.exit(basilisk::basiliskStop(proc))
-
- success <- basilisk::basiliskRun(proc, function(h5ad_path, out_path) {
- anndata <- reticulate::import("anndata")
- zarr <- reticulate::import("zarr")
-
- adata <- anndata$read_h5ad(h5ad_path)
-
- cleanup_colnames <- function(df) {
- # Reference: https://github.com/theislab/scvelo/issues/255#issuecomment-739995301
- new_colnames <- colnames(df)
- new_colnames[new_colnames == "_index"] <- "features"
- return(new_colnames)
- }
-
- noop <- function(cond) { }
-
- tryCatch({
- colnames(adata$var) <- cleanup_colnames(adata$var)
- }, error = noop)
-
- # Reconstruct, omitting raw and uns.
- adata <- anndata$AnnData(
- X = adata$X,
- obs = as.data.frame(adata$obs),
- var = as.data.frame(adata$var),
- obsm = adata$obsm,
- varm = adata$varm
- )
-
- adata$write_zarr(out_path)
-
- return(TRUE)
- }, h5ad_path = h5ad_path, out_path = out_path)
- return(success)
-}
-
-#' Save a SingleCellExperiment to an AnnData-Zarr store.
-#'
-#' @keywords internal
-#' @param sce_obj The object to save.
-#' @param out_path A path to the output Zarr store.
-#' @return TRUE if the conversion succeeds.
-#'
-#' @export
-#' @examples
-#' obj <- get_sce_obj()
-#' sce_to_anndata_zarr(obj, out_path = "data/sce.zarr")
-#' @importFrom SingleCellExperiment reducedDims reducedDims<-
-sce_to_anndata_zarr <- function(sce_obj, out_path) {
- obsm_keys <- names(as.list(reducedDims(sce_obj)))
- for(obsm_key in obsm_keys) {
- # If there are column names, then the obsm element will be stored as a data.frame,
- # but Vitessce can only handle array obsm, so we need to remove any column names.
- # Reference: https://github.com/theislab/zellkonverter/blob/e1e95b1/R/SCE2AnnData.R#L159
- colnames(reducedDims(sce_obj)[[obsm_key]]) <- NULL
- }
-
- # Use basilisk
- proc <- basilisk::basiliskStart(py_env)
- on.exit(basilisk::basiliskStop(proc))
-
- success <- basilisk::basiliskRun(proc, function(sce_obj, out_path) {
- anndata <- reticulate::import("anndata")
- zarr <- reticulate::import("zarr")
-
- adata <- zellkonverter::SCE2AnnData(sce_obj)
- adata$write_zarr(out_path)
- return(TRUE)
- }, sce_obj = sce_obj, out_path = out_path)
- return(success)
-}
-
-#' Save a SpatialExperiment to an AnnData-Zarr store.
-#'
-#' @keywords internal
-#' @param spe_obj The object to save.
-#' @param out_path A path to the output Zarr store.
-#' @return TRUE if the conversion succeeds.
-#'
-#' @export
-#' @importFrom SummarizedExperiment colData
-#' @importFrom SingleCellExperiment int_colData
-#' @importFrom SpatialExperiment colData<-
-spe_to_anndata_zarr <- function(spe_obj, out_path) {
- internal_col_data <- int_colData(spe_obj)
-
- colData(spe_obj) <- cbind(
- colData(spe_obj),
- internal_col_data$spatialCoords,
- # spatialData deprecated in 1.5.2
- # internal_col_data$spatialData,
- internal_col_data$reducedDims
- )
-
- success <- sce_to_anndata_zarr(spe_obj, out_path)
- return(success)
-}
-
-#' Save an image in a SpatialExperiment to an OME-Zarr store
-#'
-#' @keywords internal
-#' @param spe_obj The object containing the image.
-#' @param sample_id The sample_id in the imgData data frame.
-#' @param image_id The image_id in the imgData data frame.
-#' @param out_path A path to the output Zarr store.
-#' @return TRUE if the conversion succeeds.
-#'
-#' @export
-#' @examples
-#' obj <- get_spe_obj()
-#' spe_to_ome_zarr(obj, "sample1", "image1", "data/spe_image.zarr")
-#' @importFrom SpatialExperiment getImg
-#' @importFrom grDevices as.raster col2rgb
-spe_to_ome_zarr <- function(spe_obj, sample_id, image_id, out_path) {
- img_arr <- apply(as.matrix(as.raster(getImg(spe_obj, image_id = image_id, sample_id = sample_id))), c(1, 2), col2rgb)
-
- # Use basilisk
- proc <- basilisk::basiliskStart(py_env)
- on.exit(basilisk::basiliskStop(proc))
-
- success <- basilisk::basiliskRun(proc, function(img_arr, sample_id, image_id, out_path) {
- zarr <- reticulate::import("zarr")
- ome_zarr <- reticulate::import("ome_zarr")
-
- z_root <- zarr$open_group(out_path, mode = "w")
-
- # Need to copy this here since can't refer to functions in the outside environment.
- obj_list <- function(...) {
- retval <- stats::setNames(list(), character(0))
- param_list <- list(...)
- for(key in names(param_list)) {
- retval[[key]] = param_list[[key]]
- }
- retval
- }
-
- default_window <- obj_list(
- start = 0,
- min = 0,
- max = 255,
- end = 255
- )
-
- ome_zarr$writer$write_image(
- image = img_arr,
- group = z_root,
- axes = "cyx",
- omero = obj_list(
- name = image_id,
- version = "0.3",
- rdefs = obj_list(
-
- ),
- channels = list(
- obj_list(
- label = "r",
- color = "FF0000",
- window = default_window
- ),
- obj_list(
- label = "g",
- color = "00FF00",
- window = default_window
- ),
- obj_list(
- label = "b",
- color = "0000FF",
- window = default_window
- )
- )
- )
- )
- return(TRUE)
- }, img_arr = img_arr, sample_id = sample_id, image_id = image_id, out_path = out_path)
- return(success)
-}
-
-#' Save a Giotto object to an AnnData-Zarr store
-#'
-#' @keywords internal
-#' @param giotto_obj The object to save.
-#' @param out_path A path to the output Zarr store.
-#' @param X_slot The name of the slot in the Giotto object to use for adata.X
-#' @return TRUE if the conversion succeeds.
-#'
-#' @export
-#' @examples
-#' obj <- get_giotto_obj()
-#' giotto_to_anndata_zarr(obj, "data/giotto.zarr")
-#' @importFrom methods slot
-giotto_to_anndata_zarr <- function(giotto_obj, out_path, X_slot = "raw_exprs") {
-
- # Use basilisk
- proc <- basilisk::basiliskStart(py_env)
- on.exit(basilisk::basiliskStop(proc))
-
- success <- basilisk::basiliskRun(proc, function(giotto_obj, out_path, X_slot) {
- anndata <- reticulate::import("anndata")
- zarr <- reticulate::import("zarr")
-
- # Reference: https://github.com/theislab/zellkonverter/blob/master/R/SCE2AnnData.R#L237
- make_numpy_friendly <- function(x, transpose = TRUE) {
- if (transpose) {
- x <- Matrix::t(x)
- }
- if (DelayedArray::is_sparse(x)) {
- methods::as(x, "dgCMatrix")
- } else {
- as.matrix(x)
- }
- }
-
- X <- make_numpy_friendly(slot(giotto_obj, X_slot))
- obs <- slot(giotto_obj, "cell_metadata")
- var <- slot(giotto_obj, "gene_metadata")
-
- adata <- anndata$AnnData(X = X, obs = obs, var = var)
-
- obsm <- list()
-
- if(!is.null(slot(giotto_obj, "spatial_locs"))) {
- spatial_locs <- slot(giotto_obj, "spatial_locs")
- obsm[['spatial']] <- t(as.matrix(spatial_locs[, c("sdimx", "sdimy")]))
- }
-
- if(!is.null(slot(giotto_obj, "dimension_reduction"))) {
- dim_reducs <- slot(giotto_obj, "dimension_reduction")$cells
- for(dim_reduc_name in names(dim_reducs)) {
- dim_reduc_coords <- dim_reducs[[dim_reduc_name]][[dim_reduc_name]]$coordinates
- obsm[[dim_reduc_name]] <- t(as.matrix(dim_reduc_coords))
- }
- }
-
- if(length(obsm) > 0) {
- # TODO make_numpy_friendly is outside scope
- obsm <- lapply(obsm, make_numpy_friendly)
- adata$obsm <- obsm
- }
-
- adata$write_zarr(out_path)
- return(TRUE)
- }, giotto_obj = giotto_obj, out_path = out_path, X_slot = X_slot)
- return(success)
-}
diff --git a/R/export.R b/R/export.R
index 15b4f1c..3306881 100644
--- a/R/export.R
+++ b/R/export.R
@@ -10,24 +10,34 @@
#' @param out_dir The directory for storing exported files.
#' @returns If `with_config = TRUE`, returns the config after calling `to_list` with the specified `base_url`.
#' @examples
-#' vc <- VitessceConfig$new("My config")
+#' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' dataset <- vc$add_dataset("My dataset")
#' description <- vc$add_view(dataset, Component$DESCRIPTION)
#' vc$layout(description)
#' vc$export(to = "files", out_dir = "./data")
export_to_files <- function(config, with_config, base_url, out_dir) {
routes <- config$get_routes()
+
for(route in routes) {
# Get the intended web server route, removing the initial "/"
route_path <- substr(route$path, 2, stringr::str_length(route$path))
out_path <- file.path(out_dir, route_path)
- dir.create(out_path, showWarnings = FALSE, recursive = TRUE)
- # Copy the converted files from their original directory to the `out_dir`.
- static_dir <- route$directory
- files_to_copy = list.files(static_dir, full.names = TRUE)
- file.copy(files_to_copy, out_path, recursive = TRUE)
+ if(class(route)[1] == "VitessceConfigServerStaticRoute") {
+ # This is a directory.
+ dir.create(out_path, showWarnings = FALSE, recursive = TRUE)
+ # Copy the converted files from their original directory to the `out_dir`.
+ static_dir <- route$directory
+ files_to_copy <- list.files(static_dir, full.names = TRUE)
+ file.copy(files_to_copy, out_path, recursive = TRUE)
+ } else {
+ # This is a single file.
+ dir.create(dirname(out_path), showWarnings = FALSE, recursive = TRUE)
+ # Copy the converted files from their original directory to the `out_dir`.
+ file_to_copy <- route$file_path
+ file.copy(file_to_copy, out_path, recursive = TRUE)
+ }
}
if(with_config) {
diff --git a/R/helpers.R b/R/helpers.R
index d5958a7..9e5a2eb 100644
--- a/R/helpers.R
+++ b/R/helpers.R
@@ -7,10 +7,10 @@
#'
#' @export
#' @examples
-#' vc <- VitessceConfig$new("My config")
+#' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ds <- vc$add_dataset("My dataset")
#' spatial <- vc$add_view(ds, Component$SPATIAL)
-#' gene_list <- vc$add_view(ds, Component$GENES)
+#' gene_list <- vc$add_view(ds, Component$FEATURE_LIST)
#' vc$layout(hconcat(spatial, gene_list))
#' vc$widget()
hconcat <- function(...) {
@@ -27,10 +27,10 @@ hconcat <- function(...) {
#'
#' @export
#' @examples
-#' vc <- VitessceConfig$new("My config")
+#' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' ds <- vc$add_dataset("My dataset")
#' spatial <- vc$add_view(ds, Component$SPATIAL)
-#' gene_list <- vc$add_view(ds, Component$GENES)
+#' gene_list <- vc$add_view(ds, Component$FEATURE_LIST)
#' vc$layout(vconcat(spatial, gene_list))
#' vc$widget()
vconcat <- function(...) {
diff --git a/R/mock_objects.R b/R/mock_objects.R
deleted file mode 100644
index 866435c..0000000
--- a/R/mock_objects.R
+++ /dev/null
@@ -1,105 +0,0 @@
-#' Create a mock Seurat object for tests and examples.
-#' @return The object.
-#' @keywords internal
-#' @export
-#' @examples
-#' obj <- get_seurat_obj()
-#' @importFrom stats rpois
-get_seurat_obj <- function() {
- if(!requireNamespace("Seurat", quietly = TRUE)) {
- stop("Install 'Seurat' to enable creation of Seurat objects.")
- }
-
- ncells <- 100
- u <- matrix(rpois(20000, 5), ncol=ncells)
- cell_names <- paste0("Cell", seq_len(ncells))
- rownames(u) <- paste0("Gene", seq_len(nrow(u)))
- colnames(u) <- cell_names
- metadata.test <- data.frame(
- cluster_id = c(rep(1, 50), rep(2, 50))
- )
- rownames(metadata.test) <- cell_names
-
- obj <- Seurat::CreateSeuratObject(
- counts = u,
- project = "TESTING",
- assay = "RNA",
- names.field = 2,
- names.delim = "-",
- meta.data = metadata.test
- )
-
- return(obj)
-}
-
-#' Create a mock SCE object for tests and examples.
-#' @return The object.
-#' @keywords internal
-#' @export
-#' @examples
-#' obj <- get_sce_obj()
-get_sce_obj <- function() {
- ncells <- 100
- u <- matrix(rpois(20000, 5), ncol=ncells)
- v <- matrix(rnorm(20000), ncol=ncells)
- obj <- SingleCellExperiment::SingleCellExperiment(assays=list(counts=u, logcounts=v))
- rownames(obj) <- paste0("Gene", seq_len(nrow(v)))
- colnames(obj) <- paste0("Cell", seq_len(ncells))
- return(obj)
-}
-
-#' Create a mock SPE object for tests and examples.
-#' @return The object.
-#' @keywords internal
-#' @export
-#' @examples
-#' obj <- get_spe_obj()
-#' @importFrom methods new
-#' @importFrom stats rnorm rpois runif
-get_spe_obj <- function() {
-
- # Reference: https://github.com/drighelli/SpatialExperiment/blob/cbf6515/tests/testthat/test_SpatialImage-methods.R#L26
- n <- 10 # number of rows / height
- m <- 20 # number of columns / width
- N <- 3 # number of images in SpE
- .mockRaster <- function(n, m) {
- x <- runif(n*m)
- y <- matrix(x, n, m)
- as.raster(y)
- }
- .mockSPI <- function(n, m) {
- r <- .mockRaster(n, m)
- new("LoadedSpatialImage", image=r)
- }
- l <- replicate(N, .mockSPI(n, m))
- sample_id <- paste0("sample", seq_len(N))
- image_id <- paste0("image", seq_len(N))
-
- u <- matrix(rpois(3*100, 5), ncol=N)
- v <- matrix(rnorm(3*100), ncol=N)
-
- cd <- S4Vectors::DataFrame(sample_id)
- df <- S4Vectors::DataFrame(sample_id, image_id, data=I(l), scaleFactor=seq_len(N))
- obj <- SpatialExperiment::SpatialExperiment(assays=list(counts=u, logcounts=v), colData=cd, imgData=df)
- return(obj)
-}
-
-#' Create a mock Giotto object for tests and examples.
-#' @return The object.
-#' @keywords internal
-#' @export
-#' @examples
-#' obj <- get_giotto_obj()
-get_giotto_obj <- function() {
-
- if(!requireNamespace("Giotto", quietly = TRUE)) {
- stop("Install 'Giotto' to enable creation of Giotto objects.")
- }
-
- expr_path <- system.file("extdata", "giotto", "visium_DG_expr.txt", package = "vitessceR")
- loc_path <- system.file("extdata", "giotto", "visium_DG_locs.txt", package = "vitessceR")
-
- obj <- Giotto::createGiottoObject(raw_exprs = expr_path, spatial_locs = loc_path)
-
- return(obj)
-}
diff --git a/R/server.R b/R/server.R
index d361c9c..7d3fef4 100644
--- a/R/server.R
+++ b/R/server.R
@@ -42,6 +42,62 @@ VitessceConfigServerStaticRoute <- R6::R6Class("VitessceConfigServerStaticRoute"
)
)
+#' Class representing a local web server route for a file which needs to support range requests.
+#' @keywords internal
+#' @rdname VitessceConfigServerRangeRoute
+VitessceConfigServerFileRoute <- R6::R6Class("VitessceConfigServerFileRoute",
+ public = list(
+ #' @field path The path on which the web server should respond to requests using this callback.
+ path = NULL,
+ #' @field file_path The file to serve.
+ file_path = NULL,
+ #' @description
+ #' Create a new server route wrapper object.
+ #' @param path The route path.
+ #' @param file_path The file to serve on this route.
+ #' @return A new `VitessceConfigServerRangeRoute` object.
+ initialize = function(path, file_path) {
+ self$path <- path
+ self$file_path <- file_path
+ },
+ #' @description
+ #' Add handler functions to the Plumber server object to respond on this route.
+ #' @param pr_server The server instance.
+ #' @return The modified server instance.
+ create_handlers = function(pr_server) {
+ # Add the handler for range requests.
+ new_server <- plumber::pr_handle(pr_server, c("GET", "HEAD"), self$path, handler = function(req, res) {
+ if(req$REQUEST_METHOD %in% c("HEAD", "GET")) {
+ file_path <- self$file_path
+
+ res$headers <- obj_list()
+
+ # Adapted from https://github.com/rstudio/plumber/blob/e829af6a94380cb897441c1c56129504afb9564f/R/plumber-static.R#L70C9-L85C12
+ ext <- tools::file_ext(self$file_path)
+ info <- file.info(self$file_path)
+ content_type <- get_content_type(ext)
+ res$headers[["Content-Type"]] <- content_type
+ res$headers[["Content-Length"]] <- info$size
+ res$headers[["Last-Modified"]] <- http_date_string(info$mtime)
+ res$body <- NULL # For HEAD request.
+ if (req$REQUEST_METHOD == 'GET') {
+ readBin(self$file_path, 'raw', n = info$size)
+ }
+
+ # Set other headers.
+ res$headers[["Accept-Ranges"]] <- "bytes"
+ res$headers[["Access-Control-Allow-Origin"]] <- "*"
+ res$headers[["Access-Control-Expose-Headers"]] <- "Access-Control-Allow-Origin, Content-Length, Content-Range, Content-Type, Date, Server, Transfer-Encoding, range"
+ res$status <- 200
+ }
+ # Return the response object.
+ res
+ })
+ return(new_server)
+ }
+ )
+)
+
#' Class representing a local web server route for a file which needs to support range requests.
#' @keywords internal
#' @rdname VitessceConfigServerRangeRoute
diff --git a/R/widget.R b/R/widget.R
index cfbb1d1..20751cc 100644
--- a/R/widget.R
+++ b/R/widget.R
@@ -24,7 +24,7 @@
#' @export
#'
#' @examples
-#' vc <- VitessceConfig$new("My config")
+#' vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
#' vc$widget()
vitessce_widget <- function(config, theme = "dark", width = NULL, height = NULL, port = NA, base_url = NA, serve = TRUE, element_id = NULL) {
diff --git a/R/wrappers.R b/R/wrappers.R
index 8647e24..34681aa 100644
--- a/R/wrappers.R
+++ b/R/wrappers.R
@@ -1,3 +1,23 @@
+
+
+make_unique_filename <- function(file_ext) {
+ return(paste0(stringi::stri_rand_strings(1, 8), file_ext))
+}
+
+
+file_path_to_url_path <- function(local_path, prepend_slash = TRUE) {
+ if(grepl("\\", local_path, fixed = TRUE)) {
+ segments <- stringr::str_split(local_path, "\\\\")[[1]]
+ url_path <- paste(segments, collapse = "/")
+ } else {
+ url_path <- local_path
+ }
+ if(prepend_slash && substr(url_path, 1, 1) != "/") {
+ url_path <- paste0("/", url_path)
+ }
+ return(url_path)
+}
+
#' Abstract dataset object wrapper class
#' @title AbstractWrapper Class
#' @docType class
@@ -23,6 +43,9 @@ AbstractWrapper <- R6::R6Class("AbstractWrapper",
#' @field file_def_creators A list of file definition creator functions.
#' @keywords internal
file_def_creators = NULL,
+ #' @field base_dir The base directory for local data.
+ #' @keywords internal
+ base_dir = NULL,
#' @description
#' Create an abstract wrapper around a data object.
#' @param out_dir The directory for processed output files.
@@ -38,6 +61,7 @@ AbstractWrapper <- R6::R6Class("AbstractWrapper",
self$use_cache <- use_cache
self$routes <- list()
self$file_def_creators <- list()
+ self$base_dir <- NA
},
#' @description
#' Fill in the file_def_creators array.
@@ -47,8 +71,10 @@ AbstractWrapper <- R6::R6Class("AbstractWrapper",
#'
#' @param dataset_uid A unique identifier for this dataset.
#' @param obj_i Within the dataset, the index of this data wrapper object.
- convert_and_save = function(dataset_uid, obj_i) {
+ #' @param base_dir Path to a base directory.
+ convert_and_save = function(dataset_uid, obj_i, base_dir = NA) {
dir.create(self$get_out_dir(dataset_uid, obj_i), recursive = TRUE, showWarnings = FALSE)
+ self$base_dir <- base_dir
},
#' @description
#' Obtain the routes that have been created for this wrapper class.
@@ -86,6 +112,84 @@ AbstractWrapper <- R6::R6Class("AbstractWrapper",
return(route)
},
#' @description
+ #' Construct a URL to a local directory.
+ #'
+ #' @param base_url The base URL on which the web server is serving.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @param local_dir_path The path to the local directory.
+ #' @param local_dir_uid A unique identifier for this local directory in this dataset.
+ #' @return A string for the URL.
+ get_local_dir_url = function(base_url, dataset_uid, obj_i, local_dir_path, local_dir_uid) {
+ if(!self$is_remote && !is.na(self$base_dir)) {
+ return(self$get_url_simple(base_url, file_path_to_url_path(local_dir_path, prepend_slash = FALSE)))
+ }
+ return(self$get_url(base_url, dataset_uid, obj_i, local_dir_uid))
+ },
+ #' @description
+ #' Construct a URL to a local file.
+ #'
+ #' @param base_url The base URL on which the web server is serving.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @param local_file_path The path to the local file.
+ #' @param local_file_uid A unique identifier for this local file in this dataset.
+ #' @return A string for the URL.
+ get_local_file_url = function(base_url, dataset_uid, obj_i, local_file_path, local_file_uid) {
+ # Same logic as get_local_dir_url
+ return(self$get_local_dir_url(base_url, dataset_uid, obj_i, local_file_path, local_file_uid))
+ },
+ #' @description
+ #' Create a web server route for this object.
+ #'
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @param local_dir_path The path to the local directory.
+ #' @param local_dir_uid A unique identifier for this local directory in this dataset.
+ #' @return A new `VitessceConfigServerStaticRoute` instance.
+ get_local_dir_route = function(dataset_uid, obj_i, local_dir_path, local_dir_uid) {
+ if(!self$is_remote) {
+ if(is.na(self$base_dir)) {
+ route_path <- self$get_route_str(dataset_uid, obj_i, local_dir_uid)
+ } else {
+ route_path <- file_path_to_url_path(local_dir_path)
+ local_dir_path <- file.path(self$base_dir, local_dir_path)
+ }
+ route <- VitessceConfigServerStaticRoute$new(
+ route_path,
+ local_dir_path
+ )
+ return(list(route))
+ }
+ return(list())
+ },
+ #' @description
+ #' Create a web server route for this object.
+ #'
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @param local_file_path The path to the local file.
+ #' @param local_file_uid A unique identifier for this local file in this dataset.
+ #' @return A new `VitessceConfigServerFileRoute` instance.
+ get_local_file_route = function(dataset_uid, obj_i, local_file_path, local_file_uid) {
+ if(!self$is_remote) {
+ if(is.na(self$base_dir)) {
+ route_path <- self$get_route_str(dataset_uid, obj_i, local_file_uid)
+ local_file_path <- local_file_path
+ } else {
+ # Has base_dir
+ route_path <- file_path_to_url_path(local_file_path)
+ local_file_path <- file.path(self$base_dir, local_file_path)
+ }
+ route <- VitessceConfigServerFileRoute$new(
+ route_path,
+ local_file_path
+ )
+ return(list(route))
+ }
+ return(list())
+ },
+ #' @description
#' Create a local web server URL for a dataset object.
#' @param base_url The base URL on which the web server is serving.
#' @param dataset_uid The ID for this dataset.
@@ -97,6 +201,14 @@ AbstractWrapper <- R6::R6Class("AbstractWrapper",
return(retval)
},
#' @description
+ #' Construct a URL.
+ #' @param base_url The base URL on which the web server is serving.
+ #' @param suffix The suffix to append to the base URL.
+ #' @return A URL as a string like {base_url}/{suffix}
+ get_url_simple = function(base_url, suffix) {
+ return(paste0(base_url, "/", suffix))
+ },
+ #' @description
#' Create a string representing a web server route path (the part following the base URL).
#' @param dataset_uid The ID for this dataset.
#' @param obj_i The index of this data object within the dataset.
diff --git a/R/wrappers_anndata.R b/R/wrappers_anndata.R
new file mode 100644
index 0000000..2e2856f
--- /dev/null
+++ b/R/wrappers_anndata.R
@@ -0,0 +1,275 @@
+#' AnnData object wrapper class
+#' @title AnnDataWrapper Class
+#' @docType class
+#' @description
+#' Class representing an AnnData object (saved to a Zarr store) in a Vitessce dataset.
+#'
+#' @rdname AnnDataWrapper
+#' @export
+AnnDataWrapper <- R6::R6Class("AnnDataWrapper",
+ inherit = AbstractWrapper,
+ public = list(
+ #' @field adata_path The object to wrap.
+ #' @keywords internal
+ adata_path = NULL,
+ #' @field adata_url The object to wrap.
+ #' @keywords internal
+ adata_url = NULL,
+ #' @field local_dir_uid The path to the local zarr store.
+ #' @keywords internal
+ local_dir_uid = NULL,
+ #' @field obs_feature_matrix_path The path to the observation-by-feature matrix within the Zarr store.
+ #' @keywords internal
+ obs_feature_matrix_path=NULL,
+ #' @field feature_filter_path The path to the a column of adata.var within the Zarr store.
+ #' Use this if obs_feature_matrix_path points to a subset of adata.X (relative to the full adata.var).
+ #' @keywords internal
+ feature_filter_path=NULL,
+ #' @field initial_feature_filter_path The path to the a column of adata.var within the Zarr store.
+ #' Use this to load a subset of the matrix at obs_feature_matrix_path initially.
+ #' @keywords internal
+ initial_feature_filter_path=NULL,
+ #' @field obs_set_paths A list of paths to the observation sets within the Zarr store.
+ #' @keywords internal
+ obs_set_paths=NULL,
+ #' @field obs_set_names A list of names for the observation sets.
+ #' @keywords internal
+ obs_set_names=NULL,
+ #' @field obs_locations_path The path to the observation locations within the Zarr store.
+ #' @keywords internal
+ obs_locations_path=NULL,
+ #' @field obs_segmentations_path The path to the observation segmentations within the Zarr store.
+ #' @keywords internal
+ obs_segmentations_path=NULL,
+ #' @field obs_embedding_paths A list of paths to the observation embeddings within the Zarr store.
+ #' @keywords internal
+ obs_embedding_paths=NULL,
+ #' @field obs_embedding_names A list of names for the observation embeddings.
+ #' @keywords internal
+ obs_embedding_names=NULL,
+ #' @field obs_embedding_dims A list of dimensions for the observation embeddings.
+ #' @keywords internal
+ obs_embedding_dims=NULL,
+ #' @field feature_labels_path The path to the feature labels within the Zarr store.
+ #' @keywords internal
+ feature_labels_path=NULL,
+ #' @field obs_labels_path The path to the observation labels within the Zarr store.
+ #' @keywords internal
+ obs_labels_path=NULL,
+ #' @field obs_labels_paths A list of paths to the observation labels within the Zarr store.
+ #' @keywords internal
+ obs_labels_paths=NULL,
+ #' @field obs_labels_names A list of names for the observation labels.
+ #' @keywords internal
+ obs_labels_names=NULL,
+ #' @field coordination_values A list of coordination values for the file definition.
+ #' @keywords internal
+ coordination_values=NULL,
+ #' @field request_init A list of requestInit options for the Zarr store.
+ #' @keywords internal
+ request_init=NULL,
+ #' @description
+ #' Create a wrapper around an AnnData object saved to a Zarr store.
+ #' @param adata_path The path to a local Zarr store.
+ #' @param adata_url The URL to a remote Zarr store.
+ #' @param obs_feature_matrix_path The path to the observation-by-feature matrix within the Zarr store.
+ #' @param feature_filter_path The path to the a column of adata.var within the Zarr store. Use this if obs_feature_matrix_path points to a subset of adata.X (relative to the full adata.var).
+ #' @param initial_feature_filter_path The path to the a column of adata.var within the Zarr store. Use this to load a subset of the matrix at obs_feature_matrix_path initially.
+ #' @param obs_set_paths A list of paths to the observation sets within the Zarr store.
+ #' @param obs_set_names A list of names for the observation sets.
+ #' @param obs_locations_path The path to the observation locations within the Zarr store.
+ #' @param obs_segmentations_path The path to the observation segmentations within the Zarr store.
+ #' @param obs_embedding_paths A list of paths to the observation embeddings within the Zarr store.
+ #' @param obs_embedding_names A list of names for the observation embeddings.
+ #' @param obs_embedding_dims A list of dimensions for the observation embeddings.
+ #' @param request_init A list of requestInit options for the Zarr store.
+ #' @param feature_labels_path The path to the feature labels within the Zarr store.
+ #' @param obs_labels_paths A list of paths to the observation labels within the Zarr store.
+ #' @param obs_labels_names A list of names for the observation labels.
+ #' @param coordination_values A list of coordination values for the file definition.
+ #' @param ... Parameters inherited from `AbstractWrapper`.
+ #' @return A new `AnnDataWrapper` object.
+ initialize = function(adata_path = NA, adata_url = NA, obs_feature_matrix_path = NA, feature_filter_path = NA, initial_feature_filter_path = NA, obs_set_paths = NA, obs_set_names = NA, obs_locations_path = NA, obs_segmentations_path = NA, obs_embedding_paths = NA, obs_embedding_names = NA, obs_embedding_dims = NA, request_init = NA, feature_labels_path = NA, coordination_values = NA, obs_labels_paths = NA, obs_labels_names = NA, ...) {
+ super$initialize(...)
+ self$adata_path <- adata_path
+ self$adata_url <- adata_url
+
+ if(!is.na(adata_url) && !is.na(adata_path)) {
+ stop("Did not expect adata_url to be provided with adata_path")
+ }
+
+ if(is.na(adata_url) && is.na(adata_path)) {
+ stop("Expected either adata_url or adata_path to be provided")
+ }
+
+ if(!is.na(adata_path)) {
+ self$is_remote <- FALSE
+ } else {
+ self$is_remote <- TRUE
+ }
+
+ self$local_dir_uid <- make_unique_filename(".adata.zarr")
+
+ self$obs_feature_matrix_path <- obs_feature_matrix_path
+ self$obs_set_names <- obs_set_names
+ self$obs_embedding_names <- obs_embedding_names
+ self$feature_filter_path <- feature_filter_path
+ self$initial_feature_filter_path <- initial_feature_filter_path
+ self$obs_set_paths <- obs_set_paths
+ self$obs_locations_path <- obs_locations_path
+ self$obs_segmentations_path <- obs_segmentations_path
+ self$obs_embedding_paths <- obs_embedding_paths
+ self$obs_embedding_dims <- obs_embedding_dims
+ self$request_init <- request_init
+ self$feature_labels_path <- feature_labels_path
+ self$obs_labels_paths <- obs_labels_paths
+ self$obs_labels_names <- obs_labels_names
+
+ self$coordination_values <- coordination_values
+ },
+ #' @description
+ #' Create the JSON output files, web server routes, and file definition creators.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @param base_dir A base directory for local data.
+ convert_and_save = function(dataset_uid, obj_i, base_dir = NA) {
+ if(!self$is_remote) {
+ super$convert_and_save(dataset_uid, obj_i, base_dir = base_dir)
+ }
+
+ # Get the file definition creator functions.
+ file_def_creator <- self$make_file_def_creator(dataset_uid, obj_i)
+
+ # Append the new file definition creators functions to the main list.
+ self$file_def_creators <- append(self$file_def_creators, file_def_creator)
+
+ # Create a web server route object for the directory of JSON files.
+ new_routes <- self$make_routes(dataset_uid, obj_i)
+ for(route in new_routes) {
+ self$routes <- append(self$routes, route)
+ }
+ },
+ #' @description
+ #' Get a list of server route objects.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ make_routes = function(dataset_uid, obj_i) {
+ return(self$get_local_dir_route(dataset_uid, obj_i, self$adata_path, self$local_dir_uid))
+ },
+ #' @description
+ #' Get the URL to the Zarr store, to fill in the file URL in the file definitions.
+ #' @param base_url The base URL, on which the route will be served.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @keywords internal
+ #' @return A URL as a string.
+ get_zarr_url = function(base_url, dataset_uid, obj_i) {
+ if(self$is_remote) {
+ return(self$adata_url)
+ } else {
+ return(self$get_local_dir_url(base_url, dataset_uid, obj_i, self$adata_path, self$local_dir_uid))
+ }
+ },
+ #' @description
+ #' Make the file definition creator function for the cells data type.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @return A file definition creator function which takes a `base_url` parameter.
+ make_file_def_creator = function(dataset_uid, obj_i) {
+ get_anndata_zarr <- function(base_url) {
+ options <- obj_list()
+ if(!is_na(self$obs_locations_path)) {
+ options[['obsLocations']] <- obj_list()
+ options[['obsLocations']][['path']] <- self$obs_locations_path
+ }
+ if(!is_na(self$obs_segmentations_path)) {
+ options[['obsSegmentations']] <- obj_list()
+ options[['obsSegmentations']][['path']] <- self$obs_segmentations_path
+ }
+ if(!is_na(self$obs_embedding_paths)) {
+ options[['obsEmbedding']] <- list()
+ for(i in seq_len(length(self$obs_embedding_paths))) {
+ embedding_path <- self$obs_embedding_paths[i]
+ if(!is_na(self$obs_embedding_names)) {
+ embedding_name <- self$obs_embedding_names[i]
+ } else {
+ segments <- stringr::str_split(embedding_path, "/")[[1]]
+ embedding_name <- segments[-1]
+ }
+ if(!is_na(self$obs_embedding_dims)) {
+ embedding_dims <- self$obs_embedding_dims[i]
+ } else {
+ embedding_dims <- c(0, 1)
+ }
+ options[['obsEmbedding']] <- append(options[['obsEmbedding']], list(obj_list(
+ path = embedding_path,
+ embeddingType = embedding_name,
+ dims = embedding_dims
+ )))
+ }
+ }
+ if(!is_na(self$obs_set_paths)) {
+ options[['obsSets']] <- list()
+ for(i in seq_len(length(self$obs_set_paths))) {
+ set_path <- self$obs_set_paths[i]
+ if(!is_na(self$obs_set_names)) {
+ set_name <- self$obs_set_names[i]
+ } else {
+ segments <- stringr::str_split(set_path, "/")[[1]]
+ set_name <- segments[-1]
+ }
+ options[['obsSets']] <- append(options[['obsSets']], list(obj_list(
+ path = set_path,
+ name = set_name
+ )))
+ }
+ }
+ if(!is_na(self$obs_feature_matrix_path)) {
+ options[['obsFeatureMatrix']] <- obj_list()
+ options[['obsFeatureMatrix']][['path']] <- self$obs_feature_matrix_path
+ if(!is_na(self$feature_filter_path)) {
+ options[['obsFeatureMatrix']][['featureFilterPath']] <- self$feature_filter_path
+ }
+ if(!is_na(self$initial_feature_filter_path)) {
+ options[['obsFeatureMatrix']][['initialFeatureFilterPath']] <- self$initial_feature_filter_path
+ }
+ }
+ if(!is_na(self$feature_labels_path)) {
+ options[['featureLabels']] <- obj_list()
+ options[['featureLabels']][['path']] <- self$feature_labels_path
+ }
+ if(!is_na(self$obs_labels_paths)) {
+ options[['obsLabels']] <- list()
+ for(i in seq_len(length(self$obs_labels_paths))) {
+ obs_labels_path <- self$obs_labels_paths[i]
+ if(!is_na(self$obs_labels_names)) {
+ obs_labels_name <- self$obs_labels_names[i]
+ } else {
+ segments <- stringr::str_split(obs_labels_path, "/")[[1]]
+ obs_labels_name <- segments[-1]
+ }
+ options[['obsLabels']] <- append(options[['obsLabels']], list(obj_list(
+ path = obs_labels_path,
+ obsLabelsType = obs_labels_name
+ )))
+ }
+ }
+
+ file_def <- list(
+ fileType = FileType$ANNDATA_ZARR,
+ url = self$get_zarr_url(base_url, dataset_uid, obj_i),
+ options = options
+ )
+ if(!is_na(self$request_init)) {
+ file_def[['requestInit']] <- self$request_init
+ }
+ if(!is_na(self$coordination_values)) {
+ file_def[['coordinationValues']] <- self$coordination_values
+ }
+
+ return(file_def)
+ }
+ return(get_anndata_zarr)
+ }
+ ),
+)
diff --git a/R/wrappers_csv.R b/R/wrappers_csv.R
new file mode 100644
index 0000000..6a4aca1
--- /dev/null
+++ b/R/wrappers_csv.R
@@ -0,0 +1,142 @@
+#' CSV file wrapper class
+#' @title CsvWrapper Class
+#' @docType class
+#' @description
+#' Class representing a CSV file in a Vitessce dataset.
+#'
+#' @rdname CsvWrapper
+#' @export
+CsvWrapper <- R6::R6Class("CsvWrapper",
+ inherit = AbstractWrapper,
+ public = list(
+ #' @field csv_path The object to wrap.
+ #' @keywords internal
+ csv_path = NULL,
+ #' @field csv_url The object to wrap.
+ #' @keywords internal
+ csv_url = NULL,
+ #' @field local_csv_uid The path to the local zarr store.
+ #' @keywords internal
+ local_csv_uid = NULL,
+
+ #' @field data_type The Vitessce data type for this file.
+ #' @keywords internal
+ data_type = NULL,
+ #' @field options A list of options to pass to the Vitessce file definition.
+ #' @keywords internal
+ options=NULL,
+ #' @field coordination_values A list of coordination values to pass to the Vitessce file definition.
+ #' @keywords internal
+ coordination_values=NULL,
+ #' @field request_init A list of requestInit values to pass to fetch when loading the CSV over HTTP.
+ #' @keywords internal
+ request_init = NULL,
+ #' @description
+ #' Create a wrapper around a CSV file.
+ #' @param csv_path The path to a local CSV file.
+ #' @param csv_url The URL to a remote CSV file.
+ #' @param data_type The Vitessce data type for this file.
+ #' @param options A list of options to pass to the Vitessce file definition.
+ #' @param coordination_values A list of coordination values to pass to the Vitessce file definition.
+ #' @param request_init A list of requestInit values to pass to fetch when loading the CSV over HTTP.
+ #' @param ... Parameters inherited from `AbstractWrapper`.
+ #' @return A new `CsvWrapper` object.
+ initialize = function(csv_path = NA, csv_url = NA, data_type = NA, options = NA, coordination_values = NA, request_init = NA, ...) {
+ super$initialize(...)
+ self$csv_path <- csv_path
+ self$csv_url <- csv_url
+
+ if(is_na(data_type)) {
+ stop("Expected data_type to be provided.")
+ }
+
+ if(!is.na(csv_url) && !is.na(csv_path)) {
+ stop("Did not expect csv_url to be provided with csv_path.")
+ }
+
+ if(is.na(csv_url) && is.na(csv_path)) {
+ stop("Expected either csv_url or csv_path to be provided.")
+ }
+
+ if(!is.na(csv_path)) {
+ self$is_remote <- FALSE
+ } else {
+ self$is_remote <- TRUE
+ }
+
+ self$local_csv_uid <- make_unique_filename(".csv")
+
+ self$data_type <- data_type
+ self$options <- options
+ self$coordination_values <- coordination_values
+ self$request_init <- request_init
+ },
+ #' @description
+ #' Create the JSON output files, web server routes, and file definition creators.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @param base_dir A base directory for local data.
+ convert_and_save = function(dataset_uid, obj_i, base_dir = NA) {
+ if(!self$is_remote) {
+ super$convert_and_save(dataset_uid, obj_i, base_dir = base_dir)
+ }
+
+ # Get the file definition creator functions.
+ file_def_creator <- self$make_file_def_creator(dataset_uid, obj_i)
+
+ # Append the new file definition creators functions to the main list.
+ self$file_def_creators <- append(self$file_def_creators, file_def_creator)
+
+ # Create a web server route object for the directory of JSON files.
+ new_routes <- self$make_routes(dataset_uid, obj_i)
+ for(route in new_routes) {
+ self$routes <- append(self$routes, route)
+ }
+ },
+ #' @description
+ #' Get a list of server route objects.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ make_routes = function(dataset_uid, obj_i) {
+ return(self$get_local_file_route(dataset_uid, obj_i, self$csv_path, self$local_csv_uid))
+ },
+ #' @description
+ #' Get the URL to the Zarr store, to fill in the file URL in the file definitions.
+ #' @param base_url The base URL, on which the route will be served.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @keywords internal
+ #' @return A URL as a string.
+ get_csv_url = function(base_url, dataset_uid, obj_i) {
+ if(self$is_remote) {
+ return(self$csv_url)
+ } else {
+ return(self$get_local_file_url(base_url, dataset_uid, obj_i, self$csv_path, self$local_csv_uid))
+ }
+ },
+ #' @description
+ #' Make the file definition creator function for the cells data type.
+ #' @param dataset_uid The ID for this dataset.
+ #' @param obj_i The index of this data object within the dataset.
+ #' @return A file definition creator function which takes a `base_url` parameter.
+ make_file_def_creator = function(dataset_uid, obj_i) {
+ get_csv <- function(base_url) {
+ file_def <- list(
+ fileType = paste0(self$data_type, ".csv"),
+ url = self$get_csv_url(base_url, dataset_uid, obj_i)
+ )
+ if(!is_na(self$options)) {
+ file_def[['options']] <- self$options
+ }
+ if(!is_na(self$request_init)) {
+ file_def[['requestInit']] <- self$request_init
+ }
+ if(!is_na(self$coordination_values)) {
+ file_def[['coordinationValues']] <- self$coordination_values
+ }
+ return(file_def)
+ }
+ return(get_csv)
+ }
+ ),
+)
diff --git a/R/wrappers_giotto.R b/R/wrappers_giotto.R
deleted file mode 100644
index 09b6344..0000000
--- a/R/wrappers_giotto.R
+++ /dev/null
@@ -1,248 +0,0 @@
-#' Giotto object wrapper class
-#' @title GiottoWrapper Class
-#' @docType class
-#' @description
-#' Class representing a local Giotto object in a Vitessce dataset.
-#'
-#' @rdname GiottoWrapper
-#' @export
-#' @examples
-#' obj <- get_giotto_obj()
-#' w <- GiottoWrapper$new(
-#' obj,
-#' cell_embeddings = c("pca"),
-#' cell_embedding_names = c("PCA")
-#' )
-GiottoWrapper <- R6::R6Class("GiottoWrapper",
- inherit = AbstractWrapper,
- public = list(
- #' @field obj The object to wrap.
- #' @keywords internal
- obj = NULL,
- #' @field cell_embeddings The keys in the Seurat object's reductions/cell.embeddings
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embeddings = NULL,
- #' @field cell_embedding_names Names
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embedding_names = NULL,
- #' @field cell_embedding_dims The dimension indices
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embedding_dims = NULL,
- #' @field cell_set_metas The keys in the Seurat object's meta.data
- #' to use for creating cell sets.
- #' @keywords internal
- cell_set_metas = NULL,
- #' @field cell_set_meta_names The keys in the Seurat object's meta.data
- #' to use for cell set names mapped to new names.
- #' @keywords internal
- cell_set_meta_names = NULL,
- #' @field cell_set_meta_scores The keys in the Seurat object's meta.data
- #' to use for cell set names mapped to keys for scores.
- #' @keywords internal
- cell_set_meta_scores = NULL,
- #' @field zarr_folder The name for the folder at the root of the zarr store.
- #' @keywords internal
- zarr_folder = NULL,
- #' @description
- #' Create a wrapper around a Seurat object.
- #' @param obj The object to wrap.
- #' @param cell_embeddings The keys in the Seurat object's reductions/cell.embeddings
- #' to use for creating dimensionality reduction plots.
- #' @param cell_embedding_names Names
- #' to use for creating dimensionality reduction plots.
- #' @param cell_embedding_dims An array of dimension indices to use for each cell_embedding.
- #' @param cell_set_metas An optional list of keys in the object's meta.data
- #' list to use for creating cell sets.
- #' @param cell_set_meta_names If cell_set_metas is provided, this list can
- #' also be provided to set new names to replace
- #' the keys in the interface.
- #' @param cell_set_meta_scores If cell_set_metas is provided, this list can
- #' also be provided to map between meta.data keys for set annotations
- #' and keys for annotation scores.
- #' @param ... Parameters inherited from `AbstractWrapper`.
- #' @return A new `GiottoWrapper` object.
- initialize = function(obj, cell_embeddings = NA, cell_embedding_names = NA, cell_embedding_dims = NA, cell_set_metas = NA, cell_set_meta_names = NA, cell_set_meta_scores = NA, ...) {
- super$initialize(...)
- self$obj <- obj
- self$cell_embeddings <- cell_embeddings
- self$cell_embedding_names <- cell_embedding_names
- self$cell_embedding_dims <- cell_embedding_dims
- self$cell_set_metas <- cell_set_metas
- self$cell_set_meta_names <- cell_set_meta_names
- self$cell_set_meta_scores <- cell_set_meta_scores
-
- self$zarr_folder <- "giotto.zarr"
-
- self$check_obj()
- },
- #' @description
- #' Check that the object is valid
- #' @keywords internal
- #' @return Success or failure.
- check_obj = function() {
- success <- TRUE
- if(!methods::is(self$obj, "giotto")) {
- warning("Object is not of type giotto.")
- success <- FALSE
- }
- if(!is_na(self$cell_embeddings) && !all(self$cell_embeddings %in% names(self$obj@dimension_reduction$cells))) {
- warning("Specified cell_embeddings not all present in Giotto object dimension_reduction")
- success <- FALSE
- }
- if(!is_na(self$cell_set_metas) && !all(self$cell_set_metas %in% colnames(self$obj@cell_metadata))) {
- warning("Specified cell_set_metas not all present in Giotto object cell_metadata.")
- success <- FALSE
- }
- return(success)
- },
- #' @description
- #' Get the path to the zarr store, relative to the current directory.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A path as a string.
- get_zarr_path = function(dataset_uid, obj_i) {
- out_dir <- super$get_out_dir(dataset_uid, obj_i)
- zarr_filepath <- file.path(out_dir, self$zarr_folder)
- return(zarr_filepath)
- },
- #' @description
- #' Get the URL to the Zarr store, to fill in the file URL in the file definitions.
- #' @param base_url The base URL, on which the route will be served.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A URL as a string.
- get_zarr_url = function(base_url, dataset_uid, obj_i) {
- return(super$get_url(base_url, dataset_uid, obj_i, self$zarr_folder))
- },
- #' @description
- #' Create the JSON output files, web server routes, and file definition creators.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- convert_and_save = function(dataset_uid, obj_i) {
- super$convert_and_save(dataset_uid, obj_i)
-
- zarr_filepath <- self$get_zarr_path(dataset_uid, obj_i)
- if(!file.exists(zarr_filepath) || !self$use_cache) {
- giotto_to_anndata_zarr(self$obj, out_path = zarr_filepath)
- }
-
- # Get the file definition creator functions.
- cells_file_creator <- self$make_cells_file_def_creator(dataset_uid, obj_i)
- cell_sets_file_creator <- self$make_cell_sets_file_def_creator(dataset_uid, obj_i)
- expression_matrix_file_creator <- self$make_expression_matrix_file_def_creator(dataset_uid, obj_i)
-
- # Append the new file definition creators functions to the main list.
- self$file_def_creators <- append(self$file_def_creators, cells_file_creator)
- self$file_def_creators <- append(self$file_def_creators, cell_sets_file_creator)
- self$file_def_creators <- append(self$file_def_creators, expression_matrix_file_creator)
-
- # Create a web server route object for the directory of JSON files.
- self$routes <- append(self$routes, self$get_out_dir_route(dataset_uid, obj_i))
- },
- #' @description
- #' Make the file definition creator function for the cells data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_cells_file_def_creator = function(dataset_uid, obj_i) {
- get_cells <- function(base_url) {
- options <- obj_list()
- if(!is_na(slot(self$obj, "spatial_locs"))) {
- options[['xy']] <- "obsm/spatial"
- }
- if(!is_na(self$cell_embeddings)) {
- options[['mappings']] <- obj_list()
- for(i in seq_len(length(self$cell_embeddings))) {
- embedding_key <- self$cell_embeddings[i]
- if(!is_na(self$cell_embedding_names)) {
- embedding_name <- self$cell_embedding_names[i]
- } else {
- embedding_name <- embedding_key
- }
- if(!is_na(self$cell_embedding_dims)) {
- embedding_dims <- self$cell_embedding_dims[i]
- } else {
- embedding_dims <- c(0, 1)
- }
- options[['mappings']][[embedding_name]] <- obj_list(
- key = paste0("obsm/", embedding_key),
- dims = embedding_dims
- )
- }
- }
- file_def <- list(
- type = DataType$CELLS,
- fileType = FileType$ANNDATA_CELLS_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_cells)
- },
- #' @description
- #' Make the file definition creator function for the cell sets data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_cell_sets_file_def_creator = function(dataset_uid, obj_i) {
- get_cell_sets <- function(base_url) {
- options <- list()
- if(!is_na(self$cell_set_metas)) {
- for(i in seq_len(length(self$cell_set_metas))) {
- cell_set_key <- self$cell_set_metas[i]
- if(!is_na(self$cell_set_meta_names)) {
- group_name <- self$cell_set_meta_names[i]
- } else {
- group_name <- cell_set_key
- }
-
- cell_set_def <- obj_list(
- groupName = group_name,
- setName = paste0("obs/", cell_set_key)
- )
- if(!is_na(self$cell_set_meta_scores)) {
- score_name <- self$cell_set_meta_scores[i]
- # TODO: uncomment
- #cell_set_def[['scoreName']] <- score_name
- }
- options <- append(options, list(cell_set_def))
- }
- }
- file_def <- list(
- type = DataType$CELL_SETS,
- fileType = FileType$ANNDATA_CELL_SETS_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_cell_sets)
- },
- #' @description
- #' Make the file definition creator function for the expression matrix data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_expression_matrix_file_def_creator = function(dataset_uid, obj_i) {
- get_expression_matrix <- function(base_url) {
- options = obj_list(
- matrix = "X"
- )
- file_def <- list(
- type = DataType$EXPRESSION_MATRIX,
- fileType = FileType$ANNDATA_EXPRESSION_MATRIX_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_expression_matrix)
- }
- ),
-)
diff --git a/R/wrappers_images.R b/R/wrappers_images.R
index 31b7a2e..cc6b886 100644
--- a/R/wrappers_images.R
+++ b/R/wrappers_images.R
@@ -118,6 +118,9 @@ OmeTiffWrapper <- R6::R6Class("OmeTiffWrapper",
#' @field is_remote Whether or not this image is remote.
#' @keywords internal
is_remote = NULL,
+ #' @field local_img_uid
+ #' @keywords internal
+ local_img_uid = NULL,
#' @description
#' Create a wrapper around multiple image objects.
#' @param img_path A local filepath to an OME-TIFF file.
@@ -137,6 +140,8 @@ OmeTiffWrapper <- R6::R6Class("OmeTiffWrapper",
self$transformation_matrix <- transformation_matrix
self$is_bitmask <- is_bitmask
+ self$local_img_uid <- make_unique_filename(".ome.tif")
+
if(!is.na(img_url) && !is.na(img_path)) {
warning("Expected either img_path or img_url to be provided, but not both.")
}
@@ -147,9 +152,9 @@ OmeTiffWrapper <- R6::R6Class("OmeTiffWrapper",
#' Create the web server routes and file definition creators.
#' @param dataset_uid The ID for this dataset.
#' @param obj_i The index of this data object within the dataset.
- convert_and_save = function(dataset_uid, obj_i) {
+ convert_and_save = function(dataset_uid, obj_i, base_dir = NA) {
if(!self$is_remote) {
- super$convert_and_save(dataset_uid, obj_i)
+ super$convert_and_save(dataset_uid, obj_i, base_dir = base_dir)
}
# Get the file definition creator functions.
@@ -169,11 +174,18 @@ OmeTiffWrapper <- R6::R6Class("OmeTiffWrapper",
if(self$is_remote) {
return(list())
} else {
- route <- VitessceConfigServerRangeRoute$new(
- self$get_route_str(dataset_uid, obj_i, basename(self$img_path)),
- self$img_path
- )
- return(list(route))
+ if(is.na(self$base_dir)) {
+ local_img_path <- self$img_path
+ local_img_route_path <- self$get_route_str(dataset_uid, obj_i, self$local_img_uid)
+ } else {
+ local_img_path <- file.path(self$base_dir, self$img_path)
+ local_img_route_path <- file_path_to_url_path(self$img_path)
+ }
+ route <- VitessceConfigServerRangeRoute$new(
+ local_img_route_path,
+ local_img_path
+ )
+ return(list(route))
}
},
#' @description
@@ -184,27 +196,8 @@ OmeTiffWrapper <- R6::R6Class("OmeTiffWrapper",
#' @return A list that can be converted to JSON.
#' @keywords internal
make_image_def = function(dataset_uid, obj_i, base_url) {
- img_url <- NA
- if(self$is_remote) {
- img_url <- self$img_url
- } else {
- img_url <- self$get_url(base_url, dataset_uid, obj_i, basename(self$img_path))
- }
-
- img_def <- list(
- name = self$name,
- type = "ome-tiff",
- url = img_url
- )
- metadata <- obj_list()
- if(!is.na(self$transformation_matrix)) {
- metadata[['transform']] = list(
- matrix = self$transformation_matrix
- )
- }
- metadata[['isBitmask']] = self$is_bitmask
- img_def[['metadata']] = metadata
- img_def
+ img_url <- self$get_img_url(base_url, dataset_uid, obj_i)
+ return(self$create_image_json(img_url))
},
#' @description
#' Make the file definition creator function for the raster data type.
@@ -220,13 +213,38 @@ OmeTiffWrapper <- R6::R6Class("OmeTiffWrapper",
)
)
file_def <- list(
- type = DataType$RASTER,
fileType = FileType$RASTER_JSON,
options = options_def
)
return(file_def)
}
return(get_raster)
+ },
+ create_image_json = function(img_url, offsets_url = NA) {
+ metadata <- obj_list()
+ img_def <- list(
+ name = self$name,
+ type = "ome-tiff",
+ url = img_url
+ )
+ # TODO: offsets_url
+ if(!is.na(self$transformation_matrix)) {
+ metadata[['transform']] = list(
+ matrix = self$transformation_matrix
+ )
+ }
+ metadata[['isBitmask']] = self$is_bitmask
+ img_def[['metadata']] = metadata
+ img_def
+ },
+ get_img_url = function(base_url = "", dataset_uid = "", obj_i = "") {
+ if(self$is_remote) {
+ return(self$img_url)
+ }
+ if(!is.na(self$base_dir)) {
+ return(self$get_url_simple(base_url, file_path_to_url_path(self$img_path, prepend_slash = FALSE)))
+ }
+ return(self$get_url(base_url, dataset_uid, obj_i, self$local_img_uid))
}
),
)
diff --git a/R/wrappers_sce.R b/R/wrappers_sce.R
deleted file mode 100644
index 704ebc2..0000000
--- a/R/wrappers_sce.R
+++ /dev/null
@@ -1,244 +0,0 @@
-#' SingleCellExperiment object wrapper class
-#' @title SCEWrapper Class
-#' @docType class
-#' @description
-#' Class representing a local SingleCellExperiment object in a Vitessce dataset.
-#'
-#' @rdname SCEWrapper
-#' @export
-#' @examples
-#' obj <- get_sce_obj()
-#' w <- SCEWrapper$new(
-#' obj,
-#' cell_embeddings = c("pca"),
-#' cell_embedding_names = c("PCA")
-#' )
-SCEWrapper <- R6::R6Class("SCEWrapper",
- inherit = AbstractWrapper,
- public = list(
- #' @field obj The object to wrap.
- #' @keywords internal
- obj = NULL,
- #' @field cell_embeddings The keys in the Seurat object's reductions/cell.embeddings
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embeddings = NULL,
- #' @field cell_embedding_names Names
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embedding_names = NULL,
- #' @field cell_embedding_dims The dimension indices
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embedding_dims = NULL,
- #' @field cell_set_metas The keys in the Seurat object's meta.data
- #' to use for creating cell sets.
- #' @keywords internal
- cell_set_metas = NULL,
- #' @field cell_set_meta_names The keys in the Seurat object's meta.data
- #' to use for cell set names mapped to new names.
- #' @keywords internal
- cell_set_meta_names = NULL,
- #' @field cell_set_meta_scores The keys in the Seurat object's meta.data
- #' to use for cell set names mapped to keys for scores.
- #' @keywords internal
- cell_set_meta_scores = NULL,
- #' @field zarr_folder The name for the folder at the root of the zarr store.
- #' @keywords internal
- zarr_folder = NULL,
- #' @description
- #' Create a wrapper around a Seurat object.
- #' @param obj The object to wrap.
- #' @param cell_embeddings The keys in the Seurat object's reductions/cell.embeddings
- #' to use for creating dimensionality reduction plots.
- #' @param cell_embedding_names Names
- #' to use for creating dimensionality reduction plots.
- #' @param cell_embedding_dims An array of dimension indices to use for each cell_embedding.
- #' @param cell_set_metas An optional list of keys in the object's meta.data
- #' list to use for creating cell sets.
- #' @param cell_set_meta_names If cell_set_metas is provided, this list can
- #' also be provided to set new names to replace
- #' the keys in the interface.
- #' @param cell_set_meta_scores If cell_set_metas is provided, this list can
- #' also be provided to map between meta.data keys for set annotations
- #' and keys for annotation scores.
- #' @param ... Parameters inherited from `AbstractWrapper`.
- #' @return A new `SCEWrapper` object.
- initialize = function(obj, cell_embeddings = NA, cell_embedding_names = NA, cell_embedding_dims = NA, cell_set_metas = NA, cell_set_meta_names = NA, cell_set_meta_scores = NA, ...) {
- super$initialize(...)
- self$obj <- obj
- self$cell_embeddings <- cell_embeddings
- self$cell_embedding_names <- cell_embedding_names
- self$cell_embedding_dims <- cell_embedding_dims
- self$cell_set_metas <- cell_set_metas
- self$cell_set_meta_names <- cell_set_meta_names
- self$cell_set_meta_scores <- cell_set_meta_scores
-
- self$zarr_folder <- "sce.zarr"
- self$check_obj()
- },
- #' @description
- #' Check that the object is valid
- #' @keywords internal
- #' @return Success or failure.
- check_obj = function() {
- success <- TRUE
- if(!methods::is(self$obj, "SingleCellExperiment")) {
- warning("Object is not of type SingleCellExperiment.")
- success <- FALSE
- }
- if(!is_na(self$cell_embeddings) && !all(self$cell_embeddings %in% SingleCellExperiment::reducedDimNames(self$obj))) {
- warning("Specified cell_embeddings not all present in SCE object reducedDims.")
- success <- FALSE
- }
- if(!is_na(self$cell_set_metas) && !all(self$cell_set_metas %in% colnames(SingleCellExperiment::colData(self$obj)))) {
- warning("Specified cell_set_metas not all present in SCE object colData.")
- success <- FALSE
- }
- return(success)
- },
- #' @description
- #' Get the path to the zarr store, relative to the current directory.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A path as a string.
- get_zarr_path = function(dataset_uid, obj_i) {
- out_dir <- super$get_out_dir(dataset_uid, obj_i)
- zarr_filepath <- file.path(out_dir, self$zarr_folder)
- return(zarr_filepath)
- },
- #' @description
- #' Get the URL to the Zarr store, to fill in the file URL in the file definitions.
- #' @param base_url The base URL, on which the route will be served.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A URL as a string.
- get_zarr_url = function(base_url, dataset_uid, obj_i) {
- return(super$get_url(base_url, dataset_uid, obj_i, self$zarr_folder))
- },
- #' @description
- #' Create the JSON output files, web server routes, and file definition creators.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- convert_and_save = function(dataset_uid, obj_i) {
- super$convert_and_save(dataset_uid, obj_i)
-
- zarr_filepath <- self$get_zarr_path(dataset_uid, obj_i)
- if(!file.exists(zarr_filepath) || !self$use_cache) {
- sce_to_anndata_zarr(self$obj, out_path = zarr_filepath)
- }
-
- # Get the file definition creator functions.
- cells_file_creator <- self$make_cells_file_def_creator(dataset_uid, obj_i)
- cell_sets_file_creator <- self$make_cell_sets_file_def_creator(dataset_uid, obj_i)
- expression_matrix_file_creator <- self$make_expression_matrix_file_def_creator(dataset_uid, obj_i)
-
- # Append the new file definition creators functions to the main list.
- self$file_def_creators <- append(self$file_def_creators, cells_file_creator)
- self$file_def_creators <- append(self$file_def_creators, cell_sets_file_creator)
- self$file_def_creators <- append(self$file_def_creators, expression_matrix_file_creator)
-
- # Create a web server route object for the directory of JSON files.
- self$routes <- append(self$routes, self$get_out_dir_route(dataset_uid, obj_i))
- },
- #' @description
- #' Make the file definition creator function for the cells data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_cells_file_def_creator = function(dataset_uid, obj_i) {
- get_cells <- function(base_url) {
- options <- obj_list()
- if(!is_na(self$cell_embeddings)) {
- options[['mappings']] <- obj_list()
- for(i in seq_len(length(self$cell_embeddings))) {
- embedding_key <- self$cell_embeddings[i]
- if(!is_na(self$cell_embedding_names)) {
- embedding_name <- self$cell_embedding_names[i]
- } else {
- embedding_name <- embedding_key
- }
- if(!is_na(self$cell_embedding_dims)) {
- embedding_dims <- self$cell_embedding_dims[i]
- } else {
- embedding_dims <- c(0, 1)
- }
- options[['mappings']][[embedding_name]] <- obj_list(
- key = paste0("obsm/", embedding_key),
- dims = embedding_dims
- )
- }
- }
- file_def <- list(
- type = DataType$CELLS,
- fileType = FileType$ANNDATA_CELLS_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_cells)
- },
- #' @description
- #' Make the file definition creator function for the cell sets data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_cell_sets_file_def_creator = function(dataset_uid, obj_i) {
- get_cell_sets <- function(base_url) {
- options <- list()
- if(!is_na(self$cell_set_metas)) {
- for(i in seq_len(length(self$cell_set_metas))) {
- cell_set_key <- self$cell_set_metas[i]
- if(!is_na(self$cell_set_meta_names)) {
- group_name <- self$cell_set_meta_names[i]
- } else {
- group_name <- cell_set_key
- }
-
- cell_set_def <- obj_list(
- groupName = group_name,
- setName = paste0("obs/", cell_set_key)
- )
- if(!is_na(self$cell_set_meta_scores)) {
- score_name <- self$cell_set_meta_scores[i]
- # TODO: uncomment
- #cell_set_def[['scoreName']] <- score_name
- }
- options <- append(options, list(cell_set_def))
- }
- }
- file_def <- list(
- type = DataType$CELL_SETS,
- fileType = FileType$ANNDATA_CELL_SETS_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_cell_sets)
- },
- #' @description
- #' Make the file definition creator function for the expression matrix data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_expression_matrix_file_def_creator = function(dataset_uid, obj_i) {
- get_expression_matrix <- function(base_url) {
- options = obj_list(
- matrix = "X"
- )
- file_def <- list(
- type = DataType$EXPRESSION_MATRIX,
- fileType = FileType$ANNDATA_EXPRESSION_MATRIX_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_expression_matrix)
- }
- ),
-)
diff --git a/R/wrappers_seurat.R b/R/wrappers_seurat.R
deleted file mode 100644
index 8f004b5..0000000
--- a/R/wrappers_seurat.R
+++ /dev/null
@@ -1,262 +0,0 @@
-#' Seurat object wrapper class
-#' @title SeuratWrapper Class
-#' @docType class
-#' @description
-#' Class representing a local Seurat object in a Vitessce dataset.
-#'
-#' @rdname SeuratWrapper
-#' @export
-#' @examples
-#' obj <- get_seurat_obj()
-#' w <- SeuratWrapper$new(
-#' obj,
-#' cell_embeddings = c("pca"),
-#' cell_embedding_names = c("PCA")
-#' )
-SeuratWrapper <- R6::R6Class("SeuratWrapper",
- inherit = AbstractWrapper,
- public = list(
- #' @field obj The object to wrap.
- #' @keywords internal
- obj = NULL,
- #' @field assay The assay name in the Seurat object.
- #' @keywords internal
- assay = NULL,
- #' @field cell_embeddings The keys in the Seurat object's reductions/cell.embeddings
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embeddings = NULL,
- #' @field cell_embedding_names Names
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embedding_names = NULL,
- #' @field cell_embedding_dims The dimension indices
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embedding_dims = NULL,
- #' @field cell_set_metas The keys in the Seurat object's meta.data
- #' to use for creating cell sets.
- #' @keywords internal
- cell_set_metas = NULL,
- #' @field cell_set_meta_names The keys in the Seurat object's meta.data
- #' to use for cell set names mapped to new names.
- #' @keywords internal
- cell_set_meta_names = NULL,
- #' @field cell_set_meta_scores The keys in the Seurat object's meta.data
- #' to use for cell set names mapped to keys for scores.
- #' @keywords internal
- cell_set_meta_scores = NULL,
- #' @field zarr_folder The name for the folder at the root of the zarr store.
- #' @keywords internal
- zarr_folder = NULL,
- #' @description
- #' Create a wrapper around a Seurat object.
- #' @param obj The object to wrap.
- #' @param assay The assay name under the assays part of the Seurat object.
- #' @param cell_embeddings The keys in the Seurat object's reductions/cell.embeddings
- #' to use for creating dimensionality reduction plots.
- #' @param cell_embedding_names Names
- #' to use for creating dimensionality reduction plots.
- #' @param cell_embedding_dims An array of dimension indices to use for each cell_embedding.
- #' @param cell_set_metas An optional list of keys in the object's meta.data
- #' list to use for creating cell sets.
- #' @param cell_set_meta_names If cell_set_metas is provided, this list can
- #' also be provided to set new names to replace
- #' the keys in the interface.
- #' @param cell_set_meta_scores If cell_set_metas is provided, this list can
- #' also be provided to map between meta.data keys for set annotations
- #' and keys for annotation scores.
- #' @param ... Parameters inherited from `AbstractWrapper`.
- #' @return A new `SeuratWrapper` object.
- initialize = function(obj, assay = NA, cell_embeddings = NA, cell_embedding_names = NA, cell_embedding_dims = NA, cell_set_metas = NA, cell_set_meta_names = NA, cell_set_meta_scores = NA, ...) {
- super$initialize(...)
- self$obj <- obj
- if(is.na(assay)) {
- self$assay <- "RNA"
- } else {
- self$assay <- assay
- }
- self$cell_embeddings <- cell_embeddings
- self$cell_embedding_names <- cell_embedding_names
- self$cell_embedding_dims <- cell_embedding_dims
- self$cell_set_metas <- cell_set_metas
- self$cell_set_meta_names <- cell_set_meta_names
- self$cell_set_meta_scores <- cell_set_meta_scores
-
- self$zarr_folder <- "seurat.zarr"
-
- self$check_obj()
- },
- #' @description
- #' Check that the object is valid
- #' @keywords internal
- #' @return Success or failure.
- check_obj = function() {
- success <- TRUE
- if(is.null(self$obj)) {
- warning("Object is NULL.")
- return(FALSE)
- }
- if(!methods::is(self$obj, "Seurat")) {
- warning("Object is not of type Seurat.")
- success <- FALSE
- }
- if(!(self$assay %in% names(self$obj@assays))) {
- warning("Specified assay not present in Seurat object assays slot.")
- success <- FALSE
- }
- if(!is_na(self$cell_embeddings) && !all(self$cell_embeddings %in% names(self$obj@reductions))) {
- warning("Specified cell_embeddings not all present in Seurat object reductions slot.")
- success <- FALSE
- }
- if(!is_na(self$cell_set_metas) && !all(self$cell_set_metas %in% colnames(self$obj@meta.data))) {
- warning("Specified cell_set_metas not all present in columns of the Seurat object meta.data data frame.")
- success <- FALSE
- }
- return(success)
- },
- #' @description
- #' Get the path to the zarr store, relative to the current directory.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A path as a string.
- get_zarr_path = function(dataset_uid, obj_i) {
- out_dir <- super$get_out_dir(dataset_uid, obj_i)
- zarr_filepath <- file.path(out_dir, self$zarr_folder)
- return(zarr_filepath)
- },
- #' @description
- #' Get the URL to the Zarr store, to fill in the file URL in the file definitions.
- #' @param base_url The base URL, on which the route will be served.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A URL as a string.
- get_zarr_url = function(base_url, dataset_uid, obj_i) {
- return(super$get_url(base_url, dataset_uid, obj_i, self$zarr_folder))
- },
- #' @description
- #' Create the JSON output files, web server routes, and file definition creators.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- convert_and_save = function(dataset_uid, obj_i) {
- super$convert_and_save(dataset_uid, obj_i)
-
- zarr_filepath <- self$get_zarr_path(dataset_uid, obj_i)
- if(!file.exists(zarr_filepath) || !self$use_cache) {
- seurat_to_anndata_zarr(self$obj, out_path = zarr_filepath, assay = self$assay)
- }
-
- # Get the file definition creator functions.
- cells_file_creator <- self$make_cells_file_def_creator(dataset_uid, obj_i)
- cell_sets_file_creator <- self$make_cell_sets_file_def_creator(dataset_uid, obj_i)
- expression_matrix_file_creator <- self$make_expression_matrix_file_def_creator(dataset_uid, obj_i)
-
- # Append the new file definition creators functions to the main list.
- self$file_def_creators <- append(self$file_def_creators, cells_file_creator)
- self$file_def_creators <- append(self$file_def_creators, cell_sets_file_creator)
- self$file_def_creators <- append(self$file_def_creators, expression_matrix_file_creator)
-
- # Create a web server route object for the directory of JSON files.
- self$routes <- append(self$routes, self$get_out_dir_route(dataset_uid, obj_i))
- },
- #' @description
- #' Make the file definition creator function for the cells data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_cells_file_def_creator = function(dataset_uid, obj_i) {
- get_cells <- function(base_url) {
- options <- obj_list()
- if(!is_na(self$cell_embeddings)) {
- options[['mappings']] <- obj_list()
- for(i in seq_len(length(self$cell_embeddings))) {
- embedding_key <- self$cell_embeddings[i]
- if(!is_na(self$cell_embedding_names)) {
- embedding_name <- self$cell_embedding_names[i]
- } else {
- embedding_name <- embedding_key
- }
- if(!is_na(self$cell_embedding_dims)) {
- embedding_dims <- self$cell_embedding_dims[i]
- } else {
- embedding_dims <- c(0, 1)
- }
- options[['mappings']][[embedding_name]] <- obj_list(
- key = paste0("obsm/X_", embedding_key),
- dims = embedding_dims
- )
- }
- }
- file_def <- list(
- type = DataType$CELLS,
- fileType = FileType$ANNDATA_CELLS_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_cells)
- },
- #' @description
- #' Make the file definition creator function for the cell sets data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_cell_sets_file_def_creator = function(dataset_uid, obj_i) {
- get_cell_sets <- function(base_url) {
- options <- list()
- if(!is_na(self$cell_set_metas)) {
- for(i in seq_len(length(self$cell_set_metas))) {
- cell_set_key <- self$cell_set_metas[i]
- if(!is_na(self$cell_set_meta_names)) {
- group_name <- self$cell_set_meta_names[i]
- } else {
- group_name <- cell_set_key
- }
-
- cell_set_def <- obj_list(
- groupName = group_name,
- setName = paste0("obs/", cell_set_key)
- )
- if(!is_na(self$cell_set_meta_scores)) {
- score_name <- self$cell_set_meta_scores[i]
- # TODO: uncomment
- #cell_set_def[['scoreName']] <- score_name
- }
- options <- append(options, list(cell_set_def))
- }
- }
- file_def <- list(
- type = DataType$CELL_SETS,
- fileType = FileType$ANNDATA_CELL_SETS_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_cell_sets)
- },
- #' @description
- #' Make the file definition creator function for the expression matrix data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_expression_matrix_file_def_creator = function(dataset_uid, obj_i) {
- get_expression_matrix <- function(base_url) {
- options = obj_list(
- matrix = "X"
- )
- file_def <- list(
- type = DataType$EXPRESSION_MATRIX,
- fileType = FileType$ANNDATA_EXPRESSION_MATRIX_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_expression_matrix)
- }
- ),
-)
diff --git a/R/wrappers_spe.R b/R/wrappers_spe.R
deleted file mode 100644
index d23270a..0000000
--- a/R/wrappers_spe.R
+++ /dev/null
@@ -1,319 +0,0 @@
-#' SpatialExperiment object wrapper class
-#' @title SPEWrapper Class
-#' @docType class
-#' @description
-#' Class representing a local SpatialExperiment object in a Vitessce dataset.
-#'
-#' @rdname SPEWrapper
-#' @export
-#' @examples
-#' obj <- get_spe_obj()
-#' w <- SPEWrapper$new(
-#' obj,
-#' sample_id = "sample1",
-#' image_id = "image1"
-#' )
-SPEWrapper <- R6::R6Class("SPEWrapper",
- inherit = AbstractWrapper,
- public = list(
- #' @field obj The object to wrap.
- #' @keywords internal
- obj = NULL,
- #' @field img_sample_id The sample_id for the image of interest.
- #' @keywords internal
- img_sample_id = NULL,
- #' @field img_image_id The image_id for the image of interest.
- #' @keywords internal
- img_image_id = NULL,
- #' @field cell_embeddings The keys in the Seurat object's reductions/cell.embeddings
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embeddings = NULL,
- #' @field cell_embedding_names Names
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embedding_names = NULL,
- #' @field cell_embedding_dims The dimension indices
- #' to use for creating dimensionality reduction mappings.
- #' @keywords internal
- cell_embedding_dims = NULL,
- #' @field cell_set_metas The keys in the Seurat object's meta.data
- #' to use for creating cell sets.
- #' @keywords internal
- cell_set_metas = NULL,
- #' @field cell_set_meta_names The keys in the Seurat object's meta.data
- #' to use for cell set names mapped to new names.
- #' @keywords internal
- cell_set_meta_names = NULL,
- #' @field cell_set_meta_scores The keys in the Seurat object's meta.data
- #' to use for cell set names mapped to keys for scores.
- #' @keywords internal
- cell_set_meta_scores = NULL,
- #' @field zarr_folder The name for the folder at the root of the zarr store.
- #' @keywords internal
- zarr_folder = NULL,
- #' @field img_filename The name for the folder at the root of the zarr store for the image.
- #' @keywords internal
- img_filename = NULL,
- #' @description
- #' Create a wrapper around a Seurat object.
- #' @param obj The object to wrap.
- #' @param sample_id The sample_id for the image of interest.
- #' @param image_id The image_id for the image of interest.
- #' @param cell_embeddings The keys in the Seurat object's reductions/cell.embeddings
- #' to use for creating dimensionality reduction plots.
- #' @param cell_embedding_names Names
- #' to use for creating dimensionality reduction plots.
- #' @param cell_embedding_dims An array of dimension indices to use for each cell_embedding.
- #' @param cell_set_metas An optional list of keys in the object's meta.data
- #' list to use for creating cell sets.
- #' @param cell_set_meta_names If cell_set_metas is provided, this list can
- #' also be provided to set new names to replace
- #' the keys in the interface.
- #' @param cell_set_meta_scores If cell_set_metas is provided, this list can
- #' also be provided to map between meta.data keys for set annotations
- #' and keys for annotation scores.
- #' @param ... Parameters inherited from `AbstractWrapper`.
- #' @return A new `SPEWrapper` object.
- initialize = function(obj, sample_id = NA, image_id = NA, cell_embeddings = NA, cell_embedding_names = NA, cell_embedding_dims = NA, cell_set_metas = NA, cell_set_meta_names = NA, cell_set_meta_scores = NA, ...) {
- super$initialize(...)
- self$obj <- obj
- if(is_na(sample_id) && is_na(image_id)) {
- img_df <- SpatialExperiment::imgData(obj)
- if(nrow(img_df) >= 1) {
- warning("sample_id and image_id not provided, using first image in imgData")
- self$img_sample_id <- img_df[1, "sample_id"]
- self$img_image_id <- img_df[1, "image_id"]
- }
- } else {
- self$img_sample_id <- sample_id
- self$img_image_id <- image_id
- }
-
- self$cell_embeddings <- cell_embeddings
- self$cell_embedding_names <- cell_embedding_names
- self$cell_embedding_dims <- cell_embedding_dims
- self$cell_set_metas <- cell_set_metas
- self$cell_set_meta_names <- cell_set_meta_names
- self$cell_set_meta_scores <- cell_set_meta_scores
-
- self$zarr_folder <- "spe.zarr"
- self$img_filename <- paste0(self$img_sample_id, "__", self$img_image_id, ".zarr")
-
- self$check_obj()
- },
- #' @description
- #' Check that the object is valid
- #' @keywords internal
- #' @return Success or failure.
- check_obj = function() {
- success <- TRUE
- if(!methods::is(self$obj, "SpatialExperiment")) {
- warning("Object is not of type SpatialExperiment.")
- success <- FALSE
- }
- if(!is_na(self$cell_embeddings) && !all(self$cell_embeddings %in% SingleCellExperiment::reducedDimNames(self$obj))) {
- warning("Specified cell_embeddings not all present in SPE object reducedDims.")
- success <- FALSE
- }
- if(!is_na(self$cell_set_metas) && !all(self$cell_set_metas %in% colnames(SingleCellExperiment::colData(self$obj)))) {
- warning("Specified cell_set_metas not all present in SPE object colData.")
- success <- FALSE
- }
- img_df <- SpatialExperiment::imgData(self$obj)
- if(!is_na(self$img_sample_id) && !is_na(self$img_image_id) && !(self$img_sample_id %in% img_df$sample_id && self$img_image_id %in% img_df$image_id)) {
- warning("Specified sample_id and/or image_id not present in SPE object imgData.")
- success <- FALSE
- }
- return(success)
- },
- #' @description
- #' Get the path to the zarr store, relative to the current directory.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A path as a string.
- get_zarr_path = function(dataset_uid, obj_i) {
- out_dir <- super$get_out_dir(dataset_uid, obj_i)
- zarr_filepath <- file.path(out_dir, self$zarr_folder)
- return(zarr_filepath)
- },
- #' @description
- #' Get the URL to the Zarr store, to fill in the file URL in the file definitions.
- #' @param base_url The base URL, on which the route will be served.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A URL as a string.
- get_zarr_url = function(base_url, dataset_uid, obj_i) {
- return(super$get_url(base_url, dataset_uid, obj_i, self$zarr_folder))
- },
- #' @description
- #' Get the path to the image Zarr store, relative to the current directory.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A path as a string.
- get_img_path = function(dataset_uid, obj_i) {
- out_dir <- super$get_out_dir(dataset_uid, obj_i)
- zarr_filepath <- file.path(out_dir, self$img_filename)
- return(zarr_filepath)
- },
- #' @description
- #' Get the URL to the image Zarr store, to fill in the file URL in the file definitions.
- #' @param base_url The base URL, on which the route will be served.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @keywords internal
- #' @return A URL as a string.
- get_img_url = function(base_url, dataset_uid, obj_i) {
- return(super$get_url(base_url, dataset_uid, obj_i, self$img_filename))
- },
- #' @description
- #' Create the JSON output files, web server routes, and file definition creators.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- convert_and_save = function(dataset_uid, obj_i) {
- super$convert_and_save(dataset_uid, obj_i)
-
- zarr_filepath <- self$get_zarr_path(dataset_uid, obj_i)
- img_filepath <- self$get_img_path(dataset_uid, obj_i)
- if(!file.exists(zarr_filepath) || !file.exists(img_filepath) || !self$use_cache) {
- spe_to_anndata_zarr(self$obj, out_path = zarr_filepath)
- spe_to_ome_zarr(self$obj, sample_id = self$img_sample_id, image_id = self$img_image_id, out_path = img_filepath)
- }
-
- # Get the file definition creator functions.
- cells_file_creator <- self$make_cells_file_def_creator(dataset_uid, obj_i)
- cell_sets_file_creator <- self$make_cell_sets_file_def_creator(dataset_uid, obj_i)
- expression_matrix_file_creator <- self$make_expression_matrix_file_def_creator(dataset_uid, obj_i)
- raster_file_creator <- self$make_raster_file_def_creator(dataset_uid, obj_i)
-
- # Append the new file definition creators functions to the main list.
- if(!is_na(self$cell_embeddings)) {
- self$file_def_creators <- append(self$file_def_creators, cells_file_creator)
- }
- if(!is_na(self$cell_set_metas)) {
- self$file_def_creators <- append(self$file_def_creators, cell_sets_file_creator)
- }
- self$file_def_creators <- append(self$file_def_creators, expression_matrix_file_creator)
- self$file_def_creators <- append(self$file_def_creators, raster_file_creator)
-
- # Create a web server route object for the directory of JSON files.
- self$routes <- append(self$routes, self$get_out_dir_route(dataset_uid, obj_i))
- },
- #' @description
- #' Make the file definition creator function for the cells data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_cells_file_def_creator = function(dataset_uid, obj_i) {
- get_cells <- function(base_url) {
- options <- obj_list()
- if(!is_na(self$cell_embeddings)) {
- options[['mappings']] <- obj_list()
- for(i in seq_len(length(self$cell_embeddings))) {
- embedding_key <- self$cell_embeddings[i]
- if(!is_na(self$cell_embedding_names)) {
- embedding_name <- self$cell_embedding_names[i]
- } else {
- embedding_name <- embedding_key
- }
- if(!is_na(self$cell_embedding_dims)) {
- embedding_dims <- self$cell_embedding_dims[i]
- } else {
- embedding_dims <- c(0, 1)
- }
- options[['mappings']][[embedding_name]] <- obj_list(
- key = paste0("obsm/", embedding_key),
- dims = embedding_dims
- )
- }
- }
- file_def <- list(
- type = DataType$CELLS,
- fileType = FileType$ANNDATA_CELLS_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_cells)
- },
- #' @description
- #' Make the file definition creator function for the cell sets data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_cell_sets_file_def_creator = function(dataset_uid, obj_i) {
- get_cell_sets <- function(base_url) {
- options <- list()
- if(!is_na(self$cell_set_metas)) {
- for(i in seq_len(length(self$cell_set_metas))) {
- cell_set_key <- self$cell_set_metas[i]
- if(!is_na(self$cell_set_meta_names)) {
- group_name <- self$cell_set_meta_names[i]
- } else {
- group_name <- cell_set_key
- }
-
- cell_set_def <- obj_list(
- groupName = group_name,
- setName = paste0("obs/", cell_set_key)
- )
- if(!is_na(self$cell_set_meta_scores)) {
- score_name <- self$cell_set_meta_scores[i]
- # TODO: uncomment
- #cell_set_def[['scoreName']] <- score_name
- }
- options <- append(options, list(cell_set_def))
- }
- }
- file_def <- list(
- type = DataType$CELL_SETS,
- fileType = FileType$ANNDATA_CELL_SETS_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_cell_sets)
- },
- #' @description
- #' Make the file definition creator function for the expression matrix data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_expression_matrix_file_def_creator = function(dataset_uid, obj_i) {
- get_expression_matrix <- function(base_url) {
- options = obj_list(
- matrix = "X"
- )
- file_def <- list(
- type = DataType$EXPRESSION_MATRIX,
- fileType = FileType$ANNDATA_EXPRESSION_MATRIX_ZARR,
- url = self$get_zarr_url(base_url, dataset_uid, obj_i),
- options = options
- )
- return(file_def)
- }
- return(get_expression_matrix)
- },
- #' @description
- #' Make the file definition creator function for the raster data type.
- #' @param dataset_uid The ID for this dataset.
- #' @param obj_i The index of this data object within the dataset.
- #' @return A file definition creator function which takes a `base_url` parameter.
- make_raster_file_def_creator = function(dataset_uid, obj_i) {
- get_raster <- function(base_url) {
- file_def <- list(
- type = DataType$RASTER,
- fileType = FileType$RASTER_OME_ZARR,
- url = self$get_img_url(base_url, dataset_uid, obj_i)
- )
- return(file_def)
- }
- return(get_raster)
- }
- ),
-)
diff --git a/configure b/configure
deleted file mode 100755
index 9b03c32..0000000
--- a/configure
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-${R_HOME}/bin/Rscript -e "basilisk::configureBasiliskEnv()"
diff --git a/configure.win b/configure.win
deleted file mode 100755
index e9af497..0000000
--- a/configure.win
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe -e "basilisk::configureBasiliskEnv()"
diff --git a/index.md b/index.md
index dae4f1f..c5780ce 100644
--- a/index.md
+++ b/index.md
@@ -15,7 +15,7 @@ The ``vitessceR`` package includes:
* **Data preparation**
- * Use our data conversion wrapper classes to process data stored in common single-cell file types including Seurat objects.
+ * Use data conversion functions from the `vitessceAnalysisR` package to process data stored in common single-cell data structures including Seurat objects.
## Installation
@@ -35,11 +35,11 @@ The simplest way to instantiate a Vitessce widget is to create a view config bas
library(vitessceR)
# Create Vitessce view config
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
scatterplot <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "pca")
status <- vc$add_view(dataset, Component$STATUS)
-cell_sets <- vc$add_view(dataset, Component$CELL_SETS)
+cell_sets <- vc$add_view(dataset, Component$OBS_SETS)
vc$layout(hconcat(scatterplot, vconcat(status, cell_sets)))
# Render the Vitessce widget
diff --git a/inst/htmlwidgets/vitessceR.js b/inst/htmlwidgets/vitessceR.js
index c374431..0aedb40 100644
--- a/inst/htmlwidgets/vitessceR.js
+++ b/inst/htmlwidgets/vitessceR.js
@@ -48,7 +48,7 @@ HTMLWidgets.widget({
const onConfigChange = React.useCallback((newConfig) => {
if(window && window.Shiny && window.Shiny.setInputValue) {
- Shiny.setInputValue("on_config_change", newConfig);
+ Shiny.setInputValue("vitessce_on_config_change", newConfig);
}
}, [window.Shiny]);
diff --git a/man/AbstractWrapper.Rd b/man/AbstractWrapper.Rd
index 143708e..b4d561a 100644
--- a/man/AbstractWrapper.Rd
+++ b/man/AbstractWrapper.Rd
@@ -23,6 +23,8 @@ Abstract dataset object wrapper class
\item{\code{routes}}{A list of \code{VitessceConfigServerRoute} objects.}
\item{\code{file_def_creators}}{A list of file definition creator functions.}
+
+\item{\code{base_dir}}{The base directory for local data.}
}
\if{html}{\out{}}
}
@@ -34,7 +36,12 @@ Abstract dataset object wrapper class
\item \href{#method-AbstractWrapper-get_routes}{\code{AbstractWrapper$get_routes()}}
\item \href{#method-AbstractWrapper-get_file_defs}{\code{AbstractWrapper$get_file_defs()}}
\item \href{#method-AbstractWrapper-get_out_dir_route}{\code{AbstractWrapper$get_out_dir_route()}}
+\item \href{#method-AbstractWrapper-get_local_dir_url}{\code{AbstractWrapper$get_local_dir_url()}}
+\item \href{#method-AbstractWrapper-get_local_file_url}{\code{AbstractWrapper$get_local_file_url()}}
+\item \href{#method-AbstractWrapper-get_local_dir_route}{\code{AbstractWrapper$get_local_dir_route()}}
+\item \href{#method-AbstractWrapper-get_local_file_route}{\code{AbstractWrapper$get_local_file_route()}}
\item \href{#method-AbstractWrapper-get_url}{\code{AbstractWrapper$get_url()}}
+\item \href{#method-AbstractWrapper-get_url_simple}{\code{AbstractWrapper$get_url_simple()}}
\item \href{#method-AbstractWrapper-get_route_str}{\code{AbstractWrapper$get_route_str()}}
\item \href{#method-AbstractWrapper-get_out_dir}{\code{AbstractWrapper$get_out_dir()}}
\item \href{#method-AbstractWrapper-auto_view_config}{\code{AbstractWrapper$auto_view_config()}}
@@ -72,7 +79,7 @@ Each function added to this list should take in a base URL and generate a Vitess
If this wrapper is wrapping local data, then create routes and fill in the routes array.
This method is void, should not return anything.
\subsection{Usage}{
-\if{html}{\out{
}}\preformatted{AbstractWrapper$convert_and_save(dataset_uid, obj_i)}\if{html}{\out{
}}
+\if{html}{\out{}}\preformatted{AbstractWrapper$convert_and_save(dataset_uid, obj_i, base_dir = NA)}\if{html}{\out{
}}
}
\subsection{Arguments}{
@@ -81,6 +88,8 @@ This method is void, should not return anything.
\item{\code{dataset_uid}}{A unique identifier for this dataset.}
\item{\code{obj_i}}{Within the dataset, the index of this data wrapper object.}
+
+\item{\code{base_dir}}{Path to a base directory.}
}
\if{html}{\out{}}
}
@@ -141,6 +150,136 @@ A new \code{VitessceConfigServerStaticRoute} instance.
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AbstractWrapper-get_local_dir_url}{}}}
+\subsection{Method \code{get_local_dir_url()}}{
+Construct a URL to a local directory.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AbstractWrapper$get_local_dir_url(
+ base_url,
+ dataset_uid,
+ obj_i,
+ local_dir_path,
+ local_dir_uid
+)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{base_url}}{The base URL on which the web server is serving.}
+
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+
+\item{\code{local_dir_path}}{The path to the local directory.}
+
+\item{\code{local_dir_uid}}{A unique identifier for this local directory in this dataset.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A string for the URL.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AbstractWrapper-get_local_file_url}{}}}
+\subsection{Method \code{get_local_file_url()}}{
+Construct a URL to a local file.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AbstractWrapper$get_local_file_url(
+ base_url,
+ dataset_uid,
+ obj_i,
+ local_file_path,
+ local_file_uid
+)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{base_url}}{The base URL on which the web server is serving.}
+
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+
+\item{\code{local_file_path}}{The path to the local file.}
+
+\item{\code{local_file_uid}}{A unique identifier for this local file in this dataset.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A string for the URL.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AbstractWrapper-get_local_dir_route}{}}}
+\subsection{Method \code{get_local_dir_route()}}{
+Create a web server route for this object.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AbstractWrapper$get_local_dir_route(
+ dataset_uid,
+ obj_i,
+ local_dir_path,
+ local_dir_uid
+)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+
+\item{\code{local_dir_path}}{The path to the local directory.}
+
+\item{\code{local_dir_uid}}{A unique identifier for this local directory in this dataset.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A new \code{VitessceConfigServerStaticRoute} instance.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AbstractWrapper-get_local_file_route}{}}}
+\subsection{Method \code{get_local_file_route()}}{
+Create a web server route for this object.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AbstractWrapper$get_local_file_route(
+ dataset_uid,
+ obj_i,
+ local_file_path,
+ local_file_uid
+)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+
+\item{\code{local_file_path}}{The path to the local file.}
+
+\item{\code{local_file_uid}}{A unique identifier for this local file in this dataset.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A new \code{VitessceConfigServerFileRoute} instance.
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-AbstractWrapper-get_url}{}}}
\subsection{Method \code{get_url()}}{
@@ -167,6 +306,28 @@ A URL as a string.
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AbstractWrapper-get_url_simple}{}}}
+\subsection{Method \code{get_url_simple()}}{
+Construct a URL.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AbstractWrapper$get_url_simple(base_url, suffix)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{base_url}}{The base URL on which the web server is serving.}
+
+\item{\code{suffix}}{The suffix to append to the base URL.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A URL as a string like {base_url}/{suffix}
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-AbstractWrapper-get_route_str}{}}}
\subsection{Method \code{get_route_str()}}{
diff --git a/man/AnnDataWrapper.Rd b/man/AnnDataWrapper.Rd
new file mode 100644
index 0000000..184e28f
--- /dev/null
+++ b/man/AnnDataWrapper.Rd
@@ -0,0 +1,267 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/wrappers_anndata.R
+\docType{class}
+\name{AnnDataWrapper}
+\alias{AnnDataWrapper}
+\title{AnnDataWrapper Class}
+\description{
+Class representing an AnnData object (saved to a Zarr store) in a Vitessce dataset.
+}
+\details{
+AnnData object wrapper class
+}
+\keyword{internal}
+\section{Super class}{
+\code{\link[vitessceR:AbstractWrapper]{vitessceR::AbstractWrapper}} -> \code{AnnDataWrapper}
+}
+\section{Public fields}{
+\if{html}{\out{}}
+\describe{
+\item{\code{adata_path}}{The object to wrap.}
+
+\item{\code{adata_url}}{The object to wrap.}
+
+\item{\code{local_dir_uid}}{The path to the local zarr store.}
+
+\item{\code{obs_feature_matrix_path}}{The path to the observation-by-feature matrix within the Zarr store.}
+
+\item{\code{feature_filter_path}}{The path to the a column of adata.var within the Zarr store.
+Use this if obs_feature_matrix_path points to a subset of adata.X (relative to the full adata.var).}
+
+\item{\code{initial_feature_filter_path}}{The path to the a column of adata.var within the Zarr store.
+Use this to load a subset of the matrix at obs_feature_matrix_path initially.}
+
+\item{\code{obs_set_paths}}{A list of paths to the observation sets within the Zarr store.}
+
+\item{\code{obs_set_names}}{A list of names for the observation sets.}
+
+\item{\code{obs_locations_path}}{The path to the observation locations within the Zarr store.}
+
+\item{\code{obs_segmentations_path}}{The path to the observation segmentations within the Zarr store.}
+
+\item{\code{obs_embedding_paths}}{A list of paths to the observation embeddings within the Zarr store.}
+
+\item{\code{obs_embedding_names}}{A list of names for the observation embeddings.}
+
+\item{\code{obs_embedding_dims}}{A list of dimensions for the observation embeddings.}
+
+\item{\code{feature_labels_path}}{The path to the feature labels within the Zarr store.}
+
+\item{\code{obs_labels_path}}{The path to the observation labels within the Zarr store.}
+
+\item{\code{obs_labels_paths}}{A list of paths to the observation labels within the Zarr store.}
+
+\item{\code{obs_labels_names}}{A list of names for the observation labels.}
+
+\item{\code{coordination_values}}{A list of coordination values for the file definition.}
+
+\item{\code{request_init}}{A list of requestInit options for the Zarr store.}
+}
+\if{html}{\out{
}}
+}
+\section{Methods}{
+\subsection{Public methods}{
+\itemize{
+\item \href{#method-AnnDataWrapper-new}{\code{AnnDataWrapper$new()}}
+\item \href{#method-AnnDataWrapper-convert_and_save}{\code{AnnDataWrapper$convert_and_save()}}
+\item \href{#method-AnnDataWrapper-make_routes}{\code{AnnDataWrapper$make_routes()}}
+\item \href{#method-AnnDataWrapper-get_zarr_url}{\code{AnnDataWrapper$get_zarr_url()}}
+\item \href{#method-AnnDataWrapper-make_file_def_creator}{\code{AnnDataWrapper$make_file_def_creator()}}
+\item \href{#method-AnnDataWrapper-clone}{\code{AnnDataWrapper$clone()}}
+}
+}
+\if{html}{\out{
+Inherited methods
+
+
+}}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AnnDataWrapper-new}{}}}
+\subsection{Method \code{new()}}{
+Create a wrapper around an AnnData object saved to a Zarr store.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AnnDataWrapper$new(
+ adata_path = NA,
+ adata_url = NA,
+ obs_feature_matrix_path = NA,
+ feature_filter_path = NA,
+ initial_feature_filter_path = NA,
+ obs_set_paths = NA,
+ obs_set_names = NA,
+ obs_locations_path = NA,
+ obs_segmentations_path = NA,
+ obs_embedding_paths = NA,
+ obs_embedding_names = NA,
+ obs_embedding_dims = NA,
+ request_init = NA,
+ feature_labels_path = NA,
+ coordination_values = NA,
+ obs_labels_paths = NA,
+ obs_labels_names = NA,
+ ...
+)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{adata_path}}{The path to a local Zarr store.}
+
+\item{\code{adata_url}}{The URL to a remote Zarr store.}
+
+\item{\code{obs_feature_matrix_path}}{The path to the observation-by-feature matrix within the Zarr store.}
+
+\item{\code{feature_filter_path}}{The path to the a column of adata.var within the Zarr store. Use this if obs_feature_matrix_path points to a subset of adata.X (relative to the full adata.var).}
+
+\item{\code{initial_feature_filter_path}}{The path to the a column of adata.var within the Zarr store. Use this to load a subset of the matrix at obs_feature_matrix_path initially.}
+
+\item{\code{obs_set_paths}}{A list of paths to the observation sets within the Zarr store.}
+
+\item{\code{obs_set_names}}{A list of names for the observation sets.}
+
+\item{\code{obs_locations_path}}{The path to the observation locations within the Zarr store.}
+
+\item{\code{obs_segmentations_path}}{The path to the observation segmentations within the Zarr store.}
+
+\item{\code{obs_embedding_paths}}{A list of paths to the observation embeddings within the Zarr store.}
+
+\item{\code{obs_embedding_names}}{A list of names for the observation embeddings.}
+
+\item{\code{obs_embedding_dims}}{A list of dimensions for the observation embeddings.}
+
+\item{\code{request_init}}{A list of requestInit options for the Zarr store.}
+
+\item{\code{feature_labels_path}}{The path to the feature labels within the Zarr store.}
+
+\item{\code{coordination_values}}{A list of coordination values for the file definition.}
+
+\item{\code{obs_labels_paths}}{A list of paths to the observation labels within the Zarr store.}
+
+\item{\code{obs_labels_names}}{A list of names for the observation labels.}
+
+\item{\code{...}}{Parameters inherited from \code{AbstractWrapper}.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A new \code{AnnDataWrapper} object.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AnnDataWrapper-convert_and_save}{}}}
+\subsection{Method \code{convert_and_save()}}{
+Create the JSON output files, web server routes, and file definition creators.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AnnDataWrapper$convert_and_save(dataset_uid, obj_i, base_dir = NA)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+
+\item{\code{base_dir}}{A base directory for local data.}
+}
+\if{html}{\out{
}}
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AnnDataWrapper-make_routes}{}}}
+\subsection{Method \code{make_routes()}}{
+Get a list of server route objects.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AnnDataWrapper$make_routes(dataset_uid, obj_i)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+}
+\if{html}{\out{
}}
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AnnDataWrapper-get_zarr_url}{}}}
+\subsection{Method \code{get_zarr_url()}}{
+Get the URL to the Zarr store, to fill in the file URL in the file definitions.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AnnDataWrapper$get_zarr_url(base_url, dataset_uid, obj_i)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{base_url}}{The base URL, on which the route will be served.}
+
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A URL as a string.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AnnDataWrapper-make_file_def_creator}{}}}
+\subsection{Method \code{make_file_def_creator()}}{
+Make the file definition creator function for the cells data type.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AnnDataWrapper$make_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A file definition creator function which takes a \code{base_url} parameter.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-AnnDataWrapper-clone}{}}}
+\subsection{Method \code{clone()}}{
+The objects of this class are cloneable with this method.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{AnnDataWrapper$clone(deep = FALSE)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{deep}}{Whether to make a deep clone.}
+}
+\if{html}{\out{
}}
+}
+}
+}
diff --git a/man/Component.Rd b/man/Component.Rd
index 36ce25e..2b6f396 100644
--- a/man/Component.Rd
+++ b/man/Component.Rd
@@ -5,7 +5,7 @@
\alias{Component}
\title{Enumeration of Component values}
\format{
-An object of class \code{list} of length 10.
+An object of class \code{list} of length 12.
}
\usage{
Component
@@ -26,7 +26,7 @@ valid string constant values representing components.
}
}
\examples{
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
diff --git a/man/CoordinationType.Rd b/man/CoordinationType.Rd
index 9c87d9a..bc6716b 100644
--- a/man/CoordinationType.Rd
+++ b/man/CoordinationType.Rd
@@ -5,7 +5,7 @@
\alias{CoordinationType}
\title{Enumeration of Coordination Type values}
\format{
-An object of class \code{list} of length 32.
+An object of class \code{list} of length 35.
}
\usage{
CoordinationType
@@ -50,7 +50,7 @@ in the coordination space.
}
}
\examples{
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ref_dataset <- vc$add_dataset("Reference")
qry_dataset <- vc$add_dataset("Query")
ref_plot <- vc$add_view(ref_dataset, Component$SCATTERPLOT, mapping = "umap")
diff --git a/man/CsvWrapper.Rd b/man/CsvWrapper.Rd
new file mode 100644
index 0000000..d28c90f
--- /dev/null
+++ b/man/CsvWrapper.Rd
@@ -0,0 +1,208 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/wrappers_csv.R
+\docType{class}
+\name{CsvWrapper}
+\alias{CsvWrapper}
+\title{CsvWrapper Class}
+\description{
+Class representing a CSV file in a Vitessce dataset.
+}
+\details{
+CSV file wrapper class
+}
+\keyword{internal}
+\section{Super class}{
+\code{\link[vitessceR:AbstractWrapper]{vitessceR::AbstractWrapper}} -> \code{CsvWrapper}
+}
+\section{Public fields}{
+\if{html}{\out{}}
+\describe{
+\item{\code{csv_path}}{The object to wrap.}
+
+\item{\code{csv_url}}{The object to wrap.}
+
+\item{\code{local_csv_uid}}{The path to the local zarr store.}
+
+\item{\code{data_type}}{The Vitessce data type for this file.}
+
+\item{\code{options}}{A list of options to pass to the Vitessce file definition.}
+
+\item{\code{coordination_values}}{A list of coordination values to pass to the Vitessce file definition.}
+
+\item{\code{request_init}}{A list of requestInit values to pass to fetch when loading the CSV over HTTP.}
+}
+\if{html}{\out{
}}
+}
+\section{Methods}{
+\subsection{Public methods}{
+\itemize{
+\item \href{#method-CsvWrapper-new}{\code{CsvWrapper$new()}}
+\item \href{#method-CsvWrapper-convert_and_save}{\code{CsvWrapper$convert_and_save()}}
+\item \href{#method-CsvWrapper-make_routes}{\code{CsvWrapper$make_routes()}}
+\item \href{#method-CsvWrapper-get_csv_url}{\code{CsvWrapper$get_csv_url()}}
+\item \href{#method-CsvWrapper-make_file_def_creator}{\code{CsvWrapper$make_file_def_creator()}}
+\item \href{#method-CsvWrapper-clone}{\code{CsvWrapper$clone()}}
+}
+}
+\if{html}{\out{
+Inherited methods
+
+
+}}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-CsvWrapper-new}{}}}
+\subsection{Method \code{new()}}{
+Create a wrapper around a CSV file.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{CsvWrapper$new(
+ csv_path = NA,
+ csv_url = NA,
+ data_type = NA,
+ options = NA,
+ coordination_values = NA,
+ request_init = NA,
+ ...
+)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{csv_path}}{The path to a local CSV file.}
+
+\item{\code{csv_url}}{The URL to a remote CSV file.}
+
+\item{\code{data_type}}{The Vitessce data type for this file.}
+
+\item{\code{options}}{A list of options to pass to the Vitessce file definition.}
+
+\item{\code{coordination_values}}{A list of coordination values to pass to the Vitessce file definition.}
+
+\item{\code{request_init}}{A list of requestInit values to pass to fetch when loading the CSV over HTTP.}
+
+\item{\code{...}}{Parameters inherited from \code{AbstractWrapper}.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A new \code{CsvWrapper} object.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-CsvWrapper-convert_and_save}{}}}
+\subsection{Method \code{convert_and_save()}}{
+Create the JSON output files, web server routes, and file definition creators.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{CsvWrapper$convert_and_save(dataset_uid, obj_i, base_dir = NA)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+
+\item{\code{base_dir}}{A base directory for local data.}
+}
+\if{html}{\out{
}}
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-CsvWrapper-make_routes}{}}}
+\subsection{Method \code{make_routes()}}{
+Get a list of server route objects.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{CsvWrapper$make_routes(dataset_uid, obj_i)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+}
+\if{html}{\out{
}}
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-CsvWrapper-get_csv_url}{}}}
+\subsection{Method \code{get_csv_url()}}{
+Get the URL to the Zarr store, to fill in the file URL in the file definitions.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{CsvWrapper$get_csv_url(base_url, dataset_uid, obj_i)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{base_url}}{The base URL, on which the route will be served.}
+
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A URL as a string.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-CsvWrapper-make_file_def_creator}{}}}
+\subsection{Method \code{make_file_def_creator()}}{
+Make the file definition creator function for the cells data type.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{CsvWrapper$make_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{dataset_uid}}{The ID for this dataset.}
+
+\item{\code{obj_i}}{The index of this data object within the dataset.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A file definition creator function which takes a \code{base_url} parameter.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-CsvWrapper-clone}{}}}
+\subsection{Method \code{clone()}}{
+The objects of this class are cloneable with this method.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{CsvWrapper$clone(deep = FALSE)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{deep}}{Whether to make a deep clone.}
+}
+\if{html}{\out{
}}
+}
+}
+}
diff --git a/man/DataType.Rd b/man/DataType.Rd
index a5be5e9..0e94a6b 100644
--- a/man/DataType.Rd
+++ b/man/DataType.Rd
@@ -25,7 +25,7 @@ for dataset files.
}
\examples{
base_url <- "http://localhost:8000/"
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_file(
url = paste0(base_url, "cells.json"),
data_type = DataType$CELLS,
diff --git a/man/FileType.Rd b/man/FileType.Rd
index 54a0641..1989981 100644
--- a/man/FileType.Rd
+++ b/man/FileType.Rd
@@ -5,7 +5,7 @@
\alias{FileType}
\title{Enumeration of File Type values}
\format{
-An object of class \code{list} of length 11.
+An object of class \code{list} of length 12.
}
\usage{
FileType
@@ -26,10 +26,9 @@ for dataset files.
}
\examples{
base_url <- "http://localhost:8000/"
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_file(
url = paste0(base_url, "cells.json"),
- data_type = DataType$CELLS,
file_type = FileType$CELLS_JSON
)
}
diff --git a/man/GiottoWrapper.Rd b/man/GiottoWrapper.Rd
deleted file mode 100644
index 126c0b7..0000000
--- a/man/GiottoWrapper.Rd
+++ /dev/null
@@ -1,290 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/wrappers_giotto.R
-\docType{class}
-\name{GiottoWrapper}
-\alias{GiottoWrapper}
-\title{GiottoWrapper Class}
-\description{
-Class representing a local Giotto object in a Vitessce dataset.
-}
-\details{
-Giotto object wrapper class
-}
-\examples{
-obj <- get_giotto_obj()
-w <- GiottoWrapper$new(
- obj,
- cell_embeddings = c("pca"),
- cell_embedding_names = c("PCA")
-)
-}
-\keyword{internal}
-\section{Super class}{
-\code{\link[vitessceR:AbstractWrapper]{vitessceR::AbstractWrapper}} -> \code{GiottoWrapper}
-}
-\section{Public fields}{
-\if{html}{\out{}}
-\describe{
-\item{\code{obj}}{The object to wrap.}
-
-\item{\code{cell_embeddings}}{The keys in the Seurat object's reductions/cell.embeddings
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_embedding_names}}{Names
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_embedding_dims}}{The dimension indices
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_set_metas}}{The keys in the Seurat object's meta.data
-to use for creating cell sets.}
-
-\item{\code{cell_set_meta_names}}{The keys in the Seurat object's meta.data
-to use for cell set names mapped to new names.}
-
-\item{\code{cell_set_meta_scores}}{The keys in the Seurat object's meta.data
-to use for cell set names mapped to keys for scores.}
-
-\item{\code{zarr_folder}}{The name for the folder at the root of the zarr store.}
-}
-\if{html}{\out{
}}
-}
-\section{Methods}{
-\subsection{Public methods}{
-\itemize{
-\item \href{#method-GiottoWrapper-new}{\code{GiottoWrapper$new()}}
-\item \href{#method-GiottoWrapper-check_obj}{\code{GiottoWrapper$check_obj()}}
-\item \href{#method-GiottoWrapper-get_zarr_path}{\code{GiottoWrapper$get_zarr_path()}}
-\item \href{#method-GiottoWrapper-get_zarr_url}{\code{GiottoWrapper$get_zarr_url()}}
-\item \href{#method-GiottoWrapper-convert_and_save}{\code{GiottoWrapper$convert_and_save()}}
-\item \href{#method-GiottoWrapper-make_cells_file_def_creator}{\code{GiottoWrapper$make_cells_file_def_creator()}}
-\item \href{#method-GiottoWrapper-make_cell_sets_file_def_creator}{\code{GiottoWrapper$make_cell_sets_file_def_creator()}}
-\item \href{#method-GiottoWrapper-make_expression_matrix_file_def_creator}{\code{GiottoWrapper$make_expression_matrix_file_def_creator()}}
-\item \href{#method-GiottoWrapper-clone}{\code{GiottoWrapper$clone()}}
-}
-}
-\if{html}{\out{
-Inherited methods
-
-
-}}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-new}{}}}
-\subsection{Method \code{new()}}{
-Create a wrapper around a Seurat object.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$new(
- obj,
- cell_embeddings = NA,
- cell_embedding_names = NA,
- cell_embedding_dims = NA,
- cell_set_metas = NA,
- cell_set_meta_names = NA,
- cell_set_meta_scores = NA,
- ...
-)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{obj}}{The object to wrap.}
-
-\item{\code{cell_embeddings}}{The keys in the Seurat object's reductions/cell.embeddings
-to use for creating dimensionality reduction plots.}
-
-\item{\code{cell_embedding_names}}{Names
-to use for creating dimensionality reduction plots.}
-
-\item{\code{cell_embedding_dims}}{An array of dimension indices to use for each cell_embedding.}
-
-\item{\code{cell_set_metas}}{An optional list of keys in the object's meta.data
-list to use for creating cell sets.}
-
-\item{\code{cell_set_meta_names}}{If cell_set_metas is provided, this list can
-also be provided to set new names to replace
-the keys in the interface.}
-
-\item{\code{cell_set_meta_scores}}{If cell_set_metas is provided, this list can
-also be provided to map between meta.data keys for set annotations
-and keys for annotation scores.}
-
-\item{\code{...}}{Parameters inherited from \code{AbstractWrapper}.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A new \code{GiottoWrapper} object.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-check_obj}{}}}
-\subsection{Method \code{check_obj()}}{
-Check that the object is valid
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$check_obj()}\if{html}{\out{
}}
-}
-
-\subsection{Returns}{
-Success or failure.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-get_zarr_path}{}}}
-\subsection{Method \code{get_zarr_path()}}{
-Get the path to the zarr store, relative to the current directory.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$get_zarr_path(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A path as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-get_zarr_url}{}}}
-\subsection{Method \code{get_zarr_url()}}{
-Get the URL to the Zarr store, to fill in the file URL in the file definitions.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$get_zarr_url(base_url, dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{base_url}}{The base URL, on which the route will be served.}
-
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A URL as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-convert_and_save}{}}}
-\subsection{Method \code{convert_and_save()}}{
-Create the JSON output files, web server routes, and file definition creators.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$convert_and_save(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-make_cells_file_def_creator}{}}}
-\subsection{Method \code{make_cells_file_def_creator()}}{
-Make the file definition creator function for the cells data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$make_cells_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-make_cell_sets_file_def_creator}{}}}
-\subsection{Method \code{make_cell_sets_file_def_creator()}}{
-Make the file definition creator function for the cell sets data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$make_cell_sets_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-make_expression_matrix_file_def_creator}{}}}
-\subsection{Method \code{make_expression_matrix_file_def_creator()}}{
-Make the file definition creator function for the expression matrix data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$make_expression_matrix_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-GiottoWrapper-clone}{}}}
-\subsection{Method \code{clone()}}{
-The objects of this class are cloneable with this method.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{GiottoWrapper$clone(deep = FALSE)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{deep}}{Whether to make a deep clone.}
-}
-\if{html}{\out{
}}
-}
-}
-}
diff --git a/man/MultiImageWrapper.Rd b/man/MultiImageWrapper.Rd
index da656a0..c39b129 100644
--- a/man/MultiImageWrapper.Rd
+++ b/man/MultiImageWrapper.Rd
@@ -38,11 +38,16 @@ Image wrapper class
}}
diff --git a/man/OmeTiffWrapper.Rd b/man/OmeTiffWrapper.Rd
index dbd410f..fbf71ce 100644
--- a/man/OmeTiffWrapper.Rd
+++ b/man/OmeTiffWrapper.Rd
@@ -40,6 +40,8 @@ this image (see http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-ma
\item \href{#method-OmeTiffWrapper-make_raster_routes}{\code{OmeTiffWrapper$make_raster_routes()}}
\item \href{#method-OmeTiffWrapper-make_image_def}{\code{OmeTiffWrapper$make_image_def()}}
\item \href{#method-OmeTiffWrapper-make_raster_file_def_creator}{\code{OmeTiffWrapper$make_raster_file_def_creator()}}
+\item \href{#method-OmeTiffWrapper-create_image_json}{\code{OmeTiffWrapper$create_image_json()}}
+\item \href{#method-OmeTiffWrapper-get_img_url}{\code{OmeTiffWrapper$get_img_url()}}
\item \href{#method-OmeTiffWrapper-clone}{\code{OmeTiffWrapper$clone()}}
}
}
@@ -48,11 +50,16 @@ this image (see http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-ma
}}
@@ -102,7 +109,7 @@ A new \code{OmeTiffWrapper} object.
\subsection{Method \code{convert_and_save()}}{
Create the web server routes and file definition creators.
\subsection{Usage}{
-\if{html}{\out{}}\preformatted{OmeTiffWrapper$convert_and_save(dataset_uid, obj_i)}\if{html}{\out{
}}
+\if{html}{\out{}}\preformatted{OmeTiffWrapper$convert_and_save(dataset_uid, obj_i, base_dir = NA)}\if{html}{\out{
}}
}
\subsection{Arguments}{
@@ -182,6 +189,24 @@ Make the file definition creator function for the raster data type.
\subsection{Returns}{
A file definition creator function which takes a \code{base_url} parameter.
}
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-OmeTiffWrapper-create_image_json}{}}}
+\subsection{Method \code{create_image_json()}}{
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{OmeTiffWrapper$create_image_json(img_url, offsets_url = NA)}\if{html}{\out{
}}
+}
+
+}
+\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-OmeTiffWrapper-get_img_url}{}}}
+\subsection{Method \code{get_img_url()}}{
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{OmeTiffWrapper$get_img_url(base_url = "", dataset_uid = "", obj_i = "")}\if{html}{\out{
}}
+}
+
}
\if{html}{\out{
}}
\if{html}{\out{}}
diff --git a/man/SCEWrapper.Rd b/man/SCEWrapper.Rd
deleted file mode 100644
index 51d607a..0000000
--- a/man/SCEWrapper.Rd
+++ /dev/null
@@ -1,290 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/wrappers_sce.R
-\docType{class}
-\name{SCEWrapper}
-\alias{SCEWrapper}
-\title{SCEWrapper Class}
-\description{
-Class representing a local SingleCellExperiment object in a Vitessce dataset.
-}
-\details{
-SingleCellExperiment object wrapper class
-}
-\examples{
-obj <- get_sce_obj()
-w <- SCEWrapper$new(
- obj,
- cell_embeddings = c("pca"),
- cell_embedding_names = c("PCA")
-)
-}
-\keyword{internal}
-\section{Super class}{
-\code{\link[vitessceR:AbstractWrapper]{vitessceR::AbstractWrapper}} -> \code{SCEWrapper}
-}
-\section{Public fields}{
-\if{html}{\out{}}
-\describe{
-\item{\code{obj}}{The object to wrap.}
-
-\item{\code{cell_embeddings}}{The keys in the Seurat object's reductions/cell.embeddings
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_embedding_names}}{Names
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_embedding_dims}}{The dimension indices
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_set_metas}}{The keys in the Seurat object's meta.data
-to use for creating cell sets.}
-
-\item{\code{cell_set_meta_names}}{The keys in the Seurat object's meta.data
-to use for cell set names mapped to new names.}
-
-\item{\code{cell_set_meta_scores}}{The keys in the Seurat object's meta.data
-to use for cell set names mapped to keys for scores.}
-
-\item{\code{zarr_folder}}{The name for the folder at the root of the zarr store.}
-}
-\if{html}{\out{
}}
-}
-\section{Methods}{
-\subsection{Public methods}{
-\itemize{
-\item \href{#method-SCEWrapper-new}{\code{SCEWrapper$new()}}
-\item \href{#method-SCEWrapper-check_obj}{\code{SCEWrapper$check_obj()}}
-\item \href{#method-SCEWrapper-get_zarr_path}{\code{SCEWrapper$get_zarr_path()}}
-\item \href{#method-SCEWrapper-get_zarr_url}{\code{SCEWrapper$get_zarr_url()}}
-\item \href{#method-SCEWrapper-convert_and_save}{\code{SCEWrapper$convert_and_save()}}
-\item \href{#method-SCEWrapper-make_cells_file_def_creator}{\code{SCEWrapper$make_cells_file_def_creator()}}
-\item \href{#method-SCEWrapper-make_cell_sets_file_def_creator}{\code{SCEWrapper$make_cell_sets_file_def_creator()}}
-\item \href{#method-SCEWrapper-make_expression_matrix_file_def_creator}{\code{SCEWrapper$make_expression_matrix_file_def_creator()}}
-\item \href{#method-SCEWrapper-clone}{\code{SCEWrapper$clone()}}
-}
-}
-\if{html}{\out{
-Inherited methods
-
-
-}}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-new}{}}}
-\subsection{Method \code{new()}}{
-Create a wrapper around a Seurat object.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$new(
- obj,
- cell_embeddings = NA,
- cell_embedding_names = NA,
- cell_embedding_dims = NA,
- cell_set_metas = NA,
- cell_set_meta_names = NA,
- cell_set_meta_scores = NA,
- ...
-)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{obj}}{The object to wrap.}
-
-\item{\code{cell_embeddings}}{The keys in the Seurat object's reductions/cell.embeddings
-to use for creating dimensionality reduction plots.}
-
-\item{\code{cell_embedding_names}}{Names
-to use for creating dimensionality reduction plots.}
-
-\item{\code{cell_embedding_dims}}{An array of dimension indices to use for each cell_embedding.}
-
-\item{\code{cell_set_metas}}{An optional list of keys in the object's meta.data
-list to use for creating cell sets.}
-
-\item{\code{cell_set_meta_names}}{If cell_set_metas is provided, this list can
-also be provided to set new names to replace
-the keys in the interface.}
-
-\item{\code{cell_set_meta_scores}}{If cell_set_metas is provided, this list can
-also be provided to map between meta.data keys for set annotations
-and keys for annotation scores.}
-
-\item{\code{...}}{Parameters inherited from \code{AbstractWrapper}.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A new \code{SCEWrapper} object.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-check_obj}{}}}
-\subsection{Method \code{check_obj()}}{
-Check that the object is valid
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$check_obj()}\if{html}{\out{
}}
-}
-
-\subsection{Returns}{
-Success or failure.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-get_zarr_path}{}}}
-\subsection{Method \code{get_zarr_path()}}{
-Get the path to the zarr store, relative to the current directory.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$get_zarr_path(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A path as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-get_zarr_url}{}}}
-\subsection{Method \code{get_zarr_url()}}{
-Get the URL to the Zarr store, to fill in the file URL in the file definitions.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$get_zarr_url(base_url, dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{base_url}}{The base URL, on which the route will be served.}
-
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A URL as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-convert_and_save}{}}}
-\subsection{Method \code{convert_and_save()}}{
-Create the JSON output files, web server routes, and file definition creators.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$convert_and_save(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-make_cells_file_def_creator}{}}}
-\subsection{Method \code{make_cells_file_def_creator()}}{
-Make the file definition creator function for the cells data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$make_cells_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-make_cell_sets_file_def_creator}{}}}
-\subsection{Method \code{make_cell_sets_file_def_creator()}}{
-Make the file definition creator function for the cell sets data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$make_cell_sets_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-make_expression_matrix_file_def_creator}{}}}
-\subsection{Method \code{make_expression_matrix_file_def_creator()}}{
-Make the file definition creator function for the expression matrix data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$make_expression_matrix_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SCEWrapper-clone}{}}}
-\subsection{Method \code{clone()}}{
-The objects of this class are cloneable with this method.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SCEWrapper$clone(deep = FALSE)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{deep}}{Whether to make a deep clone.}
-}
-\if{html}{\out{
}}
-}
-}
-}
diff --git a/man/SPEWrapper.Rd b/man/SPEWrapper.Rd
deleted file mode 100644
index cdd97d1..0000000
--- a/man/SPEWrapper.Rd
+++ /dev/null
@@ -1,373 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/wrappers_spe.R
-\docType{class}
-\name{SPEWrapper}
-\alias{SPEWrapper}
-\title{SPEWrapper Class}
-\description{
-Class representing a local SpatialExperiment object in a Vitessce dataset.
-}
-\details{
-SpatialExperiment object wrapper class
-}
-\examples{
-obj <- get_spe_obj()
-w <- SPEWrapper$new(
- obj,
- sample_id = "sample1",
- image_id = "image1"
-)
-}
-\keyword{internal}
-\section{Super class}{
-\code{\link[vitessceR:AbstractWrapper]{vitessceR::AbstractWrapper}} -> \code{SPEWrapper}
-}
-\section{Public fields}{
-\if{html}{\out{}}
-\describe{
-\item{\code{obj}}{The object to wrap.}
-
-\item{\code{img_sample_id}}{The sample_id for the image of interest.}
-
-\item{\code{img_image_id}}{The image_id for the image of interest.}
-
-\item{\code{cell_embeddings}}{The keys in the Seurat object's reductions/cell.embeddings
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_embedding_names}}{Names
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_embedding_dims}}{The dimension indices
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_set_metas}}{The keys in the Seurat object's meta.data
-to use for creating cell sets.}
-
-\item{\code{cell_set_meta_names}}{The keys in the Seurat object's meta.data
-to use for cell set names mapped to new names.}
-
-\item{\code{cell_set_meta_scores}}{The keys in the Seurat object's meta.data
-to use for cell set names mapped to keys for scores.}
-
-\item{\code{zarr_folder}}{The name for the folder at the root of the zarr store.}
-
-\item{\code{img_filename}}{The name for the folder at the root of the zarr store for the image.}
-}
-\if{html}{\out{
}}
-}
-\section{Methods}{
-\subsection{Public methods}{
-\itemize{
-\item \href{#method-SPEWrapper-new}{\code{SPEWrapper$new()}}
-\item \href{#method-SPEWrapper-check_obj}{\code{SPEWrapper$check_obj()}}
-\item \href{#method-SPEWrapper-get_zarr_path}{\code{SPEWrapper$get_zarr_path()}}
-\item \href{#method-SPEWrapper-get_zarr_url}{\code{SPEWrapper$get_zarr_url()}}
-\item \href{#method-SPEWrapper-get_img_path}{\code{SPEWrapper$get_img_path()}}
-\item \href{#method-SPEWrapper-get_img_url}{\code{SPEWrapper$get_img_url()}}
-\item \href{#method-SPEWrapper-convert_and_save}{\code{SPEWrapper$convert_and_save()}}
-\item \href{#method-SPEWrapper-make_cells_file_def_creator}{\code{SPEWrapper$make_cells_file_def_creator()}}
-\item \href{#method-SPEWrapper-make_cell_sets_file_def_creator}{\code{SPEWrapper$make_cell_sets_file_def_creator()}}
-\item \href{#method-SPEWrapper-make_expression_matrix_file_def_creator}{\code{SPEWrapper$make_expression_matrix_file_def_creator()}}
-\item \href{#method-SPEWrapper-make_raster_file_def_creator}{\code{SPEWrapper$make_raster_file_def_creator()}}
-\item \href{#method-SPEWrapper-clone}{\code{SPEWrapper$clone()}}
-}
-}
-\if{html}{\out{
-Inherited methods
-
-
-}}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-new}{}}}
-\subsection{Method \code{new()}}{
-Create a wrapper around a Seurat object.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$new(
- obj,
- sample_id = NA,
- image_id = NA,
- cell_embeddings = NA,
- cell_embedding_names = NA,
- cell_embedding_dims = NA,
- cell_set_metas = NA,
- cell_set_meta_names = NA,
- cell_set_meta_scores = NA,
- ...
-)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{obj}}{The object to wrap.}
-
-\item{\code{sample_id}}{The sample_id for the image of interest.}
-
-\item{\code{image_id}}{The image_id for the image of interest.}
-
-\item{\code{cell_embeddings}}{The keys in the Seurat object's reductions/cell.embeddings
-to use for creating dimensionality reduction plots.}
-
-\item{\code{cell_embedding_names}}{Names
-to use for creating dimensionality reduction plots.}
-
-\item{\code{cell_embedding_dims}}{An array of dimension indices to use for each cell_embedding.}
-
-\item{\code{cell_set_metas}}{An optional list of keys in the object's meta.data
-list to use for creating cell sets.}
-
-\item{\code{cell_set_meta_names}}{If cell_set_metas is provided, this list can
-also be provided to set new names to replace
-the keys in the interface.}
-
-\item{\code{cell_set_meta_scores}}{If cell_set_metas is provided, this list can
-also be provided to map between meta.data keys for set annotations
-and keys for annotation scores.}
-
-\item{\code{...}}{Parameters inherited from \code{AbstractWrapper}.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A new \code{SPEWrapper} object.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-check_obj}{}}}
-\subsection{Method \code{check_obj()}}{
-Check that the object is valid
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$check_obj()}\if{html}{\out{
}}
-}
-
-\subsection{Returns}{
-Success or failure.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-get_zarr_path}{}}}
-\subsection{Method \code{get_zarr_path()}}{
-Get the path to the zarr store, relative to the current directory.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$get_zarr_path(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A path as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-get_zarr_url}{}}}
-\subsection{Method \code{get_zarr_url()}}{
-Get the URL to the Zarr store, to fill in the file URL in the file definitions.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$get_zarr_url(base_url, dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{base_url}}{The base URL, on which the route will be served.}
-
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A URL as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-get_img_path}{}}}
-\subsection{Method \code{get_img_path()}}{
-Get the path to the image Zarr store, relative to the current directory.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$get_img_path(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A path as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-get_img_url}{}}}
-\subsection{Method \code{get_img_url()}}{
-Get the URL to the image Zarr store, to fill in the file URL in the file definitions.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$get_img_url(base_url, dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{base_url}}{The base URL, on which the route will be served.}
-
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A URL as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-convert_and_save}{}}}
-\subsection{Method \code{convert_and_save()}}{
-Create the JSON output files, web server routes, and file definition creators.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$convert_and_save(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-make_cells_file_def_creator}{}}}
-\subsection{Method \code{make_cells_file_def_creator()}}{
-Make the file definition creator function for the cells data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$make_cells_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-make_cell_sets_file_def_creator}{}}}
-\subsection{Method \code{make_cell_sets_file_def_creator()}}{
-Make the file definition creator function for the cell sets data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$make_cell_sets_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-make_expression_matrix_file_def_creator}{}}}
-\subsection{Method \code{make_expression_matrix_file_def_creator()}}{
-Make the file definition creator function for the expression matrix data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$make_expression_matrix_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-make_raster_file_def_creator}{}}}
-\subsection{Method \code{make_raster_file_def_creator()}}{
-Make the file definition creator function for the raster data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$make_raster_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SPEWrapper-clone}{}}}
-\subsection{Method \code{clone()}}{
-The objects of this class are cloneable with this method.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SPEWrapper$clone(deep = FALSE)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{deep}}{Whether to make a deep clone.}
-}
-\if{html}{\out{
}}
-}
-}
-}
diff --git a/man/SeuratWrapper.Rd b/man/SeuratWrapper.Rd
deleted file mode 100644
index 5b928ad..0000000
--- a/man/SeuratWrapper.Rd
+++ /dev/null
@@ -1,295 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/wrappers_seurat.R
-\docType{class}
-\name{SeuratWrapper}
-\alias{SeuratWrapper}
-\title{SeuratWrapper Class}
-\description{
-Class representing a local Seurat object in a Vitessce dataset.
-}
-\details{
-Seurat object wrapper class
-}
-\examples{
-obj <- get_seurat_obj()
-w <- SeuratWrapper$new(
- obj,
- cell_embeddings = c("pca"),
- cell_embedding_names = c("PCA")
-)
-}
-\keyword{internal}
-\section{Super class}{
-\code{\link[vitessceR:AbstractWrapper]{vitessceR::AbstractWrapper}} -> \code{SeuratWrapper}
-}
-\section{Public fields}{
-\if{html}{\out{}}
-\describe{
-\item{\code{obj}}{The object to wrap.}
-
-\item{\code{assay}}{The assay name in the Seurat object.}
-
-\item{\code{cell_embeddings}}{The keys in the Seurat object's reductions/cell.embeddings
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_embedding_names}}{Names
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_embedding_dims}}{The dimension indices
-to use for creating dimensionality reduction mappings.}
-
-\item{\code{cell_set_metas}}{The keys in the Seurat object's meta.data
-to use for creating cell sets.}
-
-\item{\code{cell_set_meta_names}}{The keys in the Seurat object's meta.data
-to use for cell set names mapped to new names.}
-
-\item{\code{cell_set_meta_scores}}{The keys in the Seurat object's meta.data
-to use for cell set names mapped to keys for scores.}
-
-\item{\code{zarr_folder}}{The name for the folder at the root of the zarr store.}
-}
-\if{html}{\out{
}}
-}
-\section{Methods}{
-\subsection{Public methods}{
-\itemize{
-\item \href{#method-SeuratWrapper-new}{\code{SeuratWrapper$new()}}
-\item \href{#method-SeuratWrapper-check_obj}{\code{SeuratWrapper$check_obj()}}
-\item \href{#method-SeuratWrapper-get_zarr_path}{\code{SeuratWrapper$get_zarr_path()}}
-\item \href{#method-SeuratWrapper-get_zarr_url}{\code{SeuratWrapper$get_zarr_url()}}
-\item \href{#method-SeuratWrapper-convert_and_save}{\code{SeuratWrapper$convert_and_save()}}
-\item \href{#method-SeuratWrapper-make_cells_file_def_creator}{\code{SeuratWrapper$make_cells_file_def_creator()}}
-\item \href{#method-SeuratWrapper-make_cell_sets_file_def_creator}{\code{SeuratWrapper$make_cell_sets_file_def_creator()}}
-\item \href{#method-SeuratWrapper-make_expression_matrix_file_def_creator}{\code{SeuratWrapper$make_expression_matrix_file_def_creator()}}
-\item \href{#method-SeuratWrapper-clone}{\code{SeuratWrapper$clone()}}
-}
-}
-\if{html}{\out{
-Inherited methods
-
-
-}}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-new}{}}}
-\subsection{Method \code{new()}}{
-Create a wrapper around a Seurat object.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$new(
- obj,
- assay = NA,
- cell_embeddings = NA,
- cell_embedding_names = NA,
- cell_embedding_dims = NA,
- cell_set_metas = NA,
- cell_set_meta_names = NA,
- cell_set_meta_scores = NA,
- ...
-)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{obj}}{The object to wrap.}
-
-\item{\code{assay}}{The assay name under the assays part of the Seurat object.}
-
-\item{\code{cell_embeddings}}{The keys in the Seurat object's reductions/cell.embeddings
-to use for creating dimensionality reduction plots.}
-
-\item{\code{cell_embedding_names}}{Names
-to use for creating dimensionality reduction plots.}
-
-\item{\code{cell_embedding_dims}}{An array of dimension indices to use for each cell_embedding.}
-
-\item{\code{cell_set_metas}}{An optional list of keys in the object's meta.data
-list to use for creating cell sets.}
-
-\item{\code{cell_set_meta_names}}{If cell_set_metas is provided, this list can
-also be provided to set new names to replace
-the keys in the interface.}
-
-\item{\code{cell_set_meta_scores}}{If cell_set_metas is provided, this list can
-also be provided to map between meta.data keys for set annotations
-and keys for annotation scores.}
-
-\item{\code{...}}{Parameters inherited from \code{AbstractWrapper}.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A new \code{SeuratWrapper} object.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-check_obj}{}}}
-\subsection{Method \code{check_obj()}}{
-Check that the object is valid
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$check_obj()}\if{html}{\out{
}}
-}
-
-\subsection{Returns}{
-Success or failure.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-get_zarr_path}{}}}
-\subsection{Method \code{get_zarr_path()}}{
-Get the path to the zarr store, relative to the current directory.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$get_zarr_path(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A path as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-get_zarr_url}{}}}
-\subsection{Method \code{get_zarr_url()}}{
-Get the URL to the Zarr store, to fill in the file URL in the file definitions.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$get_zarr_url(base_url, dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{base_url}}{The base URL, on which the route will be served.}
-
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A URL as a string.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-convert_and_save}{}}}
-\subsection{Method \code{convert_and_save()}}{
-Create the JSON output files, web server routes, and file definition creators.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$convert_and_save(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-make_cells_file_def_creator}{}}}
-\subsection{Method \code{make_cells_file_def_creator()}}{
-Make the file definition creator function for the cells data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$make_cells_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-make_cell_sets_file_def_creator}{}}}
-\subsection{Method \code{make_cell_sets_file_def_creator()}}{
-Make the file definition creator function for the cell sets data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$make_cell_sets_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-make_expression_matrix_file_def_creator}{}}}
-\subsection{Method \code{make_expression_matrix_file_def_creator()}}{
-Make the file definition creator function for the expression matrix data type.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$make_expression_matrix_file_def_creator(dataset_uid, obj_i)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{dataset_uid}}{The ID for this dataset.}
-
-\item{\code{obj_i}}{The index of this data object within the dataset.}
-}
-\if{html}{\out{
}}
-}
-\subsection{Returns}{
-A file definition creator function which takes a \code{base_url} parameter.
-}
-}
-\if{html}{\out{
}}
-\if{html}{\out{}}
-\if{latex}{\out{\hypertarget{method-SeuratWrapper-clone}{}}}
-\subsection{Method \code{clone()}}{
-The objects of this class are cloneable with this method.
-\subsection{Usage}{
-\if{html}{\out{}}\preformatted{SeuratWrapper$clone(deep = FALSE)}\if{html}{\out{
}}
-}
-
-\subsection{Arguments}{
-\if{html}{\out{}}
-\describe{
-\item{\code{deep}}{Whether to make a deep clone.}
-}
-\if{html}{\out{
}}
-}
-}
-}
diff --git a/man/VitessceConfig-cash-from_list.Rd b/man/VitessceConfig-cash-from_list.Rd
index 75589fe..5946f84 100644
--- a/man/VitessceConfig-cash-from_list.Rd
+++ b/man/VitessceConfig-cash-from_list.Rd
@@ -2,9 +2,7 @@
% Please edit documentation in R/config.R
\name{VitessceConfig$from_list}
\alias{VitessceConfig$from_list}
-\title{Create a new Vitessce Config from a list
-
-A helper function to construct a new \code{VitessceConfig} object based on an existing config in a list format.}
+\title{Create a new Vitessce Config from a list}
\arguments{
\item{config}{A list containing a valid config.}
}
@@ -12,7 +10,5 @@ A helper function to construct a new \code{VitessceConfig} object based on an ex
A \code{VitessceConfig} object reflecting the list-based configuration values.
}
\description{
-Create a new Vitessce Config from a list
-
A helper function to construct a new \code{VitessceConfig} object based on an existing config in a list format.
}
diff --git a/man/VitessceConfig-cash-from_object.Rd b/man/VitessceConfig-cash-from_object.Rd
index 442bd91..af64808 100644
--- a/man/VitessceConfig-cash-from_object.Rd
+++ b/man/VitessceConfig-cash-from_object.Rd
@@ -2,9 +2,7 @@
% Please edit documentation in R/config.R
\name{VitessceConfig$from_object}
\alias{VitessceConfig$from_object}
-\title{Create a new Vitessce Config from a data object
-
-A helper function to construct a new \code{VitessceConfig} object based on an object containing single-cell or imaging data.}
+\title{Create a new Vitessce Config from a data object}
\arguments{
\item{obj}{An object from which to construct a config. Can be a SingleCellExperiment or Seurat object.}
@@ -16,7 +14,5 @@ A helper function to construct a new \code{VitessceConfig} object based on an ob
A \code{VitessceConfig} object containing the object as a member of the datasets list, with some automatically-configured views.
}
\description{
-Create a new Vitessce Config from a data object
-
A helper function to construct a new \code{VitessceConfig} object based on an object containing single-cell or imaging data.
}
diff --git a/man/VitessceConfig.Rd b/man/VitessceConfig.Rd
index c0b8f3b..9dbcaf0 100644
--- a/man/VitessceConfig.Rd
+++ b/man/VitessceConfig.Rd
@@ -16,14 +16,14 @@ VitessceConfig
## Method `VitessceConfig$add_dataset`
## ------------------------------------------------
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
## ------------------------------------------------
## Method `VitessceConfig$add_view`
## ------------------------------------------------
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
@@ -31,7 +31,7 @@ spatial <- vc$add_view(ds, "spatial")
## Method `VitessceConfig$add_coordination`
## ------------------------------------------------
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
c_scopes <- vc$add_coordination(c("spatialZoom", "spatialTargetX"))
@@ -41,7 +41,7 @@ spatial$use_coordination(c_scopes)
## Method `VitessceConfig$layout`
## ------------------------------------------------
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
scatterplot <- vc$add_view(ds, "scatterplot")
@@ -50,7 +50,7 @@ scatterplot <- vc$add_view(ds, "scatterplot")
## Method `VitessceConfig$link_views`
## ------------------------------------------------
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ref_dataset <- vc$add_dataset("Reference")
qry_dataset <- vc$add_dataset("Query")
ref_plot <- vc$add_view(ref_dataset, Component$SCATTERPLOT, mapping = "umap")
@@ -65,7 +65,7 @@ vc$link_views(
## Method `VitessceConfig$to_list`
## ------------------------------------------------
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
vc_list <- vc$to_list(base_url = "http://localhost:8000")
@@ -73,7 +73,7 @@ vc_list <- vc$to_list(base_url = "http://localhost:8000")
## Method `VitessceConfig$widget`
## ------------------------------------------------
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
@@ -83,7 +83,7 @@ vc$widget()
## Method `VitessceConfig$export`
## ------------------------------------------------
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
@@ -93,6 +93,8 @@ vc$export(with_config = TRUE, base_url = "http://localhost:3000", out_dir = "./d
\if{html}{\out{}}
\describe{
\item{\code{config}}{The internal representation of the view config.}
+
+\item{\code{base_dir}}{The base directory for the config.}
}
\if{html}{\out{
}}
}
@@ -103,6 +105,9 @@ vc$export(with_config = TRUE, base_url = "http://localhost:3000", out_dir = "./d
\item \href{#method-VitessceConfig-add_dataset}{\code{VitessceConfig$add_dataset()}}
\item \href{#method-VitessceConfig-add_view}{\code{VitessceConfig$add_view()}}
\item \href{#method-VitessceConfig-add_coordination}{\code{VitessceConfig$add_coordination()}}
+\item \href{#method-VitessceConfig-add_meta_coordination}{\code{VitessceConfig$add_meta_coordination()}}
+\item \href{#method-VitessceConfig-add_coordination_by_dict}{\code{VitessceConfig$add_coordination_by_dict()}}
+\item \href{#method-VitessceConfig-link_views_by_dict}{\code{VitessceConfig$link_views_by_dict()}}
\item \href{#method-VitessceConfig-layout}{\code{VitessceConfig$layout()}}
\item \href{#method-VitessceConfig-link_views}{\code{VitessceConfig$link_views()}}
\item \href{#method-VitessceConfig-to_list}{\code{VitessceConfig$to_list()}}
@@ -118,12 +123,14 @@ vc$export(with_config = TRUE, base_url = "http://localhost:3000", out_dir = "./d
\subsection{Method \code{new()}}{
Create a new config object.
\subsection{Usage}{
-\if{html}{\out{}}\preformatted{VitessceConfig$new(name = NA, description = NA)}\if{html}{\out{
}}
+\if{html}{\out{}}\preformatted{VitessceConfig$new(schema_version, name = NA, description = NA, base_dir = NA)}\if{html}{\out{
}}
}
\subsection{Arguments}{
\if{html}{\out{}}
\describe{
+\item{\code{schema_version}}{The Vitessce config schema version to use.}
+
\item{\code{name}}{A name for the config.}
\item{\code{description}}{A description for the config.}
@@ -157,7 +164,7 @@ A new \code{VitessceConfigDataset} object.
}
\subsection{Examples}{
\if{html}{\out{
}}
-\preformatted{vc <- VitessceConfig$new("My config")
+\preformatted{vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
}
\if{html}{\out{
}}
@@ -206,7 +213,7 @@ A new \code{VitessceConfigView} object.
}
\subsection{Examples}{
\if{html}{\out{
}}
-\preformatted{vc <- VitessceConfig$new("My config")
+\preformatted{vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
}
@@ -236,7 +243,7 @@ A list of new \code{VitessceConfigCoordinationScope} objects.
}
\subsection{Examples}{
\if{html}{\out{
}}
-\preformatted{vc <- VitessceConfig$new("My config")
+\preformatted{vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
c_scopes <- vc$add_coordination(c("spatialZoom", "spatialTargetX"))
@@ -246,6 +253,33 @@ spatial$use_coordination(c_scopes)
}
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfig-add_meta_coordination}{}}}
+\subsection{Method \code{add_meta_coordination()}}{
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfig$add_meta_coordination()}\if{html}{\out{
}}
+}
+
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfig-add_coordination_by_dict}{}}}
+\subsection{Method \code{add_coordination_by_dict()}}{
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfig$add_coordination_by_dict(input_val)}\if{html}{\out{
}}
+}
+
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfig-link_views_by_dict}{}}}
+\subsection{Method \code{link_views_by_dict()}}{
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfig$link_views_by_dict(views, input_val, meta = TRUE)}\if{html}{\out{
}}
+}
+
}
\if{html}{\out{
}}
\if{html}{\out{
}}
@@ -268,7 +302,7 @@ Self, to allow chaining.
}
\subsection{Examples}{
\if{html}{\out{
}}
-\preformatted{vc <- VitessceConfig$new("My config")
+\preformatted{vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, "spatial")
scatterplot <- vc$add_view(ds, "scatterplot")
@@ -309,7 +343,7 @@ Self, to allow chaining.
}
\subsection{Examples}{
\if{html}{\out{
}}
-\preformatted{vc <- VitessceConfig$new("My config")
+\preformatted{vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ref_dataset <- vc$add_dataset("Reference")
qry_dataset <- vc$add_dataset("Query")
ref_plot <- vc$add_view(ref_dataset, Component$SCATTERPLOT, mapping = "umap")
@@ -346,7 +380,7 @@ A \code{list} that can be serialized to JSON.
}
\subsection{Examples}{
\if{html}{\out{
}}
-\preformatted{vc <- VitessceConfig$new("My config")
+\preformatted{vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
vc_list <- vc$to_list(base_url = "http://localhost:8000")
}
@@ -405,7 +439,7 @@ The Vitessce htmlwidget.
}
\subsection{Examples}{
\if{html}{\out{
}}
-\preformatted{vc <- VitessceConfig$new("My config")
+\preformatted{vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
@@ -443,7 +477,7 @@ The Vitessce configuration as a list, with the \code{base_url} filled in.
}
\subsection{Examples}{
\if{html}{\out{
}}
-\preformatted{vc <- VitessceConfig$new("My config")
+\preformatted{vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
diff --git a/man/VitessceConfigCoordinationScope.Rd b/man/VitessceConfigCoordinationScope.Rd
index d0529f4..cb7d30a 100644
--- a/man/VitessceConfigCoordinationScope.Rd
+++ b/man/VitessceConfigCoordinationScope.Rd
@@ -36,7 +36,7 @@ Coordination scope in a VitessceConfig
\subsection{Method \code{new()}}{
Create a new coordination scope object.
\subsection{Usage}{
-\if{html}{\out{
}}\preformatted{VitessceConfigCoordinationScope$new(c_type, c_scope)}\if{html}{\out{
}}
+\if{html}{\out{
}}\preformatted{VitessceConfigCoordinationScope$new(c_type, c_scope, c_value = NA)}\if{html}{\out{
}}
}
\subsection{Arguments}{
@@ -45,6 +45,8 @@ Create a new coordination scope object.
\item{\code{c_type}}{A coordination type name.}
\item{\code{c_scope}}{A coordination scope name.}
+
+\item{\code{c_value}}{An initial value for the coordination scope.}
}
\if{html}{\out{
}}
}
diff --git a/man/VitessceConfigDataset.Rd b/man/VitessceConfigDataset.Rd
index 0080764..5a44219 100644
--- a/man/VitessceConfigDataset.Rd
+++ b/man/VitessceConfigDataset.Rd
@@ -17,7 +17,7 @@ Dataset in a VitessceConfig
## ------------------------------------------------
base_url <- "http://localhost:8000/"
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_file(
url = paste0(base_url, "cells.json"),
data_type = DataType$CELLS,
@@ -28,6 +28,8 @@ dataset <- vc$add_dataset("My dataset")$add_file(
\if{html}{\out{
}}
\describe{
\item{\code{dataset}}{The dataset as a list.}
+
+\item{\code{base_dir}}{The base directory for the config.}
}
\if{html}{\out{
}}
}
@@ -35,6 +37,8 @@ dataset <- vc$add_dataset("My dataset")$add_file(
\subsection{Public methods}{
\itemize{
\item \href{#method-VitessceConfigDataset-new}{\code{VitessceConfigDataset$new()}}
+\item \href{#method-VitessceConfigDataset-get_name}{\code{VitessceConfigDataset$get_name()}}
+\item \href{#method-VitessceConfigDataset-get_uid}{\code{VitessceConfigDataset$get_uid()}}
\item \href{#method-VitessceConfigDataset-add_file}{\code{VitessceConfigDataset$add_file()}}
\item \href{#method-VitessceConfigDataset-add_object}{\code{VitessceConfigDataset$add_object()}}
\item \href{#method-VitessceConfigDataset-get_routes}{\code{VitessceConfigDataset$get_routes()}}
@@ -48,7 +52,7 @@ dataset <- vc$add_dataset("My dataset")$add_file(
\subsection{Method \code{new()}}{
Create a new dataset object.
\subsection{Usage}{
-\if{html}{\out{
}}\preformatted{VitessceConfigDataset$new(uid, name)}\if{html}{\out{
}}
+\if{html}{\out{
}}\preformatted{VitessceConfigDataset$new(uid, name, base_dir = NA)}\if{html}{\out{
}}
}
\subsection{Arguments}{
@@ -57,6 +61,8 @@ Create a new dataset object.
\item{\code{uid}}{A unique identifier string for the dataset.}
\item{\code{name}}{A name for the dataset}
+
+\item{\code{base_dir}}{A directory which local files are configured relative to.}
}
\if{html}{\out{
}}
}
@@ -65,6 +71,32 @@ A new \code{VitessceConfigDataset} object.
}
}
\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfigDataset-get_name}{}}}
+\subsection{Method \code{get_name()}}{
+Get the dataset name.
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfigDataset$get_name()}\if{html}{\out{
}}
+}
+
+\subsection{Returns}{
+The name as a string.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfigDataset-get_uid}{}}}
+\subsection{Method \code{get_uid()}}{
+Get the dataset UID.
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfigDataset$get_uid()}\if{html}{\out{
}}
+}
+
+\subsection{Returns}{
+The uid as a string.
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{
}}
\if{latex}{\out{\hypertarget{method-VitessceConfigDataset-add_file}{}}}
\subsection{Method \code{add_file()}}{
@@ -72,9 +104,10 @@ Add a file to this dataset.
\subsection{Usage}{
\if{html}{\out{
}}\preformatted{VitessceConfigDataset$add_file(
url = NA,
- data_type = NA,
file_type = NA,
- options = NA
+ options = NA,
+ coordination_values = NA,
+ data_type = NA
)}\if{html}{\out{
}}
}
@@ -83,11 +116,11 @@ Add a file to this dataset.
\describe{
\item{\code{url}}{The URL to the file.}
-\item{\code{data_type}}{The data type for the file.}
-
\item{\code{file_type}}{The file type for the file.}
\item{\code{options}}{Optional. An options list for the file.}
+
+\item{\code{data_type}}{The data type for the file.}
}
\if{html}{\out{
}}
}
@@ -97,7 +130,7 @@ Invisible self, to allow chaining.
\subsection{Examples}{
\if{html}{\out{
}}
\preformatted{base_url <- "http://localhost:8000/"
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_file(
url = paste0(base_url, "cells.json"),
data_type = DataType$CELLS,
diff --git a/man/VitessceConfigDatasetFile.Rd b/man/VitessceConfigDatasetFile.Rd
index e1083ac..7c28c50 100644
--- a/man/VitessceConfigDatasetFile.Rd
+++ b/man/VitessceConfigDatasetFile.Rd
@@ -26,9 +26,10 @@ Create a new dataset file object.
\subsection{Usage}{
\if{html}{\out{
}}\preformatted{VitessceConfigDatasetFile$new(
url = NA,
- data_type = NA,
file_type = NA,
- options = NA
+ options = NA,
+ coordination_values = NA,
+ data_type = NA
)}\if{html}{\out{
}}
}
@@ -37,11 +38,13 @@ Create a new dataset file object.
\describe{
\item{\code{url}}{A URL for the file.}
-\item{\code{data_type}}{A data type for the file.}
-
\item{\code{file_type}}{A file type for the file.}
\item{\code{options}}{A list of options to include for the file.}
+
+\item{\code{coordination_values}}{A list of coordination values to include in the file definition.}
+
+\item{\code{data_type}}{A data type for the file.}
}
\if{html}{\out{
}}
}
diff --git a/man/VitessceConfigServerRangeRoute.Rd b/man/VitessceConfigServerRangeRoute.Rd
index 1a68d77..b023a08 100644
--- a/man/VitessceConfigServerRangeRoute.Rd
+++ b/man/VitessceConfigServerRangeRoute.Rd
@@ -1,11 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/server.R
-\name{VitessceConfigServerRangeRoute}
+\name{VitessceConfigServerFileRoute}
+\alias{VitessceConfigServerFileRoute}
\alias{VitessceConfigServerRangeRoute}
\title{Class representing a local web server route for a file which needs to support range requests.}
\description{
Class representing a local web server route for a file which needs to support range requests.
+Class representing a local web server route for a file which needs to support range requests.
+
+Class representing a local web server route for a file which needs to support range requests.
+
Class representing a local web server route for a file which needs to support range requests.
}
\keyword{internal}
@@ -14,6 +19,83 @@ Class representing a local web server route for a file which needs to support ra
\describe{
\item{\code{path}}{The path on which the web server should respond to requests using this callback.}
+\item{\code{file_path}}{The file to serve.}
+}
+\if{html}{\out{
}}
+}
+\section{Methods}{
+\subsection{Public methods}{
+\itemize{
+\item \href{#method-VitessceConfigServerFileRoute-new}{\code{VitessceConfigServerFileRoute$new()}}
+\item \href{#method-VitessceConfigServerFileRoute-create_handlers}{\code{VitessceConfigServerFileRoute$create_handlers()}}
+\item \href{#method-VitessceConfigServerFileRoute-clone}{\code{VitessceConfigServerFileRoute$clone()}}
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfigServerFileRoute-new}{}}}
+\subsection{Method \code{new()}}{
+Create a new server route wrapper object.
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfigServerFileRoute$new(path, file_path)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{
}}
+\describe{
+\item{\code{path}}{The route path.}
+
+\item{\code{file_path}}{The file to serve on this route.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A new \code{VitessceConfigServerRangeRoute} object.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfigServerFileRoute-create_handlers}{}}}
+\subsection{Method \code{create_handlers()}}{
+Add handler functions to the Plumber server object to respond on this route.
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfigServerFileRoute$create_handlers(pr_server)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{
}}
+\describe{
+\item{\code{pr_server}}{The server instance.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+The modified server instance.
+}
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfigServerFileRoute-clone}{}}}
+\subsection{Method \code{clone()}}{
+The objects of this class are cloneable with this method.
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfigServerFileRoute$clone(deep = FALSE)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{
}}
+\describe{
+\item{\code{deep}}{Whether to make a deep clone.}
+}
+\if{html}{\out{
}}
+}
+}
+}
+\section{Public fields}{
+\if{html}{\out{
}}
+\describe{
+\item{\code{path}}{The path on which the web server should respond to requests using this callback.}
+
\item{\code{file_path}}{The file to serve.}
}
\if{html}{\out{
}}
diff --git a/man/VitessceConfigView.Rd b/man/VitessceConfigView.Rd
index ee42801..9beac48 100644
--- a/man/VitessceConfigView.Rd
+++ b/man/VitessceConfigView.Rd
@@ -15,6 +15,8 @@ View in a VitessceConfig
\itemize{
\item \href{#method-VitessceConfigView-new}{\code{VitessceConfigView$new()}}
\item \href{#method-VitessceConfigView-use_coordination}{\code{VitessceConfigView$use_coordination()}}
+\item \href{#method-VitessceConfigView-use_coordination_by_dict}{\code{VitessceConfigView$use_coordination_by_dict()}}
+\item \href{#method-VitessceConfigView-use_meta_coordination}{\code{VitessceConfigView$use_meta_coordination()}}
\item \href{#method-VitessceConfigView-set_xywh}{\code{VitessceConfigView$set_xywh()}}
\item \href{#method-VitessceConfigView-set_props}{\code{VitessceConfigView$set_props()}}
\item \href{#method-VitessceConfigView-to_list}{\code{VitessceConfigView$to_list()}}
@@ -70,6 +72,24 @@ Link this view to existing coordination scope(s).
\subsection{Returns}{
Invisible self, to allow chaining.
}
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfigView-use_coordination_by_dict}{}}}
+\subsection{Method \code{use_coordination_by_dict()}}{
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfigView$use_coordination_by_dict(scopes)}\if{html}{\out{
}}
+}
+
+}
+\if{html}{\out{
}}
+\if{html}{\out{
}}
+\if{latex}{\out{\hypertarget{method-VitessceConfigView-use_meta_coordination}{}}}
+\subsection{Method \code{use_meta_coordination()}}{
+\subsection{Usage}{
+\if{html}{\out{
}}\preformatted{VitessceConfigView$use_meta_coordination(meta_scope)}\if{html}{\out{
}}
+}
+
}
\if{html}{\out{
}}
\if{html}{\out{
}}
diff --git a/man/export_to_files.Rd b/man/export_to_files.Rd
index 2f157fb..99adbfa 100644
--- a/man/export_to_files.Rd
+++ b/man/export_to_files.Rd
@@ -23,7 +23,7 @@ A helper function to export files associated with a particular Vitessce configur
We do not recommend calling this function directly. Instead, use the \code{export()} function on a \code{VitessceConfig} instance.
}
\examples{
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
description <- vc$add_view(dataset, Component$DESCRIPTION)
vc$layout(description)
diff --git a/man/get_giotto_obj.Rd b/man/get_giotto_obj.Rd
deleted file mode 100644
index 659fa4a..0000000
--- a/man/get_giotto_obj.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/mock_objects.R
-\name{get_giotto_obj}
-\alias{get_giotto_obj}
-\title{Create a mock Giotto object for tests and examples.}
-\usage{
-get_giotto_obj()
-}
-\value{
-The object.
-}
-\description{
-Create a mock Giotto object for tests and examples.
-}
-\examples{
-obj <- get_giotto_obj()
-}
-\keyword{internal}
diff --git a/man/get_sce_obj.Rd b/man/get_sce_obj.Rd
deleted file mode 100644
index 4cc3c4c..0000000
--- a/man/get_sce_obj.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/mock_objects.R
-\name{get_sce_obj}
-\alias{get_sce_obj}
-\title{Create a mock SCE object for tests and examples.}
-\usage{
-get_sce_obj()
-}
-\value{
-The object.
-}
-\description{
-Create a mock SCE object for tests and examples.
-}
-\examples{
-obj <- get_sce_obj()
-}
-\keyword{internal}
diff --git a/man/get_seurat_obj.Rd b/man/get_seurat_obj.Rd
deleted file mode 100644
index 23a00fc..0000000
--- a/man/get_seurat_obj.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/mock_objects.R
-\name{get_seurat_obj}
-\alias{get_seurat_obj}
-\title{Create a mock Seurat object for tests and examples.}
-\usage{
-get_seurat_obj()
-}
-\value{
-The object.
-}
-\description{
-Create a mock Seurat object for tests and examples.
-}
-\examples{
-obj <- get_seurat_obj()
-}
-\keyword{internal}
diff --git a/man/get_spe_obj.Rd b/man/get_spe_obj.Rd
deleted file mode 100644
index 960567c..0000000
--- a/man/get_spe_obj.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/mock_objects.R
-\name{get_spe_obj}
-\alias{get_spe_obj}
-\title{Create a mock SPE object for tests and examples.}
-\usage{
-get_spe_obj()
-}
-\value{
-The object.
-}
-\description{
-Create a mock SPE object for tests and examples.
-}
-\examples{
-obj <- get_spe_obj()
-}
-\keyword{internal}
diff --git a/man/giotto_to_anndata_zarr.Rd b/man/giotto_to_anndata_zarr.Rd
deleted file mode 100644
index 50eea05..0000000
--- a/man/giotto_to_anndata_zarr.Rd
+++ /dev/null
@@ -1,26 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data_to_zarr.R
-\name{giotto_to_anndata_zarr}
-\alias{giotto_to_anndata_zarr}
-\title{Save a Giotto object to an AnnData-Zarr store}
-\usage{
-giotto_to_anndata_zarr(giotto_obj, out_path, X_slot = "raw_exprs")
-}
-\arguments{
-\item{giotto_obj}{The object to save.}
-
-\item{out_path}{A path to the output Zarr store.}
-
-\item{X_slot}{The name of the slot in the Giotto object to use for adata.X}
-}
-\value{
-TRUE if the conversion succeeds.
-}
-\description{
-Save a Giotto object to an AnnData-Zarr store
-}
-\examples{
-obj <- get_giotto_obj()
-giotto_to_anndata_zarr(obj, "data/giotto.zarr")
-}
-\keyword{internal}
diff --git a/man/hconcat.Rd b/man/hconcat.Rd
index b3011e8..e1e3ede 100644
--- a/man/hconcat.Rd
+++ b/man/hconcat.Rd
@@ -16,10 +16,10 @@ A \code{VitessceConfigViewHConcat} object.
A helper function to construct a new \code{VitessceConfigViewHConcat} object based on multiple views.
}
\examples{
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, Component$SPATIAL)
-gene_list <- vc$add_view(ds, Component$GENES)
+gene_list <- vc$add_view(ds, Component$FEATURE_LIST)
vc$layout(hconcat(spatial, gene_list))
vc$widget()
}
diff --git a/man/py_env.Rd b/man/py_env.Rd
deleted file mode 100644
index dbebd2b..0000000
--- a/man/py_env.Rd
+++ /dev/null
@@ -1,19 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/basilisk.R
-\docType{data}
-\name{py_env}
-\alias{py_env}
-\title{The Python environment}
-\format{
-An object of class \code{BasiliskEnvironment} of length 1.
-}
-\usage{
-py_env
-}
-\description{
-Defines a conda environment via Basilisk, which is used
-to convert R objects to Zarr stores.
-This environment has been adapted from zellkonverter::.AnnDataDependencies.
-Reference: https://bioconductor.org/packages/release/bioc/vignettes/basilisk/inst/doc/motivation.html
-}
-\keyword{internal}
diff --git a/man/sce_to_anndata_zarr.Rd b/man/sce_to_anndata_zarr.Rd
deleted file mode 100644
index f5f9555..0000000
--- a/man/sce_to_anndata_zarr.Rd
+++ /dev/null
@@ -1,24 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data_to_zarr.R
-\name{sce_to_anndata_zarr}
-\alias{sce_to_anndata_zarr}
-\title{Save a SingleCellExperiment to an AnnData-Zarr store.}
-\usage{
-sce_to_anndata_zarr(sce_obj, out_path)
-}
-\arguments{
-\item{sce_obj}{The object to save.}
-
-\item{out_path}{A path to the output Zarr store.}
-}
-\value{
-TRUE if the conversion succeeds.
-}
-\description{
-Save a SingleCellExperiment to an AnnData-Zarr store.
-}
-\examples{
-obj <- get_sce_obj()
-sce_to_anndata_zarr(obj, out_path = "data/sce.zarr")
-}
-\keyword{internal}
diff --git a/man/seurat_to_anndata_zarr.Rd b/man/seurat_to_anndata_zarr.Rd
deleted file mode 100644
index 847441d..0000000
--- a/man/seurat_to_anndata_zarr.Rd
+++ /dev/null
@@ -1,26 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data_to_zarr.R
-\name{seurat_to_anndata_zarr}
-\alias{seurat_to_anndata_zarr}
-\title{Save a Seurat object to an AnnData-Zarr store.}
-\usage{
-seurat_to_anndata_zarr(seurat_obj, out_path, assay)
-}
-\arguments{
-\item{seurat_obj}{The object to save.}
-
-\item{out_path}{A path to the output Zarr store.}
-
-\item{assay}{The name of the assay to save.}
-}
-\value{
-TRUE if the conversion succeeds.
-}
-\description{
-Save a Seurat object to an AnnData-Zarr store.
-}
-\examples{
-obj <- get_seurat_obj()
-seurat_to_anndata_zarr(obj, out_path = "data/seurat.zarr", assay = "RNA")
-}
-\keyword{internal}
diff --git a/man/spe_to_anndata_zarr.Rd b/man/spe_to_anndata_zarr.Rd
deleted file mode 100644
index 4cc1b88..0000000
--- a/man/spe_to_anndata_zarr.Rd
+++ /dev/null
@@ -1,20 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data_to_zarr.R
-\name{spe_to_anndata_zarr}
-\alias{spe_to_anndata_zarr}
-\title{Save a SpatialExperiment to an AnnData-Zarr store.}
-\usage{
-spe_to_anndata_zarr(spe_obj, out_path)
-}
-\arguments{
-\item{spe_obj}{The object to save.}
-
-\item{out_path}{A path to the output Zarr store.}
-}
-\value{
-TRUE if the conversion succeeds.
-}
-\description{
-Save a SpatialExperiment to an AnnData-Zarr store.
-}
-\keyword{internal}
diff --git a/man/spe_to_ome_zarr.Rd b/man/spe_to_ome_zarr.Rd
deleted file mode 100644
index 4711b72..0000000
--- a/man/spe_to_ome_zarr.Rd
+++ /dev/null
@@ -1,28 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data_to_zarr.R
-\name{spe_to_ome_zarr}
-\alias{spe_to_ome_zarr}
-\title{Save an image in a SpatialExperiment to an OME-Zarr store}
-\usage{
-spe_to_ome_zarr(spe_obj, sample_id, image_id, out_path)
-}
-\arguments{
-\item{spe_obj}{The object containing the image.}
-
-\item{sample_id}{The sample_id in the imgData data frame.}
-
-\item{image_id}{The image_id in the imgData data frame.}
-
-\item{out_path}{A path to the output Zarr store.}
-}
-\value{
-TRUE if the conversion succeeds.
-}
-\description{
-Save an image in a SpatialExperiment to an OME-Zarr store
-}
-\examples{
-obj <- get_spe_obj()
-spe_to_ome_zarr(obj, "sample1", "image1", "data/spe_image.zarr")
-}
-\keyword{internal}
diff --git a/man/vconcat.Rd b/man/vconcat.Rd
index fede6f8..609438c 100644
--- a/man/vconcat.Rd
+++ b/man/vconcat.Rd
@@ -16,10 +16,10 @@ A \code{VitessceConfigViewVConcat} object.
A helper function to construct a new \code{VitessceConfigViewVConcat} object based on multiple views.
}
\examples{
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
ds <- vc$add_dataset("My dataset")
spatial <- vc$add_view(ds, Component$SPATIAL)
-gene_list <- vc$add_view(ds, Component$GENES)
+gene_list <- vc$add_view(ds, Component$FEATURE_LIST)
vc$layout(vconcat(spatial, gene_list))
vc$widget()
}
diff --git a/man/vitessce_widget.Rd b/man/vitessce_widget.Rd
index 7a61965..0ec9ac0 100644
--- a/man/vitessce_widget.Rd
+++ b/man/vitessce_widget.Rd
@@ -49,6 +49,6 @@ recommend calling the \code{widget()} method on the \code{VitessceConfig}
instance.
}
\examples{
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
vc$widget()
}
diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml
index fa407d9..26ecced 100644
--- a/pkgdown/_pkgdown.yml
+++ b/pkgdown/_pkgdown.yml
@@ -6,8 +6,8 @@ template:
base_font: {google: "Inter"}
authors:
- Gehlenborg Lab:
- href: http://gehlenborglab.org/
+ HIDIVE Lab:
+ href: http://hidivelab.org/
Mark Keller:
href: https://github.com/keller-mark
@@ -59,7 +59,7 @@ footer:
left: [authors]
right: built_with
components:
- authors: Developed by the Gehlenborg Lab
+ authors: Developed by the HIDIVE Lab
reference:
- title: "Working with view configs"
@@ -86,19 +86,13 @@ reference:
desc: "Wrapper classes for automating the data conversion process for Vitessce."
- contents:
- AbstractWrapper
- - SeuratWrapper
- - SCEWrapper
- - SPEWrapper
- - GiottoWrapper
+ - AnnDataWrapper
+ - CsvWrapper
- MultiImageWrapper
- OmeTiffWrapper
+ - OmeZarrWrapper
articles:
- - title: Articles
- navbar: Developer guides
- contents:
- - dev_wrapper_class
- - dev_wrapper_subclass
- title: Articles
navbar: Troubleshooting
contents:
diff --git a/tests/testthat/setup-wrappers-seurat.R b/tests/testthat/setup-wrappers-seurat.R
deleted file mode 100644
index ca14064..0000000
--- a/tests/testthat/setup-wrappers-seurat.R
+++ /dev/null
@@ -1,10 +0,0 @@
-setup({
- url <- "https://cf.10xgenomics.com/samples/cell/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz"
- dir.create("seurat", showWarnings = FALSE)
- dir.create(file.path("seurat", "out"), showWarnings = FALSE)
- download.file(url, destfile = file.path("seurat", "filtered_gene_bc_matrices.tar.gz"))
- untar(file.path("seurat", "filtered_gene_bc_matrices.tar.gz"), exdir = "seurat")
-})
-teardown({
- unlink(file.path("seurat", "filtered_gene_bc_matrices.tar.gz"))
-})
diff --git a/tests/testthat/test-config.R b/tests/testthat/test-config.R
index 78915bf..c0c3e3c 100644
--- a/tests/testthat/test-config.R
+++ b/tests/testthat/test-config.R
@@ -1,7 +1,7 @@
library(vitessceR)
test_that("VitessceConfig new", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
vc_list <- vc$to_list(base_url = "http://localhost:8000")
expect_equal(vc_list, list(
@@ -16,12 +16,11 @@ test_that("VitessceConfig new", {
})
test_that("VitessceConfig add_dataset", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
vc$add_dataset("My dataset")
vc_list <- vc$to_list(base_url = "http://localhost:8000")
-
expect_equal(vc_list, list(
version = "1.0.9",
name = "My config",
@@ -44,11 +43,12 @@ test_that("VitessceConfig add_dataset", {
})
test_that("VitessceConfigDataset add_file", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
ds <- vc$add_dataset("My dataset")
- ds$add_file("http://example.com/cells", "cells", "cells.json")
+ ds$add_file(url = "http://example.com/cells", file_type = "cells.json")
vc_list <- vc$to_list(base_url = "http://localhost:8000")
+
expect_equal(vc_list, list(
version = "1.0.9",
name = "My config",
@@ -59,9 +59,8 @@ test_that("VitessceConfigDataset add_file", {
name = "My dataset",
files = list(
list(
- url = "http://example.com/cells",
- type = "cells",
- fileType = "cells.json"
+ fileType = "cells.json",
+ url = "http://example.com/cells"
)
)
)
@@ -77,9 +76,13 @@ test_that("VitessceConfigDataset add_file", {
})
test_that("VitessceConfigDataset add_file twice", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
ds <- vc$add_dataset("My dataset")
- ds$add_file("http://example.com/cells", "cells", "cells.json")$add_file("http://example.com/molecules", "molecules", "molecules.json")
+ ds$add_file(
+ url = "http://example.com/cells", file_type = "cells.json"
+ )$add_file(
+ url = "http://example.com/molecules", file_type = "molecules.json"
+ )
vc_list <- vc$to_list(base_url = "http://localhost:8000")
expect_equal(vc_list, list(
@@ -92,14 +95,12 @@ test_that("VitessceConfigDataset add_file twice", {
name = "My dataset",
files = list(
list(
- url = "http://example.com/cells",
- type = "cells",
- fileType = "cells.json"
+ fileType = "cells.json",
+ url = "http://example.com/cells"
),
list(
- url = "http://example.com/molecules",
- type = "molecules",
- fileType = "molecules.json"
+ fileType = "molecules.json",
+ url = "http://example.com/molecules"
)
)
)
@@ -115,7 +116,7 @@ test_that("VitessceConfigDataset add_file twice", {
})
test_that("VitessceConfigDataset add_file with options", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
ds <- vc$add_dataset("My dataset")
file_options = obj_list(
@@ -131,7 +132,7 @@ test_that("VitessceConfigDataset add_file with options", {
"Image"
)
)
- ds$add_file(data_type = "cells", file_type = "cells.json", options = file_options)
+ ds$add_file(file_type = "cells.json", options = file_options)
vc_list <- vc$to_list(base_url = "http://localhost:8000")
expect_equal(vc_list, list(
@@ -144,7 +145,6 @@ test_that("VitessceConfigDataset add_file with options", {
name = "My dataset",
files = list(
list(
- type = "cells",
fileType = "cells.json",
options = file_options
)
@@ -162,17 +162,16 @@ test_that("VitessceConfigDataset add_file with options", {
})
test_that("VitessceConfigDataset add_object", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
ds <- vc$add_dataset("My dataset")
MockWrapper <- R6::R6Class("SeuratWrapper",
inherit = AbstractWrapper,
public = list(
- convert_and_save = function(dataset_uid, obj_i) {
+ convert_and_save = function(dataset_uid, obj_i, base_dir = NA) {
get_cells <- function(base_url) {
return(list(
url = "http://localhost:8000/cells",
- type = "cells",
fileType = "cells.json"
))
}
@@ -196,7 +195,6 @@ test_that("VitessceConfigDataset add_object", {
files = list(
list(
url = "http://localhost:8000/cells",
- type = "cells",
fileType = "cells.json"
)
)
@@ -213,7 +211,7 @@ test_that("VitessceConfigDataset add_object", {
})
test_that("VitessceConfig add_view", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
ds <- vc$add_dataset("My dataset")
v1 <- vc$add_view(ds, "spatial")
v2 <- vc$add_view(ds, "scatterplot", mapping = "UMAP")
@@ -260,7 +258,7 @@ test_that("VitessceConfig add_view", {
})
test_that("VitessceConfig add_coordination", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
ds <- vc$add_dataset("My dataset")
v1 <- vc$add_view(ds, "spatial")
v2 <- vc$add_view(ds, "spatial")
@@ -319,7 +317,7 @@ test_that("VitessceConfig add_coordination", {
})
test_that("VitessceConfig layout", {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.9", name = "My config")
ds <- vc$add_dataset("My dataset")
v1 <- vc$add_view(ds, "spatial")
v2 <- vc$add_view(ds, "description")
diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R
new file mode 100644
index 0000000..01643a6
--- /dev/null
+++ b/tests/testthat/test-utils.R
@@ -0,0 +1,19 @@
+library(vitessceR)
+
+test_that("file_path_to_url_path", {
+ posix_with_slash <- file_path_to_url_path("tests/data/test.snap.mtx")
+ expect_equal(posix_with_slash, "/tests/data/test.snap.mtx")
+
+ posix_without_slash <- file_path_to_url_path("tests/data/test.snap.mtx", prepend_slash = FALSE)
+ expect_equal(posix_without_slash, "tests/data/test.snap.mtx")
+
+ windows_with_slash <- file_path_to_url_path("tests\\data\\test.snap.mtx")
+ expect_equal(windows_with_slash, "/tests/data/test.snap.mtx")
+
+ # TODO: do we need to support this?
+ # posix_with_dot_and_slash <- file_path_to_url_path("./tests/data/test.snap.mtx")
+ # expect_equal(posix_with_dot_and_slash, "/tests/data/test.snap.mtx")
+
+ # posix_with_dot_without_slash <- file_path_to_url_path("./tests/data/test.snap.mtx", prepend_slash = FALSE)
+ # expect_equal(posix_with_dot_without_slash, "tests/data/test.snap.mtx")
+})
diff --git a/tests/testthat/test-wrappers-anndata.R b/tests/testthat/test-wrappers-anndata.R
new file mode 100644
index 0000000..a59b115
--- /dev/null
+++ b/tests/testthat/test-wrappers-anndata.R
@@ -0,0 +1,78 @@
+library(vitessceR)
+
+test_that("AnnDataWrapper", {
+ w <- AnnDataWrapper$new(
+ adata_path = "tests/data/test.h5ad.zarr",
+ obs_set_paths=c('obs/CellType'),
+ obs_set_names=c('Cell Type'),
+ obs_labels_names=c('Cell Label'),
+ obs_labels_paths=c('obs/CellLabel'),
+ obs_embedding_paths=c('obsm/X_umap'),
+ obs_embedding_names=c('UMAP')
+ )
+ w$local_dir_uid <- "some_uuid.h5ad.zarr"
+
+ file_def_creator <- w$make_file_def_creator("A", "0")
+ file_def <- file_def_creator("http://localhost:8000")
+
+ expect_equal(file_def, list(
+ fileType = "anndata.zarr",
+ url = "http://localhost:8000/A/0/some_uuid.h5ad.zarr",
+ options = list(
+ obsEmbedding = list(
+ obj_list(
+ path = "obsm/X_umap",
+ embeddingType = "UMAP",
+ dims = c(0, 1)
+ )
+ ),
+ obsSets = list(
+ obj_list(
+ path = "obs/CellType",
+ name = "Cell Type"
+ )
+ ),
+ obsLabels = list(
+ obj_list(
+ path = "obs/CellLabel",
+ obsLabelsType = "Cell Label"
+ )
+ )
+ )
+ ))
+})
+
+test_that("AnnDataWrapper with base dir", {
+ w <- AnnDataWrapper$new(
+ adata_path = "test.h5ad.zarr",
+ obs_set_paths=c('obs/CellType'),
+ obs_set_names=c('Cell Type'),
+ obs_embedding_paths=c('obsm/X_umap'),
+ obs_embedding_names=c('UMAP')
+ )
+ w$local_dir_uid <- "some_uuid.h5ad.zarr"
+ w$base_dir <- "tests/data"
+
+ file_def_creator <- w$make_file_def_creator("A", "0")
+ file_def <- file_def_creator("http://localhost:8000")
+
+ expect_equal(file_def, list(
+ fileType = "anndata.zarr",
+ url = "http://localhost:8000/test.h5ad.zarr",
+ options = list(
+ obsEmbedding = list(
+ obj_list(
+ path = "obsm/X_umap",
+ embeddingType = "UMAP",
+ dims = c(0, 1)
+ )
+ ),
+ obsSets = list(
+ obj_list(
+ path = "obs/CellType",
+ name = "Cell Type"
+ )
+ )
+ )
+ ))
+})
diff --git a/tests/testthat/test-wrappers-csv.R b/tests/testthat/test-wrappers-csv.R
new file mode 100644
index 0000000..785ed8d
--- /dev/null
+++ b/tests/testthat/test-wrappers-csv.R
@@ -0,0 +1,62 @@
+library(vitessceR)
+
+test_that("CsvWrapper", {
+ w <- CsvWrapper$new(
+ csv_path = "tests/data/test.csv",
+ data_type = "obsEmbedding",
+ options = obj_list(
+ obsIndex = "index",
+ obsEmbedding = c("UMAP_1", "UMAP_2")
+ ),
+ coordination_values = obj_list(
+ embeddingType = "UMAP"
+ )
+ )
+ w$local_csv_uid <- "some_uuid.csv"
+
+ file_def_creator <- w$make_file_def_creator("A", "0")
+ file_def <- file_def_creator("http://localhost:8000")
+
+ expect_equal(file_def, list(
+ fileType = "obsEmbedding.csv",
+ url = "http://localhost:8000/A/0/some_uuid.csv",
+ options = obj_list(
+ obsIndex = "index",
+ obsEmbedding = c("UMAP_1", "UMAP_2")
+ ),
+ coordinationValues = obj_list(
+ embeddingType = "UMAP"
+ )
+ ))
+})
+
+test_that("CsvWrapper with base_dir", {
+ w <- CsvWrapper$new(
+ csv_path = "test.csv",
+ data_type = "obsEmbedding",
+ options = obj_list(
+ obsIndex = "index",
+ obsEmbedding = c("UMAP_1", "UMAP_2")
+ ),
+ coordination_values = obj_list(
+ embeddingType = "UMAP"
+ )
+ )
+ w$base_dir <- "tests/data"
+ w$local_csv_uid <- "some_uuid.csv"
+
+ file_def_creator <- w$make_file_def_creator("A", "0")
+ file_def <- file_def_creator("http://localhost:8000")
+
+ expect_equal(file_def, list(
+ fileType = "obsEmbedding.csv",
+ url = "http://localhost:8000/test.csv",
+ options = obj_list(
+ obsIndex = "index",
+ obsEmbedding = c("UMAP_1", "UMAP_2")
+ ),
+ coordinationValues = obj_list(
+ embeddingType = "UMAP"
+ )
+ ))
+})
diff --git a/tests/testthat/test-wrappers-images.R b/tests/testthat/test-wrappers-images.R
new file mode 100644
index 0000000..20da432
--- /dev/null
+++ b/tests/testthat/test-wrappers-images.R
@@ -0,0 +1,26 @@
+library(vitessceR)
+
+test_that("OmeTiffWrapper", {
+ w <- OmeTiffWrapper$new(img_path = "tests/data/test.ome.tiff", name = "Test")
+ w$local_img_uid <- "test.ome.tiff"
+
+ file_def_creator <- w$make_raster_file_def_creator("A", "0")
+ file_def <- file_def_creator("http://localhost:8000")
+
+ expect_equal(file_def, list(
+ fileType = "raster.json",
+ options = list(
+ schemaVersion = "0.0.2",
+ images = list(
+ obj_list(
+ name = "Test",
+ type = "ome-tiff",
+ url = "http://localhost:8000/A/0/test.ome.tiff",
+ metadata = list(
+ isBitmask = FALSE
+ )
+ )
+ )
+ )
+ ))
+})
diff --git a/tests/testthat/test-wrappers-seurat.R b/tests/testthat/test-wrappers-seurat.R
deleted file mode 100644
index 76d078b..0000000
--- a/tests/testthat/test-wrappers-seurat.R
+++ /dev/null
@@ -1,64 +0,0 @@
-library(vitessceR)
-library(Seurat)
-
-test_that("SeuratWrapper create_cells_list", {
- pbmc.data <- Read10X(data.dir = "seurat/filtered_gene_bc_matrices/hg19")
-
- pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells = 3, min.features = 200)
- pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")
- pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)
- pbmc <- NormalizeData(pbmc, normalization.method = "LogNormalize", scale.factor = 10000)
- pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
- all.genes <- rownames(pbmc)
- pbmc <- ScaleData(pbmc, features = all.genes)
- pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))
- pbmc <- FindNeighbors(pbmc, dims = 1:10)
- pbmc <- FindClusters(pbmc, resolution = 0.5)
-
- w <- SeuratWrapper$new(
- pbmc,
- cell_embeddings = c("pca"),
- cell_embedding_names = c("PCA"),
- cell_set_metas = c("seurat_clusters"),
- cell_set_meta_names = c("Clusters"),
- out_dir = file.path("seurat", "out")
- )
-
- cells_file_def <- w$make_cells_file_def_creator("A", "1")("http://localhost")
- cell_sets_file_def <- w$make_cell_sets_file_def_creator("A", "1")("http://localhost")
- expr_mtx_file_def <- w$make_expression_matrix_file_def_creator("A", "1")("http://localhost")
-
- expect_equal(cells_file_def, list(
- type = "cells",
- fileType = "anndata-cells.zarr",
- url = "http://localhost/A/1/seurat.zarr",
- options = list(
- mappings = list(
- PCA = list(
- key = "obsm/X_pca",
- dims = c(0, 1)
- )
- )
- )
- ))
- expect_equal(cell_sets_file_def, list(
- type = "cell-sets",
- fileType = "anndata-cell-sets.zarr",
- url = "http://localhost/A/1/seurat.zarr",
- options = list(
- list(
- groupName = "Clusters",
- setName = "obs/seurat_clusters"
- )
- )
- ))
- expect_equal(expr_mtx_file_def, list(
- type = "expression-matrix",
- fileType = "anndata-expression-matrix.zarr",
- url = "http://localhost/A/1/seurat.zarr",
- options = list(
- matrix = "X"
- )
- ))
-
-})
diff --git a/tests/testthat/test-wrappers.R b/tests/testthat/test-wrappers.R
index 49b4216..38fee0f 100644
--- a/tests/testthat/test-wrappers.R
+++ b/tests/testthat/test-wrappers.R
@@ -28,3 +28,51 @@ test_that("AbstractWrapper get_out_dir", {
out_dir <- w$get_out_dir("A", 1, "cells")
expect_equal(out_dir, "test/A/1/cells")
})
+
+
+test_that("AbstractWrapper get_local_dir_route without base_dir", {
+ w <- AbstractWrapper$new(out_dir = "test")
+
+ adata_path <- "data/test.h5ad.zarr"
+ local_dir_uid <- "some_uuid.h5ad.zarr"
+
+ routes <- w$get_local_dir_route("A", 1, adata_path, local_dir_uid)
+ expect_equal(routes[[1]]$path, "/A/1/some_uuid.h5ad.zarr")
+ expect_equal(routes[[1]]$directory, "data/test.h5ad.zarr")
+})
+
+test_that("AbstractWrapper get_local_dir_route with base_dir", {
+ w <- AbstractWrapper$new(out_dir = "test")
+ w$base_dir <- "data_base"
+
+ adata_path <- "test.h5ad.zarr"
+ local_dir_uid <- "some_uuid.h5ad.zarr"
+
+ routes <- w$get_local_dir_route("A", 1, adata_path, local_dir_uid)
+ expect_equal(routes[[1]]$path, "/test.h5ad.zarr")
+ expect_equal(routes[[1]]$directory, "data_base/test.h5ad.zarr")
+})
+
+test_that("AbstractWrapper get_local_file_route without base_dir", {
+ w <- AbstractWrapper$new(out_dir = "test")
+
+ adata_path <- "data/test.csv"
+ local_dir_uid <- "some_uuid.csv"
+
+ routes <- w$get_local_file_route("A", 1, adata_path, local_dir_uid)
+ expect_equal(routes[[1]]$path, "/A/1/some_uuid.csv")
+ expect_equal(routes[[1]]$file_path, "data/test.csv")
+})
+
+test_that("AbstractWrapper get_local_file_route with base_dir", {
+ w <- AbstractWrapper$new(out_dir = "test")
+ w$base_dir <- "data_base"
+
+ adata_path <- "test.csv"
+ local_dir_uid <- "some_uuid.csv"
+
+ routes <- w$get_local_file_route("A", 1, adata_path, local_dir_uid)
+ expect_equal(routes[[1]]$path, "/test.csv")
+ expect_equal(routes[[1]]$file_path, "data_base/test.csv")
+})
+
diff --git a/tools/check.env b/tools/check.env
deleted file mode 100644
index fd9ef01..0000000
--- a/tools/check.env
+++ /dev/null
@@ -1,47 +0,0 @@
-# Reference: https://cran.r-project.org/doc/manuals/r-devel/R-ints.html#Tools
-
-# Report if package size is larger than 25 megabytes
-_R_CHECK_PKG_SIZES_THRESHOLD_=25
-
-# If true, give an error if suggested packages are not available.
-_R_CHECK_FORCE_SUGGESTS_=FALSE
-
-# Reference: https://github.com/Bioconductor/packagebuilder/blob/master/check.Renviron
-#_R_CHECK_FORCE_SUGGESTS_=TRUE
-_R_CHECK_RD_LINE_WIDTHS_=TRUE
-_R_CHECK_EXECUTABLES_=FALSE
-_R_CHECK_EXECUTABLES_EXCLUSIONS_=FALSE
-_R_CHECK_FF_DUP_=TRUE
-_R_CHECK_VC_DIR_=TRUE
-_R_CHECK_PKG_SIZES_=TRUE
-#_R_CHECK_PKG_SIZES_THRESHOLD_=5
-_R_CHECK_REPLACING_IMPORTS_=TRUE
-_R_CHECK_TIMINGS_="0"
-_R_CHECK_INSTALL_DEPENDS_=TRUE
-_R_CHECK_SUGGESTS_ONLY_=TRUE
-_R_CHECK_NO_RECOMMENDED_=TRUE
-_R_CHECK_CODE_ASSIGN_TO_GLOBALENV_=TRUE
-_R_CHECK_CODE_ATTACH_=TRUE
-_R_CHECK_CODE_DATA_INTO_GLOBALENV_=TRUE
-_R_CHECK_DOT_FIRSTLIB_=TRUE
-_R_CHECK_DEPRECATED_DEFUNCT_=TRUE
-_R_CHECK_TOPLEVELFILES_=TRUE
-_R_CHECK_LIMIT_CORES_=TRUE
-_R_CHECK_CODE_USAGE_VIA_NAMESPACES_=TRUE
-_R_CHECK_S3_METHODS_NOT_REGISTERED_=TRUE
-_R_CHECK_OVERWRITE_REGISTERED_S3_METHODS_=TRUE
-_R_S3_METHOD_LOOKUP_BASEENV_AFTER_GLOBALENV_=TRUE
-_R_CHECK_TESTS_NLINES_=20
-_R_CHECK_NATIVE_ROUTINE_REGISTRATION_=TRUE
-_R_CHECK_NO_STOP_ON_TEST_ERROR_=TRUE
-_R_CHECK_PRAGMAS_=TRUE
-_R_CHECK_COMPILATION_FLAGS_=TRUE
-_R_CHECK_R_DEPENDS_="warn"
-_R_CHECK_SERIALIZATION_=TRUE
-_R_CHECK_R_ON_PATH_=TRUE
-_R_CHECK_PACKAGES_USED_IN_TESTS_USE_SUBDIRS_=TRUE
-_R_CHECK_SHLIB_OPENMP_FLAGS_=TRUE
-_R_CHECK_CONNECTIONS_LEFT_OPEN_=TRUE
-_R_CHECK_FUTURE_FILE_TIMESTAMPS_=TRUE
-_R_CHECK_LENGTH_1_CONDITION_ =package:_R_CHECK_PACKAGE_NAME_
-_R_CHECK_LENGTH_1_LOGIC2_=package:_R_CHECK_PACKAGE_NAME_
diff --git a/vignettes/debugging.Rmd b/vignettes/debugging.Rmd
index 817e347..1af9ec3 100644
--- a/vignettes/debugging.Rmd
+++ b/vignettes/debugging.Rmd
@@ -16,20 +16,9 @@ The following code snippets assume that `vitessceR` has been loaded via `library
```r
library(vitessceR)
-vc <- VitessceConfig$new("My single-cell data visualization")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My single-cell data visualization")
```
-## Use the `out_dir` parameter for data object wrapper classes
-
-Rather than using a temporary directory, this will write converted files to the specified directory.
-This way, you can open and explore the converted output files.
-
-```r
-dir.create("./debug")
-
-dataset <- vc$add_dataset("My dataset")
-dataset <- dataset$add_object(SeuratWrapper$new(pbmc3k.final, out_dir = "./debug"))
-```
## Use the `port` parameter
diff --git a/vignettes/dev_wrapper_subclass.Rmd b/vignettes/dev_wrapper_subclass.Rmd
index fd40cb3..316b010 100644
--- a/vignettes/dev_wrapper_subclass.Rmd
+++ b/vignettes/dev_wrapper_subclass.Rmd
@@ -128,13 +128,13 @@ my_wrapped_object <- MyCustomSeuratWrapper$new(pbmc, cell_sets = cell_sets_list,
Now, we create the Vitessce config as usual:
```r
# Create Vitessce view config
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_object(my_wrapped_object)
scatterplot <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "pca")
status <- vc$add_view(dataset, Component$STATUS)
desc <- vc$add_view(dataset, Component$DESCRIPTION)
desc <- desc$set_props(description = "Visualization of a Seurat object containing the PBMC 3K dataset.")
-cell_sets <- vc$add_view(dataset, Component$CELL_SETS)
+cell_sets <- vc$add_view(dataset, Component$OBS_SETS)
vc$layout(hconcat(
vconcat(scatterplot),
vconcat(cell_sets, vconcat(desc, status))
diff --git a/vignettes/export_files.Rmd b/vignettes/export_files.Rmd
index 53c8bfe..b8e8d02 100644
--- a/vignettes/export_files.Rmd
+++ b/vignettes/export_files.Rmd
@@ -15,27 +15,32 @@ First, install the dependencies:
```r
install.packages("devtools")
devtools::install_github("satijalab/seurat-data")
+devtools::install_github("vitessce/vitessceAnalysisR")
```
Create the Vitessce configuration:
```r
library(vitessceR)
+library(vitessceAnalysisR)
library(SeuratData)
SeuratData::InstallData("pbmc3k")
data("pbmc3k.final")
force(pbmc3k.final)
-vc <- VitessceConfig$new("My config")
+adata_path <- file.path("data", "seurat", "pbmc3k.final.h5ad.zarr")
+
+vitessceAnalysisR::seurat_to_anndata_zarr(pbmc3k.final, adata_path)
+
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
dataset <- dataset$add_object(
- SeuratWrapper$new(
- pbmc3k.final,
- cell_embeddings = c("pca", "umap"),
- cell_embedding_names = c("PCA", "UMAP"),
- cell_set_meta_names = c("seurat_annotations", "seurat_clusters"),
- out_dir = file.path("data", "seuratdata")
+ AnnDataWrapper$new(
+ adata_path=adata_path,
+ obs_embedding_paths = c("obsm/X_pca", "obsm/X_umap"),
+ obs_embedding_names = c("PCA", "UMAP"),
+ obs_set_paths = c("obs/seurat_annotations", "obs/seurat_clusters")
)
)
scatterplot <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "PCA")
diff --git a/vignettes/giotto.Rmd b/vignettes/giotto.Rmd
index be60e8b..67e8188 100644
--- a/vignettes/giotto.Rmd
+++ b/vignettes/giotto.Rmd
@@ -14,6 +14,7 @@ First, install the R dependencies:
```r
install.packages("devtools")
devtools::install_github("RubD/Giotto")
+devtools::install_github("vitessce/vitessceAnalysisR")
```
@@ -30,7 +31,7 @@ instrs <- createGiottoInstructions(
save_plot = TRUE,
show_plot = FALSE,
save_dir = save_dir,
- python_path = "~/miniconda3/envs/vitessce-r-env/bin/python"
+ python_path = "~/software/miniconda3/envs/vitessce-r-env/bin/python"
)
getSpatialDataset(dataset = "seqfish_SS_cortex", directory = save_dir, method = "wget")
@@ -122,21 +123,25 @@ Set up the Vitessce widget:
```r
library(vitessceR)
+library(vitessceAnalysisR)
-w <- GiottoWrapper$new(
- SS_seqfish,
- cell_set_metas = c("cell_types"),
- cell_set_meta_names = c("Cell Types"),
- cell_embeddings = c("pca", "tsne"),
- cell_embedding_names = c("PCA", "t-SNE"),
- out_dir = file.path("data", "giotto")
+adata_path <- file.path("data", "giotto_seqfish.h5ad.zarr")
+
+vitessceAnalysisR::giotto_to_anndata_zarr(SS_seqfish, adata_path)
+
+w <- AnnDataWrapper$new(
+ adata_path = adata_path,
+ obs_set_paths = c("obs/cell_types"),
+ obs_set_names = c("Cell Types"),
+ obs_embedding_paths = c("obsm/pca", "obsm/tsne"),
+ obs_embedding_names = c("PCA", "t-SNE")
)
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_object(w)
spatial <- vc$add_view(dataset, Component$SPATIAL)
scatterplot_tsne <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "t-SNE")
-cell_sets <- vc$add_view(dataset, Component$CELL_SETS)
+cell_sets <- vc$add_view(dataset, Component$OBS_SETS)
status <- vc$add_view(dataset, Component$STATUS)
desc <- vc$add_view(dataset, Component$DESCRIPTION)
desc <- desc$set_props(description = "Visualization of a Giotto object.")
diff --git a/vignettes/json_local.Rmd b/vignettes/json_local.Rmd
index 4f1c217..0fd95e4 100644
--- a/vignettes/json_local.Rmd
+++ b/vignettes/json_local.Rmd
@@ -50,26 +50,24 @@ library(vitessceR)
base_url <- "http://localhost:8000/"
# Create Vitessce view config
-vc <- VitessceConfig$new("Codeluppi et al., Nature Methods 2018")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "Codeluppi et al., Nature Methods 2018")
dataset <- vc$add_dataset("Codeluppi")$add_file(
url = paste0(base_url, "linnarsson.cells.json"),
- data_type = DataType$CELLS,
- file_type = FileType$CELLS_JSON
+ file_type = FileType$CELLS_JSON,
+ options = obj_list(
+ embeddingTypes = c("PCA", "t-SNE")
+ )
)$add_file(
url = paste0(base_url, "linnarsson.cell-sets.json"),
- data_type = DataType$CELL_SETS,
file_type = FileType$CELL_SETS_JSON
)$add_file(
url = paste0(base_url, "linnarsson.molecules.json"),
- data_type = DataType$MOLECULES,
file_type = FileType$MOLECULES_JSON
)$add_file(
url = paste0(base_url, "linnarsson.clusters.json"),
- data_type = DataType$EXPRESSION_MATRIX,
file_type = FileType$CLUSTERS_JSON
)$add_file(
url = paste0(base_url, "linnarsson.raster.json"),
- data_type = DataType$RASTER,
file_type = FileType$RASTER_JSON
)
@@ -83,8 +81,8 @@ scatterplot_pca <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "PCA")
scatterplot_tsne <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "t-SNE")
status <- vc$add_view(dataset, Component$STATUS)
-cell_sets <- vc$add_view(dataset, Component$CELL_SETS)
-gene_list <- vc$add_view(dataset, Component$GENES)
+cell_sets <- vc$add_view(dataset, Component$OBS_SETS)
+gene_list <- vc$add_view(dataset, Component$FEATURE_LIST)
heatmap <- vc$add_view(dataset, Component$HEATMAP)$set_props(transpose = TRUE)
vc$layout(hconcat(
diff --git a/vignettes/local_data_overview.Rmd b/vignettes/local_data_overview.Rmd
index 2b44508..62da7d7 100644
--- a/vignettes/local_data_overview.Rmd
+++ b/vignettes/local_data_overview.Rmd
@@ -9,19 +9,6 @@ vignette: >
The main goal of this R package is to enable configuring Vitessce visualizations using R syntax.
-We also aim to simplify the data conversion process by providing [dataset wrapper classes](../reference/index.html#dataset-wrapper-classes) that automatically convert common single-cell data structures to [file formats supported by Vitessce](http://vitessce.io/docs/data-types-file-types/).
-
-Our effort to develop converters for R formats remains ongoing. However, we provide a guide for R developers to [write data conversion functions](./dev_wrapper_class.html) to support any type of R single-cell data structure (or to improve conversion for already-supported data structures).
+We provide functions in the companion vitessceAnalysisR package for conversion of common single-cell data structures to [file formats supported by Vitessce](http://vitessce.io/docs/data-types-file-types/).
The following vignettes in the "Examples with Local Data" section demonstrate how the dataset wrapper classes can be used with single-cell datasets stored on your local machine.
-
-## Zarr via Reticulate via Basilisk
-
-Due to a lack of native R support for Zarr, the R dataset conversion functions currently depend on a Python environment.
-
-We currently use [basilisk](https://github.com/LTLA/basilisk) and [reticulate](https://rstudio.github.io/reticulate/) to write to Zarr stores via the ``zarr`` Python package.
-
-
-## Zarr natively
-
-Subscribe to the [Zarr in R issue](https://github.com/vitessce/vitessce-r/issues/7) for future updates about native Zarr support that would avoid the need for the Python environment.
diff --git a/vignettes/ome_tiff_local.Rmd b/vignettes/ome_tiff_local.Rmd
index 5a3de6a..c5a111c 100644
--- a/vignettes/ome_tiff_local.Rmd
+++ b/vignettes/ome_tiff_local.Rmd
@@ -15,7 +15,7 @@ Configure the Vitessce widget:
library(vitessceR)
# Create Vitessce view config
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_object(
MultiImageWrapper$new(
image_wrappers = list(
diff --git a/vignettes/pkgdown.Rmd b/vignettes/pkgdown.Rmd
index 5ec139f..add0458 100644
--- a/vignettes/pkgdown.Rmd
+++ b/vignettes/pkgdown.Rmd
@@ -21,7 +21,7 @@ To render a Vitessce widget into a pkgdown article, set the [chunk options](http
`r chunk`{r echo = TRUE}
library(vitessceR)
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
# configure vitessce here
diff --git a/vignettes/seurat_azimuth.Rmd b/vignettes/seurat_azimuth.Rmd
index 826679e..df4655c 100644
--- a/vignettes/seurat_azimuth.Rmd
+++ b/vignettes/seurat_azimuth.Rmd
@@ -198,35 +198,37 @@ ref_obj@reductions$refUMAP@assay.used <- "RNA"
#### Use Vitessce for visualization ####
+ref_adata_path <- file.path(data_dir, "ref.h5ad.zarr")
+qry_adata_path <- file.path(data_dir, "qry.h5ad.zarr")
+
+vitessceAnalysisR::seurat_to_anndata_zarr(ref_obj, ref_adata_path, assay = Seurat::DefaultAssay(ref_obj))
+vitessceAnalysisR::seurat_to_anndata_zarr(qry_obj, qry_adata_path, assay = Seurat::DefaultAssay(qry_obj))
+
# Create Vitessce view config
-vc <- VitessceConfig$new("Azimuth")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "Azimuth")
ref_dataset <- vc$add_dataset("Reference")$add_object(
- SeuratWrapper$new(
- ref_obj,
- assay = Seurat::DefaultAssay(ref_obj),
- cell_embeddings = c("refUMAP"),
- cell_embedding_names = c("UMAP"),
- cell_set_metas = c("celltype.l2"),
- out_dir = file.path(data_dir, "reference"), overwrite = TRUE
+ AnnDataWrapper$new(
+ adata_path = ref_adata_path,
+ obs_embedding_paths = c("obsm/X_refUMAP"),
+ obs_embedding_names = c("UMAP"),
+ obs_set_paths = c("obs/celltype.l2")
)
)
qry_dataset <- vc$add_dataset("Query")$add_object(
- SeuratWrapper$new(
- qry_obj,
- assay = Seurat::DefaultAssay(qry_obj),
- cell_embeddings = c("umap.proj"),
- cell_embedding_names = c("UMAP"),
- cell_set_metas = c("predicted.celltype.l2"),
- cell_set_meta_names = c("celltype.l2"),
- cell_set_meta_scores = c("predicted.celltype.l2.score"),
- out_dir = file.path(data_dir, "query"), overwrite = TRUE
+ AnnDataWrapper$new(
+ adata_path = qry_adata_path,
+ obs_embedding_paths = c("obsm/X_umap.proj"),
+ obs_embedding_names = c("UMAP"),
+ obs_set_paths = c("obs/predicted.celltype.l2"),
+ obs_set_names = c("celltype.l2"),
+ obs_set_score_paths = c("obs/predicted.celltype.l2.score")
)
)
ref_plot <- vc$add_view(ref_dataset, Component$SCATTERPLOT, mapping = "UMAP")
qry_plot <- vc$add_view(qry_dataset, Component$SCATTERPLOT, mapping = "UMAP")
-cell_sets <- vc$add_view(ref_dataset, Component$CELL_SETS)
-cell_sets_2 <- vc$add_view(qry_dataset, Component$CELL_SETS)
+cell_sets <- vc$add_view(ref_dataset, Component$OBS_SETS)
+cell_sets_2 <- vc$add_view(qry_dataset, Component$OBS_SETS)
vc$link_views(
c(ref_plot, qry_plot),
diff --git a/vignettes/seurat_basic.Rmd b/vignettes/seurat_basic.Rmd
index be6794b..44cd5f6 100644
--- a/vignettes/seurat_basic.Rmd
+++ b/vignettes/seurat_basic.Rmd
@@ -16,6 +16,7 @@ First, install the R dependencies:
install.packages("seurat")
install.packages("devtools")
devtools::install_github("mojaveazure/seurat-disk")
+devtools::install_github("vitessce/vitessceAnalysisR")
```
@@ -23,6 +24,7 @@ Download the dataset, load and preprocess the Seurat object, and configure the V
```r
library(vitessceR)
+library(vitessceAnalysisR)
library(Seurat)
# Download example dataset
@@ -49,24 +51,28 @@ pbmc <- FindClusters(pbmc, resolution = 0.5)
pbmc <- ScaleData(pbmc, features = all.genes, do.center = FALSE)
+adata_path <- file.path("data", "seurat", "pbmc3k.h5ad.zarr")
+
+vitessceAnalysisR::seurat_to_anndata_zarr(pbmc, adata_path)
+
# Create Vitessce view config
-vc <- VitessceConfig$new("My config")
-dataset <- vc$add_dataset("My dataset")$add_object(SeuratWrapper$new(
- pbmc,
- cell_set_metas = c("seurat_clusters"),
- cell_embeddings = c("pca"),
- cell_embedding_names = c("PCA"),
- out_dir = file.path("data", "seurat_basic"), use_cache = TRUE
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
+dataset <- vc$add_dataset("My dataset")$add_object(AnnDataWrapper$new(
+ adata_path=adata_path,
+ obs_set_paths = c("obs/seurat_clusters"),
+ obs_embedding_paths = c("obsm/X_pca"),
+ obs_embedding_names = c("PCA"),
+ obs_feature_matrix_path = "X"
))
scatterplot <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "PCA")
status <- vc$add_view(dataset, Component$STATUS)
desc <- vc$add_view(dataset, Component$DESCRIPTION)
desc <- desc$set_props(description = "Visualization of a Seurat object containing the PBMC 3K dataset.")
-genes <- vc$add_view(dataset, Component$GENES)
+genes <- vc$add_view(dataset, Component$FEATURE_LIST)
heatmap <- vc$add_view(dataset, Component$HEATMAP)
vc$link_views(
list(scatterplot, heatmap),
- list(CoordinationType$GENE_EXPRESSION_COLORMAP_RANGE),
+ list(CoordinationType$FEATURE_VALUE_COLORMAP_RANGE),
list(c(0.0, 0.05))
)
vc$layout(hconcat(
diff --git a/vignettes/seuratdata.Rmd b/vignettes/seuratdata.Rmd
index cb7b0cd..87a875a 100644
--- a/vignettes/seuratdata.Rmd
+++ b/vignettes/seuratdata.Rmd
@@ -33,7 +33,7 @@ force(pbmc3k.final)
all.genes <- rownames(pbmc3k.final)
pbmc3k.final <- ScaleData(pbmc3k.final, features = all.genes, do.center = FALSE)
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
dataset <- dataset$add_object(SeuratWrapper$new(
pbmc3k.final,
diff --git a/vignettes/shiny.Rmd b/vignettes/shiny.Rmd
index a3fc550..918473e 100644
--- a/vignettes/shiny.Rmd
+++ b/vignettes/shiny.Rmd
@@ -14,6 +14,7 @@ First, install the dependencies:
install.packages("shiny")
install.packages("devtools")
devtools::install_github("satijalab/seurat-data")
+devtools::install_github("vitessce/vitessceAnalysisR")
```
Next, create an output element in the UI with `vitessce_output` and a corresponding server response with `render_vitessce`.
@@ -23,17 +24,21 @@ The value for the `output_id` parameter in the `vitessce_output` function should
```r
library(shiny)
library(vitessceR)
+library(vitessceAnalysisR)
library(SeuratData)
SeuratData::InstallData("pbmc3k")
data("pbmc3k.final")
force(pbmc3k.final)
-w <- SeuratWrapper$new(
- pbmc3k.final,
- cell_embeddings = c("pca", "umap"),
- cell_embedding_names = c("PCA", "UMAP"),
- cell_set_metas = c("seurat_annotations", "seurat_clusters")
+adata_path <- file.path("data", "seurat", "pbmc3k.final.h5ad.zarr")
+vitessceAnalysisR::seurat_to_anndata_zarr(pbmc3k.final, adata_path)
+
+w <- AnnDataWrapper$new(
+ adata_path=adata_path,
+ obs_embedding_paths = c("obsm/X_pca", "obsm/X_umap"),
+ obs_embedding_names = c("PCA", "UMAP"),
+ obs_set_paths = c("obs/seurat_annotations", "obs/seurat_clusters")
)
ui <- fluidPage(
@@ -43,12 +48,12 @@ ui <- fluidPage(
server <- function(input, output, session) {
output$vitessce_visualization <- render_vitessce(expr = {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
dataset <- dataset$add_object(w)
scatterplot <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "PCA")
vc$layout(scatterplot)
- vc$widget()
+ vc$widget(theme="light")
})
}
@@ -80,14 +85,15 @@ SeuratData::InstallData("pbmc3k")
data("pbmc3k.final")
force(pbmc3k.final)
-OUT_DIR <- file.path("data", "shiny")
+BASE_DIR <- file.path("data", "seurat")
+adata_filename <- "pbmc3k.final.h5ad.zarr"
+vitessceAnalysisR::seurat_to_anndata_zarr(pbmc3k.final, file.path(BASE_DIR, adata_filename))
-w <- SeuratWrapper$new(
- pbmc3k.final,
- cell_embeddings = c("pca", "umap"),
- cell_embedding_names = c("PCA", "UMAP"),
- cell_set_metas = c("seurat_annotations", "seurat_clusters"),
- out_dir = OUT_DIR
+w <- AnnDataWrapper$new(
+ adata_path=adata_filename,
+ obs_embedding_paths = c("obsm/X_pca", "obsm/X_umap"),
+ obs_embedding_names = c("PCA", "UMAP"),
+ obs_set_paths = c("obs/seurat_annotations", "obs/seurat_clusters")
)
ui <- fluidPage(
@@ -96,14 +102,20 @@ ui <- fluidPage(
)
server <- function(input, output, session) {
- addResourcePath("vitessce", OUT_DIR)
+ # Ask Shiny to also serve our data files in our local ./data/seurat folder from "/vitessce"
+ addResourcePath("vitessce", BASE_DIR)
+
+ # Render the Vitessce widget into the UI output.
output$vitessce_visualization <- render_vitessce(expr = {
- vc <- VitessceConfig$new("My config")
+
+ # Tell Vitessce that file paths (in AnnDataWrapper) are relative to the BASE_DIR folder.
+ vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config", base_dir = BASE_DIR)
dataset <- vc$add_dataset("My dataset")
dataset <- dataset$add_object(w)
scatterplot <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "PCA")
vc$layout(scatterplot)
+ # Construct a base_url value dynamically based on the Shiny session info.
BASE_URL <- paste0(
session$clientData$url_protocol,
"//",
@@ -113,60 +125,64 @@ server <- function(input, output, session) {
"/vitessce"
)
- vc$widget(serve = FALSE, base_url = BASE_URL)
+ vc$widget(theme = "light", serve = FALSE, base_url = BASE_URL)
})
}
shinyApp(ui, server)
```
-## Style issues
-
-By default, Shiny includes CSS from bootstrap in all apps.
-The bootstrap styles (font sizes in particular) can interfere with the styles for the Vitessce widget.
+## Bidirectional communication example
-One solution is add CSS to reset the font sizes for the root element of the Shiny app:
+Listen for `input$vitessce_on_config_change` events emitted by the Vitessce widget in order to observe user interactions and update the Shiny app in response.
```r
library(shiny)
library(vitessceR)
+library(vitessceAnalysisR)
library(SeuratData)
SeuratData::InstallData("pbmc3k")
data("pbmc3k.final")
force(pbmc3k.final)
-w <- SeuratWrapper$new(
- pbmc3k.final,
- cell_embeddings = c("pca", "umap"),
- cell_embedding_names = c("PCA", "UMAP"),
- cell_set_metas = c("seurat_annotations", "seurat_clusters")
+adata_path <- file.path("data", "seurat", "pbmc3k.final.h5ad.zarr")
+vitessceAnalysisR::seurat_to_anndata_zarr(pbmc3k.final, adata_path)
+
+w <- AnnDataWrapper$new(
+ adata_path=adata_path,
+ obs_embedding_paths = c("obsm/X_pca", "obsm/X_umap"),
+ obs_embedding_names = c("PCA", "UMAP"),
+ obs_set_paths = c("obs/seurat_annotations", "obs/seurat_clusters")
)
ui <- fluidPage(
- tags$head(
- tags$style(HTML("
- html, body {
- font-size: inherit;
- }
- "))
- ),
"Vitessce in a Shiny app",
vitessce_output(output_id = "vitessce_visualization", height = "600px"),
+ verbatimTextOutput("vitessce_config")
)
server <- function(input, output, session) {
output$vitessce_visualization <- render_vitessce(expr = {
- vc <- VitessceConfig$new("My config")
+ vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")
dataset <- dataset$add_object(w)
scatterplot <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "PCA")
vc$layout(scatterplot)
- vc$widget()
+ vc$widget(theme="light")
+ })
+
+ rv <- reactiveValues(current=NULL)
+
+ observeEvent(input$vitessce_on_config_change, {
+ # We can access any values from the coordination space here.
+ # In this example, we access the ID of the currently-hovered cell.
+ rv$current <- input$vitessce_on_config_change[['coordinationSpace']][['obsHighlight']]
})
+
+ output$vitessce_config <- renderPrint({ rv$current })
}
shinyApp(ui, server)
```
-
diff --git a/vignettes/single_cell_experiment.Rmd b/vignettes/single_cell_experiment.Rmd
index 4c2554c..4c79743 100644
--- a/vignettes/single_cell_experiment.Rmd
+++ b/vignettes/single_cell_experiment.Rmd
@@ -32,7 +32,7 @@ sce_zeisel <- runPCA(sce_zeisel)
# Create Vitessce view config
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_object(SCEWrapper$new(
sce_zeisel,
cell_set_metas = c("tissue", "level1class", "level2class"),
diff --git a/vignettes/spatial_experiment.Rmd b/vignettes/spatial_experiment.Rmd
index 5c817d9..dc13b76 100644
--- a/vignettes/spatial_experiment.Rmd
+++ b/vignettes/spatial_experiment.Rmd
@@ -32,7 +32,7 @@ w <- SPEWrapper$new(
)
# Create Vitessce view config
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_object(w)
spatial <- vc$add_view(dataset, Component$SPATIAL)
status <- vc$add_view(dataset, Component$STATUS)
diff --git a/vignettes/web_only/json_remote.Rmd b/vignettes/web_only/json_remote.Rmd
index d294a81..8060264 100644
--- a/vignettes/web_only/json_remote.Rmd
+++ b/vignettes/web_only/json_remote.Rmd
@@ -27,26 +27,24 @@ library(vitessceR)
base_url <- "https://s3.amazonaws.com/vitessce-data/0.0.31/master_release/linnarsson/"
# Create Vitessce view config
-vc <- VitessceConfig$new("Codeluppi et al., Nature Methods 2018")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "Codeluppi et al., Nature Methods 2018")
dataset <- vc$add_dataset("Codeluppi")$add_file(
url = paste0(base_url, "linnarsson.cells.json"),
- data_type = DataType$CELLS,
- file_type = FileType$CELLS_JSON
+ file_type = FileType$CELLS_JSON,
+ options = obj_list(
+ embeddingTypes = c("PCA", "t-SNE")
+ )
)$add_file(
url = paste0(base_url, "linnarsson.cell-sets.json"),
- data_type = DataType$CELL_SETS,
file_type = FileType$CELL_SETS_JSON
)$add_file(
url = paste0(base_url, "linnarsson.molecules.json"),
- data_type = DataType$MOLECULES,
file_type = FileType$MOLECULES_JSON
)$add_file(
url = paste0(base_url, "linnarsson.clusters.json"),
- data_type = DataType$EXPRESSION_MATRIX,
file_type = FileType$CLUSTERS_JSON
)$add_file(
url = paste0(base_url, "linnarsson.raster.json"),
- data_type = DataType$RASTER,
file_type = FileType$RASTER_JSON
)
@@ -60,8 +58,8 @@ scatterplot_pca <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "PCA")
scatterplot_tsne <- vc$add_view(dataset, Component$SCATTERPLOT, mapping = "t-SNE")
status <- vc$add_view(dataset, Component$STATUS)
-cell_sets <- vc$add_view(dataset, Component$CELL_SETS)
-gene_list <- vc$add_view(dataset, Component$GENES)
+cell_sets <- vc$add_view(dataset, Component$OBS_SETS)
+gene_list <- vc$add_view(dataset, Component$FEATURE_LIST)
heatmap <- vc$add_view(dataset, Component$HEATMAP)$set_props(transpose = TRUE)
vc$layout(hconcat(
diff --git a/vignettes/web_only/ome_tiff_remote.Rmd b/vignettes/web_only/ome_tiff_remote.Rmd
index 2fc3c60..0ad4203 100644
--- a/vignettes/web_only/ome_tiff_remote.Rmd
+++ b/vignettes/web_only/ome_tiff_remote.Rmd
@@ -37,7 +37,7 @@ file_options = obj_list(
)
# Create Vitessce view config
-vc <- VitessceConfig$new("My config")
+vc <- VitessceConfig$new(schema_version = "1.0.16", name = "My config")
dataset <- vc$add_dataset("My dataset")$add_file(
data_type = DataType$RASTER,
file_type = FileType$RASTER_JSON,