Indexing aphylo objects

# S3 method for aphylo
[(x, i, j, drop = FALSE)

# S3 method for aphylo
[(x, i, j) <- value

Arguments

x

An object of class aphylo.

i, j

Integer vector. Indices of genes or functions.

drop

Logical scalar. When TRUE, the function returns a matrix of annotations. Otherwise an object of class aphylo.

value

Integer vector. Replacing values, can be either c(0, 1, 9, NA).

Value

  • When indexing with i: A data frame with the annotations of the selected genes.

  • When only indexing with j (drop = FALSE): An aphylo object with the selected sets of annotations.

  • When only indexing with j (drop = TRUE): A data.frame with the selected annotations.

  • When indexing on both i and j: A data.frame with the selected genes and annotations.

Details

The subsetting method allows selecting one or more annotations from the aphylo object. Whenever i is specified, then aphylo returns the corresponding annotations.

Examples

set.seed(12312)
atree <- raphylo(50, P = 4)
atree[1:10,]
#>    fun0000 fun0001 fun0002 fun0003
#> 1        1       1       0       1
#> 2        1       1       1       1
#> 3        1       0       0       0
#> 4        1       0       1       1
#> 5        0       1       1       1
#> 6        1       1       1       1
#> 7        1       1       1       1
#> 8        0       0       0       1
#> 9        1       1       1       1
#> 10       0       1       1       1
atree[,2:3]
#> 
#> Phylogenetic tree with 50 tips and 49 internal nodes.
#> 
#> Tip labels:
#>   1, 2, 3, 4, 5, 6, ...
#> Node labels:
#>   51, 52, 53, 54, 55, 56, ...
#> 
#> Rooted; no branch lengths.
#> 
#>  Tip (leafs) annotations:
#>   fun0001 fun0002
#> 1       1       0
#> 2       1       1
#> 3       0       0
#> 4       0       1
#> 5       1       1
#> 6       1       1
#> 
#> ...(44 obs. omitted)...
#> 
#> 
#>  Internal node annotations:
#>   fun0001 fun0002
#> 1       1       0
#> 2       1       0
#> 3       1       0
#> 4       1       1
#> 5       1       1
#> 6       0       1
#> 
#> ...(43 obs. omitted)...
#> 
atree[, 2:3, drop = TRUE]
#>    fun0001 fun0002
#> 1        1       0
#> 2        1       1
#> 3        0       0
#> 4        0       1
#> 5        1       1
#> 6        1       1
#> 7        1       1
#> 8        0       0
#> 9        1       1
#> 10       1       1
#> 11       1       1
#> 12       1       0
#> 13       1       1
#> 14       1       0
#> 15       1       0
#> 16       1       1
#> 17       1       0
#> 18       1       0
#> 19       1       1
#> 20       1       1
#> 21       1       0
#> 22       1       1
#> 23       0       0
#> 24       0       0
#> 25       1       1
#> 26       1       0
#> 27       1       1
#> 28       0       1
#> 29       1       0
#> 30       1       0
#> 31       1       1
#> 32       1       0
#> 33       1       1
#> 34       1       0
#> 35       0       1
#> 36       1       1
#> 37       1       1
#> 38       1       0
#> 39       0       1
#> 40       1       0
#> 41       1       1
#> 42       1       1
#> 43       0       1
#> 44       1       0
#> 45       1       1
#> 46       0       1
#> 47       1       1
#> 48       1       1
#> 49       1       1
#> 50       1       0
#> 1        1       0
#> 2        1       0
#> 3        1       0
#> 4        1       1
#> 5        1       1
#> 6        0       1
#> 7        1       1
#> 8        1       1
#> 9        1       1
#> 10       1       0
#> 11       1       0
#> 12       1       1
#> 13       1       1
#> 14       1       1
#> 15       1       0
#> 16       1       1
#> 17       1       1
#> 18       0       1
#> 19       1       1
#> 20       1       0
#> 21       0       1
#> 22       1       0
#> 23       0       1
#> 24       1       0
#> 25       1       1
#> 26       1       1
#> 27       1       1
#> 28       1       1
#> 29       1       1
#> 30       1       1
#> 31       1       1
#> 32       1       0
#> 33       1       1
#> 34       1       0
#> 35       1       1
#> 36       1       0
#> 37       1       0
#> 38       0       0
#> 39       1       1
#> 40       1       0
#> 41       1       1
#> 42       0       0
#> 43       0       1
#> 44       0       0
#> 45       0       1
#> 46       1       0
#> 47       1       0
#> 48       1       1
#> 49       1       1
atree[1:10, 2:3]
#>    fun0001 fun0002
#> 1        1       0
#> 2        1       1
#> 3        0       0
#> 4        0       1
#> 5        1       1
#> 6        1       1
#> 7        1       1
#> 8        0       0
#> 9        1       1
#> 10       1       1