-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
85 lines (61 loc) · 2.65 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
output: github_document
title: "<img src='inst/Smoppix.jpg' align='centre' height='15%' width='15%'/>SMOPPIX: Single-MOlecule sPatial omics data analysed using the Probabilistic IndeX"
header-includes:
- \usepackage{titling}
- \pretitle{\begin{center}
\includegraphics[width=2in,height=2in]{inst/Smoppix.jpg}\LARGE\\}
- \posttitle{\end{center}}
---
This repo provides code for analyzing single-molecule spatial omics data and cell type location data using probabilistic indices. A simple use-case is shown below, more extensive documentation can be found in the vignette
The package can be installed from GitHub as follows:
```{r installAndLoadGitHub, eval = FALSE}
library(devtools)
install_github("sthawinke/smoppix")
```
```{r install, eval = FALSE, echo = FALSE}
library(Biocmanager)
install("smoppix")
```
Once installed, you can load the package
```{r loadSmoppix}
library(smoppix)
```
Patterns that can be detected by _smoppix_:
<img src='inst/CSR.jpg' align='centre' height='55%' width='55%'/>
<img src='inst/CSRbi.jpg' align='centre' height='55%' width='55%'/>
For illustration, we now load an example dataset, contained in the package. It is in table format, so we first convert it to a _spatstat_ hyperframe.
```{r loadYang}
data(Yang)
hypYang <- buildHyperFrame(Yang,
coordVars = c("x", "y"),
imageVars = c("day", "root", "section")
)
```
The number of unique images found is printed, make sure that this is what you expected. Now to make completely sure the software has understood us, we make an exploratory plot:
```{r explPlot, fig.height = 6}
plotExplore(hypYang)
```
As an example analysis, we estimate the univariate nearest neighbour probabilistic index as a measure of aggregation (clustering):
```{r nn}
nnObj <- estPis(hypYang, pis = "nn", null = "background", verbose = FALSE)
```
We add a variance weighting function to prepare for analysis and plot it:
```{r wf}
nnObj <- addWeightFunction(nnObj, designVars = c("day", "root"))
plotWf(nnObj, pi = "nn")
```
As expected, the weight allotted to the point pattern increases with the number of molecules in it: denser patterns provide more precise estimates of localization patterns.
Next is the inference step: we fit linear mixed models, and show the most significant results:
```{r inference}
allModsNN <- fitLMMs(nnObj, fixedVars = "day", randomVars = "root")
head(getResults(allModsNN, "nn", "Intercept"))
```
Let's make it visual and plot the most significantly aggregated transcripts:
```{r plotTopRes}
plotTopResults(hypYang, allModsNN, pi = "nn")
```
Finally write the results to a spreadsheet:
```{r writeToSpreadsheet, eval = FALSE}
writeToXlsx(allModsNN, file = "myfile.xlsx")
```