The FuzzySets
class extends the Sets
class to implement a container that also describe different grades of membership in the interval [0,1]
.
FuzzySets(relations = DataFrame(element = character(0), set = character(0), membership = numeric(0)), ...)
relations |
|
---|---|
... | Arguments passed to the |
A FuzzySets
object.
This class does not define any additional slot to the Sets
class.
However, this class defines additional validity checks to ensure that every relation stored in a FuzzySets
are associated with a numeric membership funtion in the interval [0,1]
.
# 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)) # unlist the membership values unlistMembership <- unlist(sets) # Reformat as a table relations <- DataFrame( element=unlistElements, set=unlistSets, membership=unlistMembership ) fs <- FuzzySets(relations=relations)#># Subsetting ---- fs1 <- subset(fs, set == "set1" | membership > 0.5) # Coercing ---- # to list (gene sets) ls1 <- as(fs, "list") # to matrix (continuous membership) m1 <- as(fs, "matrix") # to matrix (multiple observations) mm1 <- as.matrix(fs, fun.aggregate=min) # Getters/Setters ---- membership(fs)#> [1] 0.1 0.2 0.3 0.4 0.5 0.8