Title: | Biobase: Base functions for Bioconductor |
---|---|
Description: | Functions that are needed by many other packages or which replace R functions. |
Authors: | R. Gentleman [aut], V. Carey [aut], M. Morgan [aut], S. Falcon [aut], Haleema Khan [ctb] ('esApply' and 'BiobaseDevelopment' vignette translation from Sweave to Rmarkdown / HTML), Bioconductor Package Maintainer [cre] |
Maintainer: | Bioconductor Package Maintainer <[email protected]> |
License: | Artistic-2.0 |
Version: | 2.67.0 |
Built: | 2024-11-30 05:18:52 UTC |
Source: | https://github.com/bioc/Biobase |
Biobase Package Overview
Important data classes: ExpressionSet
,
AnnotatedDataFrame
MIAME
. Full help on methods and
associated functions is available from within class help
pages.
Additional data classes: eSet
, MIAxE
,
MultiSet
. Additional manipulation and data structuring
classes: Versioned
, VersionedBiobase
,
aggregator
, container
.
Vignette routines: openVignette
,
getPkgVigs
, openPDF
.
Package manipulation functions: createPackage
and
package.version
Data sets: aaMap
, sample.ExpressionSet
,
geneData
.
Introductory information is available from vignettes, type
openVignette()
.
Full listing of documented articles is available in HTML view by
typing help.start()
and selecting Biobase
package from the
Packages
menu or via library(help="Biobase")
.
O. Sklyar
These generic functions access generic data, abstracts, PubMed IDs
and experiment data from instances of the
eSet-class
or ExpressionSet-class
.
abstract(object) pubMedIds(object) pubMedIds(object) <- value experimentData(object) experimentData(object) <- value
abstract(object) pubMedIds(object) pubMedIds(object) <- value experimentData(object) experimentData(object) <- value
object |
Object, possibly derived from |
value |
Value to be assigned; see class of |
abstract
returns a character vector containing the abstract
(as in a published paper) associated with object
.
pubMedIds
returns a character vector of PUBMED IDs associated
with the experiment.
experimentData
returns an object representing the description
of an experiment, e.g., an object of MIAME-class
Biocore
ExpressionSet-class
, eSet-class
,
MIAME-class
This function adds a menu item for a package's vignettes.
addVigs2WinMenu(pkgName)
addVigs2WinMenu(pkgName)
pkgName |
|
The original functions addVig2Menu
, addVig4Win
, addVig4Unix
, addNonExisting
, addPDF2Vig
have been replaced by addVigs2WinMenu
, please use those instead.
The functions do not return any value.
Jianhua Zhang and Jeff Gentry
# Only works for windows now if(interactive() && .Platform$OS.type == "windows" && .Platform$GUI == "Rgui"){ addVigs2WinMenu("Biobase") }
# Only works for windows now if(interactive() && .Platform$OS.type == "windows" && .Platform$GUI == "Rgui"){ addVigs2WinMenu("Biobase") }
Given an environment and an aggregator (an object of class aggregate
simple aggregations are made.
Aggregate(x, agg)
Aggregate(x, agg)
x |
The data to be aggregated. |
agg |
The aggregator to be used. |
Given some data, x
the user can accumulate (or aggregate)
information in env
using the two supplied functions.
See the accompanying documentation for a more complete example of this
function and its use.
No value is returned. This function is evaluated purely for side
effects. The symbols and values in env
are altered.
R. Gentleman
agg1 <- new("aggregator") Aggregate(letters[1:10], agg1) # the first 10 letters should be symbols in env1 with values of 1 Aggregate(letters[5:11], agg1) # now letters[5:10] should have value 2 bb <- mget(letters[1:11], env=aggenv(agg1), ifnotfound=NA) t1 <- as.numeric(bb); names(t1) <- names(bb) t1 # a b c d e f g h i j k # 1 1 1 1 2 2 2 2 2 2 1
agg1 <- new("aggregator") Aggregate(letters[1:10], agg1) # the first 10 letters should be symbols in env1 with values of 1 Aggregate(letters[5:11], agg1) # now letters[5:10] should have value 2 bb <- mget(letters[1:11], env=aggenv(agg1), ifnotfound=NA) t1 <- as.numeric(bb); names(t1) <- names(bb) t1 # a b c d e f g h i j k # 1 1 1 1 2 2 2 2 2 2 1
A class of objects designed to help aggregate calculations over an iterative computation. The aggregator consists of three objects. An environment to hold the values. A function that sets up an initial value the first time an object is seen. An aggregate function that increments the value of an object seen previously.
This class is used to help aggregate different values over function
calls. A very simple example is to use leave one out cross-validation
for prediction. At each stage we first perform feature selection and
then cross-validate. To keep track of how often each feature is
selected we can use an aggregator. At the end of the cross-validation
we can extract the names of the features chosen from aggenv
.
new('aggregator', aggenv = [environment], initfun = [function], aggfun = [function])
aggenv
:Object of class 'environment', holds the values between iterations
initfun
:Object of class 'function' specifies how to initialize the value for a name the first time it is encountered
aggfun
:Object of class 'function' used to increment (or perform any other function) on a name
aggenv(aggregator)
:Used to access the environment of the aggregator
aggfun(aggregator)
:Used to access the function that aggregates
initfun(aggregator)
:Used to access the initializer function
An AnnotatedDataFrame
consists of two parts. There is a collection
of samples and the values of variables measured on those
samples. There is also a description of each variable measured. The
components of an AnnotatedDataFrame
can be accessed with
pData
and varMetadata
.
Versioned
AnnotatedDataFrame(data, varMetadata, dimLabels=c("rowNames", "columnNames"), ...)
AnnotatedDataFrame
instances are created using
AnnotatedDataFrame
. The function can take three arguments, data
is a
data.frame
of the samples (rows) and measured variables
(columns). varMetadata
is a data.frame
with the number
of rows equal to the number of columns of the data
argument.
varMetadata
describes aspects of each measured
variable. dimLabels
provides aesthetic control for labeling rows
and columns in the show
method. varMetadata
and
dimLabels
can be missing.
as(data.frame, "AnnotatedDataFrame")
coerces a data.frame
to an
AnnotatedDataFrame
.
annotatedDataFrameFrom
may be a convenient way to create
an AnnotatedDataFrame
from AssayData-class
.
Class-specific slots:
data
:A data.frame
containing samples (rows)
and measured variables (columns).
dimLabels
:A character
vector of length 2 that
provides labels for the rows and columns in the show
method.
varMetadata
:A data.frame
with number of rows
equal number of columns in data
, and at least one column,
named labelDescription
, containing a textual description
of each variable.
.__classVersion__
:A Versions
object describing
the R and Biobase version numbers used to created the instance.
Intended for developer use.
Class-specific methods.
as(annotatedDataFrame, "data.frame")
Coerce objects of
AnnotatedDataFrame
to data.frame
.
combine(<AnnotatedDataFrame>,
<AnnotatedDataFrame>
:Bind data from one
AnnotatedDataFrame
to a second
AnnotatedDataFrame
, returning the result as an
AnnotatedDataFrame
. Row (sample) names in each argument
must be unique. Variable names present in both arguments occupy a
single column in the resulting AnnotatedDataFrame
. Variable
names unique to either argument create columns with values
assigned for those samples where the variable is
present. varMetadata
in the returned
AnnotatedDataFrame
is updated to reflect the combination.
pData(<AnnotatedDataFrame>)
,
pData(<AnnotatedDataFrame>)<-<data.frame>
:Set and
retrieve the data (samples and variables) in the
AnnotatedDataFrame
varMetadata(<AnnotatedDataFrame>)
,
varMetadata(<AnnotatedDataFrame>)<-<data.frame>
:Set and
retrieve the meta-data (variables and their descriptions) in the
AnnotatedDataFrame
featureNames(<AnnotatedDataFrame>)
,
featureNames(<AnnotatedDataFrame>)<-<ANY>
:Set and
retrieve the feature names in AnnotatedDataFrame
; a
synonym for sampleNames
.
sampleNames(<AnnotatedDataFrame>)
,
sampleNames(<AnnotatedDataFrame>)<-<ANY>
:Set and
retrieve the sample names in AnnotatedDataFrame
varLabels(<AnnotatedDataFrame>)
,
varLabels(<AnnotatedDataFrame>)<-<data.frame>
:Set and
retrieve the variable labels in the AnnotatedDataFrame
dimLabels(<AnnotatedDataFrame>)
,
dimLabels(<AnnotatedDataFrame>) <- <character>
Retrieve
labels used for display of AnnotatedDataFrame
, e.g.,
‘rowNames’, ‘columnNames’.
Standard generic methods:
initialize(<AnnotatedDataFrame>)
:Object instantiation, used
by new
; not to be called directly by the user.
as(<data.frame>, "AnnotatedDataFrame")
:Convert a
data.frame
to an AnnotatedDataFrame.
as(<phenoData>,<AnnotatedDataFrame>)
:Convert
old-style phenoData-class
objects to
AnnotatedDataFrame
, issuing warnings as appropriate.
validObject(<AnnotatedDataFrame>)
:Validity-checking
method, ensuring coordination between data
and
varMetadata
elements
updateObject(object, ..., verbose=FALSE)
Update instance to current version, if necessary. See updateObject
isCurrent(object)
Determine whether version of object is current. See isCurrent
isVersioned(object)
Determine whether object contains a 'version' string describing its structure . See isVersioned
show(<AnnotatedDataFrame>)
Abbreviated display of object
[<sample>,<variable>
:Subset operation, taking two arguments and
indexing the sample and variable. Returns an
AnnotatedDataFrame
, i.e., including relevant
metadata. Unlike a data.frame
, setting drop=TRUE
generates an error.
[[<variable>
, $<variable>
:Selector returning a
variable (column of pData
).
[[<variable>, ...]]<-<new_value>
,
$<variable> <- <new_value>
:Replace or add a variable to
pData
. ... can include named arguments (especially
labelDescription
) to be added to varMetadata
.
head(<AnnotatedDataFrame>, n = 6L, ...)
,
tail(<AnnotatedDataFrame>, n=6L, ...)
Select the first
(last for tail) n
rows; negative n
returns the first
(last) nrow() - n
rows.
dim(<AnnotatedDataFrame>)
,
ncol(<AnnotatedDataFrame>)
:Number of samples and
variables (dim
) and variables (ncol
) in the
argument.
dimnames(<AnnotatedDataFrame>)
,
rownames(<AnnotatedDataFrame>)
,
colnames(<AnnotatedDataFrame>)
:row and column names.
V.J. Carey, after initial design by R. Gentleman
eSet
, ExpressionSet
,
read.AnnotatedDataFrame
df <- data.frame(x=1:6, y=rep(c("Low", "High"),3), z=I(LETTERS[1:6]), row.names=paste("Sample", 1:6, sep="_")) metaData <- data.frame(labelDescription=c( "Numbers", "Factor levels", "Characters")) AnnotatedDataFrame() AnnotatedDataFrame(data=df) AnnotatedDataFrame(data=df, varMetadata=metaData) as(df, "AnnotatedDataFrame") obj <- AnnotatedDataFrame() pData(obj) <- df varMetadata(obj) <- metaData validObject(obj)
df <- data.frame(x=1:6, y=rep(c("Low", "High"),3), z=I(LETTERS[1:6]), row.names=paste("Sample", 1:6, sep="_")) metaData <- data.frame(labelDescription=c( "Numbers", "Factor levels", "Characters")) AnnotatedDataFrame() AnnotatedDataFrame(data=df) AnnotatedDataFrame(data=df, varMetadata=metaData) as(df, "AnnotatedDataFrame") obj <- AnnotatedDataFrame() pData(obj) <- df varMetadata(obj) <- metaData validObject(obj)
annotatedDataFrameFrom
is a convenience for creating
AnnotatedDataFrame
objects.
Use the method with annotatedDataFrameFrom(object, byrow=FALSE,
...)
; the argument byrow
must be specified.
signature(object="assayData")
This method creates an
AnnotatedDataFrame
using sample (when byrow=FALSE
) or
feature (byrow=TRUE
) names and dimensions of an
AssayData
object as a template.
signature(object="matrix")
This method creates an
AnnotatedDataFrame
using column (when byrow=FALSE
) or
row (byrow=TRUE
) names and dimensions of a
matrix
object as a template.
signature(object="NULL")
This method (called with 'NULL'
as the object) creates an empty AnnotatedDataFrame
; provides
dimLabels
based on value of byrow
.
Biocore team
Checks if there are any missing values in an object or not.
anyMissing(x=NULL)
anyMissing(x=NULL)
x |
A |
The implementation of this method is optimized for both speed and memory.
Returns TRUE
if a missing value was detected, otherwise FALSE
.
Henrik Bengtsson (http://www.braju.com/R/)
x <- rnorm(n=1000) x[seq(300,length(x),by=100)] <- NA stopifnot(anyMissing(x) == any(is.na(x)))
x <- rnorm(n=1000) x[seq(300,length(x),by=100)] <- NA stopifnot(anyMissing(x) == any(is.na(x)))
This generic function accesses assay data stored in an object derived from
the eSet
or ExpressionSet
class.
assayData(object) assayData(object) <- value
assayData(object) assayData(object) <- value
object |
Object derived from class eSet |
value |
Named list or environment containing one or more matrices with identical dimensions |
assayData
applied to eSet
-derived classes returns a list
or environment; applied to ExpressionSet
, the method returns an
environment. See the class documentation for specific details.
Biocore
eSet-class
, ExpressionSet-class
,
SnpSet-class
Container class defined as a class union of list
and
environment
. Designed to contain one or more matrices of the
same dimension.
signature(x = "AssayData", y = "AssayData")
:
This method uses cbind
to create new AssayData elements that contain the
samples of both arguments x
and y
.
Both AssayData arguments to combine must have the same collection of
elements. The elements must have identical numbers of rows
(features). The numerical contents of any columns (samples)
present in the same element of different AssayData must be
identical. The storageMode of the AssayData arguments must be
identical, and the function returns an AssayData with storageMode
matching the incoming mode. See also combine,eSet,eSet-method
signature(object = "AssayData")
signature(object = "AssayData", value = "ANY")
:
Return or set the feature names as a character
vector. These are the row names of the AssayData
elements. value
can be a character or numeric vector; all
entries must be unique.
signature(object = "AssayData")
signature(object =
"AssayData", value="ANY")
: Return or set the sample names. These are the column
names of the the AssayData elements and the row names of
phenoData
. value
can be a character or numeric
vector.
signature(object = "AssayData")
signature(object = "AssayData",
value="character")
: Return or set the storage mode for the
instance. value
can be one of three choices:
"lockedEnvironment"
, "environment"
, and
"list"
. Environments offer a mechanism for storing data that
avoids some of the copying that occurs when using lists. Locked
environment help to ensure data integrity. Note that environments are
one of the few R objects that are pass-by-reference. This means that if
you modify a copy of an environment, you also modify the original. For
this reason, we recommend using lockedEnvironment whenever possible.
Additional functions operating on AssayData
include:
Select element name
from assayData
.
Use storage.mode
to create a
new list or environment containing the named elements in ...
Validate
assayData
, ensuring that the named elements required
are present, matrices are of the same dimension, and featureNames
(rownames) are
consistent (identical or NULL
) across entries.
See
eSet-class
See eSet-class
See eSet-class
Biocore
eSet-class
ExpressionSet-class
Cache the evaluation of an expression in the file system.
cache(expr, dir=".", prefix="tmp_R_cache_")
cache(expr, dir=".", prefix="tmp_R_cache_")
expr |
An expression of the form |
dir |
A string specifying the directory into which cache files should be written (also where to go searching for an appropriate cache file). |
prefix |
A string giving the prefix to use when naming and
searching for cache files. The default is |
This function can be useful during the development of computationally
intensive workflows, for example in vignettes or scripts. The
function uses a cache file in dir
which defaults to the current
working directory whose name is obtained by paste(prefix, name,
".RData", sep="")
.
When cache
is called and the cache file exists, it is loaded
and the object whose name is given on the left of <-
in
expr
is returned. In this case, expr
is not
evaluted.
When cache
is called and the cache file does not exist,
expr
is evaluted, its value is saved into a cache file, and
then its value is returned.
The expr
argument must be of the form of someVar <-
{expressions}
. That is, the left hand side must be a single symbol
name and the next syntactic token must be <-
.
To flush the cache and force recomputation, simply remove the cache
files. You can use file.remove
to do this.
The (cached) value of expr
.
The first version of this function had a slightly different interface
which is no longer functional. The old version has arguments
name
and expr
and the intended usage is: foo <-
cache("foo", expr)
.
Wolfgang Huber, [email protected] Seth Falcon, [email protected]
bigCalc <- function() runif(10) cache(myComplicatedObject <- bigCalc()) aCopy <- myComplicatedObject remove(myComplicatedObject) cache(myComplicatedObject <- bigCalc()) stopifnot(all.equal(myComplicatedObject, aCopy)) allCacheFiles <- list.files(".", pattern="^tmp_R_cache_.*\\.RData$", full.name=TRUE) file.remove(allCacheFiles)
bigCalc <- function() runif(10) cache(myComplicatedObject <- bigCalc()) aCopy <- myComplicatedObject remove(myComplicatedObject) cache(myComplicatedObject <- bigCalc()) stopifnot(all.equal(myComplicatedObject, aCopy)) allCacheFiles <- list.files(".", pattern="^tmp_R_cache_.*\\.RData$", full.name=TRUE) file.remove(allCacheFiles)
This generic function extracts a specific element from an object, returning a instance of the ExpressionSet class.
channel(object, name, ...)
channel(object, name, ...)
object |
An S4 object, typically derived from class
|
name |
The name of the channel, a (length one) character vector. |
... |
Additional arguments. |
An instance of class ExpressionSet
.
Biocore
obj <- NChannelSet( R=matrix(runif(100), 20, 5), G=matrix(runif(100), 20, 5)) ## G channel as ExpressionSet channel(obj, "G")
obj <- NChannelSet( R=matrix(runif(100), 20, 5), G=matrix(runif(100), 20, 5)) ## G channel as ExpressionSet channel(obj, "G")
This generic function reports or updates the channels in an object.
channelNames(object, ...) channelNames(object, ...) <- value
channelNames(object, ...) channelNames(object, ...) <- value
object |
An S4 object, typically derived from class
|
value |
Replacement value, either a character vector (to re-order existing channel names or a named character vector or list (to change channel names from the vector elements to the corresponding names). |
... |
Additional argument, not currently used. |
channelNames
returns the names of the channels in a defined
order. Change the order using the replacement method with a permuation
of the channel names as value
. Rename channels using the
replacement method with a named list, where the vector elements are a
permutation of the current channels, with corresponding names the new
identifier for the channel.
character
.
Biocore
## channelNames default to alphabetical order of channels obj <- NChannelSet( R=matrix(runif(100), 20, 5), G=matrix(-runif(100), 20, 5)) channelNames(obj) channelNames(obj) <- c(Gn="G", Rd="R") ## rename channelNames(obj) channelNames(obj) <- c("Rd", "Gn") ## reorder channelNames(obj) all(assayData(obj)[["Gn"]] <= 0) all(assayData(obj)[["Rd"]] >= 0)
## channelNames default to alphabetical order of channels obj <- NChannelSet( R=matrix(runif(100), 20, 5), G=matrix(-runif(100), 20, 5)) channelNames(obj) channelNames(obj) <- c(Gn="G", Rd="R") ## rename channelNames(obj) channelNames(obj) <- c("Rd", "Gn") ## reorder channelNames(obj) all(assayData(obj)[["Gn"]] <= 0) all(assayData(obj)[["Rd"]] >= 0)
This class can be either character
or
MIAME
.
No methods defined with class "characterORMIAME" in the signature.
See also MIAME
These generic functions return version information for classes
derived from Versioned-class
, or
VersionsNull-class
for unversioned objects. The
version information is an object of Versions-class
.
By default, classVersion
has the following behaviors:
classVersion(Versioned-instance)
Returns a Versions-class
object obtained from the object.
classVersion{"class"}
Consults the definition of class
and return the current version information, if available.
classVersion(ANY)
Return a VersionsNull-class
object to indicate no version information available.
By default, the classVersion<-
method has the following behavior:
classVersion(Versioned-instance)["id"] <- value
Assign (update or add) value
to Versions-instance
. value
is coerced to a valid version description. see Versions-class
for additional access methods.
classVersion(object) classVersion(object) <- value
classVersion(object) classVersion(object) <- value
object |
Object whose version is to be determined, as described above. |
value |
|
classVersion
returns an instance of Versions-class
Biocore team
obj <- new("VersionedBiobase") classVersion(obj) classVersion(obj)["Biobase"] classVersion(1:10) # no version classVersion("ExpressionSet") # consult ExpressionSet prototype classVersion(obj)["MyVersion"] <- "1.0.0" classVersion(obj)
obj <- new("VersionedBiobase") classVersion(obj) classVersion(obj)["Biobase"] classVersion(1:10) # no version classVersion("ExpressionSet") # consult ExpressionSet prototype classVersion(obj)["MyVersion"] <- "1.0.0" classVersion(obj)
Container class that specializes the list construct of R to provide content and access control
new('container', x = [list], content = [character], locked = [logical])
list of entities that are guaranteed to share a certain property
tag describing container contents
boolean indicator of locked status. Value of TRUE implies assignments into the container are not permitted
Class-specific methods:
content(container)
returns content
slot of argument
locked(container)
returns locked
slot of argument
Standard methods defined for 'container':
show(container)
prints container
length(container)
returns number of elements in the container
[[(index)
and [[(index, value)
access and replace elements in the container
[(index)
make a subset of a container (which will itself be a container)
x1 <- new("container", x=vector("list", length=3), content="lm") lm1 <- lm(rnorm(10)~runif(10)) x1[[1]] <- lm1
x1 <- new("container", x=vector("list", length=3), content="lm") lm1 <- lm(rnorm(10)~runif(10)) x1[[1]] <- lm1
The contents method is used to retrieve the values stored in an environment.
contents(object, all.names)
contents(object, all.names)
object |
The environment (data table) that you want to get all contents from |
all.names |
a logical indicating whether to copy all values in |
A named list is returned, where the elements are the objects stored in the environment. The names of the elements are the names of the objects.
The all.names
argument is identical to the one used in
as.list.environment
.
R. Gentleman
z <- new.env() multiassign(letters, 1:26, envir=z) contents(z)
z <- new.env() multiassign(letters, 1:26, envir=z) contents(z)
These functions can be used to make copies of environments, or to get/assign all of the objects inside of an environment.
copyEnv(oldEnv, newEnv, all.names=FALSE)
copyEnv(oldEnv, newEnv, all.names=FALSE)
oldEnv |
An environment to copy from |
newEnv |
An environment to copy to. If missing, a new environment with the same parent environment as oldEnv. |
all.names |
Whether to retrieve objects with names that start with a dot. |
copyEnv
: This function will make a copy of the contents from
oldEnv
and place them into newEnv
.
Jeff Gentry and R. Gentleman
z <- new.env(hash=TRUE, parent=emptyenv(), size=29L) multiassign(c("a","b","c"), c(1,2,3), z) a <- copyEnv(z) ls(a)
z <- new.env(hash=TRUE, parent=emptyenv(), size=29L) multiassign(c("a","b","c"), c(1,2,3), z) a <- copyEnv(z) ls(a)
Copy files, directory trees or between connections and replace all occurences of a symbol by the corresponding value.
copySubstitute(src, dest, symbolValues, symbolDelimiter="@", allowUnresolvedSymbols=FALSE, recursive = FALSE, removeExtension = "\\.in$")
copySubstitute(src, dest, symbolValues, symbolDelimiter="@", allowUnresolvedSymbols=FALSE, recursive = FALSE, removeExtension = "\\.in$")
src |
Source, either a character vector with filenames and/or directory names, or a connection object. |
dest |
Destination, either a character vector of length 1
with the name of an existing, writable directory, or a connection
object. The class of the |
symbolValues |
A named list of character strings. |
symbolDelimiter |
A character string of length one with a single character in it. |
allowUnresolvedSymbols |
Logical. If |
recursive |
Logical. If |
removeExtension |
Character. Matches to this regular expression are removed from filenames and directory names. |
Symbol substitution: this is best explained with an example. If the list
symbolValues
contains an element with name FOO
and value
bar
, and symbolDelimiter is @
, then any occurrence of
@FOO@
is replaced by bar
. This applies both the text
contents of the files in src
as well as to the filenames. See examples.
If recursive
is FALSE
, both src
and dest
must be connection or a filenames. The text in src
is read
through the function readLines
,
symbols are replaced by their values, and the result is written to
dest
through the function writeLines
.
If recursive
is TRUE
,
copySubstitute
works recursively down a directory tree (see details and example).
src
must be a character vector with multiple filenames or
directory names, dest
a directory name.
One use of this function is in
createPackage
for the automatic generation of packages from a template package directory.
None. The function is called for its side effect.
Wolfgang Huber http://www.dkfz.de/mga/whuber
## create an example file infile = tempfile() outfile = tempfile() writeLines(text=c("We will perform in @WHAT@:", "So, thanks to @WHOM@ at once and to each one,", "Whom we invite to see us crown'd at @WHERE@."), con = infile) ## create the symbol table z = list(WHAT="measure, time and place", WHOM="all", WHERE="Scone") ## run copySubstitute copySubstitute(infile, outfile, z) ## display the results readLines(outfile) ##-------------------------------------------------------------- ## This is a slightly more complicated example that demonstrates ## how copySubstitute works on nested directories ##-------------------------------------------------------------- d = tempdir() my.dir.create = function(x) {dir.create(x); return(x)} unlink(file.path(d, "src"), recursive=TRUE) unlink(file.path(d, "dest"), recursive=TRUE) ## create some directories and files: src = my.dir.create(file.path(d, "src")) dest = file.path(d, "dest") d1 = my.dir.create(file.path(src, "dir1.in")) d2 = my.dir.create(file.path(src, "dir2@[email protected]")) d3 = my.dir.create(file.path(d2, "dir3")) d4 = my.dir.create(file.path(d3, "dir4")) d5 = my.dir.create(file.path(d4, "dir5@BAR@")) writeLines(c("File1:", "FOO: @FOO@"), file.path(d1, "file1.txt.in")) writeLines(c("File2:", "BAR: @BAR@"), file.path(d2, "file2.txt.in")) writeLines(c("File3:", "SUN: @SUN@"), file.path(d3, "file3.txt.in")) writeLines(c("File4:", "MOON: @MOON@"), file.path(d4, "@[email protected]")) ## call copySubstitute copySubstitute(src, dest, recursive=TRUE, symbolValues = list(FOO="thefoo", BAR="thebar", SUN="thesun", MOON="themoon")) ## view the result listsrc = dir(src, full.names=TRUE, recursive=TRUE) listdest = dir(dest, full.names=TRUE, recursive=TRUE) listsrc listdest cat(unlist(lapply(listsrc, readLines)), sep="\n") cat(unlist(lapply(listdest, readLines)), sep="\n")
## create an example file infile = tempfile() outfile = tempfile() writeLines(text=c("We will perform in @WHAT@:", "So, thanks to @WHOM@ at once and to each one,", "Whom we invite to see us crown'd at @WHERE@."), con = infile) ## create the symbol table z = list(WHAT="measure, time and place", WHOM="all", WHERE="Scone") ## run copySubstitute copySubstitute(infile, outfile, z) ## display the results readLines(outfile) ##-------------------------------------------------------------- ## This is a slightly more complicated example that demonstrates ## how copySubstitute works on nested directories ##-------------------------------------------------------------- d = tempdir() my.dir.create = function(x) {dir.create(x); return(x)} unlink(file.path(d, "src"), recursive=TRUE) unlink(file.path(d, "dest"), recursive=TRUE) ## create some directories and files: src = my.dir.create(file.path(d, "src")) dest = file.path(d, "dest") d1 = my.dir.create(file.path(src, "dir1.in")) d2 = my.dir.create(file.path(src, "dir2@[email protected]")) d3 = my.dir.create(file.path(d2, "dir3")) d4 = my.dir.create(file.path(d3, "dir4")) d5 = my.dir.create(file.path(d4, "dir5@BAR@")) writeLines(c("File1:", "FOO: @FOO@"), file.path(d1, "file1.txt.in")) writeLines(c("File2:", "BAR: @BAR@"), file.path(d2, "file2.txt.in")) writeLines(c("File3:", "SUN: @SUN@"), file.path(d3, "file3.txt.in")) writeLines(c("File4:", "MOON: @MOON@"), file.path(d4, "@[email protected]")) ## call copySubstitute copySubstitute(src, dest, recursive=TRUE, symbolValues = list(FOO="thefoo", BAR="thebar", SUN="thesun", MOON="themoon")) ## view the result listsrc = dir(src, full.names=TRUE, recursive=TRUE) listdest = dir(dest, full.names=TRUE, recursive=TRUE) listsrc listdest cat(unlist(lapply(listsrc, readLines)), sep="\n") cat(unlist(lapply(listdest, readLines)), sep="\n")
Create a package directory from a template, with symbol-value substitution
createPackage(pkgname, destinationDir, originDir, symbolValues, unlink=FALSE, quiet=FALSE)
createPackage(pkgname, destinationDir, originDir, symbolValues, unlink=FALSE, quiet=FALSE)
pkgname |
Character. The name of the package to be written. |
destinationDir |
Character. The path to a directory where the package is to be written. |
originDir |
Character. The path to a directory that contains
the template package. Usually, this will contain a file named
|
symbolValues |
Named list of character strings. The symbol-to-value
mapping. See
|
unlink |
Logical. If |
quiet |
Logical. If |
The intended use of this function is for the automated mass production of data packages, such as the microarray annotation, CDF, and probe sequence packages.
No syntactic or other checking of the package is performed. For this, use R CMD check.
The symbols @PKGNAME@
and @DATE@
are automatically
defined with the values of pkgname
and date()
, respectively.
The function returns a list
with one element
pkgdir
: the path to the package.
Wolfgang Huber http://www.dkfz.de/mga/whuber
copySubstitute
,
the reference manual Writing R extensions.
sym = list(AUTHOR = "Hesiod", VERSION = "1.0", TITLE = "the nine muses", FORMAT = "Character vector containg the names of the 9 muses.") res = createPackage("muses", destinationDir = tempdir(), originDir = system.file("Code", package="Biobase"), symbolValues = sym, unlink = TRUE, quiet = FALSE) muses = c("Calliope", "Clio", "Erato", "Euterpe", "Melpomene", "Polyhymnia", "Terpsichore", "Thalia", "Urania") dir.create(file.path(res$pkgdir, "data")) save(muses, file = file.path(res$pkgdir, "data", "muses.rda")) res$pkgdir
sym = list(AUTHOR = "Hesiod", VERSION = "1.0", TITLE = "the nine muses", FORMAT = "Character vector containg the names of the 9 muses.") res = createPackage("muses", destinationDir = tempdir(), originDir = system.file("Code", package="Biobase"), symbolValues = sym, unlink = TRUE, quiet = FALSE) muses = c("Calliope", "Clio", "Erato", "Euterpe", "Melpomene", "Polyhymnia", "Terpsichore", "Thalia", "Urania") dir.create(file.path(res$pkgdir, "data")) save(muses, file = file.path(res$pkgdir, "data", "muses.rda")) res$pkgdir
The aaMap
data frame has 20 rows and 6 columns. Includes elementary information about amino acids.
data(aaMap)
data(aaMap)
This data frame contains the following columns:
amino acid name
one-letter code
three-letter code
side chain property at pH 7 (polar/nonpolar)
logical: side chain is hydrophilic at pH 7
logical: side chain is acidic at pH 7
Nei M and Kumar S: Molecular evolution and phylogenetics (Oxford 2000), Table 1.2
data(aaMap)
data(aaMap)
The geneData
data.frame has 500 rows and 26 columns. It consists
of a subset of real expression data from an Affymetrix U95v2 chip. The
data are anonymous. The covariate data geneCov
and
geneCovariate
are made up. The standard error data seD
is
also made up.
data(geneData)
data(geneData)
A 500 by 26 data frame.
The J. Ritz Laboratory (S. Chiaretti).
data(geneData) data(geneCovariate) data(seD)
data(geneData) data(geneCovariate) data(seD)
The expression data are real but anonymized. The data are from an experiment that used Affymetrix U95v2 chips. The data were processed by dChip and then exported to R for analysis.
The data illustrate ExpressionSet-class
, with
assayData
containing the required matrix element exprs
and
an additional matrix se.exprs
. se.exprs
has the same
dimensions as exprs
.
The phenoData and standard error estimates (se.exprs) are made up. The information in the "description" slot is fake.
data(sample.ExpressionSet)
data(sample.ExpressionSet)
The data for 26 cases, labeled A to Z and 500 genes. Each case has three covariates: sex (male/female); type (case/control); and score (testing score).
data(sample.ExpressionSet)
data(sample.ExpressionSet)
The expression data are real but anonymized. The data are from an experiment that used Affymetrix U95v2 chips. The data were processed by dChip and then exported to R for analysis.
The phenoData, standard error estimates, and description data are fake.
data(sample.MultiSet)
data(sample.MultiSet)
The data for 4 cases, labeled a to d and 500 genes. Each case has five covariates: SlideNumber: number; FileName: name; Cy3: genotype labeled Cy3; Cy5: genotype labeled Cy5; Date: date.
data(sample.MultiSet)
data(sample.MultiSet)
These generic functions access experimental information
associated with eSet-class
.
description(object, ...) description(object) <- value
description(object, ...) description(object) <- value
object |
Object, possibly derived from class |
value |
Structured information describing the experiment, e.g.,
of |
... |
Further arguments to be used by other methods. |
description
returns an object of MIAME-class
.
Biocore
Dump textual description of a package
dumpPackTxt(package)
dumpPackTxt(package)
package |
Character string naming an R package |
dumps DESCRIPTION and INDEX files from package sources
stdout
output
Other approaches using formatDL are feasible
dumpPackTxt("stats")
dumpPackTxt("stats")
esApply
is a wrapper to apply
for use with ExpressionSet
s.
The application of a function to rows of an expression array usually involves
variables in pData
. esApply
uses a special evaluation paradigm
to make this easy. The function FUN
may reference any data in
pData
by name.
esApply(X, MARGIN, FUN, ...)
esApply(X, MARGIN, FUN, ...)
X |
An instance of class |
MARGIN |
The margin to apply to, either 1 for rows (samples) or 2 for columns (features). |
FUN |
Any function |
... |
Additional parameters for |
The pData
from X
is installed in an
environment. This environment is installed as the environment of
FUN
. This will then provide bindings for any symbols in
FUN
that are the same as the names of the pData
of
X
. If FUN
has an environment already it is retained but
placed after the newly created environment. Some variable shadowing
could occur under these circumstances.
The result of with(pData(x), apply(exprs(X), MARGIN, FUN, ...))
.
V.J. Carey <[email protected]>, R. Gentleman
data(sample.ExpressionSet) ## sum columns of exprs res <- esApply(sample.ExpressionSet, 1, sum) ## t-test, spliting samples by 'sex' f <- function(x) { xx <- split(x, sex) t.test(xx[[1]], xx[[2]])$p.value } res <- esApply(sample.ExpressionSet, 1, f) ## same, but using a variable passed in the function call f <- function(x, s) { xx <- split(x, s) mean(xx[[1]]) - mean(xx[[2]]) } sex <- sample.ExpressionSet[["sex"]] res <- esApply(sample.ExpressionSet, 1, f, s = sex) # obtain the p-value of the t-test for sex difference mytt.demo <- function(y) { ys <- split(y, sex) t.test(ys[[1]], ys[[2]])$p.value } sexPValue <- esApply(sample.ExpressionSet, 1, mytt.demo) # obtain the p-value of the slope associated with score, adjusting for sex # (if we were concerned with sign we could save the z statistic instead at coef[3,3] myreg.demo <- function(y) { summary(lm(y ~ sex + score))$coef[3,4] } scorePValue <- esApply(sample.ExpressionSet, 1, myreg.demo) # a resampling method resamp <- function(ESET) { ntiss <- ncol(exprs(ESET)) newind <- sample(1:ntiss, size = ntiss, replace = TRUE) ESET[newind,] } # a filter q3g100filt <- function(eset) { apply(exprs(eset), 1, function(x) quantile(x,.75) > 100) } # filter after resampling and then apply set.seed(123) rest <- esApply({bool <- q3g100filt(resamp(sample.ExpressionSet)); sample.ExpressionSet[bool,]}, 1, mytt.demo)
data(sample.ExpressionSet) ## sum columns of exprs res <- esApply(sample.ExpressionSet, 1, sum) ## t-test, spliting samples by 'sex' f <- function(x) { xx <- split(x, sex) t.test(xx[[1]], xx[[2]])$p.value } res <- esApply(sample.ExpressionSet, 1, f) ## same, but using a variable passed in the function call f <- function(x, s) { xx <- split(x, s) mean(xx[[1]]) - mean(xx[[2]]) } sex <- sample.ExpressionSet[["sex"]] res <- esApply(sample.ExpressionSet, 1, f, s = sex) # obtain the p-value of the t-test for sex difference mytt.demo <- function(y) { ys <- split(y, sex) t.test(ys[[1]], ys[[2]])$p.value } sexPValue <- esApply(sample.ExpressionSet, 1, mytt.demo) # obtain the p-value of the slope associated with score, adjusting for sex # (if we were concerned with sign we could save the z statistic instead at coef[3,3] myreg.demo <- function(y) { summary(lm(y ~ sex + score))$coef[3,4] } scorePValue <- esApply(sample.ExpressionSet, 1, myreg.demo) # a resampling method resamp <- function(ESET) { ntiss <- ncol(exprs(ESET)) newind <- sample(1:ntiss, size = ntiss, replace = TRUE) ESET[newind,] } # a filter q3g100filt <- function(eset) { apply(exprs(eset), 1, function(x) quantile(x,.75) > 100) } # filter after resampling and then apply set.seed(123) rest <- esApply({bool <- q3g100filt(resamp(sample.ExpressionSet)); sample.ExpressionSet[bool,]}, 1, mytt.demo)
Container for high-throughput assays and experimental
metadata. Classes derived from eSet
contain one or more
identical-sized matrices as assayData
elements. Derived
classes (e.g., ExpressionSet-class
, SnpSet-class
)
specify which elements must be present in the assayData
slot.
eSet
object cannot be instantiated directly; see the examples
for usage.
eSet
is a virtual class, so instances cannot be created.
Objects created under previous definitions of eSet-class
can be
coerced to the current classes derived from eSet
using
updateOldESet
.
Introduced in eSet
:
assayData
:Contains matrices with equal
dimensions, and with column number equal to
nrow(phenoData)
. Class:AssayData-class
phenoData
:Contains experimenter-supplied variables
describing sample (i.e., columns in assayData
) phenotypes.
Class: AnnotatedDataFrame-class
featureData
:Contains variables describing features
(i.e., rows in assayData
) unique to this experiment. Use
the annotation
slot to efficiently reference feature data
common to the annotation package used in the experiment. Class:
AnnotatedDataFrame-class
experimentData
:Contains details of experimental
methods. Class: MIAME-class
annotation
:Label associated with the annotation
package used in the experiment. Class: character
protocolData
:Contains microarray equipment-generated
variables describing sample (i.e., columns in assayData
) phenotypes.
Class: AnnotatedDataFrame-class
.__classVersion__
:A Versions
object describing
the R and Biobase version numbers used to created the instance.
Intended for developer use.
Methods defined in derived classes (e.g., ExpressionSet-class
,
SnpSet-class
) may override the methods described here.
Class-specific methods:
sampleNames(object)
and
sampleNames(object)<-value
:Coordinate accessing and setting
sample names in assayData
and phenoData
featureNames(object)
,
featureNames(object) <- value
:Coordinate accessing and setting of
feature names (e.g, genes, probes) in assayData
.
dimnames(object)
, dimnames(object) <-
value
:Also rownames
and colnames
; access and set
feature and sample names.
dims(object)
:Access the common dimensions (dim
) or
column numbers (ncol
), or dimensions of all members
(dims
) of assayData
.
phenoData(object)
,
phenoData(object) <- value
:Access and set
phenoData
. Adding new columns to phenoData
is often
more easily done with eSetObject[["columnName"]] <- value
.
pData(object)
, pData(object) <- value
:Access and set
sample data information. Adding new columns to pData
is often
more easily done with eSetObject[["columnName"]] <- value
.
varMetadata(object)
,
varMetadata(eSet,value)
Access and set metadata describing
variables reported in pData
varLabels(object)
, varLabels(eSet,
value)<-
:Access and set variable labels in
phenoData
.
featureData(object)
,
featureData(object) <- value
:Access and set featureData
.
fData(object)
, fData(object) <- value
:Access and set feature data information.
fvarMetadata(object)
,
fvarMetadata(eSet,value)
Access and set metadata describing
features reported in fData
fvarLabels(object)
,
fvarLabels(eSet, value)<-
:Access and set variable labels in
featureData
.
assayData(object), assayData(object) <- value
:signature(object = "eSet", value = "AssayData")
: Access
and replace the AssayData
slot of an
eSet
instance. assayData
returns a list or
environment; elements in assayData
not accessible in other
ways (e.g., via exprs
applied directly to the eSet
)
can most reliably be accessed with, e.g., assayData(obj)[["se.exprs"]]
.
experimentData(object)
,experimentData(object) <- value
:Access and set details of experimental methods
description(object)
,description(object) <- value
:Synonymous with experimentData.
notes(object)
,notes(object) <- value
:signature(object="eSet", value="list")
Retrieve and set unstructured notes associated with eSet
.
signature(object="eSet", value="character")
As with
value="list", but append value to current list of notes.
pubMedIds(object)
, pubMedIds(eSet,value)
Access
and set PMIDs in experimentData
.
abstract(object)
:Access abstract in
experimentData
.
annotation(object)
,
annotation(object) <- value
Access and set annotation label indicating package used in the experiment.
protocolData(object)
,
protocolData(object) <- value
Access and set the protocol data.
preproc(object)
,
preproc(object) <- value
:signature(object="eSet",
value="list")
Access and set preprocessing
information
in the MIAME-class
object associated with this
eSet
.
combine(eSet,eSet)
:Combine two eSet
objects. To be combined, eSets must have identical numbers of
featureNames
, distinct sampleNames
, and identical annotation
.
storageMode(object)
, storageMode(eSet,character)<-
:Change storage mode
of assayData
. Can be used to 'unlock' environments,
or to change between list
and environment
modes of
storing assayData
.
Standard generic methods:
initialize(object)
:Object instantiation, can be called by derived classes but not usually by the user.
validObject(object)
:Validity-checking method,
ensuring (1) all assayData components have the same number of
features and samples; (2) the number and names of
phenoData
rows match the number and names of
assayData
columns
as(eSet, "ExpressionSet")
Convert instance of class "eSet"
to instance of ExpressionSet-class
, if possible.
as(eSet, "MultiSet")
Convert instance of class "eSet"
to instance of MultiSet-class
, if possible.
updateObject(object, ..., verbose=FALSE)
Update instance to current version, if necessary. Usually called through class inheritance rather than directly by the user. See updateObject
updateObjectTo(object, template, ..., verbose=FALSE)
Update instance to current version by updating slots in template
, if necessary. Usually call by class inheritance, rather than directly by the user. See updateObjectTo
isCurrent(object)
Determine whether version of object is current. See isCurrent
isVersioned(object)
Determine whether object contains a 'version' string describing its structure . See isVersioned
show(object)
Informatively display object contents.
dim(object)
, ncol
Access the common
dimensions (dim
) or column numbers (ncol
), of all
memebers (dims
) of assayData
.
object[(index)
:Conducts subsetting of matrices and phenoData components
object$name
, object$name<-value
Access and set name
column in phenoData
object[[i, ...]]
, object[[i, ...]]<-value
Access and set column i
(character or
numeric index) in phenoData
. The ... argument can include
named variables (especially labelDescription
) to be added
to varMetadata.
Additional functions:
Return matrix
element
from assayData
slot of object
.
Set element element
in assayData
slot of
object
to matrix value
. If validate=TRUE
,
check that value row and column names of conform to object.
Set element element
in assayData
slot of object
to matrix value
. If
validate=TRUE
, check that row and column names of value
conform to object.
Return element names in
assayData
slot of object
updateOldESet
Update versions of eSet
constructued using listOrEnv
as assayData
slot
(before May, 2006).
Biocore team
Method use in ExpressionSet-class
.
Related classes
AssayData-class
, AnnotatedDataFrame-class
, MIAME-class
.
Derived classes
ExpressionSet-class
, SnpSet-class
.
To update objects from previous class versions, see updateOldESet
.
# update previous eSet-like class oldESet to existing derived class ## Not run: updateOldESet(oldESet, "ExpressionSet") # create a new, ad hoc, class, for personal use # all methods outlined above are available automatically .MySet <- setClass("MySet", contains="eSet") .MySet() # Create a more robust class, with constructor and validation methods # to ensure assayData contains specific matricies .TwoColorSet <- setClass("TwoColorSet", contains="eSet") TwoColorSet <- function(phenoData=AnnotatedDataFrame(), experimentData=MIAME(), annotation=character(), R=new("matrix"), G=new("matrix"), Rb=new("matrix"), Gb=new("matrix"), ...) { .TwoColorSet(phenoData=phenoData, experimentData=experimentData, annotation=annotation, R=R, G=G, Rb=Rb, Gb=Gb, ...) } setValidity("TwoColorSet", function(object) { assayDataValidMembers(assayData(object), c("R", "G", "Rb", "Gb")) }) TwoColorSet() # eSet objects cannot be instantiated directly, only derived objects try(new("eSet")) removeClass("MySet") removeClass("TwoColorSet")
# update previous eSet-like class oldESet to existing derived class ## Not run: updateOldESet(oldESet, "ExpressionSet") # create a new, ad hoc, class, for personal use # all methods outlined above are available automatically .MySet <- setClass("MySet", contains="eSet") .MySet() # Create a more robust class, with constructor and validation methods # to ensure assayData contains specific matricies .TwoColorSet <- setClass("TwoColorSet", contains="eSet") TwoColorSet <- function(phenoData=AnnotatedDataFrame(), experimentData=MIAME(), annotation=character(), R=new("matrix"), G=new("matrix"), Rb=new("matrix"), Gb=new("matrix"), ...) { .TwoColorSet(phenoData=phenoData, experimentData=experimentData, annotation=annotation, R=R, G=G, Rb=Rb, Gb=Gb, ...) } setValidity("TwoColorSet", function(object) { assayDataValidMembers(assayData(object), c("R", "G", "Rb", "Gb")) }) TwoColorSet() # eSet objects cannot be instantiated directly, only derived objects try(new("eSet")) removeClass("MySet") removeClass("TwoColorSet")
Container for high-throughput assays and experimental
metadata. ExpressionSet
class is derived from
eSet
, and requires a matrix named exprs
as
assayData member.
## Instance creation ExpressionSet(assayData, phenoData=annotatedDataFrameFrom(assayData, byrow=FALSE), featureData=annotatedDataFrameFrom(assayData, byrow=TRUE), experimentData=MIAME(), annotation=character(), protocolData=annotatedDataFrameFrom(assayData, byrow=FALSE), ...) ## Additional methods documented below
## Instance creation ExpressionSet(assayData, phenoData=annotatedDataFrameFrom(assayData, byrow=FALSE), featureData=annotatedDataFrameFrom(assayData, byrow=TRUE), experimentData=MIAME(), annotation=character(), protocolData=annotatedDataFrameFrom(assayData, byrow=FALSE), ...) ## Additional methods documented below
assayData |
A When When |
phenoData |
An optional |
featureData |
An optional |
experimentData |
An optional |
annotation |
A |
protocolData |
An optional |
... |
Additional arguments, passed to
|
Directly extends class eSet
.
ExpressionSet
instances are usually created through
ExpressionSet()
.
Inherited from eSet
:
assayData
:Contains matrices with equal
dimensions, and with column number equal to
nrow(phenoData)
. assayData
must contain a matrix
exprs
with rows representing features (e.g., probe sets)
and columns representing samples. Additional matrices of
identical size (e.g., representing measurement errors) may
also be included in assayData
. Class:AssayData-class
phenoData
:See eSet
featureData
:See eSet
experimentData
:See eSet
annotation
:See eSet
protocolData
:See eSet
Class-specific methods.
as(exprSet,"ExpressionSet")
Coerce objects of
exprSet-class
to ExpressionSet
as(object,"data.frame")
Coerce objects of
ExpressionSet-class
to data.frame
by
transposing the expression matrix and concatenating phenoData
exprs(ExpressionSet)
, exprs(ExpressionSet,matrix)<-
Access and
set elements named exprs
in the AssayData-class
slot.
esApply(ExpressionSet, MARGIN, FUN,
...)
'apply'-like function to conveniently operate on
ExpressionSet
objects. See esApply
.
write.exprs(ExpressionSet)
Write expression values to
a text file. It takes the same arguments as
write.table
Derived from eSet
:
updateObject(object, ..., verbose=FALSE)
Update instance to current version, if necessary. See updateObject
and eSet
isCurrent(object)
Determine whether version of object is current. See isCurrent
isVersioned(object)
Determine whether object contains a 'version' string describing its structure . See isVersioned
assayData(ExpressionSet)
:See eSet
sampleNames(ExpressionSet)
and sampleNames(ExpressionSet)<-
:See eSet
featureNames(ExpressionSet)
, featureNames(ExpressionSet, value)<-
:See eSet
dims(ExpressionSet)
:See eSet
phenoData(ExpressionSet)
, phenoData(ExpressionSet,value)<-
:See eSet
varLabels(ExpressionSet)
, varLabels(ExpressionSet, value)<-
:See eSet
varMetadata(ExpressionSet)
, varMetadata(ExpressionSet,value)<-
:See eSet
pData(ExpressionSet)
, pData(ExpressionSet,value)<-
:See eSet
varMetadata(ExpressionSet)
, varMetadata(ExpressionSet,value)
See eSet
experimentData(ExpressionSet)
,experimentData(ExpressionSet,value)<-
:See eSet
pubMedIds(ExpressionSet)
, pubMedIds(ExpressionSet,value)
See eSet
abstract(ExpressionSet)
:See eSet
annotation(ExpressionSet)
, annotation(ExpressionSet,value)<-
See eSet
protocolData(ExpressionSet)
, protocolData(ExpressionSet,value)<-
See eSet
combine(ExpressionSet,ExpressionSet)
:See eSet
storageMode(ExpressionSet)
, storageMode(ExpressionSet,character)<-
:See eSet
Standard generic methods:
initialize(ExpressionSet)
:Object instantiation, used
by new
; not to be called directly by the user.
updateObject(ExpressionSet)
:Update outdated versions
of ExpressionSet
to their current definition. See
updateObject
, Versions-class
.
validObject(ExpressionSet)
:Validity-checking method, ensuring
that exprs
is a member of
assayData
. checkValidity(ExpressionSet)
imposes this
validity check, and the validity checks of eSet
.
makeDataPackage(object, author, email, packageName, packageVersion, license, biocViews, filePath, description=paste(abstract(object), collapse="\n\n"), ...)
Create a data package based on an ExpressionSet object. See
makeDataPackage
.
as(exprSet,ExpressionSet)
:Coerce exprSet
to ExpressionSet
.
as(eSet,ExpressionSet)
:Coerce the eSet
portion of an object to ExpressionSet
.
show(ExpressionSet)
See eSet
dim(ExpressionSet)
, ncol
See eSet
ExpressionSet[(index)
:See eSet
ExpressionSet$
, ExpressionSet$<-
See eSet
ExpressionSet[[i]]
, ExpressionSet[[i]]<-
See eSet
Biocore team
eSet-class
, ExpressionSet-class
.
# create an instance of ExpressionSet ExpressionSet() ExpressionSet(assayData=matrix(runif(1000), nrow=100, ncol=10)) # update an existing ExpressionSet data(sample.ExpressionSet) updateObject(sample.ExpressionSet) # information about assay and sample data featureNames(sample.ExpressionSet)[1:10] sampleNames(sample.ExpressionSet)[1:5] experimentData(sample.ExpressionSet) # subset: first 10 genes, samples 2, 4, and 10 expressionSet <- sample.ExpressionSet[1:10,c(2,4,10)] # named features and their expression levels subset <- expressionSet[c("AFFX-BioC-3_at","AFFX-BioDn-5_at"),] exprs(subset) # samples with above-average 'score' in phenoData highScores <- expressionSet$score > mean(expressionSet$score) expressionSet[,highScores] # (automatically) coerce to data.frame lm(score~AFFX.BioDn.5_at + AFFX.BioC.3_at, data=subset)
# create an instance of ExpressionSet ExpressionSet() ExpressionSet(assayData=matrix(runif(1000), nrow=100, ncol=10)) # update an existing ExpressionSet data(sample.ExpressionSet) updateObject(sample.ExpressionSet) # information about assay and sample data featureNames(sample.ExpressionSet)[1:10] sampleNames(sample.ExpressionSet)[1:5] experimentData(sample.ExpressionSet) # subset: first 10 genes, samples 2, 4, and 10 expressionSet <- sample.ExpressionSet[1:10,c(2,4,10)] # named features and their expression levels subset <- expressionSet[c("AFFX-BioC-3_at","AFFX-BioDn-5_at"),] exprs(subset) # samples with above-average 'score' in phenoData highScores <- expressionSet$score > mean(expressionSet$score) expressionSet[,highScores] # (automatically) coerce to data.frame lm(score~AFFX.BioDn.5_at + AFFX.BioC.3_at, data=subset)
These generic functions access the expression and error measurements
of assay data stored in an object derived from the eSet-class
.
exprs(object) exprs(object) <- value se.exprs(object) se.exprs(object) <- value
exprs(object) exprs(object) <- value se.exprs(object) se.exprs(object) <- value
object |
Object derived from class |
value |
Matrix with rows representing features and columns samples. |
exprs
returns a (usually large!) matrix of expression values;
se.exprs
returns the corresponding matrix of standard errors,
when available.
Biocore
eSet-class
, ExpressionSet-class
, SnpSet-class
These generic functions access feature data (experiment specific information about features) and feature meta-data (e.g., descriptions of feature covariates).
featureData(object) featureData(object) <- value fData(object) fData(object) <- value fvarLabels(object) fvarLabels(object) <- value fvarMetadata(object) fvarMetadata(object) <- value
featureData(object) featureData(object) <- value fData(object) fData(object) <- value fvarLabels(object) fvarLabels(object) <- value fvarMetadata(object) fvarMetadata(object) <- value
object |
Object, possibly derived from |
value |
Value to be assigned to corresponding object. |
featureData
returns an object containing information on both
variable values and variable meta-data. fvarLabels
returns a
character vector of measured variable names. fData
returns a data
frame with features as rows, variables as columns. fvarMetadata
returns a data frame with variable names as rows, description tags
(e.g., unit of measurement) as columns.
Biocore
These generic functions access the feature names (typically, gene or SNP
identifiers) and sample names stored in an object derived from the
eSet-class
.
featureNames(object) featureNames(object) <- value sampleNames(object) sampleNames(object) <- value
featureNames(object) featureNames(object) <- value sampleNames(object) sampleNames(object) <- value
object |
Object, possibly derived from class |
value |
Character vector containing feature or sample names. |
featureNames
returns a (usually long!) character vector
uniquely identifying each feature.sampleNames
returns a
(usually shorter) character vector identifying samples.
Biocore
ExpressionSet-class
, SnpSet-class
This function will return a listing of all vignettes stored in a package's doc
directory.
getPkgVigs(package = NULL)
getPkgVigs(package = NULL)
package |
A character vector of packages to search or
|
A data.frame with columns package
, filename
, title
.
Jeff Gentry, modifications by Wolfgang Huber.
z <- getPkgVigs() z # and look at them
z <- getPkgVigs() z # and look at them
This generic function uses Versioned-class
information
to ask whether an instance of a class (e.g., read from disk) has
current version information.
By default, isCurrent
has the following behaviors:
isCurrent(Versioned-instance)
Returns a vector of logicals, indicating whether each version matches the current version from the class prototype.
isCurrent(ANY)
Return NA
, indicating that the
version cannot be determined
isCurrent(Versioned-instance, "class")
Returns a
logical vector indicating whether version identifiers shared between
Versioned-instance
and "class"
are current.
Starting with R-2.6 / Bioconductor 2.1 / Biobase 1.15.1,
isCurrent(Versioned-instance, ...)
returns an element S4
indicating whether the class has the ‘S4’ bit set; a value of
FALSE
indicates that the object needs to be recreated.
isCurrent(object, value)
isCurrent(object, value)
object |
Object whose version is to be determined, as described above. |
value |
(Optional) character string identifying a class with which to compare versions. |
isCurrent
returns a logical vector.
Biocore team
obj <- new("VersionedBiobase") isCurrent(obj) isCurrent(1:10) # NA A <- setClass("A", contains="VersionedBiobase", prototype=prototype(new("VersionedBiobase", versions=c(A="1.0.0")))) a <- A() classVersion(a) isCurrent(a, "VersionedBiobase") # is the 'VersionedBiobase' portion current? classVersion(a)["A"] <- "1.0.1" classVersion(a) isCurrent(a, "VersionedBiobase") isCurrent(a) # more recent, so does not match 'current' defined by prototype removeClass("A")
obj <- new("VersionedBiobase") isCurrent(obj) isCurrent(1:10) # NA A <- setClass("A", contains="VersionedBiobase", prototype=prototype(new("VersionedBiobase", versions=c(A="1.0.0")))) a <- A() classVersion(a) isCurrent(a, "VersionedBiobase") # is the 'VersionedBiobase' portion current? classVersion(a)["A"] <- "1.0.1" classVersion(a) isCurrent(a, "VersionedBiobase") isCurrent(a) # more recent, so does not match 'current' defined by prototype removeClass("A")
Determines which elements of a vector occur exactly once.
isUnique(x)
isUnique(x)
x |
a vector |
A logical vector of the same length as x
, in which
TRUE
indicates uniqueness.
Wolfgang Huber
x <- c(9:20, 1:5, 3:7, 0:8) isUnique(x)
x <- c(9:20, 1:5, 3:7, 0:8) isUnique(x)
This generic function checks to see whether Versioned-class
information
is present. When the argument to isVersioned
is a character
string, the prototype of the class corresponding to the string is
consulted.
By default, isVersioned
has the following behaviors:
isVersioned(Versioned-instance)
Returns TRUE
when the instance have version information.
isCurrent("class-name")
Returns TRUE
when the named class extends Versioned-class
.
isVersioned(ANY)
Returns FALSE
isVersioned(object)
isVersioned(object)
object |
Object or class name to check for version information, as described above. |
isVersioned
returns a logical indicating whether version information is present.
Biocore team
obj <- new("VersionedBiobase") isVersioned(obj) isVersioned(1:10) # FALSE A <- setClass("A", contains="VersionedBiobase", prototype=prototype(new("VersionedBiobase", versions=c(A="1.0.0")))) a <- A() isVersioned(a) removeClass("A")
obj <- new("VersionedBiobase") isVersioned(obj) isVersioned(1:10) # FALSE A <- setClass("A", contains="VersionedBiobase", prototype=prototype(new("VersionedBiobase", versions=c(A="1.0.0")))) a <- A() isVersioned(a) removeClass("A")
These functions find the longest common prefix or suffix among the strings in a character vector.
lcPrefix(x, ignore.case=FALSE) lcPrefixC(x, ignore.case=FALSE) lcSuffix(x, ignore.case=FALSE)
lcPrefix(x, ignore.case=FALSE) lcPrefixC(x, ignore.case=FALSE) lcSuffix(x, ignore.case=FALSE)
x |
a character vector. |
ignore.case |
A logical value indicating whether or not to ignore the case in making comparisons. |
Computing the longest common suffix is helpful for truncating names of objects, like microarrays, that often have a common suffix, such as .CEL.
There are some potential problems with the approach used if multibyte character encodings are being used.
lcPrefixC
is a faster implementation in C. It only handles
ascii characters.
The common prefix or suffix.
R. Gentleman
s1 <- c("ABC.CEL", "DEF.CEL") lcSuffix(s1) s2 <- c("ABC.123", "ABC.456") lcPrefix(s2) CHK <- stopifnot CHK(".CEL" == lcSuffix(s1)) CHK("bc" == lcSuffix(c("abc", "333abc", "bc"))) CHK("c" == lcSuffix(c("c", "abc", "xxxc"))) CHK("" == lcSuffix(c("c", "abc", "xxx"))) CHK("ABC." == lcPrefix(s2)) CHK("ab" == lcPrefix(c("abcd", "abcd123", "ab", "abc", "abc333333"))) CHK("a" == lcPrefix(c("abcd", "abcd123", "ax"))) CHK("a" == lcPrefix(c("a", "abcd123", "ax"))) CHK("" == lcPrefix(c("a", "abc", "xxx"))) CHK("ab" == lcPrefixC(c("abcd", "abcd123", "ab", "abc", "abc333333"))) CHK("a" == lcPrefixC(c("abcd", "abcd123", "ax"))) CHK("a" == lcPrefixC(c("a", "abcd123", "ax"))) CHK("" == lcPrefixC(c("a", "abc", "xxx")))
s1 <- c("ABC.CEL", "DEF.CEL") lcSuffix(s1) s2 <- c("ABC.123", "ABC.456") lcPrefix(s2) CHK <- stopifnot CHK(".CEL" == lcSuffix(s1)) CHK("bc" == lcSuffix(c("abc", "333abc", "bc"))) CHK("c" == lcSuffix(c("c", "abc", "xxxc"))) CHK("" == lcSuffix(c("c", "abc", "xxx"))) CHK("ABC." == lcPrefix(s2)) CHK("ab" == lcPrefix(c("abcd", "abcd123", "ab", "abc", "abc333333"))) CHK("a" == lcPrefix(c("abcd", "abcd123", "ax"))) CHK("a" == lcPrefix(c("a", "abcd123", "ax"))) CHK("" == lcPrefix(c("a", "abc", "xxx"))) CHK("ab" == lcPrefixC(c("abcd", "abcd123", "ab", "abc", "abc333333"))) CHK("a" == lcPrefixC(c("abcd", "abcd123", "ax"))) CHK("a" == lcPrefixC(c("a", "abcd123", "ax"))) CHK("" == lcPrefixC(c("a", "abc", "xxx")))
This function returns an integer vector with the length of the elements of its argument, which is expected to be a list.
listLen(x)
listLen(x)
x |
A list |
This function returns a vector of the same length as
the list x
containing the lengths of each element.
The current implementation is intended for lists containing vectors
and the C-level length function is used to determine length. This
means no dispatch is done for the elements of the list. If your
list contains S4 objects, you should use sapply(x, length)
instead.
Jeff Gentry and R. Gentleman
foo = lapply(1:8, rnorm) listLen(foo)
foo = lapply(1:8, rnorm) listLen(foo)
This generic creates a valid R package from an R data object.
makeDataPackage(object, author, email, packageName=deparse(substitute(object)), packageVersion=package_version("1.0.0"), license="Artistic-2.0", biocViews="ExperimentData", filePath=tempdir(), ...)
makeDataPackage(object, author, email, packageName=deparse(substitute(object)), packageVersion=package_version("1.0.0"), license="Artistic-2.0", biocViews="ExperimentData", filePath=tempdir(), ...)
object |
An instance of an R data object. |
author |
The author, as a character string. |
email |
A valid email address for the maintainer, as a character string. |
packageName |
The name of the package, defaults to the name of the object instance. |
packageVersion |
The version number, as a character string. |
license |
The license, as a character string. |
biocViews |
A character vector of valid biocViews views. |
filePath |
The location to create the package. |
... |
Additional arguments to specific methods. |
The function makes use of various tools in R and Bioconductor to automatically generate the source files for a valid R package.
The return value is that from a call to link{createPackage}
which
is invoked once the default arguments are set up. The data instance
is stored in the data directory with a name the same as that of the
resulting package.
Developers implementing derived methods might force correct
package name evaluation by including 'packageName' in any
callNextMethod()
.
R. Gentleman
data(sample.ExpressionSet) ## package created in tempdir() s1 <- makeDataPackage(sample.ExpressionSet, author = "Foo Author", email = "foo@bar", packageName = "FooBarPkg", packageVersion = "1.0.0")
data(sample.ExpressionSet) ## package created in tempdir() s1 <- makeDataPackage(sample.ExpressionSet, author = "Foo Author", email = "foo@bar", packageName = "FooBarPkg", packageVersion = "1.0.0")
Find the nearest neighbors of a set of query points in the same or another set of points in an n-dimensional real vector space, using the Euclidean distance.
matchpt(x, y)
matchpt(x, y)
x |
A matrix (or vector) of coordinates.
Each row represents a point in an |
y |
Optional, matrix (or vector) with the same number of columns
as |
If y
is provided, the function searches
for each point in x
its nearest neighbor in y
.
If y
is missing, it searches
for each point in x
its nearest neighbor in x
,
excluding that point itself.
In the case of ties, only the neighbor with the smaller index is given.
The implementation is simple and of complexity nrow(x)
times
nrow(y)
. For larger problems, please consider one of the many
more efficient nearest neighbor search algorithms.
A data.frame
with two columns and nrow(x)
rows.
The first column is the index of the nearest neighbor,
the second column the distance to the nearest neighbor.
If y
was given, the index is a row number in y
,
otherwise, in x
. The row names of the result are those of x
.
Oleg Sklyar [email protected]
a <- matrix(c(2,2,3,5,1,8,-1,4,5,6), ncol=2L, nrow=5L) rownames(a) = LETTERS[seq_len(nrow(a))] matchpt(a) b <- c(1,2,4,5,6) d <- c(5.3, 3.2, 8.9, 1.3, 5.6, -6, 4.45, 3.32) matchpt(b, d) matchpt(d, b)
a <- matrix(c(2,2,3,5,1,8,-1,4,5,6), ncol=2L, nrow=5L) rownames(a) = LETTERS[seq_len(nrow(a))] matchpt(a) b <- c(1,2,4,5,6) d <- c(5.3, 3.2, 8.9, 1.3, 5.6, -6, 4.45, 3.32) matchpt(b, d) matchpt(d, b)
Class MIAME
covers MIAME entries that are not covered by other classes
in Bioconductor. Namely, experimental design, samples, hybridizations,
normalization controls, and pre-processing information. The MIAME
class
is derived from MIAxE
.
name
:Object of class character
containing the experimenter name
lab
:Object of class character
containing the laboratory where the experiment was conducted
contact
:Object of class character
containing contact information for lab and/or experimenter
title
:Object of class character
containing a single-sentence experiment title
abstract
:Object of class character
containing an abstract describing the experiment
url
:Object of class character
containing a URL for the experiment
samples
:Object of class list
containing information about the samples
hybridizations
:Object of class list
containing information about the hybridizations
normControls
:Object of class list
containing information about the controls such as house keeping genes
preprocessing
:Object of class list
containing information about the pre-processing steps used on the raw data from this experiment
pubMedIds
:Object of class character
listing strings of PubMed identifiers of papers relevant to the dataset
other
:Object of class list
containing other information for which none of the above slots does not applies
Constructor methods:
MIAME()
:MIAME(name = "", lab = "", contact = "",
title = "", abstract = "", url = "",
pubMedIds = "" , samples = "",
hybridizations = list(), normControls = list(),
preprocessing = list(), other = list())
:
Creates a new MIAME
object with slots as defined above.
Class-specific methods:
abstract(MIAME)
:An accessor function for abstract
.
combine(MIAME,MIAME)
:Combine two objects of MIAME-class
, issuing warnings when ambiguities encountered.
expinfo(MIAME)
:An accessor function for name
, lab
, contact
, title
, and url
.
hybridizations(MIAME)
:An accessor function for hybridizations
.
normControls(MIAME)
:An accessor function for normControls
.
notes(MIAME), notes(MIAME) <- value
:Accessor functions for other
. notes(MIAME) <- character
appends character to notes; use notes(MIAME) <- list
to replace the notes entirely.
otherInfo(MIAME)
:An accessor function for other
.
preproc(MIAME)
:An accessor function for preprocessing
.
pubMedIds(MIAME), pubMedIds(MIAME) <- value
:Accessor function for pubMedIds
.
samples(MIAME)
:An accessor function for samples
.
Standard generic methods:
updateObject(object, ..., verbose=FALSE)
Update instance to current version, if necessary. See updateObject
isCurrent(object)
Determine whether version of object is current. See isCurrent
isVersioned(object)
Determine whether object contains a 'version' string describing its structure . See isVersioned
show(MIAME)
:Renders information about the MIAME information
Rafael A. Irizarry
http://www.mged.org/Workgroups/MIAME/miame_1.1.html
class:characterORMIAME
, read.MIAME
The MIAxE
virtual class is a general container for storing
experiment metadata. Information such as experimental design, samples,
normalization methods and pre-processing information can be stored in
these objets.
The MIAxE
class is virtual and MIAxE
objects cannot be instantiated directly. The following classes
derive directly from the MIAxE
class: MIAME.
Introduced in MIAxE
:
.__classVersion__
:A Versions
object describing
the MIAxE
version number. Intended for developer use.
Standard generic methods:
show(object)
Informatively display object contents.
Biocore team
Related classes
MIAME-class
, ExpressionSet-class
.
Derived classes
MIAME-class
.
# Create a new class MyData <- setClass("MyData", contains="MIAxE") MyData() # MIAxE objects cannot be instantiated directly try(new("MIAxE"))
# Create a new class MyData <- setClass("MyData", contains="MIAxE") MyData() # MIAxE objects cannot be instantiated directly try(new("MIAxE"))
Assign values to names in an environment.
multiassign(x, value, envir = parent.frame(), inherits=FALSE)
multiassign(x, value, envir = parent.frame(), inherits=FALSE)
x |
A vector or list of names, represented by strings. |
value |
a vector or list of values to be assigned. |
envir |
the |
inherits |
should the enclosing frames of the environment be inspected? |
The pos
argument can specify the environment in which to assign
the object in any of several ways:
as an integer (the position in the search
list); as
the character string name of an element in the search list; or as an
environment
(including using sys.frame
to
access the currently active function calls).
The envir
argument is an alternative way to specify an
environment, but is primarily there for back compatibility.
If value
is missing and x
has names then the values in
each element of x
are assigned to the names of x
.
This function is invoked for its side effect, which is assigning
the values
to the variables in x
. If no envir
is
specified, then the assignment takes place in the currently active
environment.
If inherits
is TRUE
, enclosing environments of the supplied
environment are searched until the variable x
is encountered.
The value is then assigned in the environment in which the variable is
encountered. If the symbol is not encountered then assignment takes
place in the user's workspace (the global environment).
If inherits
is FALSE
, assignment takes place in the
initial frame of envir
.
#-- Create objects 'r1', 'r2', ... 'r6' -- nam <- paste("r",1:6, sep=".") multiassign(nam, 11:16) ls(pat="^r..$") #assign the values in y to variables with the names from y y<-list(a=4,d=mean,c="aaa") multiassign(y)
#-- Create objects 'r1', 'r2', ... 'r6' -- nam <- paste("r",1:6, sep=".") multiassign(nam, 11:16) ls(pat="^r..$") #assign the values in y to variables with the names from y y<-list(a=4,d=mean,c="aaa") multiassign(y)
Container for high-throughput assays and experimental
metadata. MutliSet
is derived from
eSet-class
. MultiSet
differs from
ExpressionSet-class
because MultiSet
can contain
any element(s) in assayData
(ExpressionSet
must have an
element named exprs
).
Directly extends class eSet
.
new('MultiSet',
phenoData = [AnnotatedDataFrame],
experimentData = [MIAME],
annotation = [character],
protocolData = [AnnotatedDataFrame],
...)
updateOldESet(oldESet,"MultiSet")
MultiSet
instances are usually created through
new("MultiSet", ...)
. The ...
arguments to new
are matrices of expression data (with features
corresponding to rows and samples to columns), phenoData
,
experimentData
, annotation
, and protocolData
.
phenoData
, experimentData
, annotation
, and
protocolData
can be missing, in which case they are assigned
default values.
updateOldESet
will take a serialized instance (e.g., saved to a disk
file with save
object created with earlier definitions of
the eSet-class
, and update the object to
MultiSet
. Warnings are issued when direct translation is not
possible; incorrectly created oldESet
instances may not be updated.
Inherited from eSet
:
assayData
:Contains zero or more matrices with equal
dimensions, and with column number equal to
nrow(phenoData)
. Each matrix in assayData
has rows
representing features (e.g., reporters) and columns representing
samples. Class:AssayData-class
phenoData
:See eSet-class
experimentData
:See eSet-class
annotation
:See eSet-class
protocolData
:See eSet-class
Class-specific methods: none
Derived from eSet-class
:
updateObject(object, ..., verbose=FALSE)
Update instance to current version, if necessary. See updateObject
and eSet
isCurrent(object)
Determine whether version of object is current. See isCurrent
isVersioned(object)
Determine whether object contains a 'version' string describing its structure . See isVersioned
sampleNames(MultiSet)
and sampleNames(MultiSet)<-
:See eSet-class
featureNames(MultiSet)
, featureNames(MultiSet, value)<-
:See eSet-class
dims(MultiSet)
:See eSet-class
phenoData(MultiSet)
, phenoData(MultiSet,value)<-
:See eSet-class
varLabels(MultiSet)
, varLabels(MultiSet, value)<-
:See eSet-class
varMetadata(MultiSet)
, varMetadata(MultiSet,value)<-
:See eSet-class
pData(MultiSet)
, pData(MultiSet,value)<-
:See eSet-class
varMetadata(MultiSet)
, varMetadata(MultiSet,value)
See eSet-class
experimentData(MultiSet)
,experimentData(MultiSet,value)<-
:See eSet-class
pubMedIds(MultiSet)
, pubMedIds(MultiSet,value)
See eSet-class
abstract(MultiSet)
:See eSet-class
annotation(MultiSet)
, annotation(MultiSet,value)<-
See eSet-class
protocolData(MultiSet)
, protocolData(MultiSet,value)<-
See eSet-class
combine(MultiSet,MultiSet)
:See eSet-class
storageMode(eSet)
, storageMode(eSet,character)<-
:See eSet-class
Standard generic methods:
initialize(MultiSet)
:Object instantiation, used by new
; not to be called directly by the user.
validObject(MultiSet)
:Validity-checking method, ensuring that all elements of assayData
are matricies with equal dimensions.
as(eSet,MultiSet)
:Coerce the eSet
portion of an object to MultiSet
.
show(MultiSet)
See eSet-class
dim(MultiSet)
, ncol
See eSet-class
MultiSet[(index)
:See eSet-class
MultiSet$
, MultiSet$<-
See eSet-class
Biocore team
eSet-class
, ExpressionSet-class
# create an instance of ExpressionSet new("MultiSet")
# create an instance of ExpressionSet new("MultiSet")
Container for high-throughput assays and experimental meta-data. Data are from experiments where a single ‘chip’ contains several (more than 1) different ‘channels’. All channels on a chip have the same set of‘features’. An experiment consists of a collection of several N-channel chips; each chip is a ‘sample’.
An NChannelSet
provides a way to coordinate assay data
(expression values) with phenotype information and references to chip
annotation data; it extends the eSet
class.
An NChannelSet
allows channels to be extracted (using the
channels
method, mentioned below), and subsets of features or
samples to be selected (using [<features>,
<samples>]
). Selection and subsetting occur so that relevant
phenotypic data is maintained by the selection or subset.
Objects can be created by calls of the form NChannelSet(
assayData, phenoData, ...)
. See the examples below.
assayData
:Object of class AssayData
, usually
an environment containing matrices of identical size. Each matrix
represents a single channel. Columns in each matrix correspond to
samples, rows to features. Once created, NChannelSet
manages
coordination of samples and channels.
phenoData
:Object of class AnnotatedDataFrame
.
The data
component of the AnnotatedDataFrame
is
data.frame
with number of rows equal to the number of
samples. Columns of the data
component correspond to measured
covariates.
The varMetadata
component consists of mandatory columns
labelDescription
(providing a textual description of each column
label in the data
component) and channel
. The channel
of varMetadata
is a factor
, with levels equal to the names
of the assayData
channels, plus the special symbol
_ALL_
. The channel
column is used to indicate which
channel(s) the corresponding column in the data
component
of AnnotatedDataFrame
correspond; the _ALL_
symbol
indicates that the data
column is applicable to all
channels. varMetadata
may contain additional columns with
arbitrary information.
Once created, NChannelSet
coordinates selection and subsetting
of channels in phenoData
.
featureData
:Object of class AnnotatedDataFrame
, used to contain
feature data that is unique to this experiment; feature-level
descriptions common to a particular chip are usually referenced
through the annotation
slot.
experimentData
:Object of class MIAME
containing descriptions of the
experiment.
annotation
:Object of class "character"
. Usually a length-1 character
string identifying the chip technology used during the
experiment. The annotation string is used to retrieve information
about features, e.g., using the annotation
package.
protocolData
:Object of class "character"
. A character vector
identifying the dates the samples were scanned during the
experiment.
.__classVersion__
:Object of class Versions
, containing
automatically created information about the class definition
Biobase package version, and other information about the user
system at the time the instance was created. See
classVersion
and updateObject
for
examples of use.
Class "eSet"
, directly.
Class "VersionedBiobase"
, by class "eSet", distance 2.
Class "Versioned"
, by class "eSet", distance 3.
Methods with class-specific functionality:
channel(object, name, ...)
signature(object="NChannelSet", name="character")
.
Return an ExperessionSet
created from the channel and
corresponding phenotype of argument name
. name
must
have length 1. Arguments ...
are rarely used, but are
passed to the ExpressionSet
constructor, for instance
to influence storage.mode
.
channelNames(object)
, channelNames(object) <- value
signature(object = "NChannelSet")
.
Obtain, reorder, or rename channels contained in
object
. See channelNames
.
selectChannels(object, names, ...
signature(object = "NChannelSet", names = "character")
.
Create a new NChannelSet
from object
, containing
only channels in names
. The ...
is not used by this
method.
object[features, samples]
signature(object = "NChannelSet",
features = "ANY", samples = "ANY")
.
Create a new NChannelSet
from object
, containing
only elements matching features
and samples
; either
index may be missing, or a character, numeric, or logical vector.
sampleNames(object) <- value
signature(object = "NChannelSet", value = "list")
assign
each (named) element of value
to the sampleNames
of
the correspondingly named elements of assayData
in
object
.
Methods with functionality derived from eSet
:
annotation
, annotation<-
, assayData
,
assayData<-
, classVersion
, classVersion<-
,
dim
, dims
, experimentData
, experimentData<-
,
featureData
, featureData<-
, phenoData
,
phenoData<-
, protocolData
, protocolData<-
,
pubMedIds
, pubMedIds<-
, sampleNames
,
sampleNames<-
, storageMode
, storageMode<-
,
varMetadata
, varMetadata<-
, isCurrent
,
isVersioned
, updateObject
.
Additional methods: coerce
(‘as’, to convert between
objects, if possible), initialize
(used internally for
creating objects), show
(invoked automatically when the
object is displayed to the screen)
Martin Morgan <[email protected]>
## An empty NChannelSet obj <- NChannelSet() ## An NChannelSet with two channels (R, G) and no phenotypic data obj <- NChannelSet(R=matrix(0,10,5), G=matrix(0,10,5)) ## An NChannelSet with two channels and channel-specific phenoData R <- matrix(0, 10, 3, dimnames=list(NULL, LETTERS[1:3])) G <- matrix(1, 10, 3, dimnames=list(NULL, LETTERS[1:3])) assayData <- assayDataNew(R=R, G=G) data <- data.frame(ChannelRData=numeric(ncol(R)), ChannelGData=numeric(ncol(R)), ChannelRAndG=numeric(ncol(R))) varMetadata <- data.frame(labelDescription=c( "R-specific phenoData", "G-specific phenoData", "Both channel phenoData"), channel=factor(c("R", "G", "_ALL_"))) phenoData <- AnnotatedDataFrame(data=data, varMetadata=varMetadata) obj <- NChannelSet(assayData=assayData, phenoData=phenoData) obj ## G channel as NChannelSet selectChannels(obj, "G") ## G channel as ExpressionSet channel(obj, "G") ## Samples "A" and "C" obj[,c("A", "C")]
## An empty NChannelSet obj <- NChannelSet() ## An NChannelSet with two channels (R, G) and no phenotypic data obj <- NChannelSet(R=matrix(0,10,5), G=matrix(0,10,5)) ## An NChannelSet with two channels and channel-specific phenoData R <- matrix(0, 10, 3, dimnames=list(NULL, LETTERS[1:3])) G <- matrix(1, 10, 3, dimnames=list(NULL, LETTERS[1:3])) assayData <- assayDataNew(R=R, G=G) data <- data.frame(ChannelRData=numeric(ncol(R)), ChannelGData=numeric(ncol(R)), ChannelRAndG=numeric(ncol(R))) varMetadata <- data.frame(labelDescription=c( "R-specific phenoData", "G-specific phenoData", "Both channel phenoData"), channel=factor(c("R", "G", "_ALL_"))) phenoData <- AnnotatedDataFrame(data=data, varMetadata=varMetadata) obj <- NChannelSet(assayData=assayData, phenoData=phenoData) obj ## G channel as NChannelSet selectChannels(obj, "G") ## G channel as ExpressionSet channel(obj, "G") ## Samples "A" and "C" obj[,c("A", "C")]
Generates an informational message that corresponds to its argument(s). Similar to warning() except prefaced by "Note:" instead of "Warning message:".
note(...)
note(...)
... |
character vectors (which are pasted together) or NULL |
This function essentially cat()'s the created string to the screen. It is intended for messages to the user that are deemed to be 'informational', as opposed to warnings, etc.
Jeff Gentry
note("This is an example of a note")
note("This is an example of a note")
These generic functions access notes (unstructured descriptive data)
associated eSet-class
.
notes(<ExpressionSet>) <- <character>
is unusual, in that the
character vector is appended to the list of notes; use
notes(<ExpressionSet>) <- <list>
to entirely replace the list.
notes(object) notes(object) <- value
notes(object) notes(object) <- value
object |
Object, possibly derived from class |
value |
Character vector containing unstructured information describing the experinement. |
notes
returns a list.
Biocore
ExpressionSet-class
, SnpSet-class
Displays the specified PDF file.
openPDF(file, bg=TRUE)
openPDF(file, bg=TRUE)
file |
A character string, indicating the file to view |
bg |
Should the pdf viewer be opened in the background. |
Currently this function works on Windows and Unix platforms. Under
Windows, whatever program is associated with the file extension will
be used. Under Unix, the function will use the program named in the
option "pdfviewer" (see help(options)
for information on
how this is set.)
The bg
argument is only interpreted on Unix.
This function is executed for its side effects. The specified PDF file
is opened in the PDF viewer and TRUE
is returned.
Jeff Gentry
## Not run: openPDF("annotate.pdf")
## Not run: openPDF("annotate.pdf")
Using the data returned by vignette
this function provides a
simple easy to use interface for opening vignettes.
openVignette(package=NULL)
openVignette(package=NULL)
package |
character string indicating the package to be used. |
If package
is NULL then all packages are scanned for
vignettes. The list of vignettes is presented to the user via the
menu
command. The user may select one of the vignettes to be
opened in a PDF viewer.
No value is returned; this function is run entirely for the side effect of opening the pdf document in the PDF viewer.
R. Gentleman
vignette
, openPDF
,
menu
, getPkgVigs
if( interactive() ) openVignette("Biobase")
if( interactive() ) openVignette("Biobase")
Will report the version number of a requested installed package
package.version(pkg, lib.loc = NULL)
package.version(pkg, lib.loc = NULL)
pkg |
The name of the package |
lib.loc |
a character vector describing the location of R library trees to search through, or ‘NULL’. The default value of ‘NULL’ corresponds to all libraries currently known. |
This function is a convenience wrapper around
package.description
, and will report simply the version number
of the requested package. If the package does not exist or if the
DESCRIPTION file can not be read, then an error will be thrown.
A character string reporting the version number.
Jeff Gentry
package.version("Biobase")
package.version("Biobase")
These generic functions access the phenotypic data (e.g., covariates) and meta-data (e.g., descriptions of covariates) associated with an experiment.
phenoData(object) phenoData(object) <- value varLabels(object) varLabels(object) <- value varMetadata(object) varMetadata(object) <- value pData(object) pData(object) <- value
phenoData(object) phenoData(object) <- value varLabels(object) varLabels(object) <- value varMetadata(object) varMetadata(object) <- value pData(object) pData(object) <- value
object |
Object, possibly derived from |
value |
Value to be assigned to corresponding object. |
phenoData
returns an object containing information on both
variable values and variable meta-data. varLabels
returns a
character vector of measured variables. pData
returns a data
frame with samples as rows, variables as columns. varMetadata
returns a data frame with variable names as rows, description tags
(e.g., unit of measurement) as columns.
Biocore
eSet-class
, ExpressionSet-class
,
SnpSet-class
This generic function handles methods for adding and retrieving protocol metadata for the samples in eSets.
protocolData(object) protocolData(object) <- value
protocolData(object) protocolData(object) <- value
object |
Object derived from class eSet |
value |
Object of class AnnotatedDataFrame |
protocolData(object)
returns an AnnotatedDataFrame containing the
protocol metadata for the samples.
Biocore
phenoData
, AnnotatedDataFrame-class
,
eSet-class
, ExpressionSet-class
,
SnpSet-class
Create an instance of class AnnotatedDataFrame by reading a file, or save an AnnotatedDataFrame to a file.
read.AnnotatedDataFrame(filename, path, sep = "\t", header = TRUE, quote = "", stringsAsFactors = FALSE, row.names = 1L, varMetadata.char="#", widget = getOption("BioC")$Base$use.widgets, sampleNames = character(0), ...) write.AnnotatedDataFrame(x, file="", varMetadata.char="#", ..., append=FALSE, fileEncoding="")
read.AnnotatedDataFrame(filename, path, sep = "\t", header = TRUE, quote = "", stringsAsFactors = FALSE, row.names = 1L, varMetadata.char="#", widget = getOption("BioC")$Base$use.widgets, sampleNames = character(0), ...) write.AnnotatedDataFrame(x, file="", varMetadata.char="#", ..., append=FALSE, fileEncoding="")
filename , file
|
file or connection from which to read / write. |
x |
An instance of class |
path |
(optional) directory in which to find |
row.names |
this argument gets passed on to
|
varMetadata.char |
lines beginning with this character are used
for the |
sep , header , quote , stringsAsFactors , ...
|
further arguments
that get passed on to |
widget |
logical. Currently this is not implemented, and
setting this option to |
sampleNames |
optional argument that could be used in conjunction
with |
append , fileEncoding
|
Arguments as described in
|
.
The function read.table
is used to read
pData
. The argument varMetadata.char
is passed on to
that function as its argument comment.char
.
Lines beginning with varMetadata.char
are expected to contain
further information on the column headers of pData
.
The format is of the form: # variable: textual explanation of the
variable, units, measurement method, etc.
(assuming that #
is the value of varMetadata.char
). See also examples.
write.AnnotatedDataFrame
outputs varLabels
and
varMetadata(x)$labelDescription
as commented header lines, and
pData(x)
as a with write.table
.
read.AnnotatedDataFrame
: An instance of class
AnnotatedDataFrame
write.AnnotatedDataFrame
: NULL
, invisibly.
Martin Morgan <[email protected]> and Wolfgang Huber,
based on read.phenoData
by Rafael A. Irizarry.
AnnotatedDataFrame
for additional methods,
read.table
for details of reading in phenotypic data
exampleFile = system.file("extdata", "pData.txt", package="Biobase") adf <- read.AnnotatedDataFrame(exampleFile) adf head(pData(adf)) head(noquote(readLines(exampleFile)), 11) write.AnnotatedDataFrame(adf) # write to console by default
exampleFile = system.file("extdata", "pData.txt", package="Biobase") adf <- read.AnnotatedDataFrame(exampleFile) adf head(pData(adf)) head(noquote(readLines(exampleFile)), 11) write.AnnotatedDataFrame(adf) # write to console by default
Reads MIAME information from a file or using a widget.
read.MIAME(filename = NULL, widget = getOption("BioC")$Base$use.widgets, ...)
read.MIAME(filename = NULL, widget = getOption("BioC")$Base$use.widgets, ...)
filename |
Filename from which to read MIAME information. |
widget |
Logical. If |
... |
Further arguments to |
Notice that the MIAME
class tries to cover the MIAME entries that are not covered by other
classes in Bioconductor. Namely, experimental design, samples,
hybridizations, normalization controls, and pre-processing
information.
The function scan
is used to read.
The file must be a flat file with the
different entries for the instance
of MIAME class separated by carriage returns. The order should be: name, lab,
contact, title, abstract, and url.
Alternatively a widget can be used.
An object of class MIAME
.
Rafael Irizarry <[email protected]>
miame <- read.MIAME(widget=FALSE) ##creates an empty instance show(miame)
miame <- read.MIAME(widget=FALSE) ##creates an empty instance show(miame)
Create an instance of class ExpressionSet by reading data from files. ‘widget’ functionality is not implemented for readExpressionSet.
readExpressionSet(exprsFile, phenoDataFile, experimentDataFile, notesFile, path, annotation, ## arguments to read.* methods exprsArgs=list(sep=sep, header=header, row.names=row.names, quote=quote, ...), phenoDataArgs=list(sep=sep, header=header, row.names=row.names, quote=quote, stringsAsFactors=stringsAsFactors, ...), experimentDataArgs=list(sep=sep, header=header, row.names=row.names, quote=quote, stringsAsFactors=stringsAsFactors, ...), sep = "\t", header = TRUE, quote = "", stringsAsFactors = FALSE, row.names = 1L, ## widget widget = getOption("BioC")$Base$use.widgets, ...)
readExpressionSet(exprsFile, phenoDataFile, experimentDataFile, notesFile, path, annotation, ## arguments to read.* methods exprsArgs=list(sep=sep, header=header, row.names=row.names, quote=quote, ...), phenoDataArgs=list(sep=sep, header=header, row.names=row.names, quote=quote, stringsAsFactors=stringsAsFactors, ...), experimentDataArgs=list(sep=sep, header=header, row.names=row.names, quote=quote, stringsAsFactors=stringsAsFactors, ...), sep = "\t", header = TRUE, quote = "", stringsAsFactors = FALSE, row.names = 1L, ## widget widget = getOption("BioC")$Base$use.widgets, ...)
exprsFile |
(character) File or connection from which to read expression
values. The file should contain a matrix with rows as features and
columns as samples. |
phenoDataFile |
(character) File or connection from which to read
phenotypic data. |
experimentDataFile |
(character) File or connection from which to read
experiment data. |
notesFile |
(character) File or connection from which to read notes;
|
path |
(optional) directory in which to find all the above files. |
annotation |
(character) A single character string indicating the annotation associated with this ExpressionSet. |
exprsArgs |
A list of arguments to be used with
|
phenoDataArgs |
A list of arguments to be used (with
|
experimentDataArgs |
A list of arguments to be used (with
|
sep , header , quote , stringsAsFactors , row.names
|
arguments used
by the |
widget |
A boolean value indicating whether widgets can be
used. Widgets are NOT yet implemented for
|
... |
Further arguments that can be passed on to the
|
Expression values are read using the read.table
function. Phenotypic data are read using the
read.AnnotatedDataFrame
function. Experiment data are
read using the read.MIAME
function. Notes are read using
the readLines
function. The return value must be a valid
ExpressionSet
. Only the exprsFile
argument is required.
An instance of the ExpressionSet
class.
Martin Morgan <[email protected]>
ExpressionSet
for additional methods.
exprsFile = system.file("extdata", "exprsData.txt", package="Biobase") phenoFile = system.file("extdata", "pData.txt", package="Biobase") ## Read ExpressionSet with appropriate parameters obj = readExpressionSet(exprsFile, phenoFile, sep = "\t", header=TRUE) obj
exprsFile = system.file("extdata", "exprsData.txt", package="Biobase") phenoFile = system.file("extdata", "pData.txt", package="Biobase") ## Read ExpressionSet with appropriate parameters obj = readExpressionSet(exprsFile, phenoFile, sep = "\t", header=TRUE) obj
The reporter
object is a 500 by 1 data frame. The rows represent
the 500 probe IDs in the geneData
data. The values in
reporter
are the predefined probe types for the probes.
reporter
is used in conjunction with the geneData
object
and its associates.
data(reporter)
data(reporter)
A 500 by 1 data frame
There are 10 predefined probe types:
AFFX-
Quality Control (QC)
_f_
SequenceFamily
_g_
CommonGroups
_s_
SimilarityConstraint
_r_
RulesDropped
_i_
Incomplete
_b_
AmbiguousProbeSet
_l_
LongProbeSet
_at
AntiSenseTarget
_st
SenseTarget
Affymetrix GeneChip Expression Analysis Data Analysis Fundamentals (http://www.affymetrix.com/Auth/support/downloads/manuals/data_analysis_fundamentals_manual.pdf)
data(reporter) ## maybe str(reporter) ; plot(reporter) ...
data(reporter) ## maybe str(reporter) ; plot(reporter) ...
Given a list with names x
and values in a set y
this function
returns a list with names in y
and values in x
.
reverseSplit(inList)
reverseSplit(inList)
inList |
A named list with values that are vectors. |
First the list is unrolled to provide a two long vectors, names are repeated,
once for each of their values. Then the names are split
by the values.
This turns out to be useful for inverting mappings between one set of identifiers and an other.
A list with length equal to the number of distinct values in the input list and values from the names of the input list.
R. Gentleman
l1 = list(a=1:4, b=c(2,3), d=c(4,5)) reverseSplit(l1)
l1 = list(a=1:4, b=c(2,3), d=c(4,5)) reverseSplit(l1)
Calculates the median for each row in a matrix.
rowMedians(x, na.rm=FALSE, ...)
rowMedians(x, na.rm=FALSE, ...)
x |
|
na.rm |
|
... |
Not use. |
The implementation of rowMedians()
is optimized for both speed and memory.
To avoid coercing to double
s (and hence memory
allocation), there is a special implementation for
integer
matrices. That is, if x
is an
integer
matrix
, then
rowMedians(as.double(x))
would require three times the memory
of rowMedians(x)
, but all this is avoided.
Returns a numeric
vector
of
length N.
Missing values are excluded before calculating the medians.
Henrik Bengtsson
See rowMeans()
in colSums
().
set.seed(1) x <- rnorm(n=234*543) x[sample(1:length(x), size=0.1*length(x))] <- NA dim(x) <- c(234,543) y1 <- rowMedians(x, na.rm=TRUE) y2 <- apply(x, MARGIN=1, FUN=median, na.rm=TRUE) stopifnot(all.equal(y1, y2)) x <- cbind(x1=3, x2=c(4:1, 2:5)) stopifnot(all.equal(rowMeans(x), rowMedians(x)))
set.seed(1) x <- rnorm(n=234*543) x[sample(1:length(x), size=0.1*length(x))] <- NA dim(x) <- c(234,543) y1 <- rowMedians(x, na.rm=TRUE) y2 <- apply(x, MARGIN=1, FUN=median, na.rm=TRUE) stopifnot(all.equal(y1, y2)) x <- cbind(x1=3, x2=c(4:1, 2:5)) stopifnot(all.equal(rowMeans(x), rowMedians(x)))
This function computes the requested quantile for each row of a matrix,
or of an ExpressionSet
.
rowQ(imat, which) rowMax(imat) rowMin(imat)
rowQ(imat, which) rowMax(imat) rowMin(imat)
imat |
Either a matrix or an |
which |
An integer indicating which order statistic should be returned. |
rowMax
and rowMin
simply call rowQ
with the appropriate argument set.
The argument which
takes values between 1, for the minimum per row,
and ncol(imat)
, for the maximum per row.
A vector of length equal to the number of rows of the input matrix containing the requested quantiles.
R. Gentleman
rowMedians
.
rowMeans()
in colSums
().
data(sample.ExpressionSet) rowMin(sample.ExpressionSet) rowQ(sample.ExpressionSet, 4)
data(sample.ExpressionSet) rowMin(sample.ExpressionSet) rowQ(sample.ExpressionSet, 4)
These classes represent scalar quantities, such as a string or a
number and are useful because they provide their own validity
checking. The classes ScalarCharacter
, ScalarLogical
,
ScalarInteger
, and ScalarNumeric
all extend their
respective base vector types and can be used interchangeably (except
they should always have length one).
The mkScalar
factory function provides a convenient way of
creating Scalar<type>
objects (see the examples section below).
mkScalar(obj)
mkScalar(obj)
obj |
An object of type |
Seth Falcon
v <- list(mkScalar("a single string"), mkScalar(1), mkScalar(1L), mkScalar(TRUE)) sapply(v, class) sapply(v, length)
v <- list(mkScalar("a single string"), mkScalar(1), mkScalar(1L), mkScalar(TRUE)) sapply(v, class) sapply(v, length)
This generic function extracts specific elements from an object, returning a instance of that object.
selectChannels(object, names, ...)
selectChannels(object, names, ...)
object |
An S4 object, typically derived from class
|
names |
Character vector of named channels. |
... |
Additional arguments. |
Instance of class object
.
Biocore
obj <- NChannelSet(R=matrix(runif(100), 20, 5), G=matrix(runif(100), 20, 5)) ## G channel as NChannelSet selectChannels(obj, "G")
obj <- NChannelSet(R=matrix(runif(100), 20, 5), G=matrix(runif(100), 20, 5)) ## G channel as NChannelSet selectChannels(obj, "G")
Extract the first and last several elements of a vector for concise rendering; insert ellipses to indicate elided elements. This function is primarily meant for developer rather than end-user use.
selectSome(obj, maxToShow=5)
selectSome(obj, maxToShow=5)
obj |
A vector. |
maxToShow |
The number of elements (including "...") to render. |
This function can be used in 'show' methods to give users exemplars of
the tokens used in a vector. For example, an
ExpressionSet
built from a yeast experiment might have
features enumerated using systematic gene names (e.g., YPR181C) or
standard gene names (e.g., SEC23). The show
method for
ExpressionSet
uses selectSome
to alert the user to
the tokens used, and thereby to indicate what vocabulary must be
understood to work with the feature names.
A string vector with at most maxToShow
plus 1 elements,
where an ellipsis ("...") is included to indicate incompleteness
of the excerpt.
Martin Morgan <[email protected]>
selectSome(1:20)
selectSome(1:20)
These generic functions access the calls and call probabilities stored in objects.
snpCall(object, ...) snpCall(object, ...) <- value snpCallProbability(object, ...) snpCallProbability(object, ...) <- value
snpCall(object, ...) snpCall(object, ...) <- value snpCallProbability(object, ...) snpCallProbability(object, ...) <- value
object |
Object, possibly derived from class |
value |
Matrix with rows representing SNP calls or call probabilities and columns samples. |
... |
Additional arguments available to methods. |
snpCall
returns a matrix of SNP calls;
snpCallProbability
returns the corresponding matrix of standard errors,
when available.
Biocore
Container for high-throughput assays and experimental
metadata. SnpSet
class is derived from
eSet
, and requires matrices call
,
callProbability
as assay data members.
Directly extends class eSet
.
new('SnpSet',
phenoData = [AnnotatedDataFrame],
experimentData = [MIAME],
annotation = [character],
protocolData = [AnnotatedDataFrame],
call = [matrix],
callProbability = [matrix],
...)
SnpSet
instances are usually created through
new("SnpSet", ...)
. Usually the arguments to new
include call
(a matrix of genotypic calls, with features (SNPs)
corresponding to rows and samples to columns), phenoData
,
experimentData
, annotation
, and protocolData
.
phenoData
, experimentData
, annotation
and
protocolData
can be missing, in which case they are assigned
default values.
Inherited from eSet
:
assayData
:Contains matrices with equal
dimensions, and with column number equal to
nrow(phenoData)
. assayData
must contain a matrix
call
with rows representing features (e.g., SNPs)
and columns representing samples, and a matrix
callProbability
describing the certainty of the
call. The content of call
and callProbability
are
not enforced by the class. Additional matrices of
identical size may also be included in
assayData
. Class:AssayData-class
phenoData
:See eSet
experimentData
:See eSet
annotation
:See eSet
protocolData
:See eSet
Class-specific methods:
snpCall(SnpSet)
, snpCall(SnpSet,matrix)<-
Access and
set elements named call
in the AssayData
slot.
exprs(SnpSet)
, exprs(SnpSet,matrix)<-
Synonym
for snpCall
.
snpCallProbability(SnpSet)
,
snpCallProbability<-(SnpSet,matrix)<-
Access and set
elements named callProbability
in the AssayData
slot.
Derived from eSet
:
updateObject(object, ..., verbose=FALSE)
Update instance to current version, if necessary. See updateObject
and eSet
isCurrent(object)
Determine whether version of object is current. See isCurrent
isVersioned(object)
Determine whether object contains a 'version' string describing its structure . See isVersioned
sampleNames(SnpSet)
and sampleNames(SnpSet)<-
:See eSet
featureNames(SnpSet)
, featureNames(SnpSet, value)<-
:See eSet
dims(SnpSet)
:See eSet
phenoData(SnpSet)
, phenoData(SnpSet,value)<-
:See eSet
varLabels(SnpSet)
, varLabels(SnpSet, value)<-
:See eSet
varMetadata(SnpSet)
, varMetadata(SnpSet,value)<-
:See eSet
pData(SnpSet)
, pData(SnpSet,value)<-
:See eSet
varMetadata(SnpSet)
, varMetadata(SnpSet,value)
See eSet
experimentData(SnpSet)
,experimentData(SnpSet,value)<-
:See eSet
pubMedIds(SnpSet)
, pubMedIds(SnpSet,value)
See eSet
abstract(SnpSet)
:See eSet
annotation(SnpSet)
, annotation(SnpSet,value)<-
See eSet
protocolData(SnpSet)
, protocolData(SnpSet,value)<-
See eSet
combine(SnpSet,SnpSet)
:See eSet
storageMode(eSet)
, storageMode(eSet,character)<-
:See eSet
Standard generic methods:
initialize(SnpSet)
:Object instantiation, used by new
; not to be called directly by the user.
validObject(SnpSet)
:Validity-checking method, ensuring that call
and callProbability
is a member of assayData
. checkValidity(SnpSet)
imposes this validity check, and the validity checks of eSet
.
show(SnpSet)
See eSet
dim(SnpSet)
, ncol
See eSet
SnpSet[(index)
:See eSet
SnpSet$
, SnpSet$<-
See eSet
Martin Morgan, V.J. Carey, after initial design by R. Gentleman
These generic functions report or change the storage mode used for assayData
.
storageMode(object) storageMode(object) <- value
storageMode(object) storageMode(object) <- value
object |
Object, derived from class |
value |
Character vector containing
|
storageMode
returns a length-1 character vector
Biocore
AssayData-class
, eSet-class
ExpressionSet-class
, SnpSet-class
Inserts line breaks (collapse
) into input character strings.
The main intention of this
function is to prepare long strings for printing, so the output
is not wider than width
.
strbreak(x, width=getOption("width"), exdent=2, collapse="\n")
strbreak(x, width=getOption("width"), exdent=2, collapse="\n")
x |
a character vector |
width |
a positive integer giving the width of the output. |
exdent |
a positive integer specifying the indentation of subsequent lines after the first line. |
collapse |
a character. This is inserted to break lines. |
Wolfgang Huber http://www.ebi.ac.uk/huber
longString = paste(rep(LETTERS, 10), collapse="", sep="") cat(strbreak(longString))
longString = paste(rep(LETTERS, 10), collapse="", sep="") cat(strbreak(longString))
Given a list of lists, this function can be used to extract a named element from each sublist.
subListExtract(L, name, simplify = FALSE, keep.names = TRUE)
subListExtract(L, name, simplify = FALSE, keep.names = TRUE)
L |
A list of named lists |
name |
The name of the element in the sublists that should be extracted. This should be a length one character vector. |
simplify |
When |
keep.names |
If |
This function is implemented in C and is intended to be faster than
calling lapply
or sapply
.
If simplify=FALSE
, a list will be returned having the same
length as L
, but with each element containing the
element named name
from the corresponding inner list of
L
.
When simplify=TRUE
, an atomic vector will be returned
containing the extracted elements. If any of the inner list elements
do not have length one or cannot be put inside an atomic vector, an
error will be raised.
Seth Falcon
list_size = 500000 innerL = list(foo="foo", bar="bar") L = rep(list(innerL), list_size) system.time({j0 = sapply(L, function(x) x$foo)}) system.time({j1 = subListExtract(L, "foo", simplify=TRUE)}) stopifnot(all.equal(j0, j1)) LS = L[1:3] names(LS) = LETTERS[1:3] subListExtract(LS, "bar", simplify=TRUE) subListExtract(LS, "bar", simplify=FALSE) subListExtract(LS, "bar", simplify=TRUE, keep.names=FALSE)
list_size = 500000 innerL = list(foo="foo", bar="bar") L = rep(list(innerL), list_size) system.time({j0 = sapply(L, function(x) x$foo)}) system.time({j1 = subListExtract(L, "foo", simplify=TRUE)}) stopifnot(all.equal(j0, j1)) LS = L[1:3] names(LS) = LETTERS[1:3] subListExtract(LS, "bar", simplify=TRUE) subListExtract(LS, "bar", simplify=FALSE) subListExtract(LS, "bar", simplify=TRUE, keep.names=FALSE)
This function will attempt to determine if the user has internet connectivity to the Bioconductor website. This is useful in many situations dealing with code that uses automated downloads and other such things.
testBioCConnection()
testBioCConnection()
TRUE if a connection is possible, FALSE if not.
Jeff Gentry
z <- testBioCConnection()
z <- testBioCConnection()
The updateObjectTo
generic function returns an instance
of object
updated to the class definition of template
.
It requires that the class of the returned object be the same as the
class of the template
argument, and that the object is valid.
Usually, updating proceeds by modifying slots in
template
with information from object
, and returning
template
. Use as
to coerce an object from one
type to another; updateObjectTo
might be useful to update a
virtual superclass. By default, updateObjectTo
has the following
behavior:
updateObjectTo(ANY-object,ANY-template)
Attempt as(ANY-object,class(ANY-template))
.
updateObjectTo(object, template, ..., verbose=FALSE)
updateObjectTo(object, template, ..., verbose=FALSE)
object |
Object to be updated. |
template |
Instance representing a template for updating object. |
... |
Additional arguments, for use in specific update methods. |
verbose |
A logical, indicating whether information about the
update should be reported. Use |
updateObjectTo
returns a valid instance of template
.
Biocore team
This function updates eSet
objects created in previous versions
of Biobase to the current class structure. Warnings indicate when
coercions change how data in the from
object are
altered. If the from
object was not a valid object of the
original eSet class, then updateOldESet
may fail.
updateOldESet(from, toClass, ...)
updateOldESet(from, toClass, ...)
from |
Object created using a previous version of the eSet class. |
toClass |
Character string identifying new class, e.g.,
|
... |
Additional arguments passed to the initialization method
for class |
Valid object of class toClass
.
Biocore
eSet-class
, ExpressionSet-class
, SnpSet-class
## Not run: updateOldESet(oldESet, "ExpressionSet") ## End(Not run)
## Not run: updateOldESet(oldESet, "ExpressionSet") ## End(Not run)
This function will output a given message and seek a response from the user, repeating the message until the input is from a valid set provided by the code.
userQuery(msg, allowed = c("y", "n"), default = "n", case.sensitive = FALSE)
userQuery(msg, allowed = c("y", "n"), default = "n", case.sensitive = FALSE)
msg |
The output message |
allowed |
Allowed input from the user |
default |
Default response if called in batch mode |
case.sensitive |
Is the response case sensitive? Defaults to
|
The input from the user
Jeff Gentry
This function facilitates constructing messages during S4 class validation, and is meant for developer rather than end-user use.
validMsg(msg, result)
validMsg(msg, result)
msg |
A character vector or NULL. |
result |
Any vector. |
This function appends result
to msg
, but only if
result
is a character vector.
Martin Morgan <[email protected]>
msg <- NULL validMsg(msg, FALSE) # still NULL msg <- validMsg(msg, "one") validMsg(msg, "two")
msg <- NULL validMsg(msg, FALSE) # still NULL msg <- validMsg(msg, "one") validMsg(msg, "two")
Use this class as a ‘superclass’ for classes requiring information about versions.
The following are defined; package developers may write additional methods.
new("Versioned", ..., versions=list())
Create a new Versioned-class
instance,
perhaps with additional named version elements (the contents of
versions
) added. Named elements of versions
are
character strings that can be coerced using package_version
, or package_version
instances.
classVersion(object)
Obtain version information about instance object
. See classVersion
.
classVersion(object) <- value
Set version information on instance object
to value
; useful when object
is an instance of a class that contains VersionClass
. See classVersion
.
classVersion(object)["id"] <- value
Create or update version information "id"
on instance object
to value
; useful when object
is an instance of a class that contains VersionClass
. See classVersion
.
show(object)
Default method returns invisible
,
to avoid printing confusing information when your own class does
not have a show
method defined. Use
classVersion(object)
to get or set version information.
Biocore
obj <- new("Versioned", versions=list(A="1.0.0")) obj classVersion(obj) A <- setClass("A", contains="Versioned") classVersion("A") a <- A() a # 'show' nothing by default classVersion(a) B <- setClass("B", contains="Versioned", prototype=prototype(new("Versioned",versions=list(B="1.0.0")))) classVersion("B") b <- B() classVersion(b) classVersion(b)["B"] <- "1.0.1" classVersion(b) classVersion("B") classVersion("B") < classVersion(b) classVersion(b) == "1.0.1" C <- setClass("C", representation(x="numeric"), contains=("VersionedBiobase"), prototype=prototype(new("VersionedBiobase", versions=c(C="1.0.1")))) setMethod("show", signature(object="C"), function(object) print(object@x)) c <- C(x=1:10) c classVersion(c)
obj <- new("Versioned", versions=list(A="1.0.0")) obj classVersion(obj) A <- setClass("A", contains="Versioned") classVersion("A") a <- A() a # 'show' nothing by default classVersion(a) B <- setClass("B", contains="Versioned", prototype=prototype(new("Versioned",versions=list(B="1.0.0")))) classVersion("B") b <- B() classVersion(b) classVersion(b)["B"] <- "1.0.1" classVersion(b) classVersion("B") classVersion("B") < classVersion(b) classVersion(b) == "1.0.1" C <- setClass("C", representation(x="numeric"), contains=("VersionedBiobase"), prototype=prototype(new("VersionedBiobase", versions=c(C="1.0.1")))) setMethod("show", signature(object="C"), function(object) print(object@x)) c <- C(x=1:10) c classVersion(c)
Use this class as a ‘superclass’ for classes requiring information
about versions. By default, the class contains versions for R and
Biobase. See Versioned-class
for additional details.
set Versioned-class
for methods.
Biocore
obj <- new("VersionedBiobase") classVersion(obj) obj <- new("VersionedBiobase", versions=list(A="1.0.0")) classVersion(obj) A <- setClass("A", contains="VersionedBiobase") classVersion("A") a <- A() classVersion(a) obj <- new("VersionedBiobase", versions=c(MyVersion="1.0.0")) classVersion(obj) B <- setClass("B", contains="VersionedBiobase", prototype=prototype(new("VersionedBiobase",versions=list(B="1.0.0")))) classVersion("B") b <- B() classVersion(b) removeClass("A") removeClass("B")
obj <- new("VersionedBiobase") classVersion(obj) obj <- new("VersionedBiobase", versions=list(A="1.0.0")) classVersion(obj) A <- setClass("A", contains="VersionedBiobase") classVersion("A") a <- A() classVersion(a) obj <- new("VersionedBiobase", versions=c(MyVersion="1.0.0")) classVersion(obj) B <- setClass("B", contains="VersionedBiobase", prototype=prototype(new("VersionedBiobase",versions=list(B="1.0.0")))) classVersion("B") b <- B() classVersion(b) removeClass("A") removeClass("B")
A class to record version number information. This class is used to
report versions; to add version information to your own class, use
Versioned-class
.
The following are defined; package developers may write additional methods.
new("Versions", ...)
Create a new Versions-class
instance,
perhaps with named version elements (the contents of
...
) added. Named elements of versions
are
character strings that can be coerced using
package_version
, or package_version
instances, Versions-class
objects.
object["id"]
Obtain version information "id"
from object
.
object["id"] <- value
Create or update version information "id"
on instance object
.
object[["id"]]
Obtain version information "id"
from object
. The result is a list of integers, corresponding to entries in the version string.
object[["id"]] <- value
Create or update version information "id"
on instance object
.
object$id
Obtain version information "id"
from object
.The result is a list of integers, corresponding to entries in the version string.
object$id <- value
Create or update version
information "id"
on instance object
.
show(object)
Display version information.
updateObject(object)
Update object
to the
current Versions-class
representation. Note that this does not
update another class that uses Versions-class
to track the
class version.
as(object, "character")
Convert object
to character representation, e.g., 1.0.0
object1 < object2
Compare object1
and object2
using version class information. Symbols in addition to <
are admissible; see ?Ops
Biocore
classVersion
isCurrent
isVersioned
obj <- new("Versions", A="1.0.0") obj obj["A"] <- "1.0.1" obj obj["B"] <- "2.0" obj obj1 <- obj obj1["B"] <- "2.0.1" obj1 == obj obj1["B"] > "2.0.0" obj["B"] == "2.0" # TRUE!
obj <- new("Versions", A="1.0.0") obj obj["A"] <- "1.0.1" obj obj["B"] <- "2.0" obj obj1 <- obj obj1["B"] <- "2.0.1" obj1 == obj obj1["B"] > "2.0.0" obj["B"] == "2.0" # TRUE!
A class used to represent the ‘version’ of unversioned objects. Useful primarily for method dispatch.
The following are defined; package developers may write additional methods.
new("VersionsNull", ...)
Create a new
VersionsNull-class
instance, ignoring any additional arguments.
show(object)
Display “No version”.
Biocore
obj <- new("VersionsNull") obj obj <- new("VersionsNull", A="1.0.0") # warning obj
obj <- new("VersionsNull") obj obj <- new("VersionsNull", A="1.0.0") # warning obj