Browse code

mv rescale_tree to treeio

Guangchuang Yu authored on 11/01/2019 11:16:48
Showing 7 changed files

... ...
@@ -2,7 +2,7 @@ Package: ggtree
2 2
 Type: Package
3 3
 Title: an R package for visualization and annotation of phylogenetic trees with
4 4
     their covariates and other associated data
5
-Version: 1.15.4
5
+Version: 1.15.5
6 6
 Authors@R: c(
7 7
 	   person("Guangchuang", "Yu",     email = "guangchuangyu@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0002-6485-8781")),
8 8
 	   person("Tommy Tsan-Yuk", "Lam", email = "tylam.tommy@gmail.com",   role = c("aut", "ths")),
... ...
@@ -100,7 +100,6 @@ export(read.phyloT)
100 100
 export(read.r8s)
101 101
 export(read.raxml)
102 102
 export(read.tree)
103
-export(rescale_tree)
104 103
 export(revts)
105 104
 export(rotate)
106 105
 export(rotate_tree)
... ...
@@ -219,7 +218,6 @@ importFrom(tibble,data_frame)
219 218
 importFrom(tidyr,gather)
220 219
 importFrom(tidytree,MRCA)
221 220
 importFrom(tidytree,as_tibble)
222
-importFrom(tidytree,get_tree_data)
223 221
 importFrom(tidytree,groupClade)
224 222
 importFrom(tidytree,groupOTU)
225 223
 importFrom(treeio,Nnode)
... ...
@@ -1,3 +1,7 @@
1
+# ggtree 1.15.5
2
+
3
++ mv `rescale_tree` to `treeio` (2019-01-11, Fri)
4
+
1 5
 # ggtree 1.15.4
2 6
 
3 7
 + reimplement `MRCA` as a method inherited from `tidytree` (2019-01-10, Thu)
... ...
@@ -1,46 +1,3 @@
1
-##' @importFrom tidytree get_tree_data
2
-set_branch_length <- function(tree_object, branch.length) {
3
-    if (branch.length == "branch.length") {
4
-        return(tree_object)
5
-    } else if (branch.length == "none") {
6
-        tree_object@phylo$edge.length <- NULL
7
-        return(tree_object)
8
-    }
9
-
10
-    if (is(tree_object, "phylo")) {
11
-        return(tree_object)
12
-    }
13
-
14
-    tree_anno <- get_tree_data(tree_object)
15
-    tree_anno$node <- as.integer(tree_anno$node)
16
-
17
-    phylo <- as.phylo(tree_object)
18
-
19
-    cn <- colnames(tree_anno)
20
-    cn <- cn[!cn %in% c('node', 'parent')]
21
-
22
-    length <- match.arg(branch.length, cn)
23
-
24
-    if (all(is.na(as.numeric(tree_anno[[length]])))) {
25
-        stop("branch.length should be numerical attributes...")
26
-    }
27
-
28
-    edge <- phylo$edge
29
-    colnames(edge) <- c("parent", "node")
30
-    edge <- as_tibble(edge)
31
-
32
-    dd <- full_join(edge, tree_anno, by = "node")
33
-
34
-    dd <- dd[match(edge[['node']], dd[['node']]),]
35
-    len <- unlist(dd[[length]])
36
-    len <- as.numeric(len)
37
-    len[is.na(len)] <- 0
38
-
39
-    phylo$edge.length <- len
40
-
41
-    tree_object@phylo <- phylo
42
-    return(tree_object)
43
-}
44 1
 
45 2
 
46 3
 calculate_angle <- function(data) {
47 4
deleted file mode 100644
... ...
@@ -1,13 +0,0 @@
1
-##' rescale branch length of tree object
2
-##'
3
-##' 
4
-##' @title rescale_tree
5
-##' @param tree_object tree object
6
-##' @param branch.length numerical features (e.g. dN/dS)
7
-##' @return update tree object
8
-##' @export
9
-##' @author Guangchuang Yu
10
-rescale_tree <- function(tree_object, branch.length) {
11
-    tree_object <- set_branch_length(tree_object, branch.length)
12
-    return(tree_object)
13
-}
... ...
@@ -6,3 +6,4 @@ drop.tip <- treeio::drop.tip
6 6
 get.fields <- treeio::get.fields
7 7
 is.tree <- treeio:::is.tree
8 8
 
9
+set_branch_length <- getFromNamespace("set_branch_length", "treeio")
9 10
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/rescale_tree.R
3
-\name{rescale_tree}
4
-\alias{rescale_tree}
5
-\title{rescale_tree}
6
-\usage{
7
-rescale_tree(tree_object, branch.length)
8
-}
9
-\arguments{
10
-\item{tree_object}{tree object}
11
-
12
-\item{branch.length}{numerical features (e.g. dN/dS)}
13
-}
14
-\value{
15
-update tree object
16
-}
17
-\description{
18
-rescale branch length of tree object
19
-}
20
-\author{
21
-Guangchuang Yu
22
-}