vignettes/seqFISH.Rmd
seqFISH.Rmd
To facilitate the implementation of methodologies and the spatial data handling in R, we designed a new class named SpatialExperiment
. This class inherits from the popular Bioconductor class SingleCellExperiment
and extend it with specific slots and get/set methods for spatial data.
Here is a schematics of the organization of the SpatialExperiment
class.
library(devtools) install_github("drighelli/SpatialExperiment")
## SingleCel... (NA -> 1.10.1) [CRAN]
##
checking for file ‘/tmp/Rtmpfchnqb/remotes10974a8b93a5/drighelli-SpatialExperiment-57a3fd6/DESCRIPTION’ ...
✔ checking for file ‘/tmp/Rtmpfchnqb/remotes10974a8b93a5/drighelli-SpatialExperiment-57a3fd6/DESCRIPTION’
##
─ preparing ‘SpatialExperiment’:
##
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
##
─ checking for LF line-endings in source and make files and shell scripts
##
─ checking for empty or unneeded directories
##
─ building ‘SpatialExperiment_0.99.3.tar.gz’
##
##
install_github("drighelli/SingleCellMultiModal", ref="BIRSBIO20_seqFISH")
##
##
checking for file ‘/tmp/Rtmpfchnqb/remotes10972476a674/drighelli-SingleCellMultiModal-53bbae1/DESCRIPTION’ ...
✔ checking for file ‘/tmp/Rtmpfchnqb/remotes10972476a674/drighelli-SingleCellMultiModal-53bbae1/DESCRIPTION’
##
─ preparing ‘SingleCellMultiModal’:
##
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
##
─ checking for LF line-endings in source and make files and shell scripts
##
─ checking for empty or unneeded directories
##
─ building ‘SingleCellMultiModal_1.1.5.tar.gz’
##
##
The dataset consists of two data types, seqFISH and scRNA-seq data was provided by @Tasic2016adult.
We stored the seqFISH data into the Bioconductor SingleCellMultiModal package to facilitate the accessibility for further use.
Here we show a schematic of how the dataset is organized once downloading it with the seqFISH
function, as illustrated in the next steps.
The user can see the available dataset by using the default options
SingleCellMultiModal::seqFISH(dataType="mouse_visual_cortex", modes="*", dry.run=TRUE)
## Available data modes for
## mouse_visual_cortex:
## scRNA_Counts, scRNA_Labels,
## seqFISH_Coordinates, seqFISH_Counts,
## seqFISH_Labels
Or simply by running:
mse <- SingleCellMultiModal::seqFISH(dataType="mouse_visual_cortex", modes="*", dry.run=FALSE)
## using temporary cache /tmp/Rtmpfchnqb/BiocFileCache
## snapshotDate(): 2020-07-10
## Working on: scRNA_Counts
## see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
## downloading 1 resources
## retrieving 1 resource
## loading from cache
## Working on: scRNA_Labels
## see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
## downloading 1 resources
## retrieving 1 resource
## loading from cache
## Working on: seqFISH_Coordinates
## see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
## downloading 1 resources
## retrieving 1 resource
## loading from cache
## Working on: seqFISH_Counts
## see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
## downloading 1 resources
## retrieving 1 resource
## loading from cache
## Working on: seqFISH_Labels
## see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
## downloading 1 resources
## retrieving 1 resource
## loading from cache
mse
## A MultiAssayExperiment object of 2 listed
## experiments with user-defined names and respective classes.
## Containing an ExperimentList class object of length 2:
## [1] seqFISH: SpatialExperiment with 113 rows and 1597 columns
## [2] scRNAseq: SingleCellExperiment with 113 rows and 1723 columns
## Functionality:
## experiments() - obtain the ExperimentList instance
## colData() - the primary/phenotype DataFrame
## sampleMap() - the sample coordination DataFrame
## `$`, `[`, `[[` - extract colData columns, subset, or experiment
## *Format() - convert into a long or wide DataFrame
## assays() - convert ExperimentList to a SimpleList of matrices
## exportClass() - save all data to files
Example with actual data:
experiments(mse)
## ExperimentList class object of length 2:
## [1] seqFISH: SpatialExperiment with 113 rows and 1597 columns
## [2] scRNAseq: SingleCellExperiment with 113 rows and 1723 columns
Check row annotations:
rownames(mse)
## CharacterList of length 2
## [["seqFISH"]] abca15 abca9 acta2 adcy4 aldh3b2 ... wrn zfp182 zfp715 zfp90
## [["scRNAseq"]] abca15 abca9 acta2 adcy4 aldh3b2 ... wrn zfp182 zfp715 zfp90
Take a peek at the sampleMap
:
sampleMap(mse)
## DataFrame with 3320 rows and 3 columns
## assay primary colname
## <factor> <character> <character>
## 1 seqFISH V2 V2
## 2 seqFISH V3 V3
## 3 seqFISH V4 V4
## 4 seqFISH V5 V5
## 5 seqFISH V6 V6
## ... ... ... ...
## 3316 scRNAseq V1720 V1720
## 3317 scRNAseq V1721 V1721
## 3318 scRNAseq V1722 V1722
## 3319 scRNAseq V1723 V1723
## 3320 scRNAseq V1724 V1724
The scRNA-seq data are accessible with $scRNAseq
, which returns a SingleCellExperiment class object, with all its associated methods.
experiments(mse)$scRNAseq
## class: SingleCellExperiment
## dim: 113 1723
## metadata(0):
## assays(1): counts
## rownames(113): abca15 abca9 ... zfp715 zfp90
## rowData names(1): X
## colnames(1723): V2 V3 ... V1723 V1724
## colData names(3): V1 V2 V3
## reducedDimNames(0):
## altExpNames(0):
Otherwhise the assay
function can be used to access the scRNAseq assay stored in the mse
MultiAssayExperiment object.
head(assay(mse, "scRNAseq"))[,1:4]
## V2 V3 V4 V5
## abca15 11 42 17 42
## abca9 22 46 22 46
## acta2 15 47 15 42
## adcy4 12 45 12 45
## aldh3b2 27 49 27 49
## amigo2 23 43 101 43
The seq-FISH data are accessible with $seqFISH
, which returns a SpatialExperiment class object.
experiments(mse)$seqFISH
## class: SpatialExperiment
## dim: 113 1597
## metadata(0):
## assays(1): counts
## rownames(113): abca15 abca9 ... zfp715 zfp90
## rowData names(1): X
## colnames(1597): V2 V3 ... V1597 V1598
## colData names(6): ID cluster ... Irrelevant Prob
## reducedDimNames(0):
## altExpNames(0):
## spatialCoordinates(4): ID Irrelevant x y
Otherwhise the assay
function can be used to access the seqFISH assay stored in the mse
MultiAssayExperiment object.
head(assay(mse, "seqFISH"))[,1:4]
## V2 V3 V4 V5
## abca15 68 49 50 39
## abca9 41 42 38 36
## acta2 25 23 16 21
## adcy4 39 54 37 18
## aldh3b2 101 47 41 52
## amigo2 93 64 93 93
Spatial coordinates can be retrieved with spatialCoords
function on the SpatialExperiment object.
(sc <- spatialCoords(experiments(mse)$seqFISH))
## DataFrame with 1597 rows and 4 columns
## ID Irrelevant x y
## <integer> <integer> <numeric> <numeric>
## 1 1 100 265.76 -231.14
## 2 2 100 290.48 -261.52
## 3 3 100 257.12 -133.35
## 4 4 100 753.46 -261.14
## 5 5 100 700.01 -169.05
## ... ... ... ... ...
## 1593 1593 100 1129.06 -1669.57
## 1594 1594 100 1044.02 -1872.66
## 1595 1595 100 1388.76 -1880.47
## 1596 1596 100 5172.85 -1340.96
## 1597 1597 100 5220.60 -1523.37
They can also be stored by using the <-
operator.
fakeCoords <- cbind(sc[,c(1:3)], sc[,3]) colnames(fakeCoords)[4] <- "y" spatialCoords(experiments(mse)$seqFISH) <- fakeCoords spatialCoords(experiments(mse)$seqFISH)
## DataFrame with 1597 rows and 4 columns
## ID Irrelevant x y
## <integer> <integer> <numeric> <numeric>
## 1 1 100 265.76 265.76
## 2 2 100 290.48 290.48
## 3 3 100 257.12 257.12
## 4 4 100 753.46 753.46
## 5 5 100 700.01 700.01
## ... ... ... ... ...
## 1593 1593 100 1129.06 1129.06
## 1594 1594 100 1044.02 1044.02
## 1595 1595 100 1388.76 1388.76
## 1596 1596 100 5172.85 5172.85
## 1597 1597 100 5220.60 5220.60
Direct access to the colnames of the spacial coordinates with spatialCoordsNames
function.
spatialCoordsNames(experiments(mse)$seqFISH)
## [1] "ID" "Irrelevant" "x" "y"
## R version 4.0.0 (2020-04-24)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.4 LTS
##
## Matrix products: default
## BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] parallel stats4 stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] SingleCellMultiModal_1.1.5 SpatialExperiment_0.99.3
## [3] SingleCellExperiment_1.10.1 MultiAssayExperiment_1.15.2
## [5] SummarizedExperiment_1.19.6 DelayedArray_0.15.7
## [7] matrixStats_0.56.0 Matrix_1.2-18
## [9] Biobase_2.49.0 GenomicRanges_1.41.5
## [11] GenomeInfoDb_1.25.8 IRanges_2.23.10
## [13] S4Vectors_0.27.12 BiocGenerics_0.35.4
## [15] devtools_2.3.1 usethis_1.6.1
## [17] BiocStyle_2.17.0
##
## loaded via a namespace (and not attached):
## [1] bitops_1.0-6 fs_1.4.2
## [3] bit64_0.9-7.1 httr_1.4.2
## [5] rprojroot_1.3-2 tools_4.0.0
## [7] backports_1.1.8 R6_2.4.1
## [9] DBI_1.1.0 withr_2.2.0
## [11] tidyselect_1.1.0 prettyunits_1.1.1
## [13] processx_3.4.3 bit_1.1-15.2
## [15] curl_4.3 compiler_4.0.0
## [17] cli_2.0.2 desc_1.2.0
## [19] bookdown_0.20 callr_3.4.3
## [21] rappdirs_0.3.1 pkgdown_1.5.1
## [23] stringr_1.4.0 digest_0.6.25
## [25] rmarkdown_2.3 XVector_0.29.3
## [27] pkgconfig_2.0.3 htmltools_0.5.0
## [29] sessioninfo_1.1.1 dbplyr_1.4.4
## [31] fastmap_1.0.1 rlang_0.4.7
## [33] RSQLite_2.2.0 shiny_1.5.0
## [35] generics_0.0.2 dplyr_1.0.0
## [37] RCurl_1.98-1.2 magrittr_1.5
## [39] GenomeInfoDbData_1.2.3 Rcpp_1.0.5
## [41] fansi_0.4.1 lifecycle_0.2.0
## [43] stringi_1.4.6 yaml_2.2.1
## [45] MASS_7.3-51.6 zlibbioc_1.35.0
## [47] pkgbuild_1.1.0 BiocFileCache_1.13.0
## [49] AnnotationHub_2.21.1 grid_4.0.0
## [51] blob_1.2.1 promises_1.1.1
## [53] ExperimentHub_1.15.0 crayon_1.3.4
## [55] lattice_0.20-41 knitr_1.29
## [57] ps_1.3.3 pillar_1.4.6
## [59] pkgload_1.1.0 glue_1.4.1
## [61] BiocVersion_3.12.0 evaluate_0.14
## [63] remotes_2.2.0 BiocManager_1.30.10
## [65] vctrs_0.3.2 httpuv_1.5.4
## [67] testthat_2.3.2 purrr_0.3.4
## [69] assertthat_0.2.1 xfun_0.15
## [71] mime_0.9 xtable_1.8-4
## [73] later_1.1.0.1 tibble_3.0.3
## [75] AnnotationDbi_1.51.1 memoise_1.1.0
## [77] ellipsis_0.3.1 interactiveDisplayBase_1.27.5