[adegenet-commits] r479 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Nov 12 13:38:21 CET 2009
Author: jombart
Date: 2009-11-12 13:38:20 +0100 (Thu, 12 Nov 2009)
New Revision: 479
Modified:
pkg/R/haploPop.R
Log:
added a plot method (will save time in the future)
Modified: pkg/R/haploPop.R
===================================================================
--- pkg/R/haploPop.R 2009-11-12 12:32:29 UTC (rev 478)
+++ pkg/R/haploPop.R 2009-11-12 12:38:20 UTC (rev 479)
@@ -344,3 +344,29 @@
return(as.dist(res))
} # end dist.haploPop
+
+
+
+
+
+
+###############
+## plot.haploPop
+###############
+plot.haploPop <- function(x, y=NULL, type="unrooted", size.limit=300, ...){
+ if(!require(ape)) stop("ape package is required")
+ if(!inherits(x, "haploPop")) stop("x is not a haploPop object")
+
+ N <- sum(sapply(x$pop,length))
+
+ if(N > size.limit) {
+ stop("tree exceeds size limit")
+ }
+
+ tre <- root(nj(dist.haploPop(x)),"1")
+ plot(tre, type=type, ...)
+ xy <- get("last_plot.phylo", envir = .PlotPhyloEnv)
+ points(xy$xx[1], xy$yy[1], col="red", pch=20, cex=2)
+
+ return(invisible(xy))
+}
More information about the adegenet-commits
mailing list