Skip to contents

Given a matrix of values where the rows and column names are species names that are labels in a tree, subset that matrix to the species that are present in the subtree starting at a given node.

Usage

subMatrix(tree_tibble, m, node = NA, simplify.names = FALSE)

Arguments

tree_tibble

A tree in the tbl_tree class of the tidytree package.

m

A matrix, typically the output of makeMatrix().

node

The ID number of the node to base the subtree.

simplify.names

Reduce the genus name to a single letter.

Value

A subset of the m matrix.

Examples

subMatrix(Halo_Tree, Halo_PercentDiff, simpl = TRUE)
#>                H_litoreum H_noricense H_salinarum H_mediterranei H_volcanii
#> H_litoreum      100.00000    21.18801    24.24792       31.27923   29.83707
#> H_noricense      21.26064   100.00000    25.05377       31.54667   30.03853
#> H_salinarum      24.15702    25.05241   100.00000       32.99448   31.51122
#> H_mediterranei   31.72595    33.57159    33.02111      100.00000   19.77441
#> H_volcanii       29.88642    30.06817    31.51689       19.60559  100.00000
#> S_japonicum      27.24648    27.88932    28.19145       31.34071   30.17554
#>                S_japonicum
#> H_litoreum        27.25050
#> H_noricense       27.57799
#> H_salinarum       28.44185
#> H_mediterranei    31.58067
#> H_volcanii        30.20358
#> S_japonicum      100.00000
subMatrix(Halo_Tree, Halo_PercentDiff, 9)
#>                         Halobacterium_litoreum Halobacterium_noricense
#> Halobacterium_litoreum               100.00000                21.18801
#> Halobacterium_noricense               21.26064               100.00000
#> Halobacterium_salinarum               24.15702                25.05241
#> Salarchaeum_japonicum                 27.24648                27.88932
#>                         Halobacterium_salinarum Salarchaeum_japonicum
#> Halobacterium_litoreum                 24.24792              27.25050
#> Halobacterium_noricense                25.05377              27.57799
#> Halobacterium_salinarum               100.00000              28.44185
#> Salarchaeum_japonicum                  28.19145             100.00000
subTree(Halo_Tree, 9) |> subMatrix(Halo_PercentDiff)
#>                         Halobacterium_litoreum Halobacterium_noricense
#> Halobacterium_litoreum               100.00000                21.18801
#> Halobacterium_noricense               21.26064               100.00000
#> Halobacterium_salinarum               24.15702                25.05241
#> Salarchaeum_japonicum                 27.24648                27.88932
#>                         Halobacterium_salinarum Salarchaeum_japonicum
#> Halobacterium_litoreum                 24.24792              27.25050
#> Halobacterium_noricense                25.05377              27.57799
#> Halobacterium_salinarum               100.00000              28.44185
#> Salarchaeum_japonicum                  28.19145             100.00000