makeSummarizedExperiment: Make Summarized Experiment

Description Usage Arguments Details Value Note See Also Examples

View source: R/makeSummarizedExperiment.R

Description

This function is a utility wrapper for SummarizedExperiment::SummarizedExperiment() that provides automatic subsetting for row and column data, as well as automatic handling of transgenes and spike-ins. Additionally, it improves upon the standard constructor by slotting useful session information into the S4Vectors::metadata() slot:

Usage

1
2
3
makeSummarizedExperiment(assays, rowRanges = NULL, rowData = NULL,
  colData = NULL, metadata = NULL, transgeneNames = NULL,
  spikeNames = NULL)

Arguments

assays

list. RNA-seq count matrices, which must have matching dimensions. Counts can be passed in either a dense matrix (matrix) or sparse matrix (sparseMatrix).

rowRanges

GRanges or NULL. Recommended. Metadata describing the assay rows. If defined, must contain genomic ranges. Can be left NULL if the genome is poorly annotated and/or ranges aren't available from AnnotationHub.

rowData

DataFrame or NULL. Not recommended. Metadata describing the assay rows, if genomic ranges are not available.

colData

DataFrame data.frame, or matrix. Metadata describing the assay columns. For bulk RNA-seq, this data describes the samples. For single-cell RNA-seq, this data describes the cells.

metadata

list or NULL. Metadata.

transgeneNames

character or NULL. Vector indicating which assay() rows denote transgenes (e.g. EGFP, TDTOMATO).

spikeNames

character or NULL. Vector indicating which assay() rows denote spike-in sequences (e.g. ERCCs).

Details

Value

Note

Column and rows always return sorted alphabetically.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
library(IRanges)
library(GenomicRanges)
library(SummarizedExperiment)

## Rows (genes)
genes <- c(
    "EGFP",  # transgene
    paste0("gene", seq_len(3L))
)
print(genes)

## Columns (samples)
samples <- paste0("sample", seq_len(4L))
print(samples)

## Counts (assay)
counts <- matrix(
    data = seq_len(16L),
    nrow = 4L,
    ncol = 4L,
    dimnames = list(genes, samples)
)
## Primary assay must be named "counts".
assays <- list(counts = counts)
print(assays)

## Row data (genomic ranges)
rowRanges <- GRanges(
    seqnames = rep("1", times = 3L),
    ranges = IRanges(
        start = seq(from = 1L, to = 201L, by = 100L),
        end = seq(from = 100L, to = 300L, by = 100L)
    )
)
## Note that we haven't defined the transgene here.
## It will be handled automatically in the function call.
names(rowRanges) <- paste0("gene", seq_len(3L))
print(rowRanges)

## Column data
colData <- DataFrame(
    genotype = rep(c("wildtype", "knockout"), times = 1L, each = 2L),
    age = rep(c(3L, 6L), 2L),
    row.names = samples
)
print(colData)

## Note that this returns with the dimnames sorted.
x <- makeSummarizedExperiment(
    assays = assays,
    rowRanges = rowRanges,
    colData = colData,
    transgeneNames = "EGFP"
)
print(x)

steinbaugh/basejump.experiment documentation built on Nov. 5, 2018, 10:36 p.m.