Diff of /docs/moleculeanalysis.Rmd [000000] .. [413088]

Switch to unified view

a b/docs/moleculeanalysis.Rmd
1
---
2
title: "Molecule Analysis"
3
output: 
4
  html_document:
5
    toc: true
6
    toc_depth: 4
7
    toc_float:
8
      collapsed: false
9
      smooth_scroll: false
10
---
11
12
<style>
13
.title{
14
  display: none;
15
}
16
body {
17
  text-align: justify
18
}
19
.center {
20
  display: block;
21
  margin-left: auto;
22
  margin-right: auto;
23
}
24
table, th, td {
25
  border-collapse: collapse;
26
  align-self: center;
27
  padding-right: 10px;
28
  padding-left: 10px;
29
}
30
</style>
31
32
```{css, echo=FALSE}
33
.watch-out {
34
  color: black;
35
}
36
```
37
38
```{r setup, include=FALSE}
39
# use rmarkdown::render_site(envir = knitr::knit_global())
40
knitr::opts_chunk$set(highlight = TRUE, echo = TRUE)
41
```
42
43
<br>
44
45
# Xenium Breast Cancer Data
46
47
VoltRon is an end-to-end spatial omic analysis package which also supports investigating spatial points in sub-cellular resolution, including those that are based on Fluorescence in situ hybrizrization where one can spatially locate each individual molecule that are hybridrized. 
48
49
In this use case, we analyse readouts of the experiments conducted on example tissue sections analysed by the [Xenium In Situ](https://www.10xgenomics.com/platforms/xenium) platform. Two tissue sections of 5 $\mu$m tickness are derived from a single formalin-fixed, paraffin-embedded (FFPE) breast cancer tissue block. More information on the spatial datasets and the study can be also be found on the [BioArxiv preprint](https://www.biorxiv.org/content/10.1101/2022.10.06.510405v1).
50
 
51
You can import these readouts from the [10x Genomics website](https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast) (specifically, import **In Situ Replicate 1/2**). Alternatively, you can **download a zipped collection of Xenium readouts** from [here](https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/SpatialDataAlignment/Xenium_vs_Visium/10X_Xenium_Visium.zip). 
52
53
<br>
54
55
## Building VoltRon objects
56
57
VoltRon includes built-in functions for converting readouts of Xenium experiments into VoltRon objects. The **importXenium** function locates all readout documents under the output folder of the Xenium experiment, and forms a VoltRon object. In this case, the Xenium data includes two assays (in the same layer) where one is the cell segmentation based cell profile data and the other is the pure molecule assay where the identity (gene of origin) of RNA molecules are given.
58
59
```{r eval = FALSE, class.source="watch-out"}
60
library(VoltRon)
61
Xen_R1 <- importXenium("Xenium_R1/outs", sample_name = "XeniumR1", import_molecules = TRUE)
62
Xen_R1
63
```
64
65
```
66
VoltRon Object 
67
XeniumR1: 
68
  Layers: Section1 
69
Assays: Xenium(Main) Xenium_mol 
70
```
71
72
<br>
73
74
## Ondisk Support **(Optional)**
75
76
You can also save the imported VoltRon object to disk and still accomplish analysis on molecule datasets.
77
78
```{r eval = FALSE, class.source="watch-out"}
79
Xen_R1 <- saveVoltRon(Xen_R1, format = "HDF5VoltRon", 
80
                      output = "Xen_R1/", replace = TRUE)
81
```
82
83
The disk-backed data can be loaded once saved on disk again
84
85
```{r eval = FALSE, class.source="watch-out"}
86
Xen_R1_disk <- loadVoltRon("Xen_R1/")
87
88
```
89
90
<br>
91
92
## Spatial Visualization
93
94
With **vrSpatialPlot**, we can visualize Xenium experiments in subcellular context. We first visualize mRNAs of ACTA2, a marker for smooth muscle cell actin, and other markers found in the breast cancer tissue sample. We can interactively select a subset of interest within the tissue section and visualize the localization of these transcripts. Here we subset a ductal carcinoma niche, and visualize mRNAs of four genes. 
95
96
```{r eval = FALSE, class.source="watch-out"}
97
Xen_R1_subset <- subset(Xen_R1, interactive = TRUE)
98
Xen_R1_subset <- Xen_R1_subset$subsets[[1]]
99
vrSpatialPlot(Xen_R1_subset, assay = "Xenium_mol", group.by = "gene",
100
              group.id = c("ACTA2", "KRT15", "TACSTD2", "CEACAM6"), pt.size = 0.2, legend.pt.size = 5)
101
```
102
103
<img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_transcripts_visualize.png" class="center">
104
105
<br>
106
107
We can use the **n.tile** argument to divide the count of selected group.ids (e.g. genes here) into hexagonal bins. We will use this argument to divide the x and y-axis into 100 tiles and aggregate transcript counts from select **group.id**
108
109
```{r eval = FALSE, class.source="watch-out"}
110
vrSpatialPlot(Xen_R1_subset, assay = "Xenium_mol", group.by = "gene", group.id = "ACTA2",
111
              legend.pt.size = 5, n.tile = 100, background.color = "black")
112
```
113
114
<img width="70%" height="70%" src="https://bimsbstatic.mdc-berlin.de/landthaler/VoltRon/Package/images/cellspot_transcripts_visualize_bins.png" class="center">
115
116
<br>