Browse code

unit test of groupOTU & groupClade

guangchuang yu authored on 22/09/2016 05:42:13
Showing 6 changed files

... ...
@@ -1,5 +1,7 @@
1 1
 CHANGES IN VERSION 1.5.14
2 2
 ------------------------
3
+ o unit test for groupOTU and groupClade <2016-09-22, Thu>
4
+ o groupOTU label groups by input group names (when input is a named list) <2016-09-22, Thu>
3 5
  o update angle calculation for geom_tiplab <2016-09-13, Thu>
4 6
  o as.polytomy to collapse binary tree to polytomy by applying 'fun' to selected 'feature' (e.g. bootstrap value less than 70). <2016-09-13, Tue>
5 7
    + currently only phylo object supported.
... ...
@@ -3,7 +3,7 @@ ggtree: an R package for visualization and annotation of phylogenetic trees with
3 3
 
4 4
 [![releaseVersion](https://img.shields.io/badge/release%20version-1.4.20-green.svg?style=flat)](https://bioconductor.org/packages/ggtree) [![develVersion](https://img.shields.io/badge/devel%20version-1.5.14-green.svg?style=flat)](https://github.com/GuangchuangYu/ggtree) [![Bioc](http://www.bioconductor.org/shields/years-in-bioc/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#since) [![total](https://img.shields.io/badge/downloads-13439/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![month](https://img.shields.io/badge/downloads-1122/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
5 5
 
6
-[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![codecov](https://codecov.io/gh/GuangchuangYu/ggtree/branch/master/graph/badge.svg)](https://codecov.io/gh/GuangchuangYu/ggtree) [![Last-changedate](https://img.shields.io/badge/last%20change-2016--09--21-green.svg)](https://github.com/GuangchuangYu/ggtree/commits/master) [![GitHub forks](https://img.shields.io/github/forks/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/network) [![GitHub stars](https://img.shields.io/github/stars/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/stargazers) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://awesome-r.com/#awesome-r-graphic-displays)
6
+[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![codecov](https://codecov.io/gh/GuangchuangYu/ggtree/branch/master/graph/badge.svg)](https://codecov.io/gh/GuangchuangYu/ggtree) [![Last-changedate](https://img.shields.io/badge/last%20change-2016--09--22-green.svg)](https://github.com/GuangchuangYu/ggtree/commits/master) [![GitHub forks](https://img.shields.io/github/forks/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/network) [![GitHub stars](https://img.shields.io/github/stars/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/stargazers) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://awesome-r.com/#awesome-r-graphic-displays)
7 7
 
8 8
 [![platform](http://www.bioconductor.org/shields/availability/devel/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#archives) [![Build Status](http://www.bioconductor.org/shields/build/devel/bioc/ggtree.svg)](https://bioconductor.org/checkResults/devel/bioc-LATEST/ggtree/) [![Linux/Mac Travis Build Status](https://img.shields.io/travis/GuangchuangYu/ggtree/master.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/GuangchuangYu/ggtree) [![AppVeyor Build Status](https://img.shields.io/appveyor/ci/Guangchuangyu/ggtree/master.svg?label=Windows)](https://ci.appveyor.com/project/GuangchuangYu/ggtree) [![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-green.svg?style=flat)](http://bioconda.github.io/recipes/bioconductor-ggtree/README.html)
9 9
 
... ...
@@ -166,11 +166,11 @@
166 166
   }  
167 167
   </style>
168 168
 
169
-<div id = 'chart39f5731fe14' class = 'rChart morris'></div>
169
+<div id = 'chart10275e5014cf' class = 'rChart morris'></div>
170 170
 
171 171
 <script type='text/javascript'>
172 172
     var chartParams = {
173
- "element": "chart39f5731fe14",
173
+ "element": "chart10275e5014cf",
174 174
 "width":            800,
175 175
 "height":            400,
176 176
 "xkey": "year",
... ...
@@ -184,7 +184,7 @@
184 184
 "pubid": "HtEfBTGE9r8C" 
185 185
 } 
186 186
 ],
187
-"id": "chart39f5731fe14",
187
+"id": "chart10275e5014cf",
188 188
 "labels": "cites" 
189 189
 },
190 190
       chartType = "Bar"
... ...
@@ -182,7 +182,7 @@
182 182
         }, 
183 183
         {
184 184
             "location": "/featuredArticles/", 
185
-            "text": "Let us know if you have published using \nggtree\n and your publication will be featured here.\n\n\n\n\n\n\n\n\n\n\n\n\n\n  .rChart {\n    display: block;\n    margin-left: auto; \n    margin-right: auto;\n    width: 800px;\n    height: 300px;\n  }  \n  \n\n\n\n\n\n\n\n    var chartParams = {\n \"element\": \"chart39f5731fe14\",\n\"width\":            800,\n\"height\":            400,\n\"xkey\": \"year\",\n\"ykeys\": [\n \"cites\" \n],\n\"data\": [\n {\n \"year\": 2016,\n\"cites\":              1,\n\"pubid\": \"HtEfBTGE9r8C\" \n} \n],\n\"id\": \"chart39f5731fe14\",\n\"labels\": \"cites\" \n},\n      chartType = \"Bar\"\n    new Morris[chartType](chartParams)\n\n\n\n\n 2016\n\n\nLack of GLYCOLATE OXIDASE 1, but not GLYCOLATE OXIDASE 2, attenuates the photorespiratory phenotype of CATALASE2-deficient \nArabidopsis\n\n\nPlant Physiology\n May. 2016 \n\n\n\n\nRange overlap drives chromosome inversion fixation in passerine birds\n\n\nbioRxiv\n May. 2016 \nhttp://dx.doi.org/10.1101/053371\n\n\n\n\nPhenotypic and Genotypic Characteristics of Shiga Toxin-Producing Escherichia coli Isolated from Surface Waters and Sediments in a Canadian Urban-Agricultural Landscape \n\n\nFront. Cell. Infect. Microbiol.\n Apr. 2016 \nhttp://dx.doi.org/10.3389%2Ffcimb.2016.00036\n\n\n\n\nWs-2\n Introgression in a Proportion of \nArabidopsis thaliana Col-0\n Stock Seed Produces Specific Phenotypes and Highlights the Importance of Routine Genetic Verification\n\n\nPlant Cell\n Mar. 2016 \nhttp://dx.doi.org/10.1105/tpc.16.00053\n\n\n\n\n 2015\n\n\nThe population genetics of drug resistance evolution in natural populations of viral, bacterial and eukaryotic pathogens \n\n\nMolecuar Ecology\n Dec. 2015 \nhttp://dx.doi.org/10.1111/mec.13474\n\n\n\n\nGenetic characterization of highly pathogenic H5 influenza viruses from poultry in Taiwan, 2015 \n\n\nInfection, Genetics and Evolution\n Dec. 2015 \nhttp://dx.doi.org/10.1016/j.meegid.2015.12.006\n\n\n\n\nTrans-species polymorphism at antimicrobial innate immunity cathelicidin genes of Atlantic cod and related species \n\n\nPeerJ\n May 2015 \nhttps://doi.org/10.7717/peerj.976", 
185
+            "text": "Let us know if you have published using \nggtree\n and your publication will be featured here.\n\n\n\n\n\n\n\n\n\n\n\n\n\n  .rChart {\n    display: block;\n    margin-left: auto; \n    margin-right: auto;\n    width: 800px;\n    height: 300px;\n  }  \n  \n\n\n\n\n\n\n\n    var chartParams = {\n \"element\": \"chart10275e5014cf\",\n\"width\":            800,\n\"height\":            400,\n\"xkey\": \"year\",\n\"ykeys\": [\n \"cites\" \n],\n\"data\": [\n {\n \"year\": 2016,\n\"cites\":              1,\n\"pubid\": \"HtEfBTGE9r8C\" \n} \n],\n\"id\": \"chart10275e5014cf\",\n\"labels\": \"cites\" \n},\n      chartType = \"Bar\"\n    new Morris[chartType](chartParams)\n\n\n\n\n 2016\n\n\nLack of GLYCOLATE OXIDASE 1, but not GLYCOLATE OXIDASE 2, attenuates the photorespiratory phenotype of CATALASE2-deficient \nArabidopsis\n\n\nPlant Physiology\n May. 2016 \n\n\n\n\nRange overlap drives chromosome inversion fixation in passerine birds\n\n\nbioRxiv\n May. 2016 \nhttp://dx.doi.org/10.1101/053371\n\n\n\n\nPhenotypic and Genotypic Characteristics of Shiga Toxin-Producing Escherichia coli Isolated from Surface Waters and Sediments in a Canadian Urban-Agricultural Landscape \n\n\nFront. Cell. Infect. Microbiol.\n Apr. 2016 \nhttp://dx.doi.org/10.3389%2Ffcimb.2016.00036\n\n\n\n\nWs-2\n Introgression in a Proportion of \nArabidopsis thaliana Col-0\n Stock Seed Produces Specific Phenotypes and Highlights the Importance of Routine Genetic Verification\n\n\nPlant Cell\n Mar. 2016 \nhttp://dx.doi.org/10.1105/tpc.16.00053\n\n\n\n\n 2015\n\n\nThe population genetics of drug resistance evolution in natural populations of viral, bacterial and eukaryotic pathogens \n\n\nMolecuar Ecology\n Dec. 2015 \nhttp://dx.doi.org/10.1111/mec.13474\n\n\n\n\nGenetic characterization of highly pathogenic H5 influenza viruses from poultry in Taiwan, 2015 \n\n\nInfection, Genetics and Evolution\n Dec. 2015 \nhttp://dx.doi.org/10.1016/j.meegid.2015.12.006\n\n\n\n\nTrans-species polymorphism at antimicrobial innate immunity cathelicidin genes of Atlantic cod and related species \n\n\nPeerJ\n May 2015 \nhttps://doi.org/10.7717/peerj.976", 
186 186
             "title": "Featured Articles"
187 187
         }, 
188 188
         {
... ...
@@ -36,10 +36,10 @@ Let us know if you have published using `ggtree` and your publication will be fe
36 36
   }  
37 37
   </style>
38 38
 
39
-<div id = 'chart39f5731fe14' class = 'rChart morris'></div>
39
+<div id = 'chart10275e5014cf' class = 'rChart morris'></div>
40 40
 <script type='text/javascript'>
41 41
     var chartParams = {
42
- "element": "chart39f5731fe14",
42
+ "element": "chart10275e5014cf",
43 43
 "width":            800,
44 44
 "height":            400,
45 45
 "xkey": "year",
... ...
@@ -53,7 +53,7 @@ Let us know if you have published using `ggtree` and your publication will be fe
53 53
 "pubid": "HtEfBTGE9r8C" 
54 54
 } 
55 55
 ],
56
-"id": "chart39f5731fe14",
56
+"id": "chart10275e5014cf",
57 57
 "labels": "cites" 
58 58
 },
59 59
       chartType = "Bar"
60 60
new file mode 100644
... ...
@@ -0,0 +1,35 @@
1
+context('groupOTU')
2
+
3
+test_that('groupOTU', {
4
+    nwk <- system.file("extdata", "sample.nwk", package="ggtree")
5
+    tree <- read.tree(nwk)
6
+    focus <- c("D", "E", "F", "G")
7
+    df <- fortify(groupOTU(tree, focus=focus))
8
+    expect_true(all(df$group[df$label %in% focus] == 1))
9
+
10
+    cls <- list(c1=c("A", "B", "C", "D", "E"),
11
+                c2=c("F", "G", "H"),
12
+                c3=c("L", "K", "I", "J"),
13
+                c4="M")
14
+    df <- fortify(groupOTU(tree, cls))
15
+    for (i in seq_along(cls)) {
16
+        expect_true(all(df$group[df$label %in% cls[[i]]] == names(cls)[i]))
17
+    }
18
+})
19
+
20
+
21
+context('groupClade')
22
+
23
+test_that('groupClade', {
24
+    nwk <- system.file("extdata", "sample.nwk", package="ggtree")
25
+    tree <- read.tree(nwk)
26
+    focus <- c("D", "E", "F", "G")
27
+    nodes <- c(21, 17)
28
+    df <- fortify(groupClade(tree, node=nodes))
29
+
30
+    for (i in seq_along(nodes)) {
31
+        expect_true(all(df$group[df$node %in% ggtree:::get.offspring.df(df, nodes[i])] == i))
32
+    }
33
+
34
+})
35
+