fdr: Calculate false discovery rate (fdr) on a tree structure

Description Usage Arguments Value Author(s) Examples

Description

fdr calculates the false discovery rate (fdr) on a tree structure at the leaf or node level.

Usage

1
fdr(tree, truth, found, only.leaf = TRUE, direction = FALSE)

Arguments

tree

A phylo object

truth

Nodes that have signals (eg. differentally abundant at different experimental conditions.). If the signals are in different directions (up and down), then provide the nodes as a list of two members (one up and one down). One could provide either node number or node label. Note: When fdr at node level is required and only leaf nodes with signal are provided, then the internal nodes which are shared and only shared by the provied leaf nodes (signal in the same direction) will be found out and used with the leaf nodes in the fdr calculation; when fdr at leaf level is required and the given nodes have internal nodes, then the descendant leaf nodes will be found out and used in the fdr calculation.

found

Nodes that have been found to have signal (eg. differentally abundant at different experimental conditions). If the signals are in different directions (up and down), then provide the nodes as a list of two members (one up and one down). One could provide either node number or node label. Note: When fdr at node level is required, then the descendant nodes of the provied nodes (include themselves) will be found out and used in the fdr calculation; when fdr at leaf level is required, then the descendant leaf nodes will be found out and used in the fdr calculation.

only.leaf

A logical value, TRUE or FALSE. If TRUE, false discovery rate is calculated at the leaf (tip) level; otherwise it is calculated at node level. The default is TRUE

direction

TRUE or FALSE. Default is FALSE. If TRUE, the signal direction is taken into account; the argument truth and found should both be a list of two members and the order of directions should match.

Value

A false discovery rate

Author(s)

Ruizhu Huang

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
library(ggtree)
data("tinyTree")
ggtree(tinyTree) + geom_text2(aes(label = node))

# Truth: two branches have differential
# abundance under different conditions.
# branch with node 16 (direction: increase)
# branch with node 13 (direction: decrease)


# ------------ ignore direction -------------------
 # Found: branches with node 17 and node 14
 # fdr at the tip level
fdr1 <- fdr(tree = tinyTree, truth = c(16, 13),
            found = c(17, 14), only.leaf = TRUE)
 # fdr at the node level
fdr2 <- fdr(tree = tinyTree, truth = c(16, 13),
            found = c(17, 14), only.leaf = FALSE)


# ------------ direction matters-------------------
# Found: branches with node 17 (up) and node 14 (down)

 # the order of direction for truth and found should be the same
(fdr3 <- fdr(tree = tinyTree, truth = list(16, 13),
            found = list(16, 13), only.leaf = TRUE,
            direction = TRUE))  # correct order

(fdr4 <- fdr(tree = tinyTree, truth = list(16, 13),
            found = list(13, 16), only.leaf = FALSE,
            direction = TRUE)) # wrong order

markrobinsonuzh/treeAGG documentation built on May 26, 2019, 9:32 a.m.