View source: R/makeSummarizedExperiment.R
| makeSummarizedExperiment | R Documentation | 
This function is a utility wrapper for SummarizedExperiment that provides
automatic subsetting for row and column data, as well as automatic handling
of transgenes and spike-ins.
makeSummarizedExperiment(
  assays = S4Vectors::SimpleList(),
  rowRanges = GenomicRanges::GRanges(),
  rowData = NULL,
  colData = S4Vectors::DataFrame(),
  metadata = list(),
  transgeneNames = NULL,
  denylist = TRUE,
  sort = TRUE,
  sessionInfo = TRUE
)
assays | 
 
  | 
rowRanges | 
 
  | 
rowData | 
 
  | 
colData | 
 
  | 
metadata | 
 
  | 
transgeneNames | 
 
  | 
denylist | 
 
  | 
sort | 
 
  | 
sessionInfo | 
 
  | 
 Providing rowRanges: RangedSummarizedExperiment.
 Providing rowData: SummarizedExperiment.
This function improves upon the standard constructor by slotting useful
session information into the metadata slot by default:
date: Today's date, returned from Sys.Date.
sessionInfo: sessioninfo::session_info() return.
This behavior can be disabled by setting sessionInfo = FALSE.
wd: Working directory, returned from getwd.
Updated 2022-09-20.
SummarizedExperiment().
help("RangedSummarizedExperiment-class", "SummarizedExperiment").
help("SummarizedExperiment-class", "SummarizedExperiment").
## Rows (genes)
genes <- c(
    sprintf("gene%02d", seq_len(3L)),
    "EGFP" # transgene
)
print(genes)
## Columns (samples)
samples <- sprintf("sample%02d", seq_len(4L))
print(samples)
## Counts (assay)
counts <- matrix(
    data = seq_len(length(genes) * length(samples)),
    nrow = length(genes),
    ncol = length(samples),
    dimnames = list(genes, samples)
)
## Primary assay must be named "counts".
assays <- S4Vectors::SimpleList("counts" = counts)
print(assays)
## Row data (genomic ranges)
## Note that we haven't defined the transgene here.
## It will be handled automatically in the function call.
rowRanges <- AcidGenomes::emptyRanges(head(genes, n = length(genes) - 1L))
print(rowRanges)
## Column data
colData <- S4Vectors::DataFrame(
    "age" = rep(
        x = c(3L, 6L),
        times = length(samples) / 2L
    ),
    "genotype" = rep(
        x = c("wildtype", "knockout"),
        times = 1L,
        each = length(samples) / 2L
    ),
    row.names = samples
)
print(colData)
## Minimal mode.
x <- makeSummarizedExperiment(assays = assays)
print(x)
x <- makeSummarizedExperiment(
    assays = assays,
    rowRanges = rowRanges,
    colData = colData,
    transgeneNames = "EGFP"
)
print(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.