[med-svn] [r-bioc-biocgenerics] 01/01: New upstream version 0.20.0
Andreas Tille
tille at debian.org
Tue Oct 25 20:06:22 UTC 2016
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to annotated tag upstream/0.20.0
in repository r-bioc-biocgenerics.
commit 96c5ce348441b9b13609e7d4d23fbd0df3b81c9e
Author: Andreas Tille <tille at debian.org>
Date: Tue Oct 25 21:41:22 2016 +0200
New upstream version 0.20.0
---
DESCRIPTION | 14 ++++-----
NAMESPACE | 5 ++-
R/replaceSlots.R | 84 ++++++++++++++++++++++++++++++-------------------
R/which.R | 35 +++++++++++++++++++++
man/which.Rd | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 194 insertions(+), 40 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index 9c2e4ac..3d4c0a7 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: BiocGenerics
Title: S4 generic functions for Bioconductor
Description: S4 generic functions needed by many Bioconductor packages.
-Version: 0.18.0
+Version: 0.20.0
Author: The Bioconductor Dev Team
Maintainer: Bioconductor Package Maintainer <maintainer at bioconductor.org>
biocViews: Infrastructure
@@ -17,10 +17,10 @@ Collate: S3-classes-as-S4-classes.R normarg-utils.R replaceSlots.R
is.unsorted.R lapply.R lengths.R mapply.R match.R nrow.R
order.R paste.R rank.R rep.R row_colnames.R sets.R sort.R
start.R subset.R table.R tapply.R unique.R unlist.R unsplit.R
- relist.R boxplot.R image.R density.R IQR.R mad.R residuals.R
- weights.R xtabs.R clusterApply.R annotation.R combine.R
- dbconn.R dge.R fileName.R normalize.R organism_species.R
- plotMA.R plotPCA.R score.R strand.R updateObject.R
- testPackage.R zzz.R
+ relist.R which.R boxplot.R image.R density.R IQR.R mad.R
+ residuals.R weights.R xtabs.R clusterApply.R annotation.R
+ combine.R dbconn.R dge.R fileName.R normalize.R
+ organism_species.R plotMA.R plotPCA.R score.R strand.R
+ updateObject.R testPackage.R zzz.R
NeedsCompilation: no
-Packaged: 2016-05-04 04:18:48 UTC; biocbuild
+Packaged: 2016-10-17 22:55:18 UTC; biocbuild
diff --git a/NAMESPACE b/NAMESPACE
index ce36595..0b07e2d 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -120,7 +120,10 @@ export(
unlist,
## from R/unsplit.R:
- unsplit
+ unsplit,
+
+ ## from R/which.R:
+ which, which.max, which.min
)
### Generics for functions defined in package utils:
diff --git a/R/replaceSlots.R b/R/replaceSlots.R
index cd5b60e..b2ef4d5 100644
--- a/R/replaceSlots.R
+++ b/R/replaceSlots.R
@@ -2,48 +2,68 @@
### Efficient multiple slots replacement of an S4 object
### -------------------------------------------------------------------------
###
+### From a caller point of views, replacement of the slots should feel atomic
+### i.e. the object gets validated only after all the slots have been replaced.
+###
### NOTE: The stuff in this file (not exported) doesn't really belong to
### BiocGenerics.
###
### TODO: This stuff would need to be moved to a more appropriate place (when
### we have one).
+###
-unsafe_replaceSlots <- function(object, ..., .slotList = list()) {
- valid_argnames <- slotNames(object)
- args <- extraArgsAsList(valid_argnames, ...)
- firstTime <- TRUE
- listUpdate <- function(object, l) {
- for (nm in names(l)) {
- ## Too risky! identical() is not reliable enough e.g. with objects
- ## that contain external pointers. For example, DNAStringSet("A") and
- ## DNAStringSet("T") are considered to be identical! identical() needs
- ## to be fixed first.
- ##if (identical(slot(object, nm), l[[nm]]))
- ## next
- if (firstTime) {
- ## Triggers a copy.
- slot(object, nm, check=FALSE) <- l[[nm]]
- firstTime <<- FALSE
- } else {
- ## In-place modification (i.e. no copy).
- `slot<-`(object, nm, check=FALSE, l[[nm]])
- }
+unsafe_replaceSlots <- function(object, ..., .slotList=list())
+{
+ slots <- c(list(...), .slotList)
+ slots_names <- names(slots)
+ ## This is too slow. See further down for a much faster way to check
+ ## that the supplied slots exist.
+ #invalid_idx <- which(!(slots_names %in% slotNames(object)))
+ #if (length(invalid_idx) != 0L) {
+ # in1string <- paste0(slots_names[invalid_idx], collapse=", ")
+ # stop(wmsg("invalid slot(s) for ", class(object), " instance: ",
+ # in1string))
+ #}
+ first_time <- TRUE
+ for (i in seq_along(slots)) {
+ slot_name <- slots_names[[i]]
+ if (slot_name == "mcols")
+ slot_name <- "elementMetadata"
+ ## Even if we won't make any use of 'old_slot_val', this is a very
+ ## efficient way to check that the supplied slot exists.
+ ## We need to check this because the slot setter won't raise an error
+ ## in case of invalid slot name when used with 'check=FALSE'. It will
+ ## silently be a no-op!
+ old_slot_val <- slot(object, slot_name) # just a
+ slot_val <- slots[[i]]
+ ## Too risky! identical() is not reliable enough e.g. with objects
+ ## that contain external pointers. For example, DNAStringSet("A")
+ ## and DNAStringSet("T") are considered to be identical! identical()
+ ## would first need to be fixed.
+ #if (identical(old_slot_val, slot_val))
+ # next
+ if (first_time) {
+ ## Triggers a copy.
+ slot(object, slot_name, check=FALSE) <- slot_val
+ first_time <<- FALSE
+ } else {
+ ## In-place modification (i.e. no copy).
+ `slot<-`(object, slot_name, check=FALSE, slot_val)
+ }
}
object
- }
- listUpdate(listUpdate(object, args), .slotList)
}
-### 'replaceSlots' is essentially a more efficient initialize for (value) S4
-### objects.
-replaceSlots <- function(object, ..., check = TRUE) {
- if (!isTRUEorFALSE(check))
- stop("'check' must be TRUE or FALSE")
- object <- unsafe_replaceSlots(object, ...)
- if (check) {
- validObject(object)
- }
- object
+### replaceSlots() is essentially a more efficient initialize(), especially
+### when called with 'check=FALSE'.
+replaceSlots <- function(object, ..., check=TRUE)
+{
+ if (!isTRUEorFALSE(check))
+ stop("'check' must be TRUE or FALSE")
+ object <- unsafe_replaceSlots(object, ...)
+ if (check)
+ validObject(object)
+ object
}
updateS4 <- function(...)
diff --git a/R/which.R b/R/which.R
new file mode 100644
index 0000000..6380494
--- /dev/null
+++ b/R/which.R
@@ -0,0 +1,35 @@
+### =========================================================================
+### The which(), which.max() and which.min() generics
+### -------------------------------------------------------------------------
+###
+### The default methods (defined in the base package) only take a
+### fixed set of arguments. We add the ... argument to the generic
+### functions defined here so they can be called with an arbitrary
+### number of effective arguments. This was motivated by the desire to
+### optionally return global subscripts from methods on List.
+
+### These generics are slated to be internalized in base R. When that
+### happens, these calls will effectively be no-ops.
+
+.which.useAsDefault <- function(x, arr.ind = FALSE, useNames = TRUE, ...)
+ base::which(x, arr.ind, useNames, ...)
+.which.max.useAsDefault <- function(x, ...) base::which.max(x, ...)
+.which.min.useAsDefault <- function(x, ...) base::which.min(x, ...)
+
+setGeneric("which",
+ function(x, arr.ind = FALSE, useNames = TRUE, ...)
+ standardGeneric("which"),
+ useAsDefault=.which.useAsDefault,
+ signature="x"
+ )
+
+setGeneric("which.max",
+ function(x, ...) standardGeneric("which.max"),
+ useAsDefault=.which.max.useAsDefault
+ )
+
+setGeneric("which.min",
+ function(x, ...) standardGeneric("which.min"),
+ useAsDefault=.which.min.useAsDefault
+ )
+
diff --git a/man/which.Rd b/man/which.Rd
new file mode 100644
index 0000000..1c3c270
--- /dev/null
+++ b/man/which.Rd
@@ -0,0 +1,96 @@
+\name{which}
+
+\alias{which}
+\alias{which.max}
+\alias{which.min}
+
+\title{Subscript generators}
+
+\description{
+ These functions all return a vector of subscripts into their input.
+
+ NOTE: This man page is for the \code{which}, \code{which.max} and
+ \code{which.min} \emph{S4 generic functions} defined in the
+ \pkg{BiocGenerics} package. See \code{?base::\link[base]{which}} and
+ \code{?base::\link[base]{which.min}} for the default methods (defined
+ in the \pkg{base} package). Bioconductor packages can define specific
+ methods for objects (typically vector-like) not supported by the
+ default methods.
+}
+
+\usage{
+which(x, arr.ind = FALSE, useNames = TRUE, ...)
+which.max(x, ...)
+which.min(x, ...)
+}
+
+\arguments{
+ \item{x}{
+ Vector-like object, logical for \code{which}, numeric for the others.
+ }
+ \item{arr.ind, useNames}{
+ See \code{?base::\link[base]{which}} for a description of these
+ arguments.
+ }
+ \item{...}{
+ Additional arguments, for use in specific methods.
+ }
+}
+
+\value{
+ See \code{?base::\link[base]{which}} and
+ \code{?base::\link[base]{which.min}} for the value returned by the
+ default methods.
+
+ Specific methods defined in Bioconductor packages will typically
+ return an object of the same class as the input objects.
+}
+
+\note{
+ The default methods (defined in the \pkg{base} package) only take a
+ fixed set of arguments. We've added the \code{...} argument to the
+ generic functions defined in the \pkg{BiocGenerics} package so they
+ can be called with an arbitrary number of effective arguments. This
+ typically allows methods to add extra arguments for
+ controlling/altering the behavior of the operation. Like for example
+ the \code{global} argument supported by the \code{which.max}
+ method for \link[IRanges]{NumericList} objects (defined in the
+ \pkg{IRanges} package).
+}
+
+\seealso{
+ \itemize{
+ \item \code{base::\link[base]{which}} for the default \code{which},
+ \code{base::\link[base]{which.min}} for the others.
+
+ \item \code{\link[methods]{showMethods}} for displaying a summary of the
+ methods defined for a given generic function.
+
+ \item \code{\link[methods]{selectMethod}} for getting the definition of
+ a specific method.
+
+ \item \link[IRanges]{which.max,NumericList-method} in the
+ \pkg{IRanges} package for an example of a specific
+ \code{which.max} method (defined for
+ \link[IRanges]{NumericList} objects).
+
+ \item \link{BiocGenerics} for a summary of all the generics defined
+ in the \pkg{BiocGenerics} package.
+ }
+}
+
+\examples{
+which
+showMethods("which")
+selectMethod("which", c("ANY", "ANY")) # the default method
+
+which.max
+showMethods("which.max")
+selectMethod("which.max", c("ANY", "ANY")) # the default method
+
+which.min
+showMethods("which.min")
+selectMethod("which.min", c("ANY", "ANY")) # the default method
+}
+
+\keyword{methods}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-bioc-biocgenerics.git
More information about the debian-med-commit
mailing list