Skip to contents

It allows to create a new set given some condition. If no element meet the condition an empty set is created.

Usage

group(object, name, ...)

# S3 method for TidySet
group(object, name, ...)

Arguments

object

A TidySet object.

name

The name of the new set.

...

A logical condition to subset some elements.

Value

A TidySet object with the new set.

Examples

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
#>   elements sets fuzzy
#> 1        a    A   0.1
#> 2        b    A   0.5
#> 3        a    B   0.2
#> 4        b    B   1.0
#> 5        a    C   1.0
sets(TS1)
#>   sets
#> 1    A
#> 2    B
#> 3    C
TS2 <- group(TS, "D", fuzzy < 0)
sets(TS2)
#>   sets
#> 1    A
#> 2    B
#> 3    D
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"))
#>    elements sets      fuzzy    type
#> 1         a    A 0.08332378    Gene
#> 2         b    A 0.99853577    Gene
#> 3         c    A 0.32073818 Protein
#> 4         d    A 0.73340704 Protein
#> 5         e    A 0.32495104  lncRNA
#> 6         f    B 0.50935597  lncRNA
#> 7         a   A2 0.78592541    Gene
#> 8         b   A2 0.19576518    Gene
#> 9         c   A2 0.98107416 Protein
#> 10        d   A2 0.04657707 Protein
#> 11        e   A2 0.20961284  lncRNA
#> 12        f   B2 0.63284649  lncRNA
#> 13        a    D 1.00000000    <NA>
#> 14        b    D 1.00000000    <NA>
#> 15        c    D 1.00000000    <NA>
#> 16        d    D 1.00000000    <NA>
#> 17        e    D 1.00000000    <NA>