Skip to content

Commit deef63f

Browse files
committed
stash status
1 parent b742f42 commit deef63f

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

demo/csama.qmd

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ library(sf)
77
library(dplyr)
88
library(ggplot2)
99
library(anndataR)
10+
library(scrapper)
1011
library(patchwork)
1112
library(reticulate)
1213
library(SpatialData)
@@ -41,7 +42,11 @@ url <- "https://zenodo.org/records/20083116/files/BC_xenium_sdata_lowres.zarr.zi
4142
dir <- dirname(zip <- tempfile("sd", fileext=".zarr.zip"))
4243
download.file(url, zip, quiet=TRUE)
4344
fnm <- unzip(zip, exdir=dir)
44-
(sd <- SpatialData::readSpatialData(dirname(fnm[1])))
45+
(sd <- readSpatialData(dirname(fnm[1])))
46+
```
47+
48+
```{r}
49+
4550
```
4651

4752
### analysis
@@ -56,8 +61,40 @@ We'll start out in Python and load the data into a `spatialdata` object:
5661

5762
### processing
5863

64+
The `SpatialData` object contains a single `table` element, represented as a
65+
`r BiocStyle::Biocpkg("SingleCellExperiment")`, annotating `cell_boundaries`:
66+
67+
```{r get-tbl}
68+
(se <- tables(sd)[[1]])
69+
```
70+
71+
We can perform standard processing tasks using tools already
72+
available in R/Bioc, e.g., `r BiocStyle::Biocpkg("scrapper")`:
73+
74+
```{r pro}
75+
# standard 'scrapper' processing:
76+
# - log-library size normalization
77+
# - highly variable gene selection
78+
# - principal component analysis
79+
# - shared-nearest neighbor graph construction
80+
# - community detection using Leiden algorithm
81+
assayNames(se) <- "counts"
82+
se <- normalizeRnaCounts.se(se)
83+
se <- chooseRnaHvgs.se(se, top=2e3)
84+
se <- runPca.se(se, features=rowData(se)$hvg)
85+
se <- clusterGraph.se(se, method="leiden", resolution=0.5)
86+
```
87+
5988
### downstream
6089

90+
Let's start out by visualization the histopathology image,
91+
i.e., the hematoxylin and eosin (H\&E) staining:
92+
93+
```{r plt-hne}
94+
cl <- rep(list(c(0, 1/3)), 3) # contrast
95+
plotSpatialData() + plotImage(sd, cl=cl)
96+
```
97+
6198
### appendix
6299

63100
::: {.callout-note icon=false, collapse=true}

0 commit comments

Comments
 (0)