Browse code

clean up code

guangchuang yu authored on 14/12/2017 08:47:21
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,73 +0,0 @@
1
-## ##' parse output from r8s
2
-## ##'
3
-## ##' 
4
-## ##' @title read.r8s
5
-## ##' @param file r8s output log file
6
-## ##' @return r8s instance
7
-## ##' @export
8
-## ##' @author Guangchuang Yu
9
-## read.r8s <- function(file) {
10
-##     r8s <- readLines(file)
11
-##     label_idx <- grep("\\[\\w+\\sDESCRIPTION\\sof\\stree\\s.*\\]", r8s)
12
-##     tree_idx <- grep("^tree\\s.*\\s=\\s", r8s)
13
-##     if (length(label_idx) != length(tree_idx)) {
14
-##         stop("fail to parse the file...")
15
-##     }
16
-
17
-##     tree_text <- gsub("^tree\\s.*\\s=\\s", "", r8s[tree_idx])
18
-##     trees <- read.tree(text=tree_text)
19
-
20
-##     label <- gsub("^\\[(\\w+)\\s.*", "\\1", r8s[label_idx])
21
-##     names(trees) <- label
22
-
23
-##     new("r8s",
24
-##         file = filename(file),
25
-##         fields = label,
26
-##         phylo = trees)
27
-## }
28
-
29
-
30
-
31
-
32
-## ##' @rdname groupClade-methods
33
-## ##' @exportMethod groupClade
34
-## ##' @param tree which tree selected
35
-## setMethod("groupClade", signature(object="r8s"),
36
-##           function(object, node, group_name="group", tree="TREE") {
37
-##               groupClade_(get.tree(object)[[tree]], node, group_name)
38
-##           })
39
-
40
-## ##' @rdname scale_color-methods
41
-## ##' @exportMethod scale_color
42
-## ##' @param tree which tree selected
43
-## setMethod("scale_color", signature(object="r8s"),
44
-##           function(object, by="bootstrap", tree="TREE") {
45
-##               scale_color_(get.tree(object)[[tree]], by)
46
-##           })
47
-
48
-
49
-## ##' @rdname gzoom-methods
50
-## ##' @exportMethod gzoom
51
-## ##' @param tree which tree selected
52
-## setMethod("gzoom", signature(object="r8s"),
53
-##           function(object, focus, subtree=FALSE, widths=c(.3, .7), tree="TREE") {
54
-##               gzoom.phylo(get.tree(object)[[tree]], focus, subtree, widths)
55
-##           })
56
-
57
-
58
-## ##' @rdname get.tree-methods
59
-## ##' @exportMethod get.tree
60
-## setMethod("get.tree", signature(object="r8s"),
61
-##           function(object,...) {
62
-##               object@phylo
63
-##           }
64
-##           )
65
-
66
-
67
-## ##' @rdname get.fields-methods
68
-## ##' @exportMethod get.fields
69
-## setMethod("get.fields", signature(object="r8s"),
70
-##           function(object, ...) {
71
-##               get.fields.tree(object)
72
-##           }
73
-##           )
Browse code

depends treeio

GuangchuangYu authored on 20/12/2016 16:39:07
Showing 1 changed files
... ...
@@ -1,73 +1,73 @@
1
-##' parse output from r8s
2
-##'
3
-##' 
4
-##' @title read.r8s
5
-##' @param file r8s output log file
6
-##' @return r8s instance
7
-##' @export
8
-##' @author Guangchuang Yu
9
-read.r8s <- function(file) {
10
-    r8s <- readLines(file)
11
-    label_idx <- grep("\\[\\w+\\sDESCRIPTION\\sof\\stree\\s.*\\]", r8s)
12
-    tree_idx <- grep("^tree\\s.*\\s=\\s", r8s)
13
-    if (length(label_idx) != length(tree_idx)) {
14
-        stop("fail to parse the file...")
15
-    }
1
+## ##' parse output from r8s
2
+## ##'
3
+## ##' 
4
+## ##' @title read.r8s
5
+## ##' @param file r8s output log file
6
+## ##' @return r8s instance
7
+## ##' @export
8
+## ##' @author Guangchuang Yu
9
+## read.r8s <- function(file) {
10
+##     r8s <- readLines(file)
11
+##     label_idx <- grep("\\[\\w+\\sDESCRIPTION\\sof\\stree\\s.*\\]", r8s)
12
+##     tree_idx <- grep("^tree\\s.*\\s=\\s", r8s)
13
+##     if (length(label_idx) != length(tree_idx)) {
14
+##         stop("fail to parse the file...")
15
+##     }
16 16
 
17
-    tree_text <- gsub("^tree\\s.*\\s=\\s", "", r8s[tree_idx])
18
-    trees <- read.tree(text=tree_text)
17
+##     tree_text <- gsub("^tree\\s.*\\s=\\s", "", r8s[tree_idx])
18
+##     trees <- read.tree(text=tree_text)
19 19
 
20
-    label <- gsub("^\\[(\\w+)\\s.*", "\\1", r8s[label_idx])
21
-    names(trees) <- label
20
+##     label <- gsub("^\\[(\\w+)\\s.*", "\\1", r8s[label_idx])
21
+##     names(trees) <- label
22 22
 
23
-    new("r8s",
24
-        file = filename(file),
25
-        fields = label,
26
-        phylo = trees)
27
-}
23
+##     new("r8s",
24
+##         file = filename(file),
25
+##         fields = label,
26
+##         phylo = trees)
27
+## }
28 28
 
