Last data update: 2014.03.03

R: Function to produce a CSV file with the p-value for each...
export.inheritR Documentation

Function to produce a CSV file with the p-value for each branch as well as a list of all of the tips in each branch's family

Description

export.inherit takes tree and unsorted.pvalues and produces a CSV file (or data frame) with p-values for each branch (including tips) as well as a list of all of the tips that belong to each branch's family (i.e., all of the tips that are descendants of the branch). The p-values are computed based on arguments involving p-value adjustment (for multiple hypothesis testing) and either Stouffer's or Fisher's p-value combination method.

Usage

export.inherit(tree, unsorted.pvalues, adjust = TRUE, side = 1, method = "hommel",
file = "", test = "Stouffers", frame = FALSE, branch="edge")

Arguments

tree

a phylogenetic tree of class phylo.

unsorted.pvalues

a data frame (or matrix) with tip labels in column 1 and p-values in column 2. The tip labels must correspond to the tip labels in tree.

adjust

a logical argument that controls whether there is p-value adjustment performed (TRUE) or not (FALSE).

side

a numerical argument that takes values 1 and 2, depending on whether the p-values in unsorted.pvalues are 1-sided or 2-sided, respectively. Only used in p-value adjustment if adjust = TRUE.

method

one of the p-value adjustment methods (used for multiple-hypothesis testing) found in p.adjust.methods ("holm", "hochberg", "hommel", "BH", "bonferroni", "BY", "fdr", and "none"). See help for p.adjust for more details on these methods. method is only used if adjust = TRUE.

file

the file path for the CSV file to be written to. If frame=TRUE, no CSV file is created. If frame=FALSE, a CSV file will only be created if file is specified.

test

a character string taking on either "Stouffers" or "Fishers". This is the p-value combination method that will be used.

frame

a logical argument that controls whether or not to return (in R) the resulting data.frame object. If FALSE, file must be specified.

branch

a character controlling branch definition: "edge" and "node" are the only options. This does not affect statistical methods, only the colors used in edge coloring. Prior to package version 1.2, only branch="node" was implemented. The edge and node numbering is internal to class phylo, and are not necessarily sequential numbers.

Details

The tip labels of tree (accessed via tree$tip.label) must have the same names (and the same length) as the tip labels in unsorted.pvalues, but may be in a different order. The p-values in column 2 of unsorted.pvalues obviously must be in the [0, 1] range. export.inherit assumes that each internal node has exactly two descendants. It also assumes that each internal node has a lower number than each of its ancestors (excluding tips).

To access the tutorial document for this package (including this function), type in R: vignette("SigTree")

Value

This function produces a CSV file; alternatively, if frame=TRUE, this function will return a data.frame object.

Author(s)

John R. Stevens and Todd R. Jones

References

Stevens J.R., Jones T.R., Lefevre M., Ganesan B., and Weimer B.C. (2015) "SigTree: identifying and visualizing significantly responsive branches in a phylogenetic tree" (Manuscript in preparation).

Jones T.R. (2012) "SigTree: An Automated Meta-Analytic Approach to Find Significant Branches in a Phylogenetic Tree" (2012). MS Thesis, Utah State University, Department of Mathematics and Statistics. http://digitalcommons.usu.edu/etd/1314

Examples

### To access the tutorial document for this package, type in R (not run here): 
# vignette("SigTree")

### Create tree, then data frame, then use plotSigTree to plot the tree
### Code for random tree and data frame
node.size <- 10
seed <- 109
# Create tree
set.seed(seed);
library(ape)
r.tree <- rtree(node.size)
# Create p-values data frame
set.seed(seed)
r.pval <- rbeta(node.size, .1, .1)
# Randomize the order of the tip labels
# (just to emphasize that labels need not be sorted)
set.seed(seed)
r.tip.label <- sample(r.tree$tip.label, size=length(r.tree$tip.label))
r.pvalues <- data.frame(label=r.tip.label, pval=r.pval)

# Create CSV file called "ExportInherit1.csv"
export.inherit(r.tree, r.pvalues, test="Stouffers", file="ExportInherit1.csv")

# Look at resulting file in R -- see package vignette
f <- export.inherit(r.tree, r.pvalues, test="Stouffers", frame=TRUE)
f

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SigTree)
Found more than one class "Annotated" in cache; using the first, from namespace 'RNeXML'
Found more than one class "Annotated" in cache; using the first, from namespace 'RNeXML'
Found more than one class "Annotated" in cache; using the first, from namespace 'RNeXML'
Found more than one class "Annotated" in cache; using the first, from namespace 'RNeXML'
Found more than one class "Annotated" in cache; using the first, from namespace 'RNeXML'
Found more than one class "Annotated" in cache; using the first, from namespace 'RNeXML'
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SigTree/export.inherit.Rd_%03d_medium.png", width=480, height=480)
> ### Name: export.inherit
> ### Title: Function to produce a CSV file with the p-value for each branch
> ###   as well as a list of all of the tips in each branch's family
> ### Aliases: export.inherit
> ### Keywords: tree
> 
> ### ** Examples
> 
> ### To access the tutorial document for this package, type in R (not run here): 
> # vignette("SigTree")
> 
> ### Create tree, then data frame, then use plotSigTree to plot the tree
> ### Code for random tree and data frame
> node.size <- 10
> seed <- 109
> # Create tree
> set.seed(seed);
> library(ape)
> r.tree <- rtree(node.size)
> # Create p-values data frame
> set.seed(seed)
> r.pval <- rbeta(node.size, .1, .1)
> # Randomize the order of the tip labels
> # (just to emphasize that labels need not be sorted)
> set.seed(seed)
> r.tip.label <- sample(r.tree$tip.label, size=length(r.tree$tip.label))
> r.pvalues <- data.frame(label=r.tip.label, pval=r.pval)
> 
> # Create CSV file called "ExportInherit1.csv"
> export.inherit(r.tree, r.pvalues, test="Stouffers", file="ExportInherit1.csv")
> 
> # Look at resulting file in R -- see package vignette
> f <- export.inherit(r.tree, r.pvalues, test="Stouffers", frame=TRUE)
> f
   Branch Stouffer's p-value  X1   X2   X3   X4   X5   X6   X7   X8   X9  X10
1     t10       1.126033e-01 t10 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
2      t9       4.218847e-13  t9 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
3      t2       9.661730e-01  t2 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
4      t6       1.925126e-07  t6 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
5      t3       5.110697e-01  t3 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
6      t8       9.433490e-01  t8 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
7      t7       5.969004e-01  t7 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
8      t1       3.539801e-03  t1 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
9      t5       1.000000e+00  t5 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
10     t4       9.890866e-01  t4 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
11   root       4.889303e-01 t10   t9   t2   t6   t3   t8   t7   t1   t5   t4
12      2       4.889303e-01  t9   t2   t6   t3   t8   t7   t1   t5   t4 <NA>
13      3       2.207669e-06  t9   t2   t6   t3 <NA> <NA> <NA> <NA> <NA> <NA>
14      4       9.698210e-09  t9   t2   t6 <NA> <NA> <NA> <NA> <NA> <NA> <NA>
15      5       2.491600e-03  t9   t2 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
16     10       9.999629e-01  t8   t7   t1   t5   t4 <NA> <NA> <NA> <NA> <NA>
17     11       5.110697e-01  t8   t7   t1 <NA> <NA> <NA> <NA> <NA> <NA> <NA>
18     12       9.715023e-01  t8   t7 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
19     16       1.000000e+00  t5   t4 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>