File: makeSummarizedExperimentFromDataFrame.Rd

package info (click to toggle)
r-bioc-summarizedexperiment 1.36.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 948 kB
  • sloc: makefile: 2
file content (87 lines) | stat: -rw-r--r-- 3,257 bytes parent folder | download | duplicates (5)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
\name{makeSummarizedExperimentFromDataFrame}

\alias{makeSummarizedExperimentFromDataFrame}

\title{Make a RangedSummarizedExperiment from a data.frame or DataFrame}

\description{
    \code{makeSummarizedExperimentFromDataFrame} uses \code{data.frame}
    or \code{DataFrame} column names to create a \link{GRanges} object for the
    \code{rowRanges} of the resulting \link{SummarizedExperiment} object.
    It requires that non-range data columns be coercible into a \code{numeric}
    \code{matrix} for the \link{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 \link{SummarizedExperiment} objects with a single
    assay.

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

\usage{
makeSummarizedExperimentFromDataFrame(df,
                                    ...,
                                    seqinfo = NULL,
                                    starts.in.df.are.0based = FALSE)
}
\arguments{
    \item{df}{
        A data.frame or \link[S4Vectors]{DataFrame} object. If not, then
        the function first tries to turn \code{df} into a data frame with
        \code{as.data.frame(df)}.
    }
    \item{...}{
        Additional arguments passed on to \link{makeGRangesFromDataFrame}
    }
    \item{seqinfo}{
        Either \code{NULL}, or a \link{Seqinfo} object, or a character vector
        of seqlevels, or a named numeric vector of sequence lengths.
        When not \code{NULL}, it must be compatible with the genomic ranges
        in \code{df} i.e. it must include at least the sequence levels
        represented in \code{df}.
    }
    \item{starts.in.df.are.0based}{
        \code{TRUE} or \code{FALSE} (the default).
        If \code{TRUE}, then the start positions of the genomic ranges in
        \code{df} are considered to be \emph{0-based} and are converted to
        \emph{1-based} in the returned \link{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 (\url{http://genome.ucsc.edu/cgi-bin/hgTables}).
    }
}
\value{
A \link{RangedSummarizedExperiment} object with rowRanges and a single assay
}
\author{
    M. Ramos
}
\seealso{
  \itemize{
      \item \link{makeGRangesFromDataFrame} 
  }
}

\examples{
## ---------------------------------------------------------------------
## 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)
}