Skip to contents

The following is an example of usage of the widget with JSON files. In this example, the JSON files are stored on a remote AWS S3 bucket. For information about remote file hosting, please visit the Hosting Data page of the main Vitessce documentation website.

To get started with this example, install the dependencies:

install.packages("devtools")
devtools::install_github("vitessce/vitessce-r")

Next, configure the Vitessce widget.

Add JSON files to the dataset using the add_file function. The add_file function returns the updated dataset, allowing the function calls to be chained.

library(vitessce)

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")
dataset <- vc$add_dataset("Codeluppi")$add_file(
  url = paste0(base_url, "linnarsson.cells.json"),
  data_type = DataType$CELLS,
  file_type = FileType$CELLS_JSON
)$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
)

desc <- vc$add_view(dataset, Component$DESCRIPTION)
desc <- desc$set_props(description = "Codeluppi et al., Nature Methods 2018: Spatial organization of the somatosensory cortex revealed by osmFISH.")

spatial <- vc$add_view(dataset, Component$SPATIAL)
spatial_layers <- vc$add_view(dataset, Component$LAYER_CONTROLLER)

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)
heatmap <- vc$add_view(dataset, Component$HEATMAP)$set_props(transpose = TRUE)

vc$layout(hconcat(
  vconcat(vconcat(desc, status), spatial_layers),
  vconcat(heatmap, spatial),
  vconcat(scatterplot_tsne, scatterplot_pca),
  vconcat(gene_list, cell_sets)
))

# Render the Vitessce widget
vc$widget(theme = "light", width = "100%")