sets: Set operations

Description Usage Arguments Value Note See Also Examples

Description

Performs set union, intersection and (asymmetric!) difference on two vector-like objects.

NOTE: This man page is for the union, intersect and setdiff S4 generic functions defined in the BiocGenerics package. See ?base::union for the default methods (defined in the base package). Bioconductor packages can define specific methods for objects (typically vector-like) not supported by the default methods.

Usage

1
2
3
union(x, y, ...)
intersect(x, y, ...)
setdiff(x, y, ...)

Arguments

x, y

Vector-like objects (typically of the same class, but not necessarily).

...

Additional arguments, for use in specific methods.

Value

See ?base::union 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 base package) only take 2 arguments. We've added the ... argument to the generic functions defined in the BiocGenerics package so they can be called with an arbitrary number of effective arguments. For union or intersect, this typically allows Bioconductor packages to define methods that compute the union or intersection of more than 2 objects. However, for setdiff, which is conceptually a binary operation, this typically allows methods to add extra arguments for controlling/altering the behavior of the operation. Like for example the ignore.strand argument supported by the setdiff method for GenomicRanges objects (defined in the GenomicRanges package). (Note that the union and intersect methods for those objects also support the ignore.strand argument.)

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
union
showMethods("union")
selectMethod("union", c("ANY", "ANY"))  # the default method

intersect
showMethods("intersect")
selectMethod("intersect", c("ANY", "ANY"))  # the default method

setdiff
showMethods("setdiff")
selectMethod("setdiff", c("ANY", "ANY"))  # the default method

Example output

Loading required package: parallel

Attaching package:BiocGenericsThe following objects are masked frompackage:parallel:

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

The following objects are masked frompackage:stats:

    IQR, mad, sd, var, xtabs

The following objects are masked frompackage:base:

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

standardGeneric for "union" defined from package "BiocGenerics"

function (x, y, ...) 
standardGeneric("union")
<bytecode: 0x560037f697e0>
<environment: 0x560037fb0c40>
Methods may be defined for arguments: x, y
Use  showMethods("union")  for currently available ones.
Function: union (package BiocGenerics)
x="ANY"

Method Definition (Class "derivedDefaultMethod"):

function (x, y, ...) 
base::union(x, y, ...)
<bytecode: 0x560037f5f6c0>
<environment: namespace:BiocGenerics>

Signatures:
        x    
target  "ANY"
defined "ANY"
standardGeneric for "intersect" defined from package "BiocGenerics"

function (x, y, ...) 
standardGeneric("intersect")
<bytecode: 0x560037974d18>
<environment: 0x560037972138>
Methods may be defined for arguments: x, y
Use  showMethods("intersect")  for currently available ones.
Function: intersect (package BiocGenerics)
x="ANY"

Method Definition (Class "derivedDefaultMethod"):

function (x, y, ...) 
base::intersect(x, y, ...)
<bytecode: 0x5600382291d8>
<environment: namespace:BiocGenerics>

Signatures:
        x    
target  "ANY"
defined "ANY"
standardGeneric for "setdiff" defined from package "BiocGenerics"

function (x, y, ...) 
standardGeneric("setdiff")
<bytecode: 0x56003a0464b0>
<environment: 0x56003a03f830>
Methods may be defined for arguments: x, y
Use  showMethods("setdiff")  for currently available ones.
Function: setdiff (package BiocGenerics)
x="ANY"

Method Definition (Class "derivedDefaultMethod"):

function (x, y, ...) 
base::setdiff(x, y, ...)
<bytecode: 0x56003a049e20>
<environment: namespace:BiocGenerics>

Signatures:
        x    
target  "ANY"
defined "ANY"

BiocGenerics documentation built on April 17, 2021, 6:01 p.m.