Simple example of use of the R object ExpressionSet, ideal for the storage of gene expression or similarly structured omic data.

knitr::opts_chunk$set(message=FALSE, warning=FALSE, eval=TRUE)
devtools::load_all(".")
library(Biobase)
library(BS831)
library(Biobase) # The package with the ExpressionSet definition, among others

The ExpressionSet object

An expression set is a data object consisting of three entities: the expression matrix (exprs), the phenotye data (pData), and the feature data (fData).

ExpressionSet example Figure 1: ExpressionSet object

We upload an expression set already available. It corresponds to a subset of samples from a gene expression dataset of head and neck squamous carcinoma (HNSC) primary tissue samples from the TCGA project.

# Load toy dataset
data(HNSC_RNASeq_toy_ES)

## if BS831 not installed you can read the data from the Google Drive folder:
## HNSC_RNASeq_toy_ES <- readRDS(file.path(Sys.getenv("OMPATH"),"data/HNSC_RNASeq_toy_ES.rds"))

## rename for easier handling
hnsc <- HNSC_RNASeq_toy_ES

dim(hnsc)        # the expression data
dim(Biobase::pData(hnsc)) # the phenotypic annotation
head(Biobase::pData(hnsc))

dim(Biobase::fData(hnsc)) # the genes' annotation
head(Biobase::fData(hnsc))

One of the advantages of using an ExpressionSet is that the three component objects are always properly paired, and subsetting can be carried out straightforwardly.

tmp <- hnsc[1:100,1:10]
dim(tmp)        # the expression data
dim(Biobase::pData(tmp)) # the phenotypic annotation
dim(Biobase::fData(tmp)) # the genes' annotation

The SummarizedExperiment object

SummarizedExperiment example Figure 2: SummarizedExperiment object [source].

The ExpressionSet is generally used for array-based experiments and gene expression data, where the rows are features, and the SummarizedExperiment is generally used for sequencing-based experiments, where the rows are GenomicRanges.

Mapping from ExpressionSet to SummarizedExperiment

It is possible to easily map an ExpressionSet to a SummarizedExperiment.

library(SummarizedExperiment)
sexp <- SummarizedExperiment::makeSummarizedExperimentFromExpressionSet(hnsc)

names(assays(sexp))
head(SummarizedExperiment::colData(sexp)) # equivalent to pData
head(SummarizedExperiment::rowData(sexp)) # equivalent to fData


montilab/BS831 documentation built on April 17, 2024, 4:51 p.m.