---
title: "Remote AnnData Demo"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Remote AnnData Demo}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

### Setup

We install the `blosc` package to be able to use Blosc as the decompression codec, since the data we want to load is Blosc-compressed.

```r
install.packages("blosc")
```

### Demo

```r
library(pizzarr)

# The path to the root of the AnnData-Zarr store.
root <- "https://data-1.vitessce.io/0.0.33/main/human-lymph-node-10x-visium/human_lymph_node_10x_visium.h5ad.zarr"

# Open the AnnData-Zarr store as an HttpStore.
store <- HttpStore$new(root)
g <- zarr_open_group(store)

obs_attrs <- g$get_item("obs")$get_attrs()$to_list()
index_colname <- obs_attrs[['_index']]
index_arr <- g$get_item(paste0("obs/", index_colname))$get_item("...")$data

umap_arr <- g$get_item("obsm/X_umap")$get_item("...")$data
cluster_arr <- g$get_item("obs/clusters")$get_item("...")$data

print(dim(umap_arr))
# [1] 3861    2

print(dim(index_arr))
# [1] 3861

print(dim(index_arr))
# [1] 3861

plot(x=umap_arr[,1], y=umap_arr[,2], col=cluster_arr)
```
