knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 5,
  fig.height = 4,
  dpi=200
)

Introduction

The NanoStringExperiment class was inherited from the SummarizedExperiment class. It was designed to encapsulate data and corresponding methods for data generated from NanoString platforms. This class serves as an intermediary class between SummarizedExperiment and NanoString platform-specific classes such as the NanoStringGeoMxSet class from the GeomxTools package. This package is meant to congregate common structures and methods to be used for extension to NanoString platform-specific packages.

There are numerous functions that NanoStringExperiment inherited from the SummarizedExperiment class. It is recommended to learn the SummarizedExperiment class prior to working with NanoStringExperiment objects. You can find these in this link: https://bioconductor.org/packages/release/bioc/html/SummarizedExperiment.html

Loading Packages

Loading the NanoStringExperiment package gives access to corresponding class and methods.

library(NanoStringExperiment)

Building a NanoStringExperiment object from NanoString data

Create a new NanoStringExperiment object using an expression matrix (assayData), phenoData (AnnotatedDataFrame containing sample phenotypic metadata), protocolData (AnnotatedDataFrame containing sample protocol metadata), featureData (AnnotatedDataFrame containing feature metadata), experimentData (list or MIAME object containing experiment details), annotation (list containing annotation file names used), dimLabels (list of variables used as row and column keys in object).

data(exampleNSEData)
demoExperiment <- NanoStringExperiment(
    assayData = testAssayData,
    phenoData = testPhenoData,
    protocolData = testProtocolData,
    featureData = testFeatureData,
    experimentData = testExperimentData,
    annotation = testAnnotation,
    dimLabels = testDimLabels)
demoExperiment

Slots and accessors

The NanoStringExperiment class inherits the slots and accessors available with any SummarizedExperiment class. There are a few added slots for data commonly used with NanoString experiments. Accessor and replacement methods have been added for these new slots.

assays(demoExperiment)
assay(demoExperiment, "exprs")[1:2, 1:2]
assay(demoExperiment, "exprsShift") <- assay(demoExperiment, "exprs") + 1
assay(demoExperiment, "exprsShift")[1:2, 1:2]

head(colData(demoExperiment))[1:2, ]
head(rowData(demoExperiment))[1:2, ]

#Version of package when object created
classVersion(demoExperiment)

annotation(demoExperiment)

design(demoExperiment) <- ~ `cell_line`
design(demoExperiment)

Subsetting

Bracket notation and the subset method are two methods for subsetting NanoStringExperiment objects. This package also includes custom NanoString subset functions such as to subset be negative features.

demoExperiment[1:5, ]
demoExperiment[colData(demoExperiment)[["cell_line"]] == "HS578T", ]

subset(demoExperiment, 
    subset = CodeClass == "Negative", 
    select = cell_line == "HS578T")

negativeControlSubset(demoExperiment)
endogenousSubset(demoExperiment)

Apply and summarize

As with a SummarizedExperiment object, you can apply functions across assay data matrices using the apply function. The NanoStringExperiment package adds additional apply and summarize functions to facilitate working with the object.

head(assayDataApply(demoExperiment, MARGIN = 2, FUN = mean))

head(esBy(demoExperiment, 
            GROUP = "cell_line", 
            FUN = function(x) { 
              assayDataApply(x, MARGIN = 1, FUN = mean, elt = "exprs") 
            }))

summary(demoExperiment, MARGIN = 2, GROUP = "cell_line")[1:2]

with(demoExperiment, table(CodeClass))

head(munge(demoExperiment, mapping = ~`cell_line` + GeneMatrix))

About this session

sessionInfo()


Nanostring-Biostats/NanoStringExperiment documentation built on April 28, 2022, 6:24 a.m.