Browse code

read.phyloT for parsing newick format of phyloT output <2016-10-11, Tue>

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@122189 bc3139a8-67e5-0310-9ffc-ced21a209358

Guangchuang Yu authored on 11/10/2016 10:03:03
Showing 4 changed files

... ...
@@ -105,6 +105,7 @@ export(read.jplace)
105 105
 export(read.nhx)
106 106
 export(read.paml_rst)
107 107
 export(read.phylip)
108
+export(read.phyloT)
108 109
 export(read.r8s)
109 110
 export(read.raxml)
110 111
 export(read.tree)
... ...
@@ -1,5 +1,7 @@
1 1
 CHANGES IN VERSION 1.5.16
2 2
 ------------------------
3
+ o read.phyloT for parsing newick format of phyloT output <2016-10-11, Tue>
4
+   + https://www.biostars.org/p/210401/#216128
3 5
  o fixed aes mapping in geom_strip <2016-10-11, Tue>
4 6
  o fixed R check <2016-10-10, Mon>
5 7
    + check.aes parameter is not available in release version of ggplot2 yet
6 8
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+##' parse output from phyloT
2
+##'
3
+##'
4
+##' @title read.phyloT
5
+##' @param file newick tree file
6
+##' @param ... additional parameters to read.tree
7
+##' @return phylo object
8
+##' @references \url{http://phylot.biobyte.de/}
9
+##' @export
10
+##' @author guangchuang yu
11
+read.phyloT <- function(file, ...) {
12
+  x <- readLines(file)
13
+  x <- paste0(gsub("\\s+", "", x), collapse="")
14
+  x <- sub("^\\(", "", x) %>% sub("\\);", ";", .)
15
+  res <- tryCatch(read.tree(text=x, ...), error=function(e) NULL)
16
+  if (is.null(res)) {
17
+      msg <- paste("`read.phyloT` only supports newick format with setting of",
18
+                   "`Internal nodes` to `collapsed`, and `Polytomy` to `No`.",
19
+                   "\nURL: http://phylot.biobyte.de/")
20
+      stop(msg)
21
+  }
22
+  return(res)
23
+}
24
+
0 25
new file mode 100644
... ...
@@ -0,0 +1,26 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/phyloT.R
3
+\name{read.phyloT}
4
+\alias{read.phyloT}
5
+\title{read.phyloT}
6
+\usage{
7
+read.phyloT(file, ...)
8
+}
9
+\arguments{
10
+\item{file}{newick tree file}
11
+
12
+\item{...}{additional parameters to read.tree}
13
+}
14
+\value{
15
+phylo object
16
+}
17
+\description{
18
+parse output from phyloT
19
+}
20
+\author{
21
+guangchuang yu
22
+}
23
+\references{
24
+\url{http://phylot.biobyte.de/}
25
+}
26
+