Skip to contents

The covariance (or correlation) matrix implied by Brownian motion on the tree: the entry for two taxa is the branch length they share from the root. It is the matrix a phylogenetic random effect needs in a model fitted elsewhere, e.g. (1 | gr(accession, cov = A)) with data2 = list(A = A) in brms::brm(), and its row and column names are the tree's accessions.

Usage

gtdb_tree_vcv(tree, corr = TRUE)

Arguments

tree

A GTDB tree, pruned with gtdb_tree_prune().

corr

If TRUE (the default), the correlation matrix, with 1 on the diagonal, which keeps the scale of the random effect's standard deviation interpretable; if FALSE, the covariance matrix.

Value

A square numeric matrix named by accession.

Details

The matrix has Ntip(tree)^2 entries, so prune the tree to the genomes in your data first (gtdb_tree_prune()).

See also

Examples

tree <- gtdb_tree_read(gtdb_example("tree"))
A <- gtdb_tree_vcv(tree)
dim(A)
#> [1] 560 560
A[1:3, 1:3]
#>                 GCF_037023725.1 GCF_900105835.1 GCF_001042985.1
#> GCF_037023725.1       1.0000000       0.9994976       0.9967292
#> GCF_900105835.1       0.9994976       1.0000000       0.9969040
#> GCF_001042985.1       0.9967292       0.9969040       1.0000000