29 29
 
30 30
 
31 31
 
32
-##' @rdname groupClade-methods
33
-##' @exportMethod groupClade
34
-##' @param tree which tree selected
35
-setMethod("groupClade", signature(object="r8s"),
36
-          function(object, node, group_name="group", tree="TREE") {
37
-              groupClade_(get.tree(object)[[tree]], node, group_name)
38
-          })
32
+## ##' @rdname groupClade-methods
33
+## ##' @exportMethod groupClade
34
+## ##' @param tree which tree selected
35
+## setMethod("groupClade", signature(object="r8s"),
36
+##           function(object, node, group_name="group", tree="TREE") {
37
+##               groupClade_(get.tree(object)[[tree]], node, group_name)
38
+##           })
39 39
 
40
-##' @rdname scale_color-methods
41
-##' @exportMethod scale_color
42
-##' @param tree which tree selected
43
-setMethod("scale_color", signature(object="r8s"),
44
-          function(object, by="bootstrap", tree="TREE") {
45
-              scale_color_(get.tree(object)[[tree]], by)
46
-          })
40
+## ##' @rdname scale_color-methods
41
+## ##' @exportMethod scale_color
42
+## ##' @param tree which tree selected
43
+## setMethod("scale_color", signature(object="r8s"),
44
+##           function(object, by="bootstrap", tree="TREE") {
45
+##               scale_color_(get.tree(object)[[tree]], by)
46
+##           })
47 47
 
48 48
 
49
-##' @rdname gzoom-methods
50
-##' @exportMethod gzoom
51
-##' @param tree which tree selected
52
-setMethod("gzoom", signature(object="r8s"),
53
-          function(object, focus, subtree=FALSE, widths=c(.3, .7), tree="TREE") {
54
-              gzoom.phylo(get.tree(object)[[tree]], focus, subtree, widths)
55
-          })
49
+## ##' @rdname gzoom-methods
50
+## ##' @exportMethod gzoom
51
+## ##' @param tree which tree selected
52
+## setMethod("gzoom", signature(object="r8s"),
53
+##           function(object, focus, subtree=FALSE, widths=c(.3, .7), tree="TREE") {
54
+##               gzoom.phylo(get.tree(object)[[tree]], focus, subtree, widths)
55
+##           })
56 56
 
57 57
 
58
-##' @rdname get.tree-methods
59
-##' @exportMethod get.tree
60
-setMethod("get.tree", signature(object="r8s"),
61
-          function(object,...) {
62
-              object@phylo
63
-          }
64
-          )
58
+## ##' @rdname get.tree-methods
59
+## ##' @exportMethod get.tree
60
+## setMethod("get.tree", signature(object="r8s"),
61
+##           function(object,...) {
62
+##               object@phylo
63
+##           }
64
+##           )
65 65
 
66 66
 
67
-##' @rdname get.fields-methods
68
-##' @exportMethod get.fields
69
-setMethod("get.fields", signature(object="r8s"),
70
-          function(object, ...) {
71
-              get.fields.tree(object)
72
-          }
73
-          )
67
+## ##' @rdname get.fields-methods
68
+## ##' @exportMethod get.fields
69
+## setMethod("get.fields", signature(object="r8s"),
70
+##           function(object, ...) {
71
+##               get.fields.tree(object)
72
+##           }
73
+##           )
Browse code

support textConnection

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

g.yu authored on 21/04/2016 11:51:12
Showing 1 changed files
... ...
@@ -21,26 +21,13 @@ read.r8s <- function(file) {
21 21
     names(trees) <- label
22 22
 
23 23
     new("r8s",
24
-        file = file,
24
+        file = filename(file),
25 25
         fields = label,
26 26
         phylo = trees)
27 27
 }
