philr: Data transformation and driver of PhILR.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/philr.R

Description

This is the main function for building the phylogenetic ILR basis, calculating the weightings (of the parts and the ILR coordinates) and then transforming the data.

Usage

1
2
philr(df, tree, sbp = NULL, part.weights = "uniform",
  ilr.weights = "uniform", return.all = FALSE)

Arguments

df

matrix of data to be transformed (samples are rows, compositional parts are columns) - zero must be dealt with either with pseudocount, multiplicative replacement, or another method.

tree

a phylo class tree object that is binary (see multi2di)

sbp

(Optional) give a precomputed sbp matrix phylo2sbp if you are going to build multiple ILR bases (e.g., with different weightings).

part.weights

weightings for parts, can be a named vector with names corresponding to colnames(df) otherwise can be a string, options include:

'uniform'

(default) uses the uniform reference measure

'gm.counts'

geometric mean of parts of df

'anorm'

aitchison norm of parts of df (after closure)

'anorm.x.gm.counts'

'anorm' times 'gm.counts'

'enorm'

euclidean norm of parts of df (after closure)

'enorm.x.gm.counts'

'enorm' times 'gm.counts', often gives good results

ilr.weights

weightings for the ILR coordiantes can be a named vector with names corresponding to names of internal nodes of tree otherwise can be a string, options include:

'uniform'

(default) no weighting of the ILR basis

'blw'

sum of children's branch lengths

'blw.sqrt'

square root of 'blw' option

'mean.descendants'

sum of children's branch lengths PLUS the sum of each child's mean distance to its descendent tips

return.all

return all computed parts (e.g., computed sign matrix(sbp), part weightings (codep), ilr weightings (codeilr.weights), contrast matrix (V)) as a list (default=FALSE) in addition to in addition to returning the transformed data (df.ilrp). If return.all==FALSE then only returns the transformed data (not in list format) If FALSE then just returns list containing df.ilrp.

Details

This is a utility function that pulls together a number of other functions in philr. The steps that are executed are as follows:

  1. Create sbp (sign matrix) if not given

  2. Create parts weightings if not given

  3. Shift the dataset with respect to the new reference measure (e.g., part weightings)

  4. Create the basis contrast matrix from the sign matrix and the reference measure

  5. Transform the data based on the contrast matrix and the reference measure

  6. Calculate the specified ILR weightings and multiply each balance by the corresponding weighting

Note for both the reference measure (part weightings) and the ILR weightings, specifying 'uniform' will give the same results as not weighting at all.

Note that some of the prespecified part.weights assume df is given as counts and not as relative abundances. Except in this case counts or relative abundances can be given.

Value

matrix if return.all=FALSE, if return.all=TRUE then a list is returned (see above).

Author(s)

Justin Silverman

See Also

phylo2sbp calculate.blw

Examples

1
2
3
4
5
6
tr <- named_rtree(5)
df <- t(rmultinom(10,100,c(.1,.6,.2,.3,.2))) + 0.65   # add a small pseudocount
colnames(df) <- tr$tip.label

philr(df, tr, part.weights='enorm.x.gm.counts',
                  ilr.weights='blw.sqrt', return.all=FALSE)

Example output

Building Sequential Binary Partition from Tree...
Building Contrast Matrix...
Transforming the Data...
Calculating ILR Weights...
              n1          n2          n3          n4
 [1,] -0.3382212 -0.02361057  0.57848333 -1.32032713
 [2,]  0.2277654  0.64691327  0.51776222 -0.16481715
 [3,] -0.5056378  0.24028272 -0.21228398  0.19358047
 [4,] -0.3249956 -0.11006983 -0.17008591  0.47334107
 [5,] -0.3739128 -0.14856638  0.39776068  1.01941812
 [6,] -0.1812327  0.36099906 -0.37105819  0.07791262
 [7,]  0.9090068 -0.54631334 -0.40847689  0.18912156
 [8,]  0.7117789 -0.02008800 -0.24944194  1.18911774
 [9,] -0.1070883 -0.51719712 -0.08231148 -1.24134947
[10,]  0.2589870  0.36425761 -0.24944194  0.09312807

philr documentation built on Nov. 8, 2020, 5:38 p.m.