FuzzySets-methods: Methods for 'FuzzySets' Objects

Description Usage Arguments Accessors Coercion Coercion to matrix Author(s) See Also Examples

Description

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'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S4 method for signature 'FuzzySets'
membership(object)

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

## S3 method for class '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.

Author(s)

Kevin Rue-Albrecht

See Also

FuzzySets, Sets-methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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

# Accessors ----

membership(fs)
fs1 <- fs
membership(fs1)[1] <- 0

# Coercion from/to FuzzySets ----

matrix1 <- as(fs, "matrix")

# Coercion to FuzzySets ----

fs1 <- as(matrix1, "FuzzySets")

kevinrue/unisets documentation built on May 15, 2020, 10:48 p.m.