28 28
 
29 29
 
30 30
 
31
-##' @rdname show-methods
32
-##' @importFrom ape print.phylo
33
-##' @exportMethod show
34
-setMethod("show", signature(object = "r8s"),
35
-          function(object) {
36
-              cat("'r8s' S4 object that stored information of\n\t",
37
-                  paste0("'", object@file, "'.\n\n"))
38
-              cat("...@ tree: ")
39
-              print.phylo(get.tree(object))                  
40
-              ## cat("\nwith the following features available:\n")
41
-              ## print_fields(object)
42
-          })
43
-
44 31
 
45 32
 ##' @rdname groupClade-methods
46 33
 ##' @exportMethod groupClade
Browse code

lots updates

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

g.yu authored on 22/12/2015 04:08:02
Showing 1 changed files
... ...
@@ -84,4 +84,3 @@ setMethod("get.fields", signature(object="r8s"),
84 84
               get.fields.tree(object)
85 85
           }
86 86
           )
87
-
Browse code

add r8s and raxml support

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

g.yu authored on 02/10/2015 06:16:16
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,87 @@
1
+##' parse output from r8s
2
+##'
3
+##' 
4
+##' @title read.r8s
5
+##' @param file r8s output log file
6
+##' @return r8s instance
7
+##' @export
8
+##' @author Guangchuang Yu
9
+read.r8s <- function(file) {
10
+    r8s <- readLines(file)
11
+    label_idx <- grep("\\[\\w+\\sDESCRIPTION\\sof\\stree\\s.*\\]", r8s)
12
+    tree_idx <- grep("^tree\\s.*\\s=\\s", r8s)
13
+    if (length(label_idx) != length(tree_idx)) {
14
+        stop("fail to parse the file...")
15
+    }
16
+
17
+    tree_text <- gsub("^tree\\s.*\\s=\\s", "", r8s[tree_idx])
18
+    trees <- read.tree(text=tree_text)
19
+
20
+    label <- gsub("^\\[(\\w+)\\s.*", "\\1", r8s[label_idx])
21
+    names(trees) <- label
22
+
23
+    new("r8s",
24
+        file = file,
25
+        fields = label,
26
+        phylo = trees)
27
+}
28
+
29
+
30
+
31
+##' @rdname show-methods
32
+##' @importFrom ape print.phylo
33
+##' @exportMethod show
34
+setMethod("show", signature(object = "r8s"),
35
+          function(object) {
36
+              cat("'r8s' S4 object that stored information of\n\t",
37
+                  paste0("'", object@file, "'.\n\n"))
38
+              cat("...@ tree: ")
39
+              print.phylo(get.tree(object))                  
40
+              ## cat("\nwith the following features available:\n")
41
+              ## print_fields(object)
42
+          })
43
+
44
+
45
+##' @rdname groupClade-methods
46
+##' @exportMethod groupClade
47
+##' @param tree which tree selected
48
+setMethod("groupClade", signature(object="r8s"),
49
+          function(object, node, group_name="group", tree="TREE") {
50
+              groupClade_(get.tree(object)[[tree]], node, group_name)
51
+          })
52
+
53
+##' @rdname scale_color-methods
54
+##' @exportMethod scale_color
55
+##' @param tree which tree selected
56
+setMethod("scale_color", signature(object="r8s"),
57
+          function(object, by="bootstrap", tree="TREE") {
58
+              scale_color_(get.tree(object)[[tree]], by)
59
+          })
60
+
61
+
62
+##' @rdname gzoom-methods
63
+##' @exportMethod gzoom
64
+##' @param tree which tree selected
65
+setMethod("gzoom", signature(object="r8s"),
66
+          function(object, focus, subtree=FALSE, widths=c(.3, .7), tree="TREE") {
67
+              gzoom.phylo(get.tree(object)[[tree]], focus, subtree, widths)
68
+          })
69
+
70
+
71
+##' @rdname get.tree-methods
72
+##' @exportMethod get.tree
73
+setMethod("get.tree", signature(object="r8s"),
74
+          function(object,...) {
75
+              object@phylo
76
+          }
77
+          )
78
+
79
+
80
+##' @rdname get.fields-methods
81
+##' @exportMethod get.fields
82
+setMethod("get.fields", signature(object="r8s"),
83
+          function(object, ...) {
84
+              get.fields.tree(object)
85
+          }
86
+          )
87
+