Title: | Exploring the Phylogenetic Signal in Continuous Traits |
---|---|
Description: | A collection of tools to explore the phylogenetic signal in univariate and multivariate data. The package provides functions to plot traits data against a phylogenetic tree, different measures and tests for the phylogenetic signal, methods to describe where the signal is located and a phylogenetic clustering method. |
Authors: | Francois Keck <[email protected]> |
Maintainer: | Francois Keck <[email protected]> |
License: | GPL-3 |
Version: | 1.3.1 |
Built: | 2024-11-05 03:28:21 UTC |
Source: | https://github.com/fkeck/phylosignal |
Set layout for plots
.layouterize(n.traits, show.tip)
.layouterize(n.traits, show.tip)
n.traits |
the number of traits in the layout |
show.tip |
a logical indicating whether tip names are included in the layout |
Set layout for plots
.layouterizeRatio(tree.ratio, n.traits, show.tip)
.layouterizeRatio(tree.ratio, n.traits, show.tip)
tree.ratio |
the ratio of phylogenetic tree included in the layout |
n.traits |
the number of traits in the layout |
show.tip |
a logical indicating whether tip names are included in the layout |
Internal function of multiplot.phylo4d. Reordering vector or matrix of settings and check for names consistencies.
.orderGrArg(x, n.tips, n.traits, new.order, tips, default)
.orderGrArg(x, n.tips, n.traits, new.order, tips, default)
x |
a vector or a matrix to order. |
n.tips |
number of tips. |
n.traits |
number of traits |
new.order |
a numeric vector giving the new order. |
tips |
a character vector giving the tips labels (with the new order) |
default |
the default value |
An ordered vector or matrix. An error if problem of consistency.
Barplot of Traits Values along a Phylogeny
## S3 method for class 'phylo4d' barplot( height, trait = names(tdata(height)), center = TRUE, scale = TRUE, tree.ladderize = FALSE, tree.type = "phylogram", tree.ratio = NULL, tree.xlim = NULL, tree.open.angle = 0, tree.open.crown = TRUE, show.tip = TRUE, tip.labels = NULL, tip.col = "black", tip.cex = 1, tip.font = 3, tip.adj = 0, data.xlim = NULL, bar.lwd = 10, bar.col = "grey35", show.data.axis = TRUE, show.trait = TRUE, trait.labels = NULL, trait.col = "black", trait.cex = 1, trait.font = 1, trait.bg.col = "grey90", error.bar.sup = NULL, error.bar.inf = NULL, error.bar.col = 1, show.box = FALSE, grid.vertical = TRUE, grid.horizontal = FALSE, grid.col = "grey25", grid.lty = "dashed", ... )
## S3 method for class 'phylo4d' barplot( height, trait = names(tdata(height)), center = TRUE, scale = TRUE, tree.ladderize = FALSE, tree.type = "phylogram", tree.ratio = NULL, tree.xlim = NULL, tree.open.angle = 0, tree.open.crown = TRUE, show.tip = TRUE, tip.labels = NULL, tip.col = "black", tip.cex = 1, tip.font = 3, tip.adj = 0, data.xlim = NULL, bar.lwd = 10, bar.col = "grey35", show.data.axis = TRUE, show.trait = TRUE, trait.labels = NULL, trait.col = "black", trait.cex = 1, trait.font = 1, trait.bg.col = "grey90", error.bar.sup = NULL, error.bar.inf = NULL, error.bar.col = 1, show.box = FALSE, grid.vertical = TRUE, grid.horizontal = FALSE, grid.col = "grey25", grid.lty = "dashed", ... )
height |
a |
trait |
the traits in the |
center |
a logical indicating whether traits values should be centered. |
scale |
a logical indicating whether traits values should be scaled. |
tree.ladderize |
a logical indicating whether the tree should be (right) ladderized. |
tree.type |
a character string specifying the type of phylogeny to be drawn.
Can be " |
tree.ratio |
a numeric value in [0, 1] giving the proportion of width of the figure for the tree. |
tree.xlim |
a numeric vector of length 2 giving the limits of the x-axis for the tree. If |
tree.open.angle |
a numeric value giving the angle in degrees left blank if |
tree.open.crown |
a logical indicating whether the crowns should be drawn following the value
of |
show.tip |
logical indicating whether tips labels should be drawn. |
tip.labels |
character vector to label the tips.
If |
tip.col |
a vector of R colors to use for the tips labels. Recycled if necessary. |
tip.cex |
a numeric vector to control character size of the tips labels. Recycled if necessary. |
tip.font |
an integer vector specifying the type of font for the tips labels: 1 (plain text), 2 (bold), 3 (italic), or 4 (bold italic). Recycled if necessary. |
tip.adj |
a vector of numeric in [0, 1] to control tips labels justification: 0 (left-justification), 0.5 (centering), or 1 (right-justification). Recycled if necessary. |
data.xlim |
numeric vector of length 2 or matrix giving the x coordinates range for the barplots/dotplots (see Details). |
bar.lwd |
a vector of numeric giving bar widths of the barplot(s). Recycled along the tips, reapeated for each trait. |
bar.col |
a vector of R colors to use for the bars. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
show.data.axis |
logical indicating whether barplots/dotplots axes should be drawn. |
show.trait |
logical indicating whether traits labels should be drawn. |
trait.labels |
character vector to label the traits.
If |
trait.col |
a vector of R colors to use for the traits labels. Recycled if necessary. |
trait.cex |
a numeric vector to control character size of the trait labels. Recycled if necessary. |
trait.font |
an integer vector specifying the type of font for the traits labels: 1 (plain text), 2 (bold), 3 (italic), or 4 (bold italic). Recycled if necessary. |
trait.bg.col |
a vector of R colors to use for the background of the barplots. Recycled if necessary. |
error.bar.sup |
a matrix giving the superior limit for error bars. Columns and rows names must match with traits and tips labels, respectively. |
error.bar.inf |
a matrix giving the inferior limit for error bars. Columns and rows names must match with traits and tips labels, respectively. |
error.bar.col |
a vector of R colors to use for the bars. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
show.box |
a logical indicating whether a box should be drawn around the plots. |
grid.vertical |
a logical incating whether vertical lines of the grid should be drawn. |
grid.horizontal |
a logical incating whether horizontal lines of the grid should be drawn. |
grid.col |
a vector of R colors to use for the lines of the grid. |
grid.lty |
the lines type of the grid. Possibly a vector. |
... |
further arguments to be passed to |
data(navic) barplot(navic)
data(navic) barplot(navic)
This function return all the names of the descents (tips) of a given node.
descentsNames(phy, node)
descentsNames(phy, node)
phy |
an object of class " |
node |
the ID of the node. |
A vector tip labels.
This function return the node number (ID) of the direct descents of a given node
directDescents(phy, node)
directDescents(phy, node)
phy |
an object of class " |
node |
the ID of the node. |
A vector of node numbers.
This function return a distance (or proximity) matrix between n points regularly distributed in 1 dimension.
distEq(n, prox = FALSE)
distEq(n, prox = FALSE)
n |
the number of points |
prox |
a logical indicating whether to return a matrix of proximity.
Default to |
A squared matrix. A matrix of class dist
if prox
is set to FALSE
.
x <- distEq(5)
x <- distEq(5)
Dotplot
dotplot(...)
dotplot(...)
... |
further arguments passed to or from other methods. |
Dotplot of Traits Values along a Phylogeny
## S3 method for class 'phylo4d' dotplot( p4d, trait = names(tdata(p4d)), center = TRUE, scale = TRUE, tree.ladderize = FALSE, tree.type = "phylogram", tree.ratio = NULL, tree.xlim = NULL, tree.open.angle = 0, tree.open.crown = TRUE, show.tip = TRUE, tip.labels = NULL, tip.col = "black", tip.cex = 1, tip.font = 3, tip.adj = 0, data.xlim = NULL, show.data.axis = TRUE, dot.col = "black", dot.pch = 20, dot.cex = 2, show.trait = TRUE, trait.labels = NULL, trait.col = "black", trait.cex = 1, trait.font = 1, trait.bg.col = "grey90", error.bar.sup = NULL, error.bar.inf = NULL, error.bar.col = 1, show.box = FALSE, grid.vertical = FALSE, grid.horizontal = TRUE, grid.col = "grey25", grid.lty = "dashed", ... )
## S3 method for class 'phylo4d' dotplot( p4d, trait = names(tdata(p4d)), center = TRUE, scale = TRUE, tree.ladderize = FALSE, tree.type = "phylogram", tree.ratio = NULL, tree.xlim = NULL, tree.open.angle = 0, tree.open.crown = TRUE, show.tip = TRUE, tip.labels = NULL, tip.col = "black", tip.cex = 1, tip.font = 3, tip.adj = 0, data.xlim = NULL, show.data.axis = TRUE, dot.col = "black", dot.pch = 20, dot.cex = 2, show.trait = TRUE, trait.labels = NULL, trait.col = "black", trait.cex = 1, trait.font = 1, trait.bg.col = "grey90", error.bar.sup = NULL, error.bar.inf = NULL, error.bar.col = 1, show.box = FALSE, grid.vertical = FALSE, grid.horizontal = TRUE, grid.col = "grey25", grid.lty = "dashed", ... )
p4d |
a |
trait |
the traits in the |
center |
a logical indicating whether traits values should be centered. |
scale |
a logical indicating whether traits values should be scaled. |
tree.ladderize |
a logical indicating whether the tree should be (right) ladderized. |
tree.type |
a character string specifying the type of phylogeny to be drawn.
Can be " |
tree.ratio |
a numeric value in [0, 1] giving the proportion of width of the figure for the tree. |
tree.xlim |
a numeric vector of length 2 giving the limits of the x-axis for the tree. If |
tree.open.angle |
a numeric value giving the angle in degrees left blank if |
tree.open.crown |
a logical indicating whether the crowns should be drawn following the value
of |
show.tip |
logical indicating whether tips labels should be drawn. |
tip.labels |
character vector to label the tips.
If |
tip.col |
a vector of R colors to use for the tips labels. Recycled if necessary. |
tip.cex |
a numeric vector to control character size of the tips labels. Recycled if necessary. |
tip.font |
an integer vector specifying the type of font for the tips labels: 1 (plain text), 2 (bold), 3 (italic), or 4 (bold italic). Recycled if necessary. |
tip.adj |
a vector of numeric in [0, 1] to control tips labels justification: 0 (left-justification), 0.5 (centering), or 1 (right-justification). Recycled if necessary. |
data.xlim |
numeric vector of length 2 or matrix giving the x coordinates range for the barplots/dotplots (see Details). |
show.data.axis |
logical indicating whether barplots/dotplots axes should be drawn. |
dot.col |
a vector of R colors to use for the points. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
dot.pch |
a numerical vector of symbol to use for the points. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
dot.cex |
a numerical vector. Character (or symbol) expansion for the points. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
show.trait |
logical indicating whether traits labels should be drawn. |
trait.labels |
character vector to label the traits.
If |
trait.col |
a vector of R colors to use for the traits labels. Recycled if necessary. |
trait.cex |
a numeric vector to control character size of the trait labels. Recycled if necessary. |
trait.font |
an integer vector specifying the type of font for the traits labels: 1 (plain text), 2 (bold), 3 (italic), or 4 (bold italic). Recycled if necessary. |
trait.bg.col |
a vector of R colors to use for the background of the barplots. Recycled if necessary. |
error.bar.sup |
a matrix giving the superior limit for error bars. Columns and rows names must match with traits and tips labels, respectively. |
error.bar.inf |
a matrix giving the inferior limit for error bars. Columns and rows names must match with traits and tips labels, respectively. |
error.bar.col |
a vector of R colors to use for the bars. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
show.box |
a logical indicating whether a box should be drawn around the plots. |
grid.vertical |
a logical incating whether vertical lines of the grid should be drawn. |
grid.horizontal |
a logical incating whether horizontal lines of the grid should be drawn. |
grid.col |
a vector of R colors to use for the lines of the grid. |
grid.lty |
the lines type of the grid. Possibly a vector. |
... |
further arguments to be passed to |
data(navic) dotplot(navic)
data(navic) dotplot(navic)
This function generates a vector of n colors evenly distributed in the RGB space. Usefull to create palettes of distinct colors.
evenColors(n)
evenColors(n)
n |
the number of colors to be in the palette. |
a vector of hexadecimal colors.
These functions can be used after barplot.phylo4d
, dotplot.phylo4d
and gridplot.phylo4d
when
tree.type
is "phylogram"
or "cladogram"
to focus on
the different part of the plot and add graphical elements.
focusTraits(x) focusTree() focusTips() focusStop()
focusTraits(x) focusTree() focusTips() focusStop()
x |
the trait to focus on. Can be a character string giving the name of the trait or an integer giving the number of the trait in order of appearance in the plot. |
#' Use focusTree
to focus on the phylogenetic tree, focusTraits
to focus on a given trait and focusTips
to focus on the tips labels.
Use focusStop
to close the editing and restore graphical settings.
For each part of the plot, the coordinate system is restored, making edition easier.
For the phylogeny, post-editing functions of the package ape
like nodelabels
can be used.
require(ape) require(phylobase) data(navic) dat <- tdata(navic) neidium.sp <- c("Neidium bisulcatum", "Neidium affine", "Neidium productum") stauroneis.sp <- c("Stauroneis kriegeri", "Stauroneis acuta", "Stauroneis gracilior", "Stauroneis phoenicenteron") neidium.mean <- mean(dat[neidium.sp,]) stauroneis.mean <- mean(dat[stauroneis.sp, ]) dotplot(navic, center = FALSE, scale = FALSE, data.xlim= c(0, 6)) focusTree() nodelabels(node=c(22, 32), pch = 20, cex = 3, col = c(2, 3)) focusTraits() segments(x0 = neidium.mean, y0 = 14.5, x1 = neidium.mean, y1 = 17.5, col = 3, lty = "dashed", lwd = 2) segments(x0 = stauroneis.mean, y0 = 2.5, x1 = stauroneis.mean, y1 = 7.5, col = 2, lty = "dashed", lwd = 2) focusTips() rect(xleft = 0, ybottom = 2.5, xright = 0.9, ytop = 7.5, col = "#FF000020", border = NA) rect(xleft = 0, ybottom = 14.5, xright = 0.9, ytop = 17.5, col = "#00FF0020", border = NA) focusStop()
require(ape) require(phylobase) data(navic) dat <- tdata(navic) neidium.sp <- c("Neidium bisulcatum", "Neidium affine", "Neidium productum") stauroneis.sp <- c("Stauroneis kriegeri", "Stauroneis acuta", "Stauroneis gracilior", "Stauroneis phoenicenteron") neidium.mean <- mean(dat[neidium.sp,]) stauroneis.mean <- mean(dat[stauroneis.sp, ]) dotplot(navic, center = FALSE, scale = FALSE, data.xlim= c(0, 6)) focusTree() nodelabels(node=c(22, 32), pch = 20, cex = 3, col = c(2, 3)) focusTraits() segments(x0 = neidium.mean, y0 = 14.5, x1 = neidium.mean, y1 = 17.5, col = 3, lty = "dashed", lwd = 2) segments(x0 = stauroneis.mean, y0 = 2.5, x1 = stauroneis.mean, y1 = 7.5, col = 2, lty = "dashed", lwd = 2) focusTips() rect(xleft = 0, ybottom = 2.5, xright = 0.9, ytop = 7.5, col = "#FF000020", border = NA) rect(xleft = 0, ybottom = 14.5, xright = 0.9, ytop = 17.5, col = "#00FF0020", border = NA) focusStop()
This function extracts clusters of species based on traits values and phylogenetic proximities.
graphClust( p4d, trait = names(tdata(p4d)), lim.phylo = 0.2, lim.trait = 0.2, select.method = "ellipse", dist.phylo = "patristic", dist.trait = "euclidean", scale.lim = TRUE )
graphClust( p4d, trait = names(tdata(p4d)), lim.phylo = 0.2, lim.trait = 0.2, select.method = "ellipse", dist.phylo = "patristic", dist.trait = "euclidean", scale.lim = TRUE )
p4d |
a |
trait |
the traits in the |
lim.phylo |
the maximum phylogenetic distance for edges selection. |
lim.trait |
the maximum trait-based distance for edges selection. |
select.method |
a character string specifying the method used to select edges.
This must be one of " |
dist.phylo |
a matrix of phylogenetic distances or a character string specifying a method to compute it. See Details. |
dist.trait |
a character string specifying the method used to compute traits distances. See Details. |
scale.lim |
logical (default |
If "dist.phylo
" is a character string,
the phylogenetic distance matrix is computed internally
using the function distTips
from the package adephylo.
All the methods supported by distTips
are available:
"patristic
","nNodes
","Abouheif
" and "sumDD
".
See distTips
for details about the methods.
If "dist.trait
" is a character string,
the traits distance matrix is computed with the dist
function.
All the methods supported by dist
are available:
"euclidean
","maximum
", "manhattan
",
"canberra
", "binary
" and "minkowski
".
See dist
for details about the methods.
An object of class graphclust
.
data(navic) gC <- graphClust(navic, lim.phylo = 1, lim.trait = 2, scale.lim = FALSE) gC plot.graphclust(gC, which = "selection", ask = FALSE) plot.graphclust(gC, which = "graph", ask = FALSE) plot.graphclust(gC, which = "tree", ask = FALSE)
data(navic) gC <- graphClust(navic, lim.phylo = 1, lim.trait = 2, scale.lim = FALSE) gC plot.graphclust(gC, which = "selection", ask = FALSE) plot.graphclust(gC, which = "graph", ask = FALSE) plot.graphclust(gC, which = "tree", ask = FALSE)
Gridplot
gridplot(...)
gridplot(...)
... |
further arguments passed to or from other methods. |
Gridplot of Traits Values along a Phylogeny
## S3 method for class 'phylo4d' gridplot( p4d, trait = names(tdata(p4d)), center = TRUE, scale = TRUE, tree.ladderize = FALSE, tree.type = "phylogram", tree.ratio = NULL, tree.xlim = NULL, tree.open.angle = 0, tree.open.crown = TRUE, show.tip = TRUE, tip.labels = NULL, tip.col = "black", tip.cex = 1, tip.font = 3, tip.adj = 0, cell.col = white2red(100), show.color.scale = TRUE, show.trait = TRUE, trait.labels = NULL, trait.col = "black", trait.cex = 0.7, trait.font = 1, trait.bg.col = "grey90", show.box = FALSE, grid.vertical = FALSE, grid.horizontal = FALSE, grid.col = "grey25", grid.lty = "dashed", ... )
## S3 method for class 'phylo4d' gridplot( p4d, trait = names(tdata(p4d)), center = TRUE, scale = TRUE, tree.ladderize = FALSE, tree.type = "phylogram", tree.ratio = NULL, tree.xlim = NULL, tree.open.angle = 0, tree.open.crown = TRUE, show.tip = TRUE, tip.labels = NULL, tip.col = "black", tip.cex = 1, tip.font = 3, tip.adj = 0, cell.col = white2red(100), show.color.scale = TRUE, show.trait = TRUE, trait.labels = NULL, trait.col = "black", trait.cex = 0.7, trait.font = 1, trait.bg.col = "grey90", show.box = FALSE, grid.vertical = FALSE, grid.horizontal = FALSE, grid.col = "grey25", grid.lty = "dashed", ... )
p4d |
a |
trait |
the traits in the |
center |
a logical indicating whether traits values should be centered. |
scale |
a logical indicating whether traits values should be scaled. |
tree.ladderize |
a logical indicating whether the tree should be (right) ladderized. |
tree.type |
a character string specifying the type of phylogeny to be drawn.
Can be " |
tree.ratio |
a numeric value in [0, 1] giving the proportion of width of the figure for the tree. |
tree.xlim |
a numeric vector of length 2 giving the limits of the x-axis for the tree. If |
tree.open.angle |
a numeric value giving the angle in degrees left blank if |
tree.open.crown |
a logical indicating whether the crowns should be drawn following the value
of |
show.tip |
logical indicating whether tips labels should be drawn. |
tip.labels |
character vector to label the tips.
If |
tip.col |
a vector of R colors to use for the tips labels. Recycled if necessary. |
tip.cex |
a numeric vector to control character size of the tips labels. Recycled if necessary. |
tip.font |
an integer vector specifying the type of font for the tips labels: 1 (plain text), 2 (bold), 3 (italic), or 4 (bold italic). Recycled if necessary. |
tip.adj |
a vector of numeric in [0, 1] to control tips labels justification: 0 (left-justification), 0.5 (centering), or 1 (right-justification). Recycled if necessary. |
cell.col |
a vector of colors for |
show.color.scale |
logical indicating whether color scale should be drawn. |
show.trait |
logical indicating whether traits labels should be drawn. |
trait.labels |
character vector to label the traits.
If |
trait.col |
a vector of R colors to use for the traits labels. Recycled if necessary. |
trait.cex |
a numeric vector to control character size of the trait labels. Recycled if necessary. |
trait.font |
an integer vector specifying the type of font for the traits labels: 1 (plain text), 2 (bold), 3 (italic), or 4 (bold italic). Recycled if necessary. |
trait.bg.col |
a vector of R colors to use for the background of the barplots. Recycled if necessary. |
show.box |
a logical indicating whether a box should be drawn around the plots. |
grid.vertical |
a logical incating whether vertical lines of the grid should be drawn. |
grid.horizontal |
a logical incating whether horizontal lines of the grid should be drawn. |
grid.col |
a vector of R colors to use for the lines of the grid. |
grid.lty |
the lines type of the grid. Possibly a vector. |
... |
further arguments to be passed to |
data(navic) gridplot(navic) # Multivariate data require(phylobase) tipData(navic) <- matrix(rnorm(170), nrow = 17) gridplot(navic)
data(navic) gridplot(navic) # Multivariate data require(phylobase) tipData(navic) <- matrix(rnorm(170), nrow = 17) gridplot(navic)
Computes permutation test for Blomberg's K Star
kStarTest(xr, vcvr, reps)
kStarTest(xr, vcvr, reps)
xr |
a vector of data |
vcvr |
phylogenetic variance-covariance matrix |
reps |
the number of permutations |
Computes permutation test for Blomberg's K
kTest(xr, vcvr, reps)
kTest(xr, vcvr, reps)
xr |
a vector of data |
vcvr |
phylogenetic variance-covariance matrix |
reps |
the number of permutations |
Test Pagel's Lambda Optimize Pagel's Lambda and do a likelihood ratio test.
lambdaTest(x, vcv)
lambdaTest(x, vcv)
x |
a vector of numeric data. |
vcv |
the phylogenetic variance-covariance matrix. |
The optimization process is currently performed in R.
This function computes Local Indicator of Phylogenetic Association (local Moran's I) for each tip of a tree. Tests are based on permutations.
lipaMoran( p4d, trait = names(tdata(p4d)), reps = 999, alternative = "greater", prox.phylo = "patristic", as.p4d = FALSE )
lipaMoran( p4d, trait = names(tdata(p4d)), reps = 999, alternative = "greater", prox.phylo = "patristic", as.p4d = FALSE )
p4d |
a |
trait |
the traits in the |
reps |
a numeric value. Number of repetitions for the estimation of p.values with randomization. |
alternative |
a character string specifying the alternative hypothesis for the tests.
Must be one of |
prox.phylo |
a matrix of phylogenetic proximities or a character string specifying a method to compute it. See Details. |
as.p4d |
logical. Should the results returned as a |
If "prox.phylo
" is a character string,
the phylogenetic proximity matrix is computed internally
using the function proxTips
from the package adephylo.
Different methods are available:
"patristic
","nNodes
","Abouheif
" and "sumDD
".
See proxTips
for details about the methods.
If as.p4d
is FALSE
(default), the function returns a list:
A matrix of LIPA indices computed for each tip of the tree and each trait.
A matrix of p-values (tests of LIPA indices)
Number of permutations for the tests
Alternative hypothesis for the tests
If as.p4d
is TRUE
, the function returns a phylo4d
object
with LIPA values as tips associated data.
Anselin L. (1995) Local Indicators of Spatial Association-LISA. Geographical Analysis 27, 93-115.
Mantel statistic
mantelStat(xr, Wr)
mantelStat(xr, Wr)
xr |
a matrix of traits. |
Wr |
a matrix of weights. |
Check for constitency of rows and columns names between a matrix of traits values and phylo4d object.
matchTipsAndTraits( x, p4d = NULL, p4d.tips = NULL, p4d.traits = NULL, subset = TRUE )
matchTipsAndTraits( x, p4d = NULL, p4d.tips = NULL, p4d.traits = NULL, subset = TRUE )
x |
a matrix of data. |
p4d |
a phylo4d object. |
p4d.tips |
tips labels (relevant if p4d is |
p4d.traits |
traits labels (relevant if p4d is |
subset |
a logical. Should the data matrix be subsetted using tips and traits labels. |
The data matrix (eventually subsetted). An error if no consistency between the data and the tree.
Computes permutation test for Moran's I
moranTest(xr, Wr, reps)
moranTest(xr, Wr, reps)
xr |
a vector of data |
Wr |
a weighting matrix |
reps |
the number of permutations |
This function provides a general interface to plot phylo4d
object
(i.e. phylogenetic tree and data).
multiplot.phylo4d( p4d, trait = names(tdata(p4d)), center = TRUE, scale = TRUE, plot.type = "barplot", tree.ladderize = FALSE, tree.type = "phylogram", tree.ratio = NULL, tree.xlim = NULL, tree.open.angle = 0, tree.open.crown = TRUE, show.tip = TRUE, tip.labels = NULL, tip.col = "black", tip.cex = 1, tip.font = 3, tip.adj = 0, data.xlim = NULL, bar.lwd = 10, bar.col = "grey35", show.data.axis = TRUE, dot.col = "black", dot.pch = 20, dot.cex = 2, cell.col = white2red(100), show.color.scale = TRUE, show.trait = TRUE, trait.labels = NULL, trait.col = "black", trait.cex = 1, trait.font = 1, trait.bg.col = "grey90", error.bar.sup = NULL, error.bar.inf = NULL, error.bar.col = 1, show.box = FALSE, grid.vertical = TRUE, grid.horizontal = FALSE, grid.col = "grey25", grid.lty = "dashed", ... )
multiplot.phylo4d( p4d, trait = names(tdata(p4d)), center = TRUE, scale = TRUE, plot.type = "barplot", tree.ladderize = FALSE, tree.type = "phylogram", tree.ratio = NULL, tree.xlim = NULL, tree.open.angle = 0, tree.open.crown = TRUE, show.tip = TRUE, tip.labels = NULL, tip.col = "black", tip.cex = 1, tip.font = 3, tip.adj = 0, data.xlim = NULL, bar.lwd = 10, bar.col = "grey35", show.data.axis = TRUE, dot.col = "black", dot.pch = 20, dot.cex = 2, cell.col = white2red(100), show.color.scale = TRUE, show.trait = TRUE, trait.labels = NULL, trait.col = "black", trait.cex = 1, trait.font = 1, trait.bg.col = "grey90", error.bar.sup = NULL, error.bar.inf = NULL, error.bar.col = 1, show.box = FALSE, grid.vertical = TRUE, grid.horizontal = FALSE, grid.col = "grey25", grid.lty = "dashed", ... )
p4d |
a |
trait |
the traits in the |
center |
a logical indicating whether traits values should be centered. |
scale |
a logical indicating whether traits values should be scaled. |
plot.type |
a character string specifying the type of plot for traits data.
Can be " |
tree.ladderize |
a logical indicating whether the tree should be (right) ladderized. |
tree.type |
a character string specifying the type of phylogeny to be drawn.
Can be " |
tree.ratio |
a numeric value in [0, 1] giving the proportion of width of the figure for the tree. |
tree.xlim |
a numeric vector of length 2 giving the limits of the x-axis for the tree. If |
tree.open.angle |
a numeric value giving the angle in degrees left blank if |
tree.open.crown |
a logical indicating whether the crowns should be drawn following the value
of |
show.tip |
logical indicating whether tips labels should be drawn. |
tip.labels |
character vector to label the tips.
If |
tip.col |
a vector of R colors to use for the tips labels. Recycled if necessary. |
tip.cex |
a numeric vector to control character size of the tips labels. Recycled if necessary. |
tip.font |
an integer vector specifying the type of font for the tips labels: 1 (plain text), 2 (bold), 3 (italic), or 4 (bold italic). Recycled if necessary. |
tip.adj |
a vector of numeric in [0, 1] to control tips labels justification: 0 (left-justification), 0.5 (centering), or 1 (right-justification). Recycled if necessary. |
data.xlim |
numeric vector of length 2 or matrix giving the x coordinates range for the barplots/dotplots (see Details). |
bar.lwd |
a vector of numeric giving bar widths of the barplot(s). Recycled along the tips, reapeated for each trait. |
bar.col |
a vector of R colors to use for the bars. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
show.data.axis |
logical indicating whether barplots/dotplots axes should be drawn. |
dot.col |
a vector of R colors to use for the points. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
dot.pch |
a numerical vector of symbol to use for the points. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
dot.cex |
a numerical vector. Character (or symbol) expansion for the points. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
cell.col |
a vector of colors for |
show.color.scale |
logical indicating whether color scale should be drawn. |
show.trait |
logical indicating whether traits labels should be drawn. |
trait.labels |
character vector to label the traits.
If |
trait.col |
a vector of R colors to use for the traits labels. Recycled if necessary. |
trait.cex |
a numeric vector to control character size of the trait labels. Recycled if necessary. |
trait.font |
an integer vector specifying the type of font for the traits labels: 1 (plain text), 2 (bold), 3 (italic), or 4 (bold italic). Recycled if necessary. |
trait.bg.col |
a vector of R colors to use for the background of the barplots. Recycled if necessary. |
error.bar.sup |
a matrix giving the superior limit for error bars. Columns and rows names must match with traits and tips labels, respectively. |
error.bar.inf |
a matrix giving the inferior limit for error bars. Columns and rows names must match with traits and tips labels, respectively. |
error.bar.col |
a vector of R colors to use for the bars. Recycled along the tips, reapeated for each trait. The user can also provide a matrix for a finer tuning (see Details) |
show.box |
a logical indicating whether a box should be drawn around the plots. |
grid.vertical |
a logical incating whether vertical lines of the grid should be drawn. |
grid.horizontal |
a logical incating whether horizontal lines of the grid should be drawn. |
grid.col |
a vector of R colors to use for the lines of the grid. |
grid.lty |
the lines type of the grid. Possibly a vector. |
... |
further arguments to be passed to |
Computes log-likelihood for data and a given value of Pagel's Lambda
pagelLogLik(lambda, xr, vcvr)
pagelLogLik(lambda, xr, vcvr)
lambda |
the value of Pagel's Lambda |
xr |
a vector of data |
vcvr |
phylogenetic variance-covariance matrix |
Adapted from Liam Revell's R function 'phylosig' in phytools.
This function computes a phylogenetic correlogram.
phyloCorrelogram( p4d, trait = names(tdata(p4d)), dist.phylo = "patristic", sigma = NULL, n.points = 100, ci.bs = 1000, ci.conf = 0.95 )
phyloCorrelogram( p4d, trait = names(tdata(p4d)), dist.phylo = "patristic", sigma = NULL, n.points = 100, ci.bs = 1000, ci.conf = 0.95 )
p4d |
a |
trait |
the traits in the |
dist.phylo |
a matrix of phylogenetic distances or a character string specifying a method to compute it. See Details. |
sigma |
a numeric value giving the standard deviation of the normal distribution used
to compute the matrix of phylogenetic weights. If |
n.points |
an integer giving the number of points at which to compute the correlogram's statistics. |
ci.bs |
an integer giving the number of bootstrap replicates for confidence interval estimation. |
ci.conf |
a value between 0 and 1 giving the confidence level of the confidence interval. |
This function computes a correlogram on a continuous scale of phylogenetic distance.
This is achieved by using a collection of specific phylogenetic weights matrices generated
with the "lag-norm
" method of phyloWeights
and different values of "mu
".
The confidence envelope is computed by bootstrapping. At each iteration, the autocorrelation is re-estimated after re-standardization of the matrix of phylogenetic weights. The nonparametric confidence intervals are computed at each lag by first order normal approximation. Intervals are constrained between 0 and 1.
If there is one trait, the function computes Moran's I. If there is more than one trait, the function computes the Mantel's statistic (Oden and Sokal 1986).
If "dist.phylo
" is a character string,
the phylogenetic distance matrix is computed internally
using the function distTips
from the package adephylo.
See distTips
for details about the methods.
An object of class "phylocorrelogram
".
Oden N.L. & Sokal R.R. (1986) Directional Autocorrelation: An Extension of Spatial Correlograms to Two Dimensions. Systematic Zoology 35, 608-617.
plot.phylocorrelogram
,
correlogram.formula
in ape for correlograms based on taxonomic levels.
## Not run: data(navic) pc <- phyloCorrelogram(navic) plot(pc) ## End(Not run)
## Not run: data(navic) pc <- phyloCorrelogram(navic) plot(pc) ## End(Not run)
A collection of tools to explore the phylogenetic signal in univariate and multivariate data. The package provides functions to plot traits data against a phylogenetic tree, different measures and tests for the phylogenetic signal, methods to describe where the signal is located and a phylogenetic clustering method.
This function computes phylogenetic signal statistics
(Blomberg's K and K*, Abouheif's Cmean, Moran's I, and Pagel's Lambda) for traits in phylo4d
objects.
phyloSignal( p4d, methods = c("all", "I", "Cmean", "Lambda", "K", "K.star"), reps = 999, W = NULL )
phyloSignal( p4d, methods = c("all", "I", "Cmean", "Lambda", "K", "K.star"), reps = 999, W = NULL )
p4d |
a |
methods |
a character vector giving the methods to compute phylogenetic signal (see Details). |
reps |
an integer. The number of repetitions for the estimation of p.values with randomization. |
W |
an optional matrix of phylogenetic weights to compute Moran's I. By default the matrix
is computed with the function |
p4d must be a phylo4d
object as defined in phylobase package.
By default, the methods
argument is set to "all
" and all the available methods are used.
The user can specify which method(s) to use. Possible methods are
"I
" (Gittleman & Kot 1990), "Cmean
" (Abouheif 1999)", "Lambda
" (Pagel 1999),
"K
" and "K.star
" (Blomberg et al. 2003).
A list of two dataframes with the values of statistics and associated p.values for each tested trait and method.
This function is a general wrapper for C++ subroutines. C++ code is adapted from R functions in Pavoine and Ricotta (2013) and Revell (2012).
Abouheif E. (1999) A method for testing the assumption of phylogenetic independence in comparative data. Evolutionary Ecology Research 1, 895-909. Blomberg S.P., Garland Jr T. & Ives A.R. (2003) Testing for phylogenetic signal in comparative data: behavioral traits are more labile. Evolution 57, 717-745. Gittleman J.L. & Kot M. (1990) Adaptation: Statistics and a null model for estimating phylogenetic effects. Systematic Biology 39, 227-241. Pagel M. (1999) Inferring the historical patterns of biological evolution. Nature 401, 877-884. Revell L.J. (2012) phytools: an R package for phylogenetic comparative biology (and other things). Methods in Ecology and Evolution 3, 217-223. Pavoine S. & Ricotta C. (2013) Testing for Phylogenetic Signal in Biological Traits: The Ubiquity of Cross-Product Statistics. Evolution 67, 828-840.
require(ape) require(phylobase) data(navic) tipData(navic)$rand <- rnorm(17) tipData(navic)$BM <- rTraitCont(as(navic, "phylo")) phyloSignal(navic)
require(ape) require(phylobase) data(navic) tipData(navic)$rand <- rnorm(17) tipData(navic)$BM <- rTraitCont(as(navic, "phylo")) phyloSignal(navic)
This function computes phylogenetic signal statistics and p-values for bootsrapped replicates a phylogenetic tree and produce boxplots to represent the results. This can be useful to check the impact of phylogenetic reconstruction uncertainty on phylogenetic signal.
phyloSignalBS( p4d, multiphylo, methods = c("all", "I", "Cmean", "Lambda", "K", "K.star"), reps = 999, W = NULL, pb = TRUE )
phyloSignalBS( p4d, multiphylo, methods = c("all", "I", "Cmean", "Lambda", "K", "K.star"), reps = 999, W = NULL, pb = TRUE )
p4d |
a |
multiphylo |
a |
methods |
a character vector giving the methods to compute phylogenetic signal (see |
reps |
an integer. The number of repetitions for the estimation of p.values with randomization. |
W |
an optional matrix of phylogenetic weights to compute Moran's I. By default the matrix
is computed with the function |
pb |
a logical. Should a progress bar be printed? (default |
Time consumption can be important if there are many bootraped trees and tested traits.
The data generated are returned invisibly as a list.
This function computes phylogenetic signal statistics and p-values for a given trait and a given method at each internal node of a phylogenetic tree.
phyloSignalINT( p4d, trait = names(tipData(p4d))[1], method = "Cmean", reps = 999, W = NULL )
phyloSignalINT( p4d, trait = names(tipData(p4d))[1], method = "Cmean", reps = 999, W = NULL )
p4d |
a |
trait |
a character string giving the trait to use to compute the signal. By default the first trait is taken from |
method |
a character vector giving the method to use to compute phylogenetic signal
(default is " |
reps |
an integer. The number of repetitions for the estimation of p.values with randomization. |
W |
an optional matrix of phylogenetic weights to compute Moran's I. By default the matrix
is computed with the function |
A phylo4d
object with phylogenetic signal statistics and p-values as nodes associated data.
This function simulates different phylogenetic signal statistics for a given phylogenetic tree along a gradient of Brownian Motion influence.
phyloSim( tree, methods = c("all", "I", "Cmean", "Lambda", "K", "K.star"), nsim = 99, reps = 999, W = NULL, model = "BM", pb = TRUE )
phyloSim( tree, methods = c("all", "I", "Cmean", "Lambda", "K", "K.star"), nsim = 99, reps = 999, W = NULL, model = "BM", pb = TRUE )
tree |
a |
methods |
a character vector giving the methods to compute phylogenetic signal (see Details). |
nsim |
a numeric value. Number of simulated traits at each step in the gradient. |
reps |
a numeric value. Number of repetitions for the estimation of p.values with randomization. |
W |
an optional matrix of phylogenetic weights to compute Moran's I. By default the matrix
is computed with the function |
model |
the model to use for traits simulation (only " |
pb |
a logical. Should a progress bar be printed? (default |
By default, the methods
argument is set to "all
" and all the available methods are used.
The user can specify which method(s) to use. Possible values are
"I
", "Cmean
", "Lambda
", "K
" and "K.star
",
see phyloSignal
for further details.
An object of class phylosim
.
## Not run: data(navic) psim <- phyloSim(navic) plot(psim) plot.phylosim(psim, what = "pval", stacked.methods = TRUE) ## End(Not run)
## Not run: data(navic) psim <- phyloSim(navic) plot(psim) plot.phylosim(psim, what = "pval", stacked.methods = TRUE) ## End(Not run)
This function crosses traits data with simulations to estimate the phylogenetic signal as a fraction of a Brownian Motion process. This is experimental.
phyloSimSignal(p4d, phylosim, quantiles = c(0.05, 0.95))
phyloSimSignal(p4d, phylosim, quantiles = c(0.05, 0.95))
p4d |
a |
phylosim |
a |
quantiles |
a vector of two numeric values between 0 and 1 giving the minimum and the maximum quantiles to estimate statistics fluctuations. |
An object of class phylosimsignal
with a print
and a plot
method.
This function can be used to compute a phylogenetic weights matrix with different methods.
phyloWeights( tree, dist.phylo = "patristic", method = "lag-norm", mu = 0, sigma = 5, dmax = 10, alpha = 1, beta = 1 )
phyloWeights( tree, dist.phylo = "patristic", method = "lag-norm", mu = 0, sigma = 5, dmax = 10, alpha = 1, beta = 1 )
tree |
a |
dist.phylo |
a character string specifying the method used to compute phylogenetic distances.
Available distances are " |
method |
a method to compute phylogenetic weights from phylogenetic distances.
Available methods are " |
mu |
a numeric value giving the mean of the distribution if |
sigma |
a numeric value giving the standard deviation
of the distribution if |
dmax |
the maximum phylogenetic distance to use to delineate clades. |
alpha |
a numeric value giving the exponent to use if |
beta |
a numeric value giving the factor to use if |
Method "inverse
":
The phylogenetic distance matrix is computed internally
using the function distTips
from the package adephylo.
See distTips
for details about the methods.
A square matrix of phylogenetic weights whose sums of rows is 1.
proxTips
in adephylo.
This function produces three plots (selectable by which
):
a plot of edges selection based on phylogenetic against trait distances of taxa pairs,
a plot of the graph produced with the selected edges
and a plot of the clustered phylogenetic tree.
## S3 method for class 'graphclust' plot( x, which = c("selection", "graph", "tree"), ask = TRUE, colored = TRUE, ... )
## S3 method for class 'graphclust' plot( x, which = c("selection", "graph", "tree"), ask = TRUE, colored = TRUE, ... )
x |
a |
which |
a character vector to select plots.
Must be one or more of " |
ask |
logical if |
colored |
logical indicating if plots must include colors. |
... |
further arguments to be passed to or from other methods. They are currently ignored in this function. |
data(navic) gC <- graphClust(navic, lim.phylo = 1, lim.trait = 2, scale.lim = FALSE) plot.graphclust(gC, which = "selection", ask = FALSE) plot.graphclust(gC, which = "graph", ask = FALSE) plot.graphclust(gC, which = "tree", ask = FALSE)
data(navic) gC <- graphClust(navic, lim.phylo = 1, lim.trait = 2, scale.lim = FALSE) plot.graphclust(gC, which = "selection", ask = FALSE) plot.graphclust(gC, which = "graph", ask = FALSE) plot.graphclust(gC, which = "tree", ask = FALSE)
This function plots phylogenetic correlograms produced by phyloCorrelogram
## S3 method for class 'phylocorrelogram' plot( x, show.ci = TRUE, show.h0 = TRUE, show.test = TRUE, xlab = "Phylogenetic distance", ylab = "Correlation", main = "Phylogenetic correlogram", ... )
## S3 method for class 'phylocorrelogram' plot( x, show.ci = TRUE, show.h0 = TRUE, show.test = TRUE, xlab = "Phylogenetic distance", ylab = "Correlation", main = "Phylogenetic correlogram", ... )
x |
a |
show.ci |
a logical indicating whether to plot the confidence interval envelop (default |
show.h0 |
a logical indicating whether to plot the the line showing the expected
value of Moran's I under the null hypothesis of no phylogenetic autocorrelation (default |
show.test |
a logical indicating whether to plot indicator of significance (default |
xlab |
a label for the x axis. |
ylab |
a label for the y axis. |
main |
a main title for the plot |
... |
other graphical parameters passed to the |
## Not run: data(navic) pc <- phyloCorrelogram(navic) plot(pc) ## End(Not run)
## Not run: data(navic) pc <- phyloCorrelogram(navic) plot(pc) ## End(Not run)
phylosim
objectThis function plots a phylosim
object to visualize the behaviour of
phylogenetic signal statistics for a given phylogenetic tree
## S3 method for class 'phylosim' plot( x, what = c("stat", "pval"), stacked.methods = FALSE, quantiles = c(0.05, 0.95), col = 1:5, legend = TRUE, ... )
## S3 method for class 'phylosim' plot( x, what = c("stat", "pval"), stacked.methods = FALSE, quantiles = c(0.05, 0.95), col = 1:5, legend = TRUE, ... )
x |
a |
what |
what to represent on the plot.
Can be the statistics used to measure the signal (" |
stacked.methods |
a logical. If different methods have been used, should they
be plotted on the same graphic ( |
quantiles |
a vector of two numeric values between 0 and 1
giving the minimum and the maximum quantiles to plot.
Set to |
col |
a vector of colors for the different methods. |
legend |
a logical. If |
... |
further arguments to be passed to or from other methods. |
## Not run: data(navic) psim <- phyloSim(navic) plot(psim) plot.phylosim(psim, what = "pval", stacked.methods = TRUE) ## End(Not run)
## Not run: data(navic) psim <- phyloSim(navic) plot(psim) plot.phylosim(psim, what = "pval", stacked.methods = TRUE) ## End(Not run)
Plot signal estimation as a fraction of a Brownian Motion process.
## S3 method for class 'phylosimsignal' plot( x, methods = NULL, traits = NULL, stacked.methods = FALSE, stacked.traits = FALSE, print.quantiles = TRUE, col = 1:5, legend = TRUE, ... )
## S3 method for class 'phylosimsignal' plot( x, methods = NULL, traits = NULL, stacked.methods = FALSE, stacked.traits = FALSE, print.quantiles = TRUE, col = 1:5, legend = TRUE, ... )
x |
an object of class |
methods |
a character vector giving the methods
(included in the |
traits |
a character vector giving the traits
(included in the |
stacked.methods |
If different methods have been used, should they
be plotted on the same graphic ( |
stacked.traits |
If different traits have been used, should they
be plotted on the same graphic ( |
print.quantiles |
logical stating whether quantiles should be plotted. |
col |
a vector of colors for the different methods. |
legend |
a logical. If |
... |
further arguments to be passed to or from other methods. |
#' Print results of phylogenetically constrained clustering
## S3 method for class 'graphclust' print(x, ...)
## S3 method for class 'graphclust' print(x, ...)
x |
a |
... |
further arguments to be passed to or from other methods. |
Print signal estimation as a fraction of a Brownian Motion process.
## S3 method for class 'phylosimsignal' print(x, ...)
## S3 method for class 'phylosimsignal' print(x, ...)
x |
an object of class |
... |
further arguments to be passed to or from other methods. |
This function creates an object of class phylo4d
by combining
a phylogenetic tree and its associated tips data stored in two distinct files.
read.p4d(phylo.file, data.file, phylo.format = "newick", data.format = "table")
read.p4d(phylo.file, data.file, phylo.format = "newick", data.format = "table")
phylo.file |
the name of the file which the phylogenetic tree is to be read from. |
data.file |
the name of the file which the tips data are to be read from. |
phylo.format |
the format of the phylogenetic tree provided.
Possible formats are " |
data.format |
the format of the table with tips data.
Possible formats are " |
phylo.file
and data.file
can be provided as objects of mode character
or double-quoted strings.
The phylogenetic tree can be imported in two formats.
The newick
format refers
to the simple parenthetic format known as the Newick or New Hampshire format. The tree is
read by calling the function read.tree
of the ape package.
The nexus
format refers to NEXUS format. The tree is
read by calling the function read.nexus
of the ape package.
Tips data are imported from a table formatted file. The different formats allow to use
different separator and decimal characters.
They correspond to the variants of read.table
:
table
use read.table
with default settings.
csv
use read.csv
with default settings.
csv2
use read.csv2
with default settings.
delim
use read.delim
with default settings.
delim2
use read.delim2
with default settings.
An object of class phylo4d
.
phylo4d
to create a phylo4d
object.
This function simulates the evolution of continuous characters along a phylogeny. Traits values can be more or less influenced by the provided model.
rTraitContWeight(tree, model = "BM", weight = 1, as.p4d = FALSE)
rTraitContWeight(tree, model = "BM", weight = 1, as.p4d = FALSE)
tree |
an object of class " |
model |
the model to use (" |
weight |
a numeric vector with values ranging between 0 and 1 giving the balance between pure random evolution and the selected model. |
as.p4d |
logical. Should the phylogenetic tree and the simulated data coerced to a |
An object of class phyloSimSignal.
This function subset all the components of a phyloSimSignal object following the methods and traits provided.
subsetPhyloSimSignal(x, methods, traits)
subsetPhyloSimSignal(x, methods, traits)
x |
an object of class |
methods |
a character vector giving the methods to keep. |
traits |
a character vector giving the traits to keep. |
A phyloSimSignal
object
A simple color palette for gridplots.
white2red(n)
white2red(n)
n |
the number of colors to be in the palette. |