seqFISH Spatial Data Workflow

Introduction

The SpatialExperiment package provides classes and methods for single cell spatial data handling.

This vignettes shows how to create a SpatialExperiment class by loading a seqFISH spatial dataset.

The seqFISH data are part of the BIRS Biointegration Workshop Hackathon previously published in Zhu et al. 2018.

Installation

if(!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("SpatialExperiment")

Loading data and libraries

We stored the provided seqFish and scRNA-seq data inside the SpatialExperiment external data seqFISH folder.

library(SpatialExperiment)

seqFISH data

fishCoordFile <- system.file(file.path("extdata", "seqFISH",
                            "fcortex.coordinates.txt"), 
                            package="SpatialExperiment")
fishCoordinates <- read.table(fishCoordFile, header=FALSE, sep=" ")
colnames(fishCoordinates) <- c("Cell_ID", "Irrelevant", "x", "y")

fishCellLabsFile <- system.file(file.path("extdata", "seqFISH", 
                            "seqfish_cell_labels.tsv"),
                            package="SpatialExperiment")
fishCellLabels <- read.table(file=fishCellLabsFile, header=FALSE, sep="\t")
colnames(fishCellLabels) <- c("Cell_ID", "cluster", "class", "classID", 
                                "Irrelevant", "Prob")
fishFeatCountsFile <- system.file(file.path("extdata", "seqFISH",
                            "seqfish_normalized_cortex_b2_testing.txt"), 
                            package="SpatialExperiment")
fishFeaturesCounts <- read.table(file=fishFeatCountsFile, 
                                header=FALSE, sep="\t", row.names=1)

SpatialExperiment package

Class handling

We can load the data inside the SpatialExperiment class. We then use the show method for looking at the class description.

se <- SpatialExperiment(rowData=rownames(fishFeaturesCounts),
                        colData=fishCellLabels,
                        assays=SimpleList(counts=as.matrix(fishFeaturesCounts)),
                        spatialCoords=fishCoordinates)
show(se)

Spatial Coordinates

With the aid of the spatialCoords methods we can get and set the spatial coordinates.

Getter

spatialCoords(se)

Setter

We create a fake fish coordinates data frame and overwrite the old one, showing that the y coordinates are identical to the x ones.

fakeFishCoords <- cbind(fishCoordinates[,c(1:3)], fishCoordinates[,3])
colnames(fakeFishCoords) <- c("Cell_ID", "Irrelevant", "x", "y")
spatialCoords(se) <- fakeFishCoords
spatialCoords(se)
sessionInfo()


Try the SpatialExperiment package in your browser

Any scripts or data that you put into this service are public.

SpatialExperiment documentation built on Nov. 8, 2020, 7:35 p.m.