This page documents the S4 generics and methods defined for objects inheriting of the FuzzySets class. The FuzzySets class directly extends Sets and thus inherits of all methods defined for the parent class. In the usage below, object and x represent an object of class inheriting from FuzzySets, and value is an object of a class specified in the S4 method signature or as outlined in 'Accessors'.

# S4 method for FuzzySets
membership(object)

# S4 method for FuzzySets
membership(object) <- value

# S3 method for FuzzySets
as.matrix(x, fill = NA_real_, ...)

as.FuzzySets.matrix(matrix, ...)

Arguments

object, x

An object of class inheriting from FuzzySets.

value

An object of a class specified in the S4 method signature or as outlined in 'Accessors'.

fill

Value with which to fill in structural missings, passed to acast(). Defaults to NA_real_, to contrast with relations explictly associated with a membership function of 0.

...

Additional arguments passed to and from other methods.

matrix

A matrix. The matrix will be coerced to double type and the value will be taken to indicate the membership function.

Accessors

membership(object) returns a numeric vector of membership function for each relation.

Coercion

as(x, "matrix") and as.matrix(x) return a matrix with elements as rows, sets as columns, and a numeric value indicating the membership function.

Coercion to matrix

As it is possible to store multiple relations between the same gene and gene set, it may be necessary to collapse multiple observations of the membership function into a single value. To this end, the form as.matrix(x, fun.aggregate) can be used to provide an aggregation function. See examples.

See also

Examples

# Constructor ---- # Visually intuitive definition of sets, elements, and membership sets <- list( set1=c("A"=0.1, "B"=0.2), set2=c("B"=0.3, "C"=0.4, "D"=0.5), set3=c("E"=0.8)) # unlist the set names unlistSets <- rep(names(sets), lengths(sets)) # unlist the element names unlistElements <- unlist(sapply(sets, names), use.names = FALSE) # unlist the membership values unlistMembership <- unlist(sets, use.names = FALSE) # Reformat as a table relations <- DataFrame( element=unlistElements, set=unlistSets, membership=unlistMembership ) fs <- FuzzySets(relations=relations) fs
#> FuzzySets with 6 relations between 5 elements and 3 sets #> element set | membership #> <character> <character> | <numeric> #> [1] A set1 | 0.1 #> [2] B set1 | 0.2 #> [3] B set2 | 0.3 #> [4] C set2 | 0.4 #> [5] D set2 | 0.5 #> [6] E set3 | 0.8 #> ----------- #> elementInfo: IdVector with 0 metadata #> setInfo: IdVector with 0 metadata
# Accessors ---- membership(fs)
#> [1] 0.1 0.2 0.3 0.4 0.5 0.8
fs1 <- fs membership(fs1)[1] <- 0 # Coercion from/to FuzzySets ---- matrix1 <- as(fs, "matrix") # Coercion to FuzzySets ---- fs1 <- as(matrix1, "FuzzySets")
#> Dropping relations with NA membership function