makeSummarizedExperimentFromDataFrame: Make a RangedSummarizedExperiment from a data.frame or...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/makeSummarizedExperimentFromDataFrame.R

Description

makeSummarizedExperimentFromDataFrame uses data.frame or DataFrame column names to create a GRanges object for the rowRanges of the resulting SummarizedExperiment object. It requires that non-range data columns be coercible into a numeric matrix for the SummarizedExperiment constructor. All columns that are not part of the row ranges attribute are assumed to be experiment data; thus, keeping metadata columns will not be supported. Note that this function only returns SummarizedExperiment objects with a single assay.

If metadata columns are to be kept, one can first construct the row ranges attribute by using the makeGRangesFromDataFrame function and subsequently creating the SummarizedExperiment.

Usage

1
2
3
4
makeSummarizedExperimentFromDataFrame(df,
                                    ...,
                                    seqinfo = NULL,
                                    starts.in.df.are.0based = FALSE)

Arguments

df

A data.frame or DataFrame object. If not, then the function first tries to turn df into a data frame with as.data.frame(df).

...

Additional arguments passed on to makeGRangesFromDataFrame

seqinfo

Either NULL, or a Seqinfo object, or a character vector of seqlevels, or a named numeric vector of sequence lengths. When not NULL, it must be compatible with the genomic ranges in df i.e. it must include at least the sequence levels represented in df.

starts.in.df.are.0based

TRUE or FALSE (the default). If TRUE, then the start positions of the genomic ranges in df are considered to be 0-based and are converted to 1-based in the returned GRanges object. This feature is intended to make it more convenient to handle input that contains data obtained from resources using the "0-based start" convention. A notorious example of such resource is the UCSC Table Browser (http://genome.ucsc.edu/cgi-bin/hgTables).

Value

A RangedSummarizedExperiment object with rowRanges and a single assay

Author(s)

M. Ramos

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## ---------------------------------------------------------------------
## BASIC EXAMPLES
## ---------------------------------------------------------------------

# Note that rownames of the data.frame are also rownames of the result
df <- data.frame(chr="chr2", start = 11:15, end = 12:16,
                 strand = c("+", "-", "+", "*", "."), expr0 = 3:7,
                 expr1 = 8:12, expr2 = 12:16,
                 row.names = paste0("GENE", letters[5:1]))
df

exRSE <- makeSummarizedExperimentFromDataFrame(df)

exRSE

assay(exRSE)

rowRanges(exRSE)

Example output

Loading required package: GenomicRanges
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit, which, which.max, which.min

Loading required package: S4Vectors

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: IRanges
Loading required package: GenomeInfoDb
Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

       chr start end strand expr0 expr1 expr2
GENEe chr2    11  12      +     3     8    12
GENEd chr2    12  13      -     4     9    13
GENEc chr2    13  14      +     5    10    14
GENEb chr2    14  15      *     6    11    15
GENEa chr2    15  16      .     7    12    16
class: RangedSummarizedExperiment 
dim: 5 3 
metadata(0):
assays(1): ''
rownames(5): GENEe GENEd GENEc GENEb GENEa
rowData names(0):
colnames(3): expr0 expr1 expr2
colData names(0):
      expr0 expr1 expr2
GENEe     3     8    12
GENEd     4     9    13
GENEc     5    10    14
GENEb     6    11    15
GENEa     7    12    16
GRanges object with 5 ranges and 0 metadata columns:
        seqnames    ranges strand
           <Rle> <IRanges>  <Rle>
  GENEe     chr2  [11, 12]      +
  GENEd     chr2  [12, 13]      -
  GENEc     chr2  [13, 14]      +
  GENEb     chr2  [14, 15]      *
  GENEa     chr2  [15, 16]      *
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths

SummarizedExperiment documentation built on Nov. 8, 2020, 8:28 p.m.