Title: | Working with Sets the Tidy Way |
---|---|
Description: | Implements a class and methods to work with sets, doing intersection, union, complementary sets, power sets, cartesian product and other set operations in a "tidy" way. These set operations are available for both classical sets and fuzzy sets. Import sets from several formats or from other several data structures. |
Authors: | Lluís Revilla Sancho [aut, cre, cph] , Zebulun Arendsee [rev], Jennifer Chang [rev] |
Maintainer: | Lluís Revilla Sancho <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.9.0.9002 |
Built: | 2024-11-27 03:57:26 UTC |
Source: | https://github.com/ropensci/BaseSet |
Functions to help to perform some action to just some type of data: elements,
sets or relations.
activate
: To table the focus of future manipulations: elements, sets
or relations.
active
: To check the focus on the TidySet
.
deactivate
: To remove the focus on a specific TidySet
-
activate(.data, what) active(.data) deactivate(.data)
activate(.data, what) active(.data) deactivate(.data)
.data |
A |
what |
Either "elements", "sets" or "relations" |
A TidySet
object.
Other methods:
TidySet-class
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) elements(a) <- cbind(elements(a), type = c(rep("Gene", 4), rep("lncRNA", 2)) ) # Filter in the whole TidySet filter(a, elements == "a") filter(a, elements == "a", type == "Gene") # Equivalent to filter_elements filter_element(a, type == "Gene") a <- activate(a, "elements") active(a) filter(a, type == "Gene") a <- deactivate(a) active(a) filter(a, type == "Gene")
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) elements(a) <- cbind(elements(a), type = c(rep("Gene", 4), rep("lncRNA", 2)) ) # Filter in the whole TidySet filter(a, elements == "a") filter(a, elements == "a", type == "Gene") # Equivalent to filter_elements filter_element(a, type == "Gene") a <- activate(a, "elements") active(a) filter(a, type == "Gene") a <- deactivate(a) active(a) filter(a, type == "Gene")
Add column to a slot of the TidySet object.
add_column(object, slot, columns) ## S4 method for signature 'TidySet,character' add_column(object, slot, columns)
add_column(object, slot, columns) ## S4 method for signature 'TidySet,character' add_column(object, slot, columns)
object |
A TidySet object. |
slot |
A TidySet slot. |
columns |
The columns to add. |
A TidySet
object.
add_column(object = TidySet, slot = character)
: Add a column to any slot
Other column:
remove_column()
Other methods:
TidySet-class
,
activate()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) add_column(TS, "relations", data.frame(well = c( "GOOD", "BAD", "WORSE", "UGLY", "FOE", "HEY" )))
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) add_column(TS, "relations", data.frame(well = c( "GOOD", "BAD", "WORSE", "UGLY", "FOE", "HEY" )))
Functions to add elements. If the elements are new they are added, otherwise they are omitted.
add_elements(object, elements, ...)
add_elements(object, elements, ...)
object |
A |
elements |
A character vector of the elements. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A TidySet
object with the new elements.
add_element
doesn't set up any other information about the elements.
Remember to add/modify them if needed with mutate
or mutate_element
Other add_*:
add_relations()
,
add_sets()
x <- list("a" = letters[1:5], "b" = LETTERS[3:7]) a <- tidySet(x) b <- add_elements(a, "fg") elements(b)
x <- list("a" = letters[1:5], "b" = LETTERS[3:7]) a <- tidySet(x) b <- add_elements(a, "fg") elements(b)
Given a TidySet adds new relations between elements and sets.
add_relation(object, relations, ...) ## S4 method for signature 'TidySet,data.frame' add_relation(object, relations)
add_relation(object, relations, ...) ## S4 method for signature 'TidySet,data.frame' add_relation(object, relations)
object |
A TidySet object |
relations |
A data.frame object |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A TidySet
object.
add_relation(object = TidySet, relations = data.frame)
: Adds relations
Other methods:
TidySet-class
,
activate()
,
add_column()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) relations <- data.frame( sets = c(rep("A2", 5), "B2"), elements = letters[seq_len(6)], fuzzy = runif(6), new = runif(6) ) add_relation(TS, relations)
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) relations <- data.frame( sets = c(rep("A2", 5), "B2"), elements = letters[seq_len(6)], fuzzy = runif(6), new = runif(6) ) add_relation(TS, relations)
Adds new relations to existing or new sets and elements. If the sets or elements do not exist they are added.
add_relations(object, elements, sets, fuzzy, ...)
add_relations(object, elements, sets, fuzzy, ...)
object |
A |
elements |
A character vector of the elements. |
sets |
A character vector of sets to be added. |
fuzzy |
The strength of the membership. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A TidySet
object with the new relations.
add_relations
doesn't set up any other information about the
relationship.
Remember to add/modify them if needed with mutate
or mutate_relation
add_relation()
to add relations with new sets or/and
new elements.
Other add_*:
add_elements()
,
add_sets()
x <- list("a" = letters[1:5], "b" = LETTERS[3:7]) a <- tidySet(x) add_relations(a, elements = c("a", "b", "g"), sets = "d") add_relations(a, elements = c("a", "b"), sets = c("d", "g")) add_relations(a, elements = c("a", "b"), sets = c("d", "g"), fuzzy = 0.5) add_relations(a, elements = c("a", "b"), sets = c("d", "g"), fuzzy = c(0.5, 0.7) )
x <- list("a" = letters[1:5], "b" = LETTERS[3:7]) a <- tidySet(x) add_relations(a, elements = c("a", "b", "g"), sets = "d") add_relations(a, elements = c("a", "b"), sets = c("d", "g")) add_relations(a, elements = c("a", "b"), sets = c("d", "g"), fuzzy = 0.5) add_relations(a, elements = c("a", "b"), sets = c("d", "g"), fuzzy = c(0.5, 0.7) )
Functions to add sets. If the sets are new they are added, otherwise they are omitted.
add_sets(object, sets, ...)
add_sets(object, sets, ...)
object |
A |
sets |
A character vector of sets to be added. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A TidySet
object with the new sets.
add_sets
doesn't set up any other information about the sets.
Remember to add/modify them if needed with mutate
or mutate_set
Other add_*:
add_elements()
,
add_relations()
x <- list("a" = letters[1:5], "b" = LETTERS[3:7]) a <- tidySet(x) b <- add_sets(a, "fg") sets(b)
x <- list("a" = letters[1:5], "b" = LETTERS[3:7]) a <- tidySet(x) b <- add_sets(a, "fg") sets(b)
Are two elements connected ?
## S3 method for class 'TidySet' adjacency(object) adjacency_element(object) adjacency_set(object) ## S3 method for class 'TidySet' adjacency(object)
## S3 method for class 'TidySet' adjacency(object) adjacency_element(object) adjacency_set(object) ## S3 method for class 'TidySet' adjacency(object)
object |
A TidySet object |
A square matrix, 1 if two nodes are connected, 0 otherwise.
x <- list("SET1" = letters[1:5], "SET2" = LETTERS[3:7]) a <- tidySet(x) adjacency_element(a) adjacency_set(a)
x <- list("SET1" = letters[1:5], "SET2" = LETTERS[3:7]) a <- tidySet(x) adjacency_element(a) adjacency_set(a)
Use arrange to extract the columns of a TidySet object. You can use activate with filter or use the specific function. The S3 method filters using all the information on the TidySet.
## S3 method for class 'TidySet' arrange(.data, ...) arrange_set(.data, ...) arrange_element(.data, ...) arrange_relation(.data, ...)
## S3 method for class 'TidySet' arrange(.data, ...) arrange_set(.data, ...) arrange_element(.data, ...) arrange_relation(.data, ...)
.data |
The TidySet object |
... |
Comma separated list of variables names or expressions integer column position to be used to reorder the TidySet. |
A TidySet object
dplyr::arrange()
and activate()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("A", 5), "B", rep("A2", 5), "B2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) a <- mutate_element(a, type = c(rep("Gene", 4), rep("lncRNA", 2)) ) b <- arrange(a, desc(type)) elements(b) b <- arrange_element(a, elements) elements(b) # Arrange sets arrange_set(a, sets)
relations <- data.frame( sets = c(rep("A", 5), "B", rep("A2", 5), "B2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) a <- mutate_element(a, type = c(rep("Gene", 4), rep("lncRNA", 2)) ) b <- arrange(a, desc(type)) elements(b) b <- arrange_element(a, elements) elements(b) # Arrange sets arrange_set(a, sets)
Flattens the three slots to a single big table
## S3 method for class 'TidySet' as.data.frame(x, ...)
## S3 method for class 'TidySet' as.data.frame(x, ...)
x |
The |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A data.frame
table.
Converts a TidySet to a list.
## S3 method for class 'TidySet' as.list(x, ...)
## S3 method for class 'TidySet' as.list(x, ...)
x |
A TidySet object to be coerced to a list. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A list.
r <- data.frame(sets = c("A", "A", "A", "B", "C"), elements = c(letters[1:3], letters[2:3]), fuzzy = runif(5), info = rep_len(c("important", "very important"), 5)) TS <- tidySet(r) TS as.list(TS)
r <- data.frame(sets = c("A", "A", "A", "B", "C"), elements = c(letters[1:3], letters[2:3]), fuzzy = runif(5), info = rep_len(c("important", "very important"), 5)) TS <- tidySet(r) TS as.list(TS)
This method combines TidySets. It only works if the first element is a TidySet.
## S4 method for signature 'TidySet' c(x, ...)
## S4 method for signature 'TidySet' c(x, ...)
x |
A TidySet object. |
... |
Objects to be concatenated. All NULL entries are dropped. |
TS <- tidySet(list(A = letters[1:5], B = letters[6])) TS2 <- c(TS, data.frame(sets = "C", elements = "gg"))
TS <- tidySet(list(A = letters[1:5], B = letters[6])) TS2 <- c(TS, data.frame(sets = "C", elements = "gg"))
Calculates the membership of sets according to the logic defined in FUN.
cardinality(object, sets = NULL, ...) ## S4 method for signature 'TidySet' cardinality(object, sets, FUN = "sum", ...)
cardinality(object, sets = NULL, ...) ## S4 method for signature 'TidySet' cardinality(object, sets, FUN = "sum", ...)
object |
A TidySet object. |
sets |
Character vector with the name of the sets. |
... |
Other arguments passed to |
FUN |
Function that returns a single numeric value given a vector of fuzzy values. |
cardinality(TidySet)
: Cardinality of sets
rel <- list(A = letters[1:3], B = letters[1:2]) TS <- tidySet(rel) cardinality(TS, "A")
rel <- list(A = letters[1:3], B = letters[1:2]) TS <- tidySet(rel) cardinality(TS, "A")
Given two sets creates new sets with one element of each set
cartesian(object, set1, set2, name = NULL, ...) ## S3 method for class 'TidySet' cartesian( object, set1, set2, name = NULL, keep = TRUE, keep_relations = keep, keep_elements = keep, keep_sets = keep, ... )
cartesian(object, set1, set2, name = NULL, ...) ## S3 method for class 'TidySet' cartesian( object, set1, set2, name = NULL, keep = TRUE, keep_relations = keep, keep_elements = keep, keep_sets = keep, ... )
object |
A TidySet object. |
set1 , set2
|
The name of the sets to be used for the cartesian product |
name |
The name of the new set. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
keep |
A logical value if you want to keep. |
keep_relations |
A logical value if you wan to keep old relations. |
keep_elements |
A logical value if you wan to keep old elements. |
keep_sets |
A logical value if you wan to keep old sets. |
A TidySet object with the new set
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)] ) TS <- tidySet(relations) cartesian(TS, "a", "b")
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)] ) TS <- tidySet(relations) cartesian(TS, "a", "b")
Use complement to find elements or sets the TidySet object. You can use activate with complement or use the specific function. You must specify if you want the complements of sets or elements.
complement(.data, ...)
complement(.data, ...)
.data |
The TidySet object |
... |
Other arguments passed to either |
A TidySet object
Other complements:
complement_element()
,
complement_set()
,
subtract()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
rel <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(rel) TS %>% activate("elements") %>% complement("a") TS %>% activate("elements") %>% complement("a", "C_a", keep = FALSE) TS %>% activate("set") %>% complement("A") TS %>% activate("set") %>% complement("A", keep = FALSE) TS %>% activate("set") %>% complement("A", FUN = function(x){abs(x - 0.2)}, keep = FALSE)
rel <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(rel) TS %>% activate("elements") %>% complement("a") TS %>% activate("elements") %>% complement("a", "C_a", keep = FALSE) TS %>% activate("set") %>% complement("A") TS %>% activate("set") %>% complement("A", keep = FALSE) TS %>% activate("set") %>% complement("A", FUN = function(x){abs(x - 0.2)}, keep = FALSE)
Return the objects without the elements listed
complement_element(object, elements, ...) ## S4 method for signature 'TidySet,characterORfactor' complement_element( object, elements, name = NULL, FUN = NULL, keep = TRUE, keep_relations = keep, keep_elements = keep, keep_sets = keep )
complement_element(object, elements, ...) ## S4 method for signature 'TidySet,characterORfactor' complement_element( object, elements, name = NULL, FUN = NULL, keep = TRUE, keep_relations = keep, keep_elements = keep, keep_sets = keep )
object |
A TidySet object. |
elements |
The set to look for the complement. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
name |
Name of the new set. By default it adds a "C". |
FUN |
A function to be applied when performing the union. The standard union is the "max" function, but you can provide any other function that given a numeric vector returns a single number. |
keep |
Logical value to keep all the other sets. |
keep_relations |
A logical value if you wan to keep old relations. |
keep_elements |
A logical value if you wan to keep old elements. |
keep_sets |
A logical value if you wan to keep old sets. |
A TidySet
object.
complement_element(object = TidySet, elements = characterORfactor)
: Complement of the elements.
Other complements:
complement_set()
,
complement()
,
subtract()
Other methods that create new sets:
complement_set()
,
intersection()
,
subtract()
,
union()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) complement_element(TS, "a", "C_a") complement_element(TS, "a", "C_a", keep = FALSE)
relations <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) complement_element(TS, "a", "C_a") complement_element(TS, "a", "C_a", keep = FALSE)
Return the complement for a set
complement_set(object, sets, ...) ## S4 method for signature 'TidySet,characterORfactor' complement_set( object, sets, name = NULL, FUN = NULL, keep = TRUE, keep_relations = keep, keep_elements = keep, keep_sets = keep )
complement_set(object, sets, ...) ## S4 method for signature 'TidySet,characterORfactor' complement_set( object, sets, name = NULL, FUN = NULL, keep = TRUE, keep_relations = keep, keep_elements = keep, keep_sets = keep )
object |
A TidySet object. |
sets |
The name of the set to look for the complement. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
name |
Name of the new set. By default it adds a "C". |
FUN |
A function to be applied when performing the union. The standard union is the "max" function, but you can provide any other function that given a numeric vector returns a single number. |
keep |
Logical value to keep all the other sets. |
keep_relations |
A logical value if you wan to keep old relations. |
keep_elements |
A logical value if you wan to keep old elements. |
keep_sets |
A logical value if you wan to keep old sets. |
A TidySet
object.
complement_set(object = TidySet, sets = characterORfactor)
: Complement of the sets.
Other complements:
complement_element()
,
complement()
,
subtract()
Other methods that create new sets:
complement_element()
,
intersection()
,
subtract()
,
union()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) complement_set(TS, "A")
relations <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) complement_set(TS, "A")
Retrieve the column names of the slots of a TidySet.
## S3 method for class 'TidySet' dimnames(x)
## S3 method for class 'TidySet' dimnames(x)
x |
A TidySet object. |
A list with the names of the columns of the sets, elements and relations.
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) dimnames(TS)
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) dimnames(TS)
Drop elements and sets without any relation.
## S3 method for class 'TidySet' droplevels(x, elements = TRUE, sets = TRUE, relations = TRUE, ...)
## S3 method for class 'TidySet' droplevels(x, elements = TRUE, sets = TRUE, relations = TRUE, ...)
x |
A TidySet object. |
elements |
Logical value: Should elements be dropped? |
sets |
Logical value: Should sets be dropped? |
relations |
Logical value: Should sets be dropped? |
... |
Other arguments, currently ignored. |
A TidySet object.
rel <- list(A = letters[1:3], B = character()) TS <- tidySet(rel) TS sets(TS) TS2 <- droplevels(TS) TS2 sets(TS2)
rel <- list(A = letters[1:3], B = character()) TS <- tidySet(rel) TS sets(TS) TS2 <- droplevels(TS) TS2 sets(TS2)
Assuming that the fuzzy values are probabilities, calculates the probability of being of different sizes for a given set.
element_size(object, elements = NULL) ## S4 method for signature 'TidySet' element_size(object, elements = NULL)
element_size(object, elements = NULL) ## S4 method for signature 'TidySet' element_size(object, elements = NULL)
object |
A TidySet object. |
elements |
The element from which the length is calculated. |
A list with the size of the elements or the probability of having that size.
element_size(TidySet)
: Calculates the number of sets an element appears
with length_set()
cardinality
Other sizes:
set_size()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("A", 5), "B", "C"), elements = c(letters[seq_len(6)], letters[6]), fuzzy = runif(7) ) a <- tidySet(relations) element_size(a)
relations <- data.frame( sets = c(rep("A", 5), "B", "C"), elements = c(letters[seq_len(6)], letters[6]), fuzzy = runif(7) ) a <- tidySet(relations) element_size(a)
Given TidySet retrieve the elements or substitute them.
elements(object) elements(object) <- value ## S4 method for signature 'TidySet' elements(object) ## S4 replacement method for signature 'TidySet' elements(object) <- value replace_elements(object, value) ## S4 method for signature 'TidySet,missing' nElements(object) ## S4 method for signature 'TidySet,logical' nElements(object, all)
elements(object) elements(object) <- value ## S4 method for signature 'TidySet' elements(object) ## S4 replacement method for signature 'TidySet' elements(object) <- value replace_elements(object, value) ## S4 method for signature 'TidySet,missing' nElements(object) ## S4 method for signature 'TidySet,logical' nElements(object, all)
object |
A TidySet object. |
value |
Modification of the elements. |
all |
A logical value to count all elements or just those present. |
A data.frame
with information about the elements
elements(TidySet)
: Retrieve the elements
elements(TidySet) <- value
: Modify the elements
nElements(object = TidySet, all = missing)
: Return the number of elements
nElements(object = TidySet, all = logical)
: Return the number of elements
Other slots:
relations()
,
sets()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
TS <- tidySet(list(A = letters[1:5], B = letters[2:10])) elements(TS) elements(TS) <- data.frame(elements = letters[10:1]) TS2 <- replace_elements(TS, data.frame(elements = letters[1:11])) nElements(TS) nElements(TS2)
TS <- tidySet(list(A = letters[1:5], B = letters[2:10])) elements(TS) elements(TS) <- data.frame(elements = letters[10:1]) TS2 <- replace_elements(TS, data.frame(elements = letters[1:11])) nElements(TS) nElements(TS2)
Operators acting on TidySet to extract or replace parts. They are designed to resemble the basic operators.
## S4 method for signature 'TidySet' x$name ## S4 replacement method for signature 'TidySet' x$name <- value ## S4 method for signature 'TidySet' x[i, j, k, ..., drop = TRUE] ## S4 replacement method for signature 'TidySet' x[i, j, k, ...] <- value ## S4 method for signature 'TidySet' x[[i, j, ..., exact = TRUE]] ## S4 replacement method for signature 'TidySet' x[[i]] <- value
## S4 method for signature 'TidySet' x$name ## S4 replacement method for signature 'TidySet' x$name <- value ## S4 method for signature 'TidySet' x[i, j, k, ..., drop = TRUE] ## S4 replacement method for signature 'TidySet' x[i, j, k, ...] <- value ## S4 method for signature 'TidySet' x[[i, j, ..., exact = TRUE]] ## S4 replacement method for signature 'TidySet' x[[i]] <- value
x |
A TidySet object. |
name |
The data about the TidySet object to extract. |
value |
The value to overwrite |
i |
Which rows do you want to keep? By default all. |
j |
Which slot do you want to extract? One of "sets", "elements" or "relations". |
k |
Which columns do you want to extract. By default all. |
... |
Other arguments currently ignored. |
drop |
Remove remaining elements, sets and relations? Passed to all
arguments of |
exact |
A logical value. FALSE if fuzzy matching is wanted. Add values to the TidySet. Allows to control to which slot is it added. |
Always returns a valid TidySet.
TS <- tidySet(list(A = letters[1:5], B = letters[6])) TS[, "sets", "origin"] <- sample(c("random", "non-random"), 2, replace = TRUE) TS[, "sets", "type"] <- c("Fantastic", "Wonderful") # This produces a warning # TS$description <- c("What", "can", "I", "say", "now", "?") # Better to be explicit: TS[, "relations", "description"] <- c("What", "can", "I", "say", "now", "?") relations(TS) TS[, "elements", "description"] <- rev(c("What", "can", "I", "say", "now", "?")) elements(TS) # Which will be deleted? # TS$description <- NULL TS$type TS$origin <- c("BCN", "BDN") # Different subsets TS[1, "elements"] TS[1, "sets"] # Always print TS TS[, "sets", c("type", "origin")] # Same TS[, "sets", "origin"] # Drop column type is(TS[, "sets", "origin"]) TS[, "sets"] TS[["A"]] TS[["B"]] TS[["C"]] # Any other set is the empty set
TS <- tidySet(list(A = letters[1:5], B = letters[6])) TS[, "sets", "origin"] <- sample(c("random", "non-random"), 2, replace = TRUE) TS[, "sets", "type"] <- c("Fantastic", "Wonderful") # This produces a warning # TS$description <- c("What", "can", "I", "say", "now", "?") # Better to be explicit: TS[, "relations", "description"] <- c("What", "can", "I", "say", "now", "?") relations(TS) TS[, "elements", "description"] <- rev(c("What", "can", "I", "say", "now", "?")) elements(TS) # Which will be deleted? # TS$description <- NULL TS$type TS$origin <- c("BCN", "BDN") # Different subsets TS[1, "elements"] TS[1, "sets"] # Always print TS TS[, "sets", c("type", "origin")] # Same TS[, "sets", "origin"] # Drop column type is(TS[, "sets", "origin"]) TS[, "sets"] TS[["A"]] TS[["B"]] TS[["C"]] # Any other set is the empty set
Use filter to subset the TidySet object. You can use activate with filter or use the specific function. The S3 method filters using all the information on the TidySet.
## S3 method for class 'TidySet' filter(.data, ...) filter_set(.data, ...) filter_element(.data, ...) filter_relation(.data, ...)
## S3 method for class 'TidySet' filter(.data, ...) filter_set(.data, ...) filter_element(.data, ...) filter_relation(.data, ...)
.data |
The TidySet object. |
... |
The logical predicates in terms of the variables of the sets. |
A TidySet object.
dplyr::filter()
and activate()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12), type = c(rep("Gene", 4), rep("lncRNA", 2)) ) TS <- tidySet(relations) TS <- move_to(TS, from = "relations", to = "elements", column = "type") filter(TS, elements == "a") # Equivalent to filter_relation filter(TS, elements == "a", sets == "a") filter_relation(TS, elements == "a", sets == "a") # Filter element filter_element(TS, type == "Gene") # Filter sets and by property of elements simultaneously filter(TS, sets == "b", type == "lncRNA") # Filter sets filter_set(TS, sets == "b")
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12), type = c(rep("Gene", 4), rep("lncRNA", 2)) ) TS <- tidySet(relations) TS <- move_to(TS, from = "relations", to = "elements", column = "type") filter(TS, elements == "a") # Equivalent to filter_relation filter(TS, elements == "a", sets == "a") filter_relation(TS, elements == "a", sets == "a") # Filter element filter_element(TS, type == "Gene") # Filter sets and by property of elements simultaneously filter(TS, sets == "b", type == "lncRNA") # Filter sets filter_set(TS, sets == "b")
Read a GO Annotation File (GAF) formatted file
getGAF(x)
getGAF(x)
x |
A file in GAF format |
A TidySet object
The format is defined here.
Other IO functions:
getGMT()
,
getOBO()
gafFile <- system.file( package = "BaseSet", "extdata", "go_human_rna_valid_subset.gaf" ) gs <- getGAF(gafFile) head(gs)
gafFile <- system.file( package = "BaseSet", "extdata", "go_human_rna_valid_subset.gaf" ) gs <- getGAF(gafFile) head(gs)
The GMT (Gene Matrix Transposed) file format is a tab delimited file format that describes groups of genes. In this format, each row represents a group. Each group is described by a name, a description, and the genes in it.
getGMT(con, sep = "\t", ...)
getGMT(con, sep = "\t", ...)
con |
File name of the GMT file. |
sep |
GMT file field separator, by default tabs. |
... |
Other arguments passed to |
A TidySet object.
The file format is defined by the Broad Institute here
Other IO functions:
getGAF()
,
getOBO()
gmtFile <- system.file( package = "BaseSet", "extdata", "hallmark.gene.symbol.gmt" ) gs <- getGMT(gmtFile) nRelations(gs) nElements(gs) nSets(gs)
gmtFile <- system.file( package = "BaseSet", "extdata", "hallmark.gene.symbol.gmt" ) gs <- getGMT(gmtFile) nRelations(gs) nElements(gs) nSets(gs)
Read an Open Biological and Biomedical Ontologies (OBO) formatted file
getOBO(x)
getOBO(x)
x |
Path to a file in OBO format. |
A TidySet object.
The format is described here
Other IO functions:
getGAF()
,
getGMT()
oboFile <- system.file( package = "BaseSet", "extdata", "go-basic_subset.obo" ) gs <- getOBO(oboFile) head(gs)
oboFile <- system.file( package = "BaseSet", "extdata", "go-basic_subset.obo" ) gs <- getOBO(oboFile) head(gs)
It allows to create a new set given some condition. If no element meet the condition an empty set is created.
group(object, name, ...) ## S3 method for class 'TidySet' group(object, name, ...)
group(object, name, ...) ## S3 method for class 'TidySet' group(object, name, ...)
object |
A TidySet object. |
name |
The name of the new set. |
... |
A logical condition to subset some elements. |
A TidySet object with the new set.
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
x <- list("A" = c("a" = 0.1, "b" = 0.5), "B" = c("a" = 0.2, "b" = 1)) TS <- tidySet(x) TS1 <- group(TS, "C", fuzzy < 0.5) TS1 sets(TS1) TS2 <- group(TS, "D", fuzzy < 0) sets(TS2) r <- data.frame( sets = c(rep("A", 5), "B", rep("A2", 5), "B2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12), type = c(rep("Gene", 2), rep("Protein", 2), rep("lncRNA", 2)) ) TS3 <- tidySet(r) group(TS3, "D", sets %in% c("A", "A2"))
x <- list("A" = c("a" = 0.1, "b" = 0.5), "B" = c("a" = 0.2, "b" = 1)) TS <- tidySet(x) TS1 <- group(TS, "C", fuzzy < 0.5) TS1 sets(TS1) TS2 <- group(TS, "D", fuzzy < 0) sets(TS2) r <- data.frame( sets = c(rep("A", 5), "B", rep("A2", 5), "B2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12), type = c(rep("Gene", 2), rep("Protein", 2), rep("lncRNA", 2)) ) TS3 <- tidySet(r) group(TS3, "D", sets %in% c("A", "A2"))
Use group_by to group the TidySet object. You can use activate with group_by or with the whole data.
## S3 method for class 'TidySet' group_by(.data, ...)
## S3 method for class 'TidySet' group_by(.data, ...)
.data |
The TidySet object |
... |
The logical predicates in terms of the variables of the sets |
A grouped data.frame (See The dplyr help page)
dplyr::group_by()
and activate()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) elements(a) <- cbind(elements(a), type = c(rep("Gene", 4), rep("lncRNA", 2)) ) group_by(a, elements)
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) elements(a) <- cbind(elements(a), type = c(rep("Gene", 4), rep("lncRNA", 2)) ) group_by(a, elements)
Check which elements are in which sets.
incidence(object) ## S4 method for signature 'TidySet' incidence(object)
incidence(object) ## S4 method for signature 'TidySet' incidence(object)
object |
Object to be coerced or tested. |
A matrix with elements in rows and sets in columns where the values indicate the relationship between the element and the set.
incidence(TidySet)
: Incidence of the TidySet
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
x <- list("a" = letters[1:5], "b" = LETTERS[3:7]) a <- tidySet(x) incidence(a)
x <- list("a" = letters[1:5], "b" = LETTERS[3:7]) a <- tidySet(x) incidence(a)
Checks if the elements of the sets are present in more than one set.
independent(object, sets)
independent(object, sets)
object |
A |
sets |
A character vector with the names of the sets to analyze. |
A logical value indicating if the sets are independent (TRUE) or not.
x <- list("A" = letters[1:5], "B" = letters[3:7], "C" = letters[6:10]) TS <- tidySet(x) independent(TS) independent(TS, c("A", "B")) independent(TS, c("A", "C")) independent(TS, c("B", "C"))
x <- list("A" = letters[1:5], "B" = letters[3:7], "C" = letters[6:10]) TS <- tidySet(x) independent(TS) independent(TS, c("A", "B")) independent(TS, c("A", "C")) independent(TS, c("B", "C"))
Given a TidySet creates a new set with the elements on the both of them following the logic defined on FUN.
intersection(object, sets, ...) ## S4 method for signature 'TidySet,character' intersection( object, sets, name = NULL, FUN = "min", keep = FALSE, keep_relations = keep, keep_elements = keep, keep_sets = keep, ... )
intersection(object, sets, ...) ## S4 method for signature 'TidySet,character' intersection( object, sets, name = NULL, FUN = "min", keep = FALSE, keep_relations = keep, keep_elements = keep, keep_sets = keep, ... )
object |
A TidySet object. |
sets |
The character of sets to be intersect. |
... |
Other named arguments passed to |
name |
The name of the new set. By defaults joins the sets with an ∪. |
FUN |
A function to be applied when performing the union. The standard intersection is the "min" function, but you can provide any other function that given a numeric vector returns a single number. |
keep |
A logical value if you want to keep originals sets. |
keep_relations |
A logical value if you wan to keep old relations. |
keep_elements |
A logical value if you wan to keep old elements. |
keep_sets |
A logical value if you wan to keep old sets. |
#' The default uses the min
function following the standard fuzzy definition, but it can
be changed.
A TidySet
object.
intersection(object = TidySet, sets = character)
: Applies the standard intersection
Other methods that create new sets:
complement_element()
,
complement_set()
,
subtract()
,
union()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
rel <- data.frame( sets = c(rep("A", 5), "B"), elements = c("a", "b", "c", "d", "f", "f") ) TS <- tidySet(rel) intersection(TS, c("A", "B")) # Default Name intersection(TS, c("A", "B"), "C") # Set the name # Fuzzy set rel <- data.frame( sets = c(rep("A", 5), "B"), elements = c("a", "b", "c", "d", "f", "f"), fuzzy = runif(6) ) TS2 <- tidySet(rel) intersection(TS2, c("A", "B"), "C") intersection(TS2, c("A", "B"), "C", FUN = function(x){max(sqrt(x))})
rel <- data.frame( sets = c(rep("A", 5), "B"), elements = c("a", "b", "c", "d", "f", "f") ) TS <- tidySet(rel) intersection(TS, c("A", "B")) # Default Name intersection(TS, c("A", "B"), "C") # Set the name # Fuzzy set rel <- data.frame( sets = c(rep("A", 5), "B"), elements = c("a", "b", "c", "d", "f", "f"), fuzzy = runif(6) ) TS2 <- tidySet(rel) intersection(TS2, c("A", "B"), "C") intersection(TS2, c("A", "B"), "C", FUN = function(x){max(sqrt(x))})
Check if some elements are also sets of others. This is also known as hierarchical sets.
is_nested(object) ## S3 method for class 'TidySet' is_nested(object)
is_nested(object) ## S3 method for class 'TidySet' is_nested(object)
object |
A TidySet object. |
A logical value: TRUE if there are some sets included as elements of others.
adjacency
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- list(A = letters[1:3], B = c(letters[4:5])) TS <- tidySet(relations) is_nested(TS) TS2 <- add_relation(TS, data.frame(elements = "A", sets = "B")) # Note that A is both a set and an element of B TS2 is_nested(TS2)
relations <- list(A = letters[1:3], B = c(letters[4:5])) TS <- tidySet(relations) is_nested(TS) TS2 <- add_relation(TS, data.frame(elements = "A", sets = "B")) # Note that A is both a set and an element of B TS2 is_nested(TS2)
Check if there are fuzzy sets. A fuzzy set is a set where the relationship between elements is given by a probability (or uncertainty).
is.fuzzy(object) ## S4 method for signature 'TidySet' is.fuzzy(object)
is.fuzzy(object) ## S4 method for signature 'TidySet' is.fuzzy(object)
object |
Object to be coerced or tested. |
A logical value.
is.fuzzy(TidySet)
: Check if it is fuzzy
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
TS <- tidySet(list(A = letters[1:5], B = letters[2:10])) is.fuzzy(TS)
TS <- tidySet(list(A = letters[1:5], B = letters[2:10])) is.fuzzy(TS)
Given several probabilities it looks for how probable is to have a vector of each length
length_set(probability)
length_set(probability)
probability |
A numeric vector of probabilities. |
A vector with the probability of each set.
length_probability()
to calculate the probability of a specific
length.
length_set(c(0.5, 0.1, 0.3, 0.5, 0.25, 0.23))
length_set(c(0.5, 0.1, 0.3, 0.5, 0.25, 0.23))
Returns the number of sets in the object.
## S3 method for class 'TidySet' length(x)
## S3 method for class 'TidySet' length(x)
x |
A TidySet object. No replacement function is available, either delete sets or add them. |
A numeric value.
dim()
, ncol()
and nrow()
.
Also look at lengths()
for the number of relations of sets.
TS <- tidySet(list(A = letters[1:5], B = letters[6])) length(TS)
TS <- tidySet(list(A = letters[1:5], B = letters[6])) length(TS)
Returns the number of relations of each set in the object.
## S4 method for signature 'TidySet' lengths(x, use.names = TRUE)
## S4 method for signature 'TidySet' lengths(x, use.names = TRUE)
x |
A TidySet object. |
use.names |
A logical value whether to inherit names or not. |
A vector with the number of different relations for each set.
length()
, Use set_size()
if you are using fuzzy sets.
TS <- tidySet(list(A = letters[1:5], B = letters[6])) lengths(TS)
TS <- tidySet(list(A = letters[1:5], B = letters[6])) lengths(TS)
Moves information from one slot to other slots. For instance from the sets to the relations.
move_to(object, from, to, columns) ## S4 method for signature ## 'TidySet,characterORfactor,characterORfactor,character' move_to(object, from, to, columns)
move_to(object, from, to, columns) ## S4 method for signature ## 'TidySet,characterORfactor,characterORfactor,character' move_to(object, from, to, columns)
object |
A TidySet object. |
from |
The name of the slot where the content is. |
to |
The name of the slot to move the content. |
columns |
The name of the columns that should be moved. |
A TidySet object where the content is moved from one slot to other.
move_to(
object = TidySet,
from = characterORfactor,
to = characterORfactor,
columns = character
)
: Move columns
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
x <- list("A" = c("a" = 0.1, "b" = 0.5), "B" = c("a" = 0.2, "b" = 1)) TS <- tidySet(x) TS <- mutate_element(TS, b = runif(2)) TS2 <- move_to(TS, from = "elements", to = "relations", "b") # Note that apparently we haven't changed anything: TS2
x <- list("A" = c("a" = 0.1, "b" = 0.5), "B" = c("a" = 0.2, "b" = 1)) TS <- tidySet(x) TS <- mutate_element(TS, b = runif(2)) TS2 <- move_to(TS, from = "elements", to = "relations", "b") # Note that apparently we haven't changed anything: TS2
Calculates the probability that all probabilities happened simultaneously.
independent_probabilities()
just multiply the probabilities of the index
passed.
multiply_probabilities(p, i) independent_probabilities(p, i)
multiply_probabilities(p, i) independent_probabilities(p, i)
p |
Numeric vector of probabilities. |
i |
Numeric integer index of the complementary probability. |
A numeric value of the probability.
multiply_probabilities(c(0.5, 0.1, 0.3, 0.5, 0.25, 0.23), c(1, 3)) independent_probabilities(c(0.5, 0.1, 0.3, 0.5, 0.25, 0.23), c(1, 3))
multiply_probabilities(c(0.5, 0.1, 0.3, 0.5, 0.25, 0.23), c(1, 3)) independent_probabilities(c(0.5, 0.1, 0.3, 0.5, 0.25, 0.23), c(1, 3))
Use mutate to alter the TidySet object. You can use activate with mutate or use the specific function. The S3 method filters using all the information on the TidySet.
## S3 method for class 'TidySet' mutate(.data, ...) mutate_set(.data, ...) mutate_element(.data, ...) mutate_relation(.data, ...)
## S3 method for class 'TidySet' mutate(.data, ...) mutate_set(.data, ...) mutate_element(.data, ...) mutate_relation(.data, ...)
.data |
The TidySet object. |
... |
The logical predicates in terms of the variables of the sets. |
A TidySet object
dplyr::mutate()
and activate()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) a <- mutate_element(a, Type = c(rep("Gene", 4), rep("lncRNA", 2))) a b <- mutate_relation(a, Type = sample(c("PPI", "PF", "MP"), 12, replace = TRUE ))
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) a <- mutate_element(a, Type = c(rep("Gene", 4), rep("lncRNA", 2))) a b <- mutate_relation(a, Type = sample(c("PPI", "PF", "MP"), 12, replace = TRUE ))
Retrieve the name of the elements.
name_elements(object, all, ...) ## S4 method for signature 'TidySet,logical' name_elements(object, all = TRUE) ## S4 method for signature 'TidySet,missing' name_elements(object, all) ## S4 replacement method for signature 'TidySet,logical,characterORfactor' name_elements(object, all) <- value ## S4 replacement method for signature 'TidySet,missing,characterORfactor' name_elements(object) <- value
name_elements(object, all, ...) ## S4 method for signature 'TidySet,logical' name_elements(object, all = TRUE) ## S4 method for signature 'TidySet,missing' name_elements(object, all) ## S4 replacement method for signature 'TidySet,logical,characterORfactor' name_elements(object, all) <- value ## S4 replacement method for signature 'TidySet,missing,characterORfactor' name_elements(object) <- value
object |
A TidySet object. |
all |
A logical value if all elements should be reported or only those present. |
... |
Other arguments passed to methods. |
value |
A character with the new names for the elements. |
A TidySet
object.
name_elements(object = TidySet, all = logical)
: Name elements
name_elements(object = TidySet, all = missing)
: Name elements
name_elements(object = TidySet, all = logical) <- value
: Rename elements
name_elements(object = TidySet, all = missing) <- value
: Rename elements
Other names:
name_elements<-()
,
name_sets<-()
,
name_sets()
,
rename_elements()
,
rename_set()
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) name_elements(TS)
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) name_elements(TS)
Rename elements.
name_elements(object, all, ...) <- value
name_elements(object, all, ...) <- value
object |
A TidySet object. |
all |
A logical value whether to return all elements or just those present. |
... |
Other arguments passed to methods. |
value |
A character with the new names for the elements. |
A TidySet
object.
Other names:
name_elements()
,
name_sets<-()
,
name_sets()
,
rename_elements()
,
rename_set()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) TS name_elements(TS) <- letters[1:6]
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) TS name_elements(TS) <- letters[1:6]
Retrieve the name of the sets.
name_sets(object, all, ...) ## S4 method for signature 'TidySet,logical' name_sets(object, all = TRUE) ## S4 method for signature 'TidySet,missing' name_sets(object, all) ## S4 replacement method for signature 'TidySet,logical,characterORfactor' name_sets(object, all) <- value ## S4 replacement method for signature 'TidySet,missing,characterORfactor' name_sets(object, all) <- value
name_sets(object, all, ...) ## S4 method for signature 'TidySet,logical' name_sets(object, all = TRUE) ## S4 method for signature 'TidySet,missing' name_sets(object, all) ## S4 replacement method for signature 'TidySet,logical,characterORfactor' name_sets(object, all) <- value ## S4 replacement method for signature 'TidySet,missing,characterORfactor' name_sets(object, all) <- value
object |
A TidySet object. |
all |
A logical value if all sets should be reported or only those present. |
... |
Other arguments passed to methods. |
value |
A character with the new names for the sets. |
A TidySet
object.
name_sets(object = TidySet, all = logical)
: Name sets
name_sets(object = TidySet, all = missing)
: Name sets
name_sets(object = TidySet, all = logical) <- value
: Rename sets
name_sets(object = TidySet, all = missing) <- value
: Rename sets
Other names:
name_elements<-()
,
name_elements()
,
name_sets<-()
,
rename_elements()
,
rename_set()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) name_sets(TS)
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) name_sets(TS)
Rename sets.
name_sets(object, all, ...) <- value
name_sets(object, all, ...) <- value
object |
A TidySet object. |
all |
A logical value whether it should return all sets present. |
... |
Other arguments passed to methods. |
value |
A character with the new names for the sets. |
A TidySet
object.
Other names:
name_elements<-()
,
name_elements()
,
name_sets()
,
rename_elements()
,
rename_set()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) TS name_sets(TS) <- LETTERS[1:2]
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) TS name_sets(TS) <- LETTERS[1:2]
Retrieve the column names of a slots of a TidySet.
## S3 method for class 'TidySet' names(x)
## S3 method for class 'TidySet' names(x)
x |
A TidySet object. |
A vector with the names of the present columns of the sets, elements and relations. If a slot is active it only returns the names of that slot.
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) names(TS) names(activate(TS, "sets"))
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) names(TS) names(activate(TS, "sets"))
Helps setting up the name of an operation.
naming( start = NULL, sets1, middle = NULL, sets2 = NULL, collapse_symbol = "union" )
naming( start = NULL, sets1, middle = NULL, sets2 = NULL, collapse_symbol = "union" )
start , middle
|
Character used as a start symbol or to divide
|
sets1 , sets2
|
Character of sets |
collapse_symbol |
Name of the symbol that joins the sets on
|
A character vector combining the sets
naming(sets1 = c("a", "b")) naming(sets1 = "a", middle = "union", sets2 = "b") naming(sets1 = "a", middle = "intersection", sets2 = c("b", "c")) naming(sets1 = "a", middle = "intersection", sets2 = c("b", "c")) naming( start = "complement", sets1 = "a", middle = "intersection", sets2 = c("b", "c"), collapse_symbol = "intersection" )
naming(sets1 = c("a", "b")) naming(sets1 = "a", middle = "union", sets2 = "b") naming(sets1 = "a", middle = "intersection", sets2 = c("b", "c")) naming(sets1 = "a", middle = "intersection", sets2 = c("b", "c")) naming( start = "complement", sets1 = "a", middle = "intersection", sets2 = c("b", "c"), collapse_symbol = "intersection" )
Check the number of elements of the TidySet.
nElements(object, all)
nElements(object, all)
object |
Object to be coerced or tested. |
all |
Logical value to count all elements. |
A numeric value with the number of elements.
Other count functions:
nRelations()
,
nSets()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
TS <- tidySet(list(A = letters[1:2], B = letters[5:7])) nElements(TS)
TS <- tidySet(list(A = letters[1:2], B = letters[5:7])) nElements(TS)
Check the number of relations of the TidySet.
nRelations(object)
nRelations(object)
object |
Object to be coerced or tested. |
A numeric value with the number of the relations.
Other count functions:
nElements()
,
nSets()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
TS <- tidySet(list(A = letters[1:2], B = letters[5:7])) nRelations(TS)
TS <- tidySet(list(A = letters[1:2], B = letters[5:7])) nRelations(TS)
Check the number of sets of the TidySet
nSets(object, all)
nSets(object, all)
object |
Object to be coerced or tested. |
all |
Logical value to count all sets. |
The number of sets present.
Other count functions:
nElements()
,
nRelations()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
TS <- tidySet(list(A = letters[1:2], B = letters[5:7])) nSets(TS)
TS <- tidySet(list(A = letters[1:2], B = letters[5:7])) nSets(TS)
Create the power set of the object: All the combinations of the elements of the sets.
power_set(object, set, name, ...)
power_set(object, set, name, ...)
object |
A TidySet object. |
set |
The name of the set to be used for the power set, if not provided all are used. |
name |
The root name of the new set, if not provided the standard notation "P()" is used. |
... |
Other arguments passed down if possible. |
A TidySet object with the new set.
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)] ) TS <- tidySet(relations) power_set(TS, "a", name = "power_set")
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)] ) TS <- tidySet(relations) power_set(TS, "a", name = "power_set")
Use pull to extract the columns of a TidySet object. You can use activate with filter or use the specific function. The S3 method filters using all the information on the TidySet.
## S3 method for class 'TidySet' pull(.data, var = -1, name = NULL, ...) pull_set(.data, var = -1, name = NULL, ...) pull_element(.data, var = -1, name = NULL, ...) pull_relation(.data, var = -1, name = NULL, ...)
## S3 method for class 'TidySet' pull(.data, var = -1, name = NULL, ...) pull_set(.data, var = -1, name = NULL, ...) pull_element(.data, var = -1, name = NULL, ...) pull_relation(.data, var = -1, name = NULL, ...)
.data |
The TidySet object |
var |
The literal variable name, a positive integer or a negative integer column position. |
name |
Column used to name the output. |
... |
Currently not used. |
A TidySet object
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) a <- mutate_element(a, type = c(rep("Gene", 4), rep("lncRNA", 2))) pull(a, type) # Equivalent to pull_relation b <- activate(a, "relations") pull_relation(b, elements) pull_element(b, elements) # Filter element pull_element(a, type) # Filter sets pull_set(a, sets)
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) a <- mutate_element(a, type = c(rep("Gene", 4), rep("lncRNA", 2))) pull(a, type) # Equivalent to pull_relation b <- activate(a, "relations") pull_relation(b, elements) pull_element(b, elements) # Filter element pull_element(a, type) # Filter sets pull_set(a, sets)
Given TidySet retrieve the relations or substitute them.
TidySet()
object
relations(object) relations(object) <- value ## S4 method for signature 'TidySet' relations(object) replace_relations(object, value) ## S4 replacement method for signature 'TidySet' relations(object) <- value ## S4 method for signature 'TidySet' nRelations(object)
relations(object) relations(object) <- value ## S4 method for signature 'TidySet' relations(object) replace_relations(object, value) ## S4 replacement method for signature 'TidySet' relations(object) <- value ## S4 method for signature 'TidySet' nRelations(object)
object |
Object to be coerced or tested. |
value |
Modification of the relations. |
A data.frame
with information about the relations between
elements and sets.
relations(TidySet)
: Retrieve the relations
relations(TidySet) <- value
: Modify the relations
nRelations(TidySet)
: Return the number of unique relations
Other slots:
elements()
,
sets()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
TS <- tidySet(list(A = letters[1:2], B = letters[5:7])) relations(TS)
TS <- tidySet(list(A = letters[1:2], B = letters[5:7])) relations(TS)
Removes column from a slot of the TidySet object.
remove_column(object, slot, column_names) ## S4 method for signature 'TidySet,character,character' remove_column(object, slot, column_names)
remove_column(object, slot, column_names) ## S4 method for signature 'TidySet,character,character' remove_column(object, slot, column_names)
object |
A TidySet object. |
slot |
A TidySet slot. |
column_names |
The name of the columns. |
A TidySet
object.
remove_column(object = TidySet, slot = character, column_names = character)
: Remove columns to any slot
Other column:
add_column()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
x <- data.frame(sets = c(rep("A", 5), rep("B", 5)), elements = c(letters[1:5], letters[3:7]), extra = sample(c("YES", "NO"), 10, replace = TRUE)) TS <- tidySet(x) TS remove_column(TS, "relations", "extra")
x <- data.frame(sets = c(rep("A", 5), rep("B", 5)), elements = c(letters[1:5], letters[3:7]), extra = sample(c("YES", "NO"), 10, replace = TRUE)) TS <- tidySet(x) TS remove_column(TS, "relations", "extra")
Given a TidySet remove elements and the related relations and if required also the sets.
remove_element(object, elements, ...) ## S4 method for signature 'TidySet,characterORfactor' remove_element(object, elements)
remove_element(object, elements, ...) ## S4 method for signature 'TidySet,characterORfactor' remove_element(object, elements)
object |
A TidySet object. |
elements |
The elements to be removed. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A TidySet
object.
remove_element(object = TidySet, elements = characterORfactor)
: Removes everything related to an element
Other remove functions:
remove_relation()
,
remove_set()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) remove_element(TS, "c")
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) remove_element(TS, "c")
Given a TidySet removes relations between elements and sets
remove_relation(object, elements, sets, ...) ## S4 method for signature 'TidySet,characterORfactor,characterORfactor' remove_relation(object, elements, sets)
remove_relation(object, elements, sets, ...) ## S4 method for signature 'TidySet,characterORfactor,characterORfactor' remove_relation(object, elements, sets)
object |
A TidySet object |
elements |
The elements of the sets. |
sets |
The name of the new set. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A TidySet
object.
remove_relation(
object = TidySet,
elements = characterORfactor,
sets = characterORfactor
)
: Removes a relation between elements and sets.
Other remove functions:
remove_element()
,
remove_set()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) remove_relation(TS, "A", "a")
relations <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) remove_relation(TS, "A", "a")
Given a TidySet remove sets and the related relations and if required also the elements
remove_set(object, sets, ...) ## S4 method for signature 'TidySet,characterORfactor' remove_set(object, sets)
remove_set(object, sets, ...) ## S4 method for signature 'TidySet,characterORfactor' remove_set(object, sets)
object |
A TidySet object. |
sets |
The sets to be removed. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
A TidySet
object.
remove_set(object = TidySet, sets = characterORfactor)
: Removes everything related to a set
Other remove functions:
remove_element()
,
remove_relation()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) remove_set(TS, "B")
relations <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) remove_set(TS, "B")
Change the default names of sets and elements.
rename_elements(object, old, new) ## S4 method for signature 'TidySet' rename_elements(object, old, new)
rename_elements(object, old, new) ## S4 method for signature 'TidySet' rename_elements(object, old, new)
object |
A TidySet object. |
old |
A character vector of to be renamed. |
new |
A character vector of with new names. |
A TidySet
object.
rename_elements(TidySet)
: Rename elements
Other renames:
rename_set()
Other names:
name_elements<-()
,
name_elements()
,
name_sets<-()
,
name_sets()
,
rename_set()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
x <- list("A" = letters[1:5], "B" = letters[3:7]) TS <- tidySet(x) name_elements(TS) TS2 <- rename_elements(TS, "a", "first") name_elements(TS2)
x <- list("A" = letters[1:5], "B" = letters[3:7]) TS <- tidySet(x) name_elements(TS) TS2 <- rename_elements(TS, "a", "first") name_elements(TS2)
Change the default names of sets and elements.
rename_set(object, old, new) ## S4 method for signature 'TidySet' rename_set(object, old, new)
rename_set(object, old, new) ## S4 method for signature 'TidySet' rename_set(object, old, new)
object |
A TidySet object. |
old |
A character vector of to be renamed. |
new |
A character vector of with new names. |
A TidySet
object.
rename_set(TidySet)
: Rename sets
Other renames:
rename_elements()
Other names:
name_elements<-()
,
name_elements()
,
name_sets<-()
,
name_sets()
,
rename_elements()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
x <- list("A" = letters[1:5], "B" = letters[3:7]) TS <- tidySet(x) name_sets(TS) TS2 <- rename_set(TS, "A", "C") name_sets(TS2)
x <- list("A" = letters[1:5], "B" = letters[3:7]) TS <- tidySet(x) name_sets(TS) TS2 <- rename_set(TS, "A", "C") name_sets(TS2)
Use select to extract the columns of a TidySet object. You can use activate with filter or use the specific function. The S3 method filters using all the information on the TidySet.
## S3 method for class 'TidySet' select(.data, ...) select_set(.data, ...) select_element(.data, ...) select_relation(.data, ...)
## S3 method for class 'TidySet' select(.data, ...) select_set(.data, ...) select_element(.data, ...) select_relation(.data, ...)
.data |
The TidySet object |
... |
The name of the columns you want to keep, remove or rename. |
A TidySet object
dplyr::select()
and activate()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
set_size()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) a <- mutate_element(a, type = c(rep("Gene", 4), rep("lncRNA", 2)) ) a <- mutate_set(a, Group = c("UFM", "UAB", "UPF", "MIT")) b <- select(a, -type) elements(b) b <- select_element(a, elements) elements(b) # Select sets select_set(a, sets)
relations <- data.frame( sets = c(rep("a", 5), "b", rep("a2", 5), "b2"), elements = rep(letters[seq_len(6)], 2), fuzzy = runif(12) ) a <- tidySet(relations) a <- mutate_element(a, type = c(rep("Gene", 4), rep("lncRNA", 2)) ) a <- mutate_set(a, Group = c("UFM", "UAB", "UPF", "MIT")) b <- select(a, -type) elements(b) b <- select_element(a, elements) elements(b) # Select sets select_set(a, sets)
Assuming that the fuzzy values are probabilities, calculates the probability of being of different sizes for a given set.
set_size(object, sets = NULL) ## S4 method for signature 'TidySet' set_size(object, sets = NULL)
set_size(object, sets = NULL) ## S4 method for signature 'TidySet' set_size(object, sets = NULL)
object |
A TidySet object. |
sets |
The sets from which the length is calculated. |
A list with the size of the set or the probability of having that size.
set_size(TidySet)
: Calculates the size of a set using length_set()
cardinality
Other sizes:
element_size()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
sets()
,
subtract()
,
union()
relations <- data.frame( sets = c(rep("A", 5), "B", "C"), elements = c(letters[seq_len(6)], letters[6]), fuzzy = runif(7) ) a <- tidySet(relations) set_size(a)
relations <- data.frame( sets = c(rep("A", 5), "B", "C"), elements = c(letters[seq_len(6)], letters[6]), fuzzy = runif(7) ) a <- tidySet(relations) set_size(a)
Name and symbol of operations related to sets, including intersection and union among others:
set_symbols
set_symbols
An object of class character
of length 16.
https://www.fileformat.info/info/unicode/category/Sm/list.htm
set_symbols
set_symbols
Given TidySet retrieve the sets or substitute them.
sets(object) sets(object) <- value ## S4 method for signature 'TidySet' sets(object) ## S4 replacement method for signature 'TidySet' sets(object) <- value replace_sets(object, value) ## S4 method for signature 'TidySet,missing' nSets(object) ## S4 method for signature 'TidySet,logical' nSets(object, all)
sets(object) sets(object) <- value ## S4 method for signature 'TidySet' sets(object) ## S4 replacement method for signature 'TidySet' sets(object) <- value replace_sets(object, value) ## S4 method for signature 'TidySet,missing' nSets(object) ## S4 method for signature 'TidySet,logical' nSets(object, all)
object |
A |
value |
Modification of the sets. |
all |
A logical value whether it should return all sets or only those present. |
A data.frame
with information from the sets.
sets(TidySet)
: Retrieve the sets information
sets(TidySet) <- value
: Modify the sets information
nSets(object = TidySet, all = missing)
: Return the number of sets
nSets(object = TidySet, all = logical)
: Return the number of sets
Other slots:
elements()
,
relations()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
subtract()
,
union()
TS <- tidySet(list(A = letters[1:5], B = letters[2:10])) sets(TS) sets(TS) <- data.frame(sets = c("B", "A")) TS2 <- replace_sets(TS, data.frame(sets = c("A", "B", "C"))) sets(TS2) nSets(TS) nSets(TS2)
TS <- tidySet(list(A = letters[1:5], B = letters[2:10])) sets(TS) sets(TS) <- data.frame(sets = c("B", "A")) TS2 <- replace_sets(TS, data.frame(sets = c("A", "B", "C"))) sets(TS2) nSets(TS) nSets(TS2)
Prints the resulting table of a TidySet object. Does not shown elements or
sets without any relationship (empty sets). To see them use sets()
or
elements()
.
## S4 method for signature 'TidySet' show(object)
## S4 method for signature 'TidySet' show(object)
object |
A TidySet |
A table with the information of the relationships.
Calculate the size of the elements or sets, using the fuzzy values as probabilities. First it must have active either sets or elements.
size(object, ...)
size(object, ...)
object |
A TidySet object. |
... |
Character vector with the name of elements or sets you want to calculate the size of. |
The size of the elements or sets. If there is no active slot or it is the relations slot returns the TidySet object with a warning.
A related concept cardinality()
. It is calculated using
length_set()
.
rel <- data.frame( sets = c(rep("A", 5), "B", "C"), elements = c(letters[seq_len(6)], letters[6]) ) TS <- tidySet(rel) TS <- activate(TS, "elements") size(TS) TS <- activate(TS, "sets") size(TS) # With fuzzy sets relations <- data.frame( sets = c(rep("A", 5), "B", "C"), elements = c(letters[seq_len(6)], letters[6]), fuzzy = runif(7) ) TS <- tidySet(relations) TS <- activate(TS, "elements") size(TS) TS <- activate(TS, "sets") size(TS)
rel <- data.frame( sets = c(rep("A", 5), "B", "C"), elements = c(letters[seq_len(6)], letters[6]) ) TS <- tidySet(rel) TS <- activate(TS, "elements") size(TS) TS <- activate(TS, "sets") size(TS) # With fuzzy sets relations <- data.frame( sets = c(rep("A", 5), "B", "C"), elements = c(letters[seq_len(6)], letters[6]), fuzzy = runif(7) ) TS <- tidySet(relations) TS <- activate(TS, "elements") size(TS) TS <- activate(TS, "sets") size(TS)
Elements in a set not present in the other set. Equivalent to
setdiff()
.
subtract(object, set_in, not_in, ...) ## S4 method for signature 'TidySet,characterORfactor,characterORfactor' subtract( object, set_in, not_in, name = NULL, keep = TRUE, keep_relations = keep, keep_elements = keep, keep_sets = keep )
subtract(object, set_in, not_in, ...) ## S4 method for signature 'TidySet,characterORfactor,characterORfactor' subtract( object, set_in, not_in, name = NULL, keep = TRUE, keep_relations = keep, keep_elements = keep, keep_sets = keep )
object |
A TidySet object. |
set_in |
Name of the sets where the elements should be present. |
not_in |
Name of the sets where the elements should not be present. |
... |
Placeholder for other arguments that could be passed to the method. Currently not used. |
name |
Name of the new set. By default it adds a "C". |
keep |
Logical value to keep all the other sets. |
keep_relations |
A logical value if you wan to keep old relations. |
keep_elements |
A logical value if you wan to keep old elements. |
keep_sets |
A logical value if you wan to keep old sets. |
A TidySet
object.
subtract(
object = TidySet,
set_in = characterORfactor,
not_in = characterORfactor
)
: Elements present in sets but not in other sets
Other complements:
complement_element()
,
complement_set()
,
complement()
Other methods that create new sets:
complement_element()
,
complement_set()
,
intersection()
,
union()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
union()
relations <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) subtract(TS, "A", "B") subtract(TS, "A", "B", keep = FALSE)
relations <- data.frame( sets = c("A", "A", "B", "B", "C", "C"), elements = letters[seq_len(6)], fuzzy = runif(6) ) TS <- tidySet(relations) subtract(TS, "A", "B") subtract(TS, "A", "B", keep = FALSE)
Convert GSEABase classes to a TidySet
tidy(object) ## S3 method for class 'GeneSetCollection' tidy(object) ## S3 method for class 'GeneSet' tidy(object)
tidy(object) ## S3 method for class 'GeneSetCollection' tidy(object) ## S3 method for class 'GeneSet' tidy(object)
object |
A GeneSetCollection or a GeneSet derived object |
A TidySet object.
tidy(GeneSetCollection)
: Converts to a tidySet given a GeneSetCollection
tidy(GeneSet)
: Converts to a tidySet given a GeneSet
# Needs GSEABase pacakge from Bioconductor if (requireNamespace("GSEABase", quietly = TRUE)) { library("GSEABase") gs <- GeneSet() gs tidy(gs) fl <- system.file("extdata", "Broad.xml", package="GSEABase") gs2 <- getBroadSets(fl) # actually, a list of two gene sets TS <- tidy(gs2) dim(TS) sets(TS) }
# Needs GSEABase pacakge from Bioconductor if (requireNamespace("GSEABase", quietly = TRUE)) { library("GSEABase") gs <- GeneSet() gs tidy(gs) fl <- system.file("extdata", "Broad.xml", package="GSEABase") gs2 <- getBroadSets(fl) # actually, a list of two gene sets TS <- tidy(gs2) dim(TS) sets(TS) }
These functions help to create a TidySet
object from
data.frame
, list
, matrix
, and GO3AnnDbBimap
.
They can create both fuzzy and standard sets.
tidySet(relations) ## S3 method for class 'data.frame' tidySet(relations) ## S3 method for class 'list' tidySet(relations) ## S3 method for class 'matrix' tidySet(relations) ## S3 method for class 'Go3AnnDbBimap' tidySet(relations) ## S3 method for class 'TidySet' tidySet(relations)
tidySet(relations) ## S3 method for class 'data.frame' tidySet(relations) ## S3 method for class 'list' tidySet(relations) ## S3 method for class 'matrix' tidySet(relations) ## S3 method for class 'Go3AnnDbBimap' tidySet(relations) ## S3 method for class 'TidySet' tidySet(relations)
relations |
An object to be coerced to a TidySet. |
Elements or sets without any relation are not shown when printed.
A TidySet object.
tidySet(data.frame)
: Given the relations in a data.frame
tidySet(list)
: Convert to a TidySet from a list.
tidySet(matrix)
: Convert an incidence matrix into a TidySet
tidySet(Go3AnnDbBimap)
: Convert Go3AnnDbBimap into a TidySet object.
tidySet(TidySet)
: Convert TidySet into a TidySet object.
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)] ) tidySet(relations) relations2 <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) tidySet(relations2) # A x <- list("A" = letters[1:5], "B" = LETTERS[3:7]) tidySet(x) # A fuzzy set taken encoded as a list A <- runif(5) names(A) <- letters[1:5] B <- runif(5) names(B) <- letters[3:7] relations <- list(A, B) tidySet(relations) # Will error # x <- list("A" = letters[1:5], "B" = LETTERS[3:7], "c" = runif(5)) # a <- tidySet(x) # Only characters or factors are allowed as elements. M <- matrix(c(1, 0.5, 1, 0), ncol = 2, dimnames = list(c("A", "B"), c("a", "b"))) tidySet(M)
relations <- data.frame( sets = c(rep("a", 5), "b"), elements = letters[seq_len(6)] ) tidySet(relations) relations2 <- data.frame( sets = c(rep("A", 5), "B"), elements = letters[seq_len(6)], fuzzy = runif(6) ) tidySet(relations2) # A x <- list("A" = letters[1:5], "B" = LETTERS[3:7]) tidySet(x) # A fuzzy set taken encoded as a list A <- runif(5) names(A) <- letters[1:5] B <- runif(5) names(B) <- letters[3:7] relations <- list(A, B) tidySet(relations) # Will error # x <- list("A" = letters[1:5], "B" = LETTERS[3:7], "c" = runif(5)) # a <- tidySet(x) # Only characters or factors are allowed as elements. M <- matrix(c(1, 0.5, 1, 0), ncol = 2, dimnames = list(c("A", "B"), c("a", "b"))) tidySet(M)
A set is a group of unique elements it can be either a fuzzy set, where the relationship is between 0 or 1 or nominal.
When printed if an element or a set do not have any relationship is not
shown.
They can be created from lists, matrices or data.frames. Check tidySet()
constructor for more information.
relations
A data.frame with elements and the sets were they belong.
elements
A data.frame of unique elements and related information.
sets
A data.frame of unique sets and related information.
Other methods:
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
,
union()
x <- list("A" = letters[1:5], "B" = LETTERS[3:7]) a <- tidySet(x) a x <- list("A" = letters[1:5], "B" = character()) b <- tidySet(x) b name_sets(b)
x <- list("A" = letters[1:5], "B" = LETTERS[3:7]) a <- tidySet(x) a x <- list("A" = letters[1:5], "B" = character()) b <- tidySet(x) b name_sets(b)
Given a TidySet merges several sets into the new one using the logic defined on FUN.
union(object, ...) ## S3 method for class 'TidySet' union( object, sets, name = NULL, FUN = "max", keep = FALSE, keep_relations = keep, keep_elements = keep, keep_sets = keep, ... )
union(object, ...) ## S3 method for class 'TidySet' union( object, sets, name = NULL, FUN = "max", keep = FALSE, keep_relations = keep, keep_elements = keep, keep_sets = keep, ... )
object |
A TidySet object. |
... |
Other named arguments passed to |
sets |
The name of the sets to be used. |
name |
The name of the new set. By defaults joins the sets with an ∩. |
FUN |
A function to be applied when performing the union. The standard union is the "max" function, but you can provide any other function that given a numeric vector returns a single number. |
keep |
A logical value if you want to keep. |
keep_relations |
A logical value if you wan to keep old relations. |
keep_elements |
A logical value if you wan to keep old elements. |
keep_sets |
A logical value if you wan to keep old sets. |
The default uses the max
function following the standard fuzzy definition, but it can be
changed. See examples below.
A TidySet
object.
Other methods that create new sets:
complement_element()
,
complement_set()
,
intersection()
,
subtract()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
subtract()
# Classical set rel <- data.frame( sets = c(rep("A", 5), "B", "B"), elements = c(letters[seq_len(6)], "a") ) TS <- tidySet(rel) union(TS, c("B", "A")) # Fuzzy set rel <- data.frame( sets = c(rep("A", 5), "B", "B"), elements = c(letters[seq_len(6)], "a"), fuzzy = runif(7) ) TS2 <- tidySet(rel) # Standard default logic union(TS2, c("B", "A"), "C") # Probability logic union(TS2, c("B", "A"), "C", FUN = union_probability)
# Classical set rel <- data.frame( sets = c(rep("A", 5), "B", "B"), elements = c(letters[seq_len(6)], "a") ) TS <- tidySet(rel) union(TS, c("B", "A")) # Fuzzy set rel <- data.frame( sets = c(rep("A", 5), "B", "B"), elements = c(letters[seq_len(6)], "a"), fuzzy = runif(7) ) TS2 <- tidySet(rel) # Standard default logic union(TS2, c("B", "A"), "C") # Probability logic union(TS2, c("B", "A"), "C", FUN = union_probability)
Tests if a given object is union-closed.
union_closed(object, ...) ## S3 method for class 'TidySet' union_closed(object, sets = NULL, ...)
union_closed(object, ...) ## S3 method for class 'TidySet' union_closed(object, sets = NULL, ...)
object |
A TidySet object. |
... |
Other named arguments passed to |
sets |
The name of the sets to be used. |
A logical value: TRUE
if the combinations of sets produce already
existing sets, FALSE
otherwise.
l <- list(A = "1", B = c("1", "2"), C = c("2", "3", "4"), D = c("1", "2", "3", "4") ) TS <- tidySet(l) union_closed(TS) union_closed(TS, sets = c("A", "B", "C")) union_closed(TS, sets = c("A", "B", "C", "D"))
l <- list(A = "1", B = c("1", "2"), C = c("2", "3", "4"), D = c("1", "2", "3", "4") ) TS <- tidySet(l) union_closed(TS) union_closed(TS, sets = c("A", "B", "C")) union_closed(TS, sets = c("A", "B", "C", "D"))
Creates all the possibilities and then add them up.
union_probability
Assumes independence between the probabilities to
calculate the final size.
union_probability(p) length_probability(p, size)
union_probability(p) length_probability(p, size)
p |
Numeric vector of probabilities. |
size |
Integer value of the size of the selected values. |
A numeric value of the probability of the given size.
multiply_probabilities()
and length_set()
length_probability(c(0.5, 0.75), 2) length_probability(c(0.5, 0.75, 0.66), 1) length_probability(c(0.5, 0.1, 0.3, 0.5, 0.25, 0.23), 2) union_probability(c(0.5, 0.1, 0.3))
length_probability(c(0.5, 0.75), 2) length_probability(c(0.5, 0.75, 0.66), 1) length_probability(c(0.5, 0.1, 0.3, 0.5, 0.25, 0.23), 2) union_probability(c(0.5, 0.1, 0.3))