---
title: "seqFISH Mouse Visual Cortex"
author: "Dario Righelli"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
    BiocStyle::html_document:
      toc_float: true
vignette: >
    %\VignetteIndexEntry{seqFISH Mouse Visual Cortex}
    %\VignetteEncoding{UTF-8}
    %\VignetteEngine{knitr::rmarkdown}
package: SingleCellMultiModal
bibliography: ../inst/REFERENCES.bib
editor_options:
  chunk_output_type: console
---

# Installation

```{r,eval=FALSE}
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("SingleCellMultiModal")
```

## Load packages

```{r,include=TRUE, results="hide", message=FALSE, warning=FALSE}
library(MultiAssayExperiment)
library(SpatialExperiment)
library(SingleCellMultiModal)
```


# seq-FISH dataset

The dataset consists of two data types,
seq-FISH data was provided by @Zhu2018identification, while scRNA-seq data
was provided by @Tasic2016adult.

Data have been retrievedas part of the
[Hackathon](https://github.com/BIRSBiointegration/Hackathon/tree/master/seqFISH)
in the
[Mathematical Frameworks for Integrative Analysis of Emerging Biological DataTypes](https://www.birs.ca/events/2020/5-day-workshops/20w5197) workshop.

## Downloading datasets

The user can see the available dataset by using the default options

```{r}
seqFISH(
    DataType="mouse_visual_cortex", modes="*", dry.run=TRUE, version="2.0.0"
)
```

Or simply by running:

```{r}
seqfish <- seqFISH(
    DataType="mouse_visual_cortex", modes="*", dry.run=FALSE, version="2.0.0"
)
seqfish
```

Extract the list of experiments _without_ the associated colData.

```{r}
experiments(seqfish)
```

## Exploring the data structure

Check row annotations for all experiments:

```{r}
rownames(seqfish)
```

Take a peek at the `sampleMap` (graph representation of assays, cells, and
barcodes):

```{r}
sampleMap(seqfish)
```

## Visualize matching cell identifiers across assays

```{r}
upsetSamples(seqfish)
```

This shows that about 1597 cells match across both modalities / assays.

## scRNA-seq data

The scRNA-seq data are accessible with `$scRNAseq`, which returns a
*SingleCellExperiment* class object, with all its associated methods.

```{r}
seqfish[["scRNAseq"]]
```

Otherwhise the `assay` function can be used to access the *scRNAseq* assay
stored in the `seqfish` *MultiAssayExperiment* object.

```{r}
head(assay(seqfish, "scRNAseq"))[,1:4]
```

## seq-FISH data

The seq-FISH data are accessible with `$seqFISH`, which returns a
**SpatialExperiment** class object.

```{r}
seqfish[["seqFISH"]]
```

Otherwhise the `assay` function can be used to access the *seqFISH* assay
stored in the `seqfish` *MultiAssayExperiment* object.

```{r}
head(assay(seqfish, "seqFISH"))[,1:4]
```

Spatial data can be retrieved with `spatialData` function on the
*SpatialExperiment* object.

```{r}
(sd <- spatialData(seqfish[["seqFISH"]]))
```

Spatial coordinates within the spatial data can be retrieved in matrix form
with `spatialCoords` function on the *SpatialExperiment* object.

```{r}
head(sc <- spatialCoords(seqfish[["seqFISH"]]))
```

Direct access to the colnames of the spacial coordinates with
`spatialCoordsNames` function.

```{r}
spatialCoordsNames(seqfish[["seqFISH"]])
```


## Other data version

The provided seqFISH dataset comes out in two different versions:

* 1.0.0 - provides the same seqFISH data as shown in the rest of this
vignette, but it returns the full normalized scRNA-seq data matrix (with
labels), as released from the original authors on the GEO database.
* 2.0.0 - provides the same seqFISH data as shown in the rest of this
vignette, but it returns a processed subset of the original scRNA-seq data,
providing only the same genes present in the seqFISH data matrix.

### Data version 1.0.0

The full scRNA-seq data matrix is 24057 rows x 1809 columns.

To access the v1.0.0 simply run

```{r}
seqFISH(
    DataType="mouse_visual_cortex", modes="*", dry.run=FALSE, version="1.0.0"
)
```

# Session Info

```{r, tidy=TRUE}
sessionInfo()
```

