From noreply at r-forge.r-project.org Wed Feb 12 19:32:36 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 12 Feb 2014 19:32:36 +0100 (CET) Subject: [Phylobase-commits] r844 - in pkg: . vignettes Message-ID: <20140212183236.7C5BF186E63@r-forge.r-project.org> Author: francois Date: 2014-02-12 19:32:35 +0100 (Wed, 12 Feb 2014) New Revision: 844 Added: pkg/vignettes/ pkg/vignettes/developer.Rnw pkg/vignettes/developer.pdf pkg/vignettes/phylobase.Rnw pkg/vignettes/phylobase.pdf Log: vignettes moved to their own directory as suggested since R 2.14 Added: pkg/vignettes/developer.Rnw =================================================================== --- pkg/vignettes/developer.Rnw (rev 0) +++ pkg/vignettes/developer.Rnw 2014-02-12 18:32:35 UTC (rev 844) @@ -0,0 +1,367 @@ +\documentclass{article} +%\VignettePackage{phylobase} +%\VignetteIndexEntry{A developers guide for contributing to phylobase} + +\usepackage[utf8]{inputenc} % for UTF-8/single quotes from sQuote() +\usepackage{graphicx} % for jpeg and pdf figure support +\usepackage[usenames,dvipsnames]{color} % loads colors w/ easy names for coloring our links +\definecolor{DarkBlue}{rgb}{0,0,0.56} +\usepackage[colorlinks=true,urlcolor=DarkBlue,linkcolor=BrickRed,bookmarks=true]{hyperref} +\usepackage{url} +\usepackage[noae]{Sweave} + +\newcommand{\code}[1]{{{\tt #1}}} +\newcommand{\pb}{\texttt{phylobase }} + +%% Use a little bit more of the page +%% borrowed from Rd.sty, of r-project.org +\addtolength{\textheight}{12mm} +\addtolength{\topmargin}{-9mm} % still fits on US paper +\addtolength{\textwidth}{24mm} % still fits on US paper +\setlength{\oddsidemargin}{10mm} +\setlength{\evensidemargin}{\oddsidemargin} + +\title{Developers guide to \pb} +\author{Peter Cowan, Ben Bolker \& other developers of \pb} +\date{\today} + +\begin{document} +%% inspired by the adephylo vignette +\DefineVerbatimEnvironment{Sinput}{Verbatim} +{formatcom={\color{BrickRed}},fontsize=\footnotesize, baselinestretch=0.75} +\DefineVerbatimEnvironment{Soutput}{Verbatim} +{formatcom={\color{DarkBlue}},fontsize=\footnotesize, baselinestretch=0.75} + +\SweaveOpts{fig=FALSE, eps=FALSE, pdf=TRUE, width=6, height=6} + +\maketitle + +\tableofcontents + +<>= +options(width=40) +@ + +\section{Introduction} + +This vignette is intended as a guide for the development of \pb and a repository of technical notes of primary interest to it's developers and others interested in gory details --- by contrast the other \pb vignette is more of an introduction \& user's manual. + +\section{R-Forge} + +Our development infrastructure hosted by R-Forge,\footnote{\url{http://phylobase.r-forge.r-project.org}} and includes a Subversion repository (see \autoref{subversion}~[\nameref{subversion}]) for source code management, trackers for bug reports and feature requests,\footnote{\url{http://r-forge.r-project.org/tracker/?group_id=111}} and mailing lists for development discussion and tracking changes in the source code.\footnote{\url{http://r-forge.r-project.org/mail/?group_id=111}} + +The R-Forge manual\footnote{\url{http://r-forge.r-project.org/R-Forge_Manual.pdf}} describes how to develop a package using their infrastructure Of particular importance is the section on getting ssh keys to work so that you can commit changes to the \code{phylobase} code using Subversion (\code{svn}). + +On feature of R-Forge is a package repository that allows prerelease versions of \pb to be install directly from \code{R}. + +<>= +install.packages("phylobase", repos = "http://r-forge.r-project.org") +@ + +\section{Building \code{phylobase}} + +If you are interested in building \pb from source, you will need the same tools required to build \code{R} itself. These are documented in the R Installation and Administration manual.\footnote{\url{http://cran.r-project.org/doc/manuals/R-admin.html}} If you are running Mac OS X you???ll need to have the developer tools.\footnote{\url{http://developer.apple.com/technology/xcode.html}} On Windows you'll need to install the ``Windows toolset''\footnote{\url{http://www.murdoch-sutherland.com/Rtools/}} as described in the above manual. If you are running Linux, you probably already know what you need. To build the vignettes and \LaTeX~documentation you will need to install a \TeX~distribution like MacTex\footnote{\url{http://www.tug.org/mactex/}} for Mac OS X, Tex-Live for Linux, or MiKTeX\footnote{\url{http://www.miktex.org/}} for Windows. Once you have the proper tools installed follow the instruction in the Writing \code{R} Extensions manual.\footnote{\url{http://cran.r-project.org/doc/manuals/R-exts.html}} + +\section{Coding standards} + +We try to follow the coding standards of Bioconductor.\footnote{\url{http://wiki.fhcrc.org/bioc/Coding_Standards}} Namely, variables and particularily function exposed to users should be in \code{camelCase}. As of this writing many non-exported functions are prefixed with `.' however, future private functions should be named without this convention. Indentation should be 4 spaces and tabs should be avoided. We also use \code{<-} for assignment, and place spaces after commas, in indexes and function calls (e.g. \code{df[2, 2]} and \code{seq(1, 2, 0.1)}, not \code{df[2,2]} or \code{seq(1,2,0.1}.) + +\section{Release procedure} + +When the package code has stabilized or significant bugs have been fixed we want to push those changes out to CRAN. This section documents the release sequence used for when submitting the package to CRAN. + +\begin{enumerate} + \item Update the NEWS file which resides in the pkg/ directory and describes changes in the package since its last release. New changes should be appended above the earlier entries and formatted so that it can be read by \code{news(package="phylobase")}, (format documented in \code{?news}). Briefly, the version header should look like a previous entry and changes should be grouped in categories which start at the beginning of a line. Within each category individual changes should be marked with an indented (4 spaces) asterisk, with the change text indented and wrapped a further four space, eight total. The most comprehensive way to find the changes since the last version is to look at the SVN log. This procedure was followed for the the 0.5 release and assumes that you have the entire project checked out, including the www and tags directories. + +Navigate to the tag for the previous release and get the revision it was created: +\begin{verbatim} +~$ cd phylobase/tags/phylobase-0.4 +~$ svn log --stop-on-copy +------------------------------------------------------------------------ +r309 | skembel | 2008-12-18 12:55:14 -0800 (Thu, 18 Dec 2008) | 1 line + +Tagging current version as 0.4 prior to hackathon changes +------------------------------------------------------------------------ +\end{verbatim} + +In this case we can see that the tag was created in revision 309 and as this was the current release, we want all the changes that have been made since. To do that we navigate to the top level to get the change log from any branches that have been made and save the log. If there are unmerged branches, care should be taken to exclude those changes from the NEWS file. Because this file may be rather large we'll output it to a file. + +\begin{verbatim} +~$ cd ../.. +~$ svn log -r309:HEAD > RecentChanges.txt +\end{verbatim} + +The NEWS file can then be updated by going through the RecentChanges.txt file and picking out significant changes. + + \item The DESCRIPTION file should be updated to reflect the new version number and current date. Version numbers should follow the 0.5.0 format (no dashes), and the date should be formatted as 2009-01-30. + \item Rebuild the vignettes to incorporate the latest changes. CRAN may not have all the package we use to build our vignettes or able to run latex the multiple time necessary to generate the PDFs with the proper cross references and table of contents. + +\begin{verbatim} +~$ cd phylobase/pkg/inst/doc +~$ R CMD Sweave phylobase.Rnw +~$ pdflatex phylobase.tex +~$ pdflatex phylobase.tex +~$ pdflatex phylobase.tex + +~$ R CMD Sweave developer.Rnw +~$ pdflatex developer.tex +~$ pdflatex developer.tex +~$ pdflatex developer.tex + +~$ rm *.toc *.out *.log *.aux *.tex +\end{verbatim} + + \item Code freeze. Before the package can be submitted to CRAN it must pass the R-Forge build and check process which happens every night. The easiest way to handle this is to freeze the the code for a day or two after the NEWS, DESCRIPTION and PDF files have been updated. + \item Tag the release in SVN. Each release is tagged so that a copy of it is easily available if needed at a later date. This is done using the SVN copy as follows for a hypothetical 0.5.1 release: + +\begin{verbatim} +~$ cd phylobase/ +~$ svn copy pkg/ tags/phylobase-0.5.1 +~$ svn commit -m "tagging version 0.5.1" +\end{verbatim} + + \item Uploading to CRAN is done by clicking the Upload to CRAN link on the R-Forge package page. Ensure that the revision number corresponds to the revision with the updated NEWS etc. files. + \item Update the R-Forge website with the correct version number and PDFs of the vignettes. +\end{enumerate} + +\section{Unit testing with RUnit} + +We are in the process of moving our testing infrastructure to the \code{RUnit}\footnote{\url{http://cran.r-project.org/web/packages/RUnit/index.html}} framework. New contributions and bug fixes should be accompanied by unit tests which test the basic functionality of the code as well as edge cases (e.g what happens when the function is passed an empty string or negative number -- even when those inputs don't make sense.) Unit tests are stored in the \code{inst/unitTests/} directory and are named according to the source file they correspond to. See the included tests and the \code{RUnit} documentation for further details. \code{RUnit} has a few advantages over the other testing frameworks in \code{R}, namely the examples in documentation, vignettes, + +\section{Non-exported functions} + +These functions are for internal use in \code{phylobase} not exported. Since most are not documented elsewhere, they are documented here. + +\begin{description} + + \addcontentsline{toc}{subsection}{.chnumsort} + \item[\code{.chnumsort}] A convenience function that coerces vector of strings to numbers for sorting, then coerces the vector back to stings. Currently only used inside the \code{prune} method. + + \addcontentsline{toc}{subsection}{.createEdge} + \item[\code{.createEdge}] + + \addcontentsline{toc}{subsection}{.createLabels} + \item[\code{.createLabels}] Used any time labels are needed, including when updating the labels via \code{labels()<-} or constructing a \code{phylo4} object. It takes a vector of names to use or \code{NULL} if new labels should be generated, integers indicating the number of tips and internal nodes, as well as a string to indicated the type of labels to generate ``tip'' and ``internal'', for either tip or internal labels along or ``allnode'' or all nodes. + + \addcontentsline{toc}{subsection}{.genlab} + \item[\code{.genlab}] A handy function that can generate labels for applying to nodes and tips. The function takes to arguments, a `base' string, and an integer indicating the number of labels desired. The result is a vector of string with a number (padded with `0') suffix e.g. \code{foo01...foo12}. This function is used to generate names in the \code{.createLabels} function as well as for for making temporary names during the \code{prune} method. + + \addcontentsline{toc}{subsection}{.phylo4Data} + \item[\code{.phylo4Data}] + + \addcontentsline{toc}{subsection}{.phylo4ToDataFrame} + \item[\code{.phylo4ToDataFrame}] + + \addcontentsline{toc}{subsection}{.bubLegendGrob} + \item[\code{.bubLegendGrob}] This function generates a \code{Grid} graphics object (a grob) for drawing the \code{phylobubbles()} legend. For reason I have not been able to understand, it must be defined outside of the \code{phylobubbles} function. It takes the raw tip data values for a \code{phylo4d} object as well as the scaled values used for making the bubble plot, both of these vectors are passed directly to the \code{drawDetails.bubLegend} function. + + \addcontentsline{toc}{subsection}{drawDetails.bubLegend} + \item[\code{drawDetails.bubLegend}] This function is the \code{drawDetails} method for the \code{bubLegend} grob described above. The \code{drawDetails} method is called every time a plot is generated or resized. In this case it calculates labels and sizes for drawing the example bubbles in the phylobubbles legend. This is necessary because the because the main bubble plot bubble can change in size as the plot is resized. Because the legend and the bubble plot occur in different viewports the legend cannot know the size of the main plot circles (they are plotted relative to the space available in their viewport.) + + \addcontentsline{toc}{subsection}{orderIndex} + \item[\code{orderIndex}] This function is called from the \code{reorder} method. It takes a \code{phylo4} or \code{phylo4d} object and a string indicating the desired tree ordering, currently one of ``preorder'' or ``postorder''. It's value is a vector indicating the respective ordering of the edge matrix from top to bottom (i.e. in postorder the first edge in the edge matrix would terminate in a tip, while in preorder the first edge would be the root edge. + +\end{description} + +\section{The Nexus Class Library and Rcpp} + +\subsection{Organization of the repository} +We manage NCL source code as a ``Vendor branch'' as described in the ``SVN +book''. You should refer to this section of the SVN book before upgrading to a +newer version of NCL. + +The original copies of NCL are stored at the root of the repository in the +folder \code{libncl/}. + +When a new version of NCL is released: +\begin{enumerate} + \item the newest tarball should be unpacked in the folder with the appropriate version number; + \item this new directory should then be copied over the \code{current/} folder + (using \code{svn copy}); + \item the potential new files should be added with \code{svn add}, and the + missing files removed with \code{svn delete}. At this stage, the changes can + be commited. + \item The new version of NCL can then be tagged. + \item The new version of NCL can finally be merged in the \code{pkg/src} directory. +\end{enumerate} + +For more information look at the section ``General Vendor Branch Management'' in +the SVN book\footnote{\url{http://svnbook.red-bean.com/en/1.5/svn.advanced.vendorbr.html}}. + +\section{S4 classes and methods} + +\section{Grid graphics} + +\section{Converting between tree formats and ``round-trip'' issues} + +We should in principle be able to convert from other formats to \code{phylo4}(\code{d}) and (\code{ape::phylo}, \code{ouch::ouch} etc.) and back without losing any information. The two classes of exceptions would be (1) where \code{phylo4} stores \emph{less} information than the other formats (we would try to avoid this), and (2) where there are ambiguities etc. in the other formats (we would try to avoid this, too, but it may be difficult; ideally we would consult the package maintainers and try to get them to eliminate the ambiguities in their formats). + +Ideally we would be able to use \code{identical()} to test equality --- this tests ``bit-by-bit'' equality, and is intolerant of \emph{any} differences in format. More loosely, \code{all.equal()} allows for numeric variation below a certain tolerance, etc. (these correspond to \code{RUnit::checkEquals()} and \code{RUnit::checkIdentical()}). + +Case in point: \code{ape} is not entirely consistent in its internal representations, which causes some difficulty in creating perfect round trips (see \code{tests/roundtrip.R} for workarounds). In particular, + +\begin{itemize} + + \item \code{unroot()} contains several statements that subtract 1 from + components of the data structure that were previously stored + as \code{integer}. Because 1 is subtracted an not \code{1L} + (an explicitly integer constant), this coerces those elements + to be \code{numeric} instead. + + \item different ways of creating trees in \code{ape} + (\code{read.tree()}, \code{rcoal()}) + generate structures with the internal elements in different orders. + When \code{phylobase} re-exports them, it always uses the order + \{\code{edge}, \code{edge.length}, \code{tip.label}, + \code{Nnode}, [\code{node.label}], [\code{root.edge}]\}, + which matches the trees produced by \code{rcoal} but not + those produced by \code{read.tree} + + \item because of differences in ordering standards, it's not + clear that we can always preserve ordering information through + non-trivial manipulations in phylobase +\end{itemize} + + +\appendix +\section{Subversion}\label{subversion} + +\subsection{Organization of the \code{phylobase} repository} +The \code{phylobase} subversion repository is organized with four top level directories +\begin{itemize} + \item \code{branches/} where changes that will result in large disruption of the package take place + \item \code{libncl/} where we keep unaltered source of NCL. + \item \code{pkg/} where the main trunk of the project exists. This directory is built and available through the R-Forge install mechanism so it is important that it passes \code{R CMD check} + \item \code{tags/} where copies of previous \code{phylobase} releases are kept + \item \code{www/} where the R-Forge webpage for phylobase is maintained. This must be kept and the top level for R-Forge to find it +\end{itemize} + +\subsection{Using subversion for the first time} +The general a subversion work flow goes as follows. I???ve written this with macs linux in mind, however windows users will follow the same work flow but probably use a graphical front end for subversion, like TortoiseSVN.\footnote{\url{http://tortoisesvn.tigris.org/}} + +R-Forge allows code to be checked out in two different ways. First, you can get the code anonymously using this terminal command: + +\begin{verbatim} +svn checkout \ +svn://svn.r-forge.r-project.org/svnroot/phylobase +\end{verbatim} + +If you would like to make commits directly to the source repository you need to register with R-Forge and be added to the \code{phylobase} project as a developer. Once you've done this, you???ll need to have the ssh key set up in your R-Forge account. These terminal commands will make a copy of the folder ``phylobase'', and all the source files for the package, in whatever directory you are in (in this case ``\code{~/Code}''), change ``\code{[name]}'' to your R-Forge username. + +\begin{verbatim} +cd ~/Code/ +svn checkout \ +svn+ssh://[name]@svn.r-forge.r-project.org/svnroot/phylobase +\end{verbatim} + +Once you have a copy of the package, hack away at it and adding functions and documentation. Save changes. Then check to make sure you have the latest version of the package, it is often the case that another developer has committed a change while you were working. + +\begin{verbatim} +svn update +\end{verbatim} + +R provides some tools for checking packages. They help ensure that the package can be installed and that all the proper documentation has been added. To keep the repository clean of files that are created during the build process copy the package folder to a tmp folder before running the check. + +\begin{verbatim} +cp -R ~/Code/phylobase/pkg/ ~/Code/phylobase-tmp/ +R CMD check ~/Code/phylobase-tmp +\end{verbatim} + +Fix any errors or warnings that come up, and repeat \code{R CMD check} as necessary. The R core developers provide a manual \footnote{\url{http://cran.r-project.org/doc/manuals/R-exts.pdf}} for writing R Extensions (packages) which describes the package and documentation formats. Main gotchas are being sure that you???ve properly updated the \code{DESCRIPTION} and \code{NAMESPACE} files and ensuring that the documentation is in the proper format. \code{R CMD check} warnings/errors are very useful for helping figure out what the issue is. And, the command \code{prompt()} will provide ``fill-in-the-blank'' documentation if you???re documenting a function for the first time. + +The next step is to take a look at what we???ve actually changed. The \code{status} command will show any file that???s been added (\code{A}), modified (\code{M}), or is unknown (and may need to be added) to subversion (\code{?}). + +\begin{verbatim} +svn status +\end{verbatim} + +For instance if I???ve added a new file called foo.R subversion doesn???t +follow it until I tell it to. So I might see something like: + +\begin{verbatim} +? fooBar.R +\end{verbatim} + +Which we can remedy with + +\begin{verbatim} +svn add fooBar.R +\end{verbatim} + +svn status will then show: + +\begin{verbatim} +A fooBar.R +\end{verbatim} + +Update again for good measure (you can???t overdo it on this). + +\begin{verbatim} +svn up +\end{verbatim} + +And, finally commit the changes with a helpful message (the -m portion) about what they change does: + +\begin{verbatim} +svn commit fooBar.R -m "Function fooBar for calculating foo on the class bar" +\end{verbatim} + +Subversion, has a whole bag of tricks, full documentation of which can be found in the subversion book.\footnote{\url{http://svnbook.red-bean.com/}} There are also a number of graphical interface programs that you can use with Subversion as well. + +\subsection{Subversion patches} + +If you don't have developer access to the project but you'd like to fix a bug or add a feature you can provide the change as a patch. To make a patch with subversion first get a copy of the most recent code. + +\begin{verbatim} +svn checkout svn://svn.r-forge.r-project.org/svnroot/phylobase/pkg +\end{verbatim} + +Make whatever changes in the code or documentation are necessary. For instance if there is a simple function \code{helloWorld}, in a file called fooBar.R + +\begin{verbatim} +helloWorld <- function(){ + # This is a comment + print('Hello World!') +} +\end{verbatim} + +And, I want to update it, would find the file fooBar.R in my svn checkout and change it to: + +\begin{verbatim} +helloWorld <- function(x){ + # This is a comment + # This is a new comment + print(paste('Hello', x, '!') +} +\end{verbatim} + +To supply that change to a developer with subversion access I would make a diff file of the change. The way to make a diff is to run the \code{svn diff} command on the file in question. + +\begin{verbatim} +svn diff fooBar.R > helloWorld.diff +\end{verbatim} + +This however just spits the output of \code{svn diff} to the terminal. To save the output to a file use ``\code{>}'' which tells the terminal to save the output to a file, this file should end in ``.diff'' and will have pluses and minuses to indicate which lines have been added and removed. + +\begin{verbatim} +svn diff fooBar.R > fooBar.diff +\end{verbatim} + +\begin{verbatim} +--- /Users/birch/fooBar.R ++++ /Users/birch/fooBar.R +@@ -1,4 +1,5 @@ +-helloWorld <- function(){ ++helloWorld <- function(x){ + # This is a comment +- print('Hello World!') ++ # This is a new comment ++ print(paste('Hello', x, '!') + } +\end{verbatim} + +The fooBar.diff file can then be sent to the developers mailing list or the R-Forge Patches issue tracker.\footnote{\url{https://r-forge.r-project.org/tracker/?atid=490&group_id=111&func=browse}} Where another developer can easily review and apply the patch. + +\subsection{Branching and merging with svn} + +\end{document} Added: pkg/vignettes/developer.pdf =================================================================== --- pkg/vignettes/developer.pdf (rev 0) +++ pkg/vignettes/developer.pdf 2014-02-12 18:32:35 UTC (rev 844) @@ -0,0 +1,3300 @@ +%PDF-1.4 +%???? +1 0 obj +<< /S /GoTo /D (section.1) >> +endobj +4 0 obj +(Introduction) +endobj +5 0 obj +<< /S /GoTo /D (section.2) >> +endobj +8 0 obj +(R-Forge) +endobj +9 0 obj +<< /S /GoTo /D (section.3) >> +endobj +12 0 obj +(Building phylobase) +endobj +13 0 obj +<< /S /GoTo /D (section.4) >> +endobj +16 0 obj +(Coding standards) +endobj +17 0 obj +<< /S /GoTo /D (section.5) >> +endobj +20 0 obj +(Release procedure) +endobj +21 0 obj +<< /S /GoTo /D (section.6) >> +endobj +24 0 obj +(Unit testing with RUnit) +endobj +25 0 obj +<< /S /GoTo /D (section.7) >> +endobj +28 0 obj +(Non-exported functions) +endobj +29 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +32 0 obj +(.chnumsort) +endobj +33 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +35 0 obj +(.createEdge) +endobj +36 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +38 0 obj +(.createLabels) +endobj +39 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +41 0 obj +(.genlab) +endobj +42 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +44 0 obj +(.phylo4Data) +endobj +45 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +47 0 obj +(.phylo4ToDataFrame) +endobj +48 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +50 0 obj +(.bubLegendGrob) +endobj +51 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +53 0 obj +(drawDetails.bubLegend) +endobj +54 0 obj +<< /S /GoTo /D (section*.2) >> +endobj +56 0 obj +(orderIndex) +endobj +57 0 obj +<< /S /GoTo /D (section.8) >> +endobj +60 0 obj +(The Nexus Class Library and Rcpp) +endobj +61 0 obj +<< /S /GoTo /D (subsection.8.1) >> +endobj +64 0 obj +(Organization of the repository) +endobj +65 0 obj +<< /S /GoTo /D (section.9) >> +endobj +68 0 obj +(S4 classes and methods) +endobj +69 0 obj +<< /S /GoTo /D (section.10) >> +endobj +72 0 obj +(Grid graphics) +endobj +73 0 obj +<< /S /GoTo /D (section.11) >> +endobj +76 0 obj +(Converting between tree formats and ``round-trip'' issues) +endobj +77 0 obj +<< /S /GoTo /D (appendix.A) >> +endobj +80 0 obj +(Subversion) +endobj +81 0 obj +<< /S /GoTo /D (subsection.A.1) >> +endobj +84 0 obj +(Organization of the phylobase repository) +endobj +85 0 obj +<< /S /GoTo /D (subsection.A.2) >> +endobj +88 0 obj +(Using subversion for the first time) +endobj +89 0 obj +<< /S /GoTo /D (subsection.A.3) >> +endobj +92 0 obj +(Subversion patches) +endobj +93 0 obj +<< /S /GoTo /D (subsection.A.4) >> +endobj +96 0 obj +(Branching and merging with svn) +endobj +97 0 obj +<< /S /GoTo /D [98 0 R /Fit ] >> +endobj +126 0 obj << +/Length 1202 +/Filter /FlateDecode +>> +stream +x??Y[S?8~?Wx?a???U?,??\ +?]??????????`{d???=????P \?/?-??;?#?`??` _3? ????$ Q??`p?,A2??1?0L??pO?ET?jZ7Qlot? ?p<+ ?nM}??? +9N??u????i=?[?????% ?kc?R?e?4EiF?'?DT??( +0?[??s{??wnnGU?????????A????g ++??K"?$??>?d??%?S\??}P??g???}?yd???rHT?slQL?#DSPb\xB?"?ds +6????? ?rCk?Cb?\2 ?#?M? +6 d(TX?8????0???&?G? V??e.,f#S?q?p,w???w`d?;?tN??>??? l?????C???????N? /?G ??4???5?2??d?????]o +?i?R?&??\????B?,?2^?L?-?TYq;????H3???8?@??c +???*?4?5e?p.?yi&????g?r? +*1OAc??C@:6>?U?.?N?ZU8??Y?C?f?? ??~??6???6?? +E4 +'???N[`c2B??8????g?]??~!???? ]j^o?).????Un??b??!?G????r??Z?B}?kJ??s?g???B? ??????u=???????M?m;Sm?k2I????(???l?$H{M?v???o?2??\??m?R???&+*?^?X_?M0b???r????pU]??????;?mD?????A?-xh??^?gt??]K???Atk??)?G????????F???x?`???&7???{??[k ?Y? v??;:?????R2??K????_?????|K^???5??$M??G???/???[?? +.z +endstream +endobj +98 0 obj << +/Type /Page +/Contents 126 0 R +/Resources 125 0 R +/MediaBox [0 0 612 792] +/Parent 137 0 R +/Annots [ 99 0 R 100 0 R 101 0 R 102 0 R 103 0 R 104 0 R 105 0 R 106 0 R 107 0 R 108 0 R 109 0 R 110 0 R 111 0 R 112 0 R 113 0 R 114 0 R 115 0 R 116 0 R 117 0 R 118 0 R 119 0 R 120 0 R 121 0 R 122 0 R 123 0 R 124 0 R ] +>> endobj +99 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 522.744 179.452 531.655] +/A << /S /GoTo /D (section.1) >> +>> endobj +100 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 498.889 156.379 509.655] +/A << /S /GoTo /D (section.2) >> +>> endobj +101 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 476.695 209.7 487.82] +/A << /S /GoTo /D (section.3) >> +>> endobj +102 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 455.054 204.514 465.902] +/A << /S /GoTo /D (section.4) >> +>> endobj +103 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 433.136 207.895 443.984] +/A << /S /GoTo /D (section.5) >> +>> endobj +104 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 411.218 237.887 422.066] +/A << /S /GoTo /D (section.6) >> +>> endobj +105 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 389.3 235.057 400.148] +/A << /S /GoTo /D (section.7) >> +>> endobj +106 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 379.282 164.523 388.193] +/A << /S /GoTo /D (section*.2) >> +>> endobj +107 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 365.39 166.819 376.238] +/A << /S /GoTo /D (section*.2) >> +>> endobj +108 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 355.372 173.24 364.283] +/A << /S /GoTo /D (section*.2) >> +>> endobj +109 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 341.48 147.282 352.328] +/A << /S /GoTo /D (section*.2) >> +>> endobj +110 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 329.524 169.283 340.373] +/A << /S /GoTo /D (section*.2) >> +>> endobj +111 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 317.569 207.916 328.417] +/A << /S /GoTo /D (section*.2) >> +>> endobj +112 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 305.614 189.028 316.462] +/A << /S /GoTo /D (section*.2) >> +>> endobj +113 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 293.659 218.487 304.507] +/A << /S /GoTo /D (section*.2) >> +>> endobj +114 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 283.641 163.388 292.552] +/A << /S /GoTo /D (section*.2) >> +>> endobj +115 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 259.786 294.386 270.634] +/A << /S /GoTo /D (section.8) >> +>> endobj +116 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 247.831 271.344 258.679] +/A << /S /GoTo /D (subsection.8.1) >> +>> endobj +117 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 227.85 233.339 236.761] +/A << /S /GoTo /D (section.9) >> +>> endobj +118 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 203.995 184.919 214.843] +/A << /S /GoTo /D (section.10) >> +>> endobj +119 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 182.077 404.038 192.925] +/A << /S /GoTo /D (section.11) >> +>> endobj +120 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [99.35 162.097 170.556 171.008] +/A << /S /GoTo /D (appendix.A) >> +>> endobj +121 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 147.928 321.738 159.052] +/A << /S /GoTo /D (subsection.A.1) >> +>> endobj +122 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 136.249 288.115 147.097] +/A << /S /GoTo /D (subsection.A.2) >> +>> endobj +123 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 124.294 221.808 135.142] +/A << /S /GoTo /D (subsection.A.3) >> +>> endobj +124 0 obj << +/Type /Annot +/Subtype /Link +/Border[0 0 0]/H/I/C[1 0 0] +/Rect [114.294 112.339 281.971 123.187] +/A << /S /GoTo /D (subsection.A.4) >> +>> endobj +127 0 obj << +/D [98 0 R /XYZ 99.346 730.572 null] +>> endobj +128 0 obj << +/D [98 0 R /XYZ 100.346 692.71 null] +>> endobj +133 0 obj << +/D [98 0 R /XYZ 100.346 535.793 null] +>> endobj +125 0 obj << +/Font << /F15 129 0 R /F16 130 0 R /F17 131 0 R /F28 132 0 R /F29 134 0 R /F30 135 0 R /F8 136 0 R >> +/ProcSet [ /PDF /Text ] +>> endobj +164 0 obj << +/Length 3038 +/Filter /FlateDecode +>> +stream +x??Y[??8~?WD<,i??_?8??F????? ??????J?\?ni?o?s|?TR +??y?8?c??w.xk/?~}????g????bRE?;_y<p?EZ?X??y??????s???????O???eW????????i/aI$"<#??3-8}}?)???R??\????r|???-???.??-K?c{???4??Q??}$ [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/phylobase -r 844 From noreply at r-forge.r-project.org Wed Feb 12 19:34:21 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 12 Feb 2014 19:34:21 +0100 (CET) Subject: [Phylobase-commits] r845 - pkg/inst/doc Message-ID: <20140212183421.5ED48186EAA@r-forge.r-project.org> Author: francois Date: 2014-02-12 19:34:20 +0100 (Wed, 12 Feb 2014) New Revision: 845 Removed: pkg/inst/doc/developer.Rnw pkg/inst/doc/developer.pdf pkg/inst/doc/phylobase.Rnw pkg/inst/doc/phylobase.pdf Log: vignettes removed from inst/doc as suggested since R 2.14 Deleted: pkg/inst/doc/developer.Rnw =================================================================== --- pkg/inst/doc/developer.Rnw 2014-02-12 18:32:35 UTC (rev 844) +++ pkg/inst/doc/developer.Rnw 2014-02-12 18:34:20 UTC (rev 845) @@ -1,367 +0,0 @@ -\documentclass{article} -%\VignettePackage{phylobase} -%\VignetteIndexEntry{A developers guide for contributing to phylobase} - -\usepackage[utf8]{inputenc} % for UTF-8/single quotes from sQuote() -\usepackage{graphicx} % for jpeg and pdf figure support -\usepackage[usenames,dvipsnames]{color} % loads colors w/ easy names for coloring our links -\definecolor{DarkBlue}{rgb}{0,0,0.56} -\usepackage[colorlinks=true,urlcolor=DarkBlue,linkcolor=BrickRed,bookmarks=true]{hyperref} -\usepackage{url} -\usepackage[noae]{Sweave} - -\newcommand{\code}[1]{{{\tt #1}}} -\newcommand{\pb}{\texttt{phylobase }} - -%% Use a little bit more of the page -%% borrowed from Rd.sty, of r-project.org -\addtolength{\textheight}{12mm} -\addtolength{\topmargin}{-9mm} % still fits on US paper -\addtolength{\textwidth}{24mm} % still fits on US paper -\setlength{\oddsidemargin}{10mm} -\setlength{\evensidemargin}{\oddsidemargin} - -\title{Developers guide to \pb} -\author{Peter Cowan, Ben Bolker \& other developers of \pb} -\date{\today} - -\begin{document} -%% inspired by the adephylo vignette -\DefineVerbatimEnvironment{Sinput}{Verbatim} -{formatcom={\color{BrickRed}},fontsize=\footnotesize, baselinestretch=0.75} -\DefineVerbatimEnvironment{Soutput}{Verbatim} -{formatcom={\color{DarkBlue}},fontsize=\footnotesize, baselinestretch=0.75} - -\SweaveOpts{fig=FALSE, eps=FALSE, pdf=TRUE, width=6, height=6} - -\maketitle - -\tableofcontents - -<>= -options(width=40) -@ - -\section{Introduction} - -This vignette is intended as a guide for the development of \pb and a repository of technical notes of primary interest to it's developers and others interested in gory details --- by contrast the other \pb vignette is more of an introduction \& user's manual. - -\section{R-Forge} - -Our development infrastructure hosted by R-Forge,\footnote{\url{http://phylobase.r-forge.r-project.org}} and includes a Subversion repository (see \autoref{subversion}~[\nameref{subversion}]) for source code management, trackers for bug reports and feature requests,\footnote{\url{http://r-forge.r-project.org/tracker/?group_id=111}} and mailing lists for development discussion and tracking changes in the source code.\footnote{\url{http://r-forge.r-project.org/mail/?group_id=111}} - -The R-Forge manual\footnote{\url{http://r-forge.r-project.org/R-Forge_Manual.pdf}} describes how to develop a package using their infrastructure Of particular importance is the section on getting ssh keys to work so that you can commit changes to the \code{phylobase} code using Subversion (\code{svn}). - -On feature of R-Forge is a package repository that allows prerelease versions of \pb to be install directly from \code{R}. - -<>= -install.packages("phylobase", repos = "http://r-forge.r-project.org") -@ - -\section{Building \code{phylobase}} - -If you are interested in building \pb from source, you will need the same tools required to build \code{R} itself. These are documented in the R Installation and Administration manual.\footnote{\url{http://cran.r-project.org/doc/manuals/R-admin.html}} If you are running Mac OS X you???ll need to have the developer tools.\footnote{\url{http://developer.apple.com/technology/xcode.html}} On Windows you'll need to install the ``Windows toolset''\footnote{\url{http://www.murdoch-sutherland.com/Rtools/}} as described in the above manual. If you are running Linux, you probably already know what you need. To build the vignettes and \LaTeX~documentation you will need to install a \TeX~distribution like MacTex\footnote{\url{http://www.tug.org/mactex/}} for Mac OS X, Tex-Live for Linux, or MiKTeX\footnote{\url{http://www.miktex.org/}} for Windows. Once you have the proper tools installed follow the instruction in the Writing \code{R} Extensions manual.\footnote{\url{http://cran.r-project.org/doc/manuals/R-exts.html}} - -\section{Coding standards} - -We try to follow the coding standards of Bioconductor.\footnote{\url{http://wiki.fhcrc.org/bioc/Coding_Standards}} Namely, variables and particularily function exposed to users should be in \code{camelCase}. As of this writing many non-exported functions are prefixed with `.' however, future private functions should be named without this convention. Indentation should be 4 spaces and tabs should be avoided. We also use \code{<-} for assignment, and place spaces after commas, in indexes and function calls (e.g. \code{df[2, 2]} and \code{seq(1, 2, 0.1)}, not \code{df[2,2]} or \code{seq(1,2,0.1}.) - -\section{Release procedure} - -When the package code has stabilized or significant bugs have been fixed we want to push those changes out to CRAN. This section documents the release sequence used for when submitting the package to CRAN. - -\begin{enumerate} - \item Update the NEWS file which resides in the pkg/ directory and describes changes in the package since its last release. New changes should be appended above the earlier entries and formatted so that it can be read by \code{news(package="phylobase")}, (format documented in \code{?news}). Briefly, the version header should look like a previous entry and changes should be grouped in categories which start at the beginning of a line. Within each category individual changes should be marked with an indented (4 spaces) asterisk, with the change text indented and wrapped a further four space, eight total. The most comprehensive way to find the changes since the last version is to look at the SVN log. This procedure was followed for the the 0.5 release and assumes that you have the entire project checked out, including the www and tags directories. - -Navigate to the tag for the previous release and get the revision it was created: -\begin{verbatim} -~$ cd phylobase/tags/phylobase-0.4 -~$ svn log --stop-on-copy ------------------------------------------------------------------------- -r309 | skembel | 2008-12-18 12:55:14 -0800 (Thu, 18 Dec 2008) | 1 line - -Tagging current version as 0.4 prior to hackathon changes ------------------------------------------------------------------------- -\end{verbatim} - -In this case we can see that the tag was created in revision 309 and as this was the current release, we want all the changes that have been made since. To do that we navigate to the top level to get the change log from any branches that have been made and save the log. If there are unmerged branches, care should be taken to exclude those changes from the NEWS file. Because this file may be rather large we'll output it to a file. - -\begin{verbatim} -~$ cd ../.. -~$ svn log -r309:HEAD > RecentChanges.txt -\end{verbatim} - -The NEWS file can then be updated by going through the RecentChanges.txt file and picking out significant changes. - - \item The DESCRIPTION file should be updated to reflect the new version number and current date. Version numbers should follow the 0.5.0 format (no dashes), and the date should be formatted as 2009-01-30. - \item Rebuild the vignettes to incorporate the latest changes. CRAN may not have all the package we use to build our vignettes or able to run latex the multiple time necessary to generate the PDFs with the proper cross references and table of contents. - -\begin{verbatim} -~$ cd phylobase/pkg/inst/doc -~$ R CMD Sweave phylobase.Rnw -~$ pdflatex phylobase.tex -~$ pdflatex phylobase.tex -~$ pdflatex phylobase.tex - -~$ R CMD Sweave developer.Rnw -~$ pdflatex developer.tex -~$ pdflatex developer.tex -~$ pdflatex developer.tex - -~$ rm *.toc *.out *.log *.aux *.tex -\end{verbatim} - - \item Code freeze. Before the package can be submitted to CRAN it must pass the R-Forge build and check process which happens every night. The easiest way to handle this is to freeze the the code for a day or two after the NEWS, DESCRIPTION and PDF files have been updated. - \item Tag the release in SVN. Each release is tagged so that a copy of it is easily available if needed at a later date. This is done using the SVN copy as follows for a hypothetical 0.5.1 release: - -\begin{verbatim} -~$ cd phylobase/ -~$ svn copy pkg/ tags/phylobase-0.5.1 -~$ svn commit -m "tagging version 0.5.1" -\end{verbatim} - - \item Uploading to CRAN is done by clicking the Upload to CRAN link on the R-Forge package page. Ensure that the revision number corresponds to the revision with the updated NEWS etc. files. - \item Update the R-Forge website with the correct version number and PDFs of the vignettes. -\end{enumerate} - -\section{Unit testing with RUnit} - -We are in the process of moving our testing infrastructure to the \code{RUnit}\footnote{\url{http://cran.r-project.org/web/packages/RUnit/index.html}} framework. New contributions and bug fixes should be accompanied by unit tests which test the basic functionality of the code as well as edge cases (e.g what happens when the function is passed an empty string or negative number -- even when those inputs don't make sense.) Unit tests are stored in the \code{inst/unitTests/} directory and are named according to the source file they correspond to. See the included tests and the \code{RUnit} documentation for further details. \code{RUnit} has a few advantages over the other testing frameworks in \code{R}, namely the examples in documentation, vignettes, - -\section{Non-exported functions} - -These functions are for internal use in \code{phylobase} not exported. Since most are not documented elsewhere, they are documented here. - -\begin{description} - - \addcontentsline{toc}{subsection}{.chnumsort} - \item[\code{.chnumsort}] A convenience function that coerces vector of strings to numbers for sorting, then coerces the vector back to stings. Currently only used inside the \code{prune} method. - - \addcontentsline{toc}{subsection}{.createEdge} - \item[\code{.createEdge}] - - \addcontentsline{toc}{subsection}{.createLabels} - \item[\code{.createLabels}] Used any time labels are needed, including when updating the labels via \code{labels()<-} or constructing a \code{phylo4} object. It takes a vector of names to use or \code{NULL} if new labels should be generated, integers indicating the number of tips and internal nodes, as well as a string to indicated the type of labels to generate ``tip'' and ``internal'', for either tip or internal labels along or ``allnode'' or all nodes. - - \addcontentsline{toc}{subsection}{.genlab} - \item[\code{.genlab}] A handy function that can generate labels for applying to nodes and tips. The function takes to arguments, a `base' string, and an integer indicating the number of labels desired. The result is a vector of string with a number (padded with `0') suffix e.g. \code{foo01...foo12}. This function is used to generate names in the \code{.createLabels} function as well as for for making temporary names during the \code{prune} method. - - \addcontentsline{toc}{subsection}{.phylo4Data} - \item[\code{.phylo4Data}] - - \addcontentsline{toc}{subsection}{.phylo4ToDataFrame} - \item[\code{.phylo4ToDataFrame}] - - \addcontentsline{toc}{subsection}{.bubLegendGrob} - \item[\code{.bubLegendGrob}] This function generates a \code{Grid} graphics object (a grob) for drawing the \code{phylobubbles()} legend. For reason I have not been able to understand, it must be defined outside of the \code{phylobubbles} function. It takes the raw tip data values for a \code{phylo4d} object as well as the scaled values used for making the bubble plot, both of these vectors are passed directly to the \code{drawDetails.bubLegend} function. - - \addcontentsline{toc}{subsection}{drawDetails.bubLegend} - \item[\code{drawDetails.bubLegend}] This function is the \code{drawDetails} method for the \code{bubLegend} grob described above. The \code{drawDetails} method is called every time a plot is generated or resized. In this case it calculates labels and sizes for drawing the example bubbles in the phylobubbles legend. This is necessary because the because the main bubble plot bubble can change in size as the plot is resized. Because the legend and the bubble plot occur in different viewports the legend cannot know the size of the main plot circles (they are plotted relative to the space available in their viewport.) - - \addcontentsline{toc}{subsection}{orderIndex} - \item[\code{orderIndex}] This function is called from the \code{reorder} method. It takes a \code{phylo4} or \code{phylo4d} object and a string indicating the desired tree ordering, currently one of ``preorder'' or ``postorder''. It's value is a vector indicating the respective ordering of the edge matrix from top to bottom (i.e. in postorder the first edge in the edge matrix would terminate in a tip, while in preorder the first edge would be the root edge. - -\end{description} - -\section{The Nexus Class Library and Rcpp} - -\subsection{Organization of the repository} -We manage NCL source code as a ``Vendor branch'' as described in the ``SVN -book''. You should refer to this section of the SVN book before upgrading to a -newer version of NCL. - -The original copies of NCL are stored at the root of the repository in the -folder \code{libncl/}. - -When a new version of NCL is released: -\begin{enumerate} - \item the newest tarball should be unpacked in the folder with the appropriate version number; - \item this new directory should then be copied over the \code{current/} folder - (using \code{svn copy}); - \item the potential new files should be added with \code{svn add}, and the - missing files removed with \code{svn delete}. At this stage, the changes can - be commited. - \item The new version of NCL can then be tagged. - \item The new version of NCL can finally be merged in the \code{pkg/src} directory. -\end{enumerate} - -For more information look at the section ``General Vendor Branch Management'' in -the SVN book\footnote{\url{http://svnbook.red-bean.com/en/1.5/svn.advanced.vendorbr.html}}. - -\section{S4 classes and methods} - -\section{Grid graphics} - -\section{Converting between tree formats and ``round-trip'' issues} - -We should in principle be able to convert from other formats to \code{phylo4}(\code{d}) and (\code{ape::phylo}, \code{ouch::ouch} etc.) and back without losing any information. The two classes of exceptions would be (1) where \code{phylo4} stores \emph{less} information than the other formats (we would try to avoid this), and (2) where there are ambiguities etc. in the other formats (we would try to avoid this, too, but it may be difficult; ideally we would consult the package maintainers and try to get them to eliminate the ambiguities in their formats). - -Ideally we would be able to use \code{identical()} to test equality --- this tests ``bit-by-bit'' equality, and is intolerant of \emph{any} differences in format. More loosely, \code{all.equal()} allows for numeric variation below a certain tolerance, etc. (these correspond to \code{RUnit::checkEquals()} and \code{RUnit::checkIdentical()}). - -Case in point: \code{ape} is not entirely consistent in its internal representations, which causes some difficulty in creating perfect round trips (see \code{tests/roundtrip.R} for workarounds). In particular, - -\begin{itemize} - - \item \code{unroot()} contains several statements that subtract 1 from - components of the data structure that were previously stored - as \code{integer}. Because 1 is subtracted an not \code{1L} - (an explicitly integer constant), this coerces those elements - to be \code{numeric} instead. - - \item different ways of creating trees in \code{ape} - (\code{read.tree()}, \code{rcoal()}) - generate structures with the internal elements in different orders. - When \code{phylobase} re-exports them, it always uses the order - \{\code{edge}, \code{edge.length}, \code{tip.label}, - \code{Nnode}, [\code{node.label}], [\code{root.edge}]\}, - which matches the trees produced by \code{rcoal} but not - those produced by \code{read.tree} - - \item because of differences in ordering standards, it's not - clear that we can always preserve ordering information through - non-trivial manipulations in phylobase -\end{itemize} - - -\appendix -\section{Subversion}\label{subversion} - -\subsection{Organization of the \code{phylobase} repository} -The \code{phylobase} subversion repository is organized with four top level directories -\begin{itemize} - \item \code{branches/} where changes that will result in large disruption of the package take place - \item \code{libncl/} where we keep unaltered source of NCL. - \item \code{pkg/} where the main trunk of the project exists. This directory is built and available through the R-Forge install mechanism so it is important that it passes \code{R CMD check} - \item \code{tags/} where copies of previous \code{phylobase} releases are kept - \item \code{www/} where the R-Forge webpage for phylobase is maintained. This must be kept and the top level for R-Forge to find it -\end{itemize} - -\subsection{Using subversion for the first time} -The general a subversion work flow goes as follows. I???ve written this with macs linux in mind, however windows users will follow the same work flow but probably use a graphical front end for subversion, like TortoiseSVN.\footnote{\url{http://tortoisesvn.tigris.org/}} - -R-Forge allows code to be checked out in two different ways. First, you can get the code anonymously using this terminal command: - -\begin{verbatim} -svn checkout \ -svn://svn.r-forge.r-project.org/svnroot/phylobase -\end{verbatim} - -If you would like to make commits directly to the source repository you need to register with R-Forge and be added to the \code{phylobase} project as a developer. Once you've done this, you???ll need to have the ssh key set up in your R-Forge account. These terminal commands will make a copy of the folder ``phylobase'', and all the source files for the package, in whatever directory you are in (in this case ``\code{~/Code}''), change ``\code{[name]}'' to your R-Forge username. - -\begin{verbatim} -cd ~/Code/ -svn checkout \ -svn+ssh://[name]@svn.r-forge.r-project.org/svnroot/phylobase -\end{verbatim} - -Once you have a copy of the package, hack away at it and adding functions and documentation. Save changes. Then check to make sure you have the latest version of the package, it is often the case that another developer has committed a change while you were working. - -\begin{verbatim} -svn update -\end{verbatim} - -R provides some tools for checking packages. They help ensure that the package can be installed and that all the proper documentation has been added. To keep the repository clean of files that are created during the build process copy the package folder to a tmp folder before running the check. - -\begin{verbatim} -cp -R ~/Code/phylobase/pkg/ ~/Code/phylobase-tmp/ -R CMD check ~/Code/phylobase-tmp -\end{verbatim} - -Fix any errors or warnings that come up, and repeat \code{R CMD check} as necessary. The R core developers provide a manual \footnote{\url{http://cran.r-project.org/doc/manuals/R-exts.pdf}} for writing R Extensions (packages) which describes the package and documentation formats. Main gotchas are being sure that you???ve properly updated the \code{DESCRIPTION} and \code{NAMESPACE} files and ensuring that the documentation is in the proper format. \code{R CMD check} warnings/errors are very useful for helping figure out what the issue is. And, the command \code{prompt()} will provide ``fill-in-the-blank'' documentation if you???re documenting a function for the first time. - -The next step is to take a look at what we???ve actually changed. The \code{status} command will show any file that???s been added (\code{A}), modified (\code{M}), or is unknown (and may need to be added) to subversion (\code{?}). - -\begin{verbatim} -svn status -\end{verbatim} - -For instance if I???ve added a new file called foo.R subversion doesn???t -follow it until I tell it to. So I might see something like: - -\begin{verbatim} -? fooBar.R -\end{verbatim} - -Which we can remedy with - -\begin{verbatim} -svn add fooBar.R -\end{verbatim} - -svn status will then show: - -\begin{verbatim} -A fooBar.R -\end{verbatim} - -Update again for good measure (you can???t overdo it on this). - -\begin{verbatim} -svn up -\end{verbatim} - -And, finally commit the changes with a helpful message (the -m portion) about what they change does: - -\begin{verbatim} -svn commit fooBar.R -m "Function fooBar for calculating foo on the class bar" -\end{verbatim} - -Subversion, has a whole bag of tricks, full documentation of which can be found in the subversion book.\footnote{\url{http://svnbook.red-bean.com/}} There are also a number of graphical interface programs that you can use with Subversion as well. - -\subsection{Subversion patches} - -If you don't have developer access to the project but you'd like to fix a bug or add a feature you can provide the change as a patch. To make a patch with subversion first get a copy of the most recent code. - -\begin{verbatim} -svn checkout svn://svn.r-forge.r-project.org/svnroot/phylobase/pkg -\end{verbatim} - -Make whatever changes in the code or documentation are necessary. For instance if there is a simple function \code{helloWorld}, in a file called fooBar.R - -\begin{verbatim} -helloWorld <- function(){ - # This is a comment - print('Hello World!') -} -\end{verbatim} - -And, I want to update it, would find the file fooBar.R in my svn checkout and change it to: - -\begin{verbatim} -helloWorld <- function(x){ - # This is a comment - # This is a new comment - print(paste('Hello', x, '!') -} -\end{verbatim} - -To supply that change to a developer with subversion access I would make a diff file of the change. The way to make a diff is to run the \code{svn diff} command on the file in question. - -\begin{verbatim} -svn diff fooBar.R > helloWorld.diff -\end{verbatim} - -This however just spits the output of \code{svn diff} to the terminal. To save the output to a file use ``\code{>}'' which tells the terminal to save the output to a file, this file should end in ``.diff'' and will have pluses and minuses to indicate which lines have been added and removed. - -\begin{verbatim} -svn diff fooBar.R > fooBar.diff -\end{verbatim} - -\begin{verbatim} ---- /Users/birch/fooBar.R -+++ /Users/birch/fooBar.R -@@ -1,4 +1,5 @@ --helloWorld <- function(){ -+helloWorld <- function(x){ - # This is a comment -- print('Hello World!') -+ # This is a new comment -+ print(paste('Hello', x, '!') - } -\end{verbatim} - -The fooBar.diff file can then be sent to the developers mailing list or the R-Forge Patches issue tracker.\footnote{\url{https://r-forge.r-project.org/tracker/?atid=490&group_id=111&func=browse}} Where another developer can easily review and apply the patch. - -\subsection{Branching and merging with svn} - -\end{document} Deleted: pkg/inst/doc/developer.pdf =================================================================== --- pkg/inst/doc/developer.pdf 2014-02-12 18:32:35 UTC (rev 844) +++ pkg/inst/doc/developer.pdf 2014-02-12 18:34:20 UTC (rev 845) @@ -1,3300 +0,0 @@ -%PDF-1.4 -%???? -1 0 obj -<< /S /GoTo /D (section.1) >> -endobj -4 0 obj -(Introduction) -endobj -5 0 obj -<< /S /GoTo /D (section.2) >> -endobj -8 0 obj -(R-Forge) -endobj -9 0 obj -<< /S /GoTo /D (section.3) >> -endobj -12 0 obj -(Building phylobase) -endobj -13 0 obj -<< /S /GoTo /D (section.4) >> -endobj -16 0 obj -(Coding standards) -endobj -17 0 obj -<< /S /GoTo /D (section.5) >> -endobj -20 0 obj -(Release procedure) -endobj -21 0 obj -<< /S /GoTo /D (section.6) >> -endobj -24 0 obj -(Unit testing with RUnit) -endobj -25 0 obj -<< /S /GoTo /D (section.7) >> -endobj -28 0 obj -(Non-exported functions) -endobj -29 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -32 0 obj -(.chnumsort) -endobj -33 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -35 0 obj -(.createEdge) -endobj -36 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -38 0 obj -(.createLabels) -endobj -39 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -41 0 obj -(.genlab) -endobj -42 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -44 0 obj -(.phylo4Data) -endobj -45 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -47 0 obj -(.phylo4ToDataFrame) -endobj -48 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -50 0 obj -(.bubLegendGrob) -endobj -51 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -53 0 obj -(drawDetails.bubLegend) -endobj -54 0 obj -<< /S /GoTo /D (section*.2) >> -endobj -56 0 obj -(orderIndex) -endobj -57 0 obj -<< /S /GoTo /D (section.8) >> -endobj -60 0 obj -(The Nexus Class Library and Rcpp) -endobj -61 0 obj -<< /S /GoTo /D (subsection.8.1) >> -endobj -64 0 obj -(Organization of the repository) -endobj -65 0 obj -<< /S /GoTo /D (section.9) >> -endobj -68 0 obj -(S4 classes and methods) -endobj -69 0 obj -<< /S /GoTo /D (section.10) >> -endobj -72 0 obj -(Grid graphics) -endobj -73 0 obj -<< /S /GoTo /D (section.11) >> -endobj -76 0 obj -(Converting between tree formats and ``round-trip'' issues) -endobj -77 0 obj -<< /S /GoTo /D (appendix.A) >> -endobj -80 0 obj -(Subversion) -endobj -81 0 obj -<< /S /GoTo /D (subsection.A.1) >> -endobj -84 0 obj -(Organization of the phylobase repository) -endobj -85 0 obj -<< /S /GoTo /D (subsection.A.2) >> -endobj -88 0 obj -(Using subversion for the first time) -endobj -89 0 obj -<< /S /GoTo /D (subsection.A.3) >> -endobj -92 0 obj -(Subversion patches) -endobj -93 0 obj -<< /S /GoTo /D (subsection.A.4) >> -endobj -96 0 obj -(Branching and merging with svn) -endobj -97 0 obj -<< /S /GoTo /D [98 0 R /Fit ] >> -endobj -126 0 obj << -/Length 1202 -/Filter /FlateDecode ->> -stream -x??Y[S?8~?Wx?a???U?,??\ -?]??????????`{d???=????P \?/?-??;?#?`??` _3? ????$ Q??`p?,A2??1?0L??pO?ET?jZ7Qlot? ?p<+ ?nM}??? -9N??u????i=?[?????% ?kc?R?e?4EiF?'?DT??( -0?[??s{??wnnGU?????????A????g -+??K"?$??>?d??%?S\??}P??g???}?yd???rHT?slQL?#DSPb\xB?"?ds -6????? ?rCk?Cb?\2 ?#?M? -6 d(TX?8????0???&?G? V??e.,f#S?q?p,w???w`d?;?tN??>??? l?????C???????N? /?G ??4???5?2??d?????]o -?i?R?&??\????B?,?2^?L?-?TYq;????H3???8?@??c -???*?4?5e?p.?yi&????g?r? -*1OAc??C@:6>?U?.?N?ZU8??Y?C?f?? ??~??6???6?? -E4 -'???N[`c2B??8????g?]??~!???? ]j^o?).????Un??b??!?G????r??Z?B}?kJ??s?g???B? ??????u=???????M?m;Sm?k2I????(???l?$H{M?v???o?2??\??m?R???&+*?^?X_?M0b???r????pU]??????;?mD?????A?-xh??^?gt??]K???Atk??)?G????????F???x?`???&7???{??[k ?Y? v??;:?????R2??K????_?????|K^???5??$M??G???/???[?? -.z -endstream -endobj -98 0 obj << -/Type /Page -/Contents 126 0 R -/Resources 125 0 R -/MediaBox [0 0 612 792] -/Parent 137 0 R -/Annots [ 99 0 R 100 0 R 101 0 R 102 0 R 103 0 R 104 0 R 105 0 R 106 0 R 107 0 R 108 0 R 109 0 R 110 0 R 111 0 R 112 0 R 113 0 R 114 0 R 115 0 R 116 0 R 117 0 R 118 0 R 119 0 R 120 0 R 121 0 R 122 0 R 123 0 R 124 0 R ] ->> endobj -99 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 522.744 179.452 531.655] -/A << /S /GoTo /D (section.1) >> ->> endobj -100 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 498.889 156.379 509.655] -/A << /S /GoTo /D (section.2) >> ->> endobj -101 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 476.695 209.7 487.82] -/A << /S /GoTo /D (section.3) >> ->> endobj -102 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 455.054 204.514 465.902] -/A << /S /GoTo /D (section.4) >> ->> endobj -103 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 433.136 207.895 443.984] -/A << /S /GoTo /D (section.5) >> ->> endobj -104 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 411.218 237.887 422.066] -/A << /S /GoTo /D (section.6) >> ->> endobj -105 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 389.3 235.057 400.148] -/A << /S /GoTo /D (section.7) >> ->> endobj -106 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 379.282 164.523 388.193] -/A << /S /GoTo /D (section*.2) >> ->> endobj -107 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 365.39 166.819 376.238] -/A << /S /GoTo /D (section*.2) >> ->> endobj -108 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 355.372 173.24 364.283] -/A << /S /GoTo /D (section*.2) >> ->> endobj -109 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 341.48 147.282 352.328] -/A << /S /GoTo /D (section*.2) >> ->> endobj -110 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 329.524 169.283 340.373] -/A << /S /GoTo /D (section*.2) >> ->> endobj -111 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 317.569 207.916 328.417] -/A << /S /GoTo /D (section*.2) >> ->> endobj -112 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 305.614 189.028 316.462] -/A << /S /GoTo /D (section*.2) >> ->> endobj -113 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 293.659 218.487 304.507] -/A << /S /GoTo /D (section*.2) >> ->> endobj -114 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 283.641 163.388 292.552] -/A << /S /GoTo /D (section*.2) >> ->> endobj -115 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 259.786 294.386 270.634] -/A << /S /GoTo /D (section.8) >> ->> endobj -116 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 247.831 271.344 258.679] -/A << /S /GoTo /D (subsection.8.1) >> ->> endobj -117 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 227.85 233.339 236.761] -/A << /S /GoTo /D (section.9) >> ->> endobj -118 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 203.995 184.919 214.843] -/A << /S /GoTo /D (section.10) >> ->> endobj -119 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 182.077 404.038 192.925] -/A << /S /GoTo /D (section.11) >> ->> endobj -120 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [99.35 162.097 170.556 171.008] -/A << /S /GoTo /D (appendix.A) >> ->> endobj -121 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 147.928 321.738 159.052] -/A << /S /GoTo /D (subsection.A.1) >> ->> endobj -122 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 136.249 288.115 147.097] -/A << /S /GoTo /D (subsection.A.2) >> ->> endobj -123 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 124.294 221.808 135.142] -/A << /S /GoTo /D (subsection.A.3) >> ->> endobj -124 0 obj << -/Type /Annot -/Subtype /Link -/Border[0 0 0]/H/I/C[1 0 0] -/Rect [114.294 112.339 281.971 123.187] -/A << /S /GoTo /D (subsection.A.4) >> ->> endobj -127 0 obj << -/D [98 0 R /XYZ 99.346 730.572 null] ->> endobj -128 0 obj << -/D [98 0 R /XYZ 100.346 692.71 null] ->> endobj -133 0 obj << -/D [98 0 R /XYZ 100.346 535.793 null] ->> endobj -125 0 obj << -/Font << /F15 129 0 R /F16 130 0 R /F17 131 0 R /F28 132 0 R /F29 134 0 R /F30 135 0 R /F8 136 0 R >> -/ProcSet [ /PDF /Text ] ->> endobj -164 0 obj << -/Length 3038 -/Filter /FlateDecode ->> -stream -x??Y[??8~?WD<,i??_?8??F????? ??????J?\?ni?o?s|?TR -??y?8?c??w.xk/?~}????g????bRE?;_y<p?EZ?X??y??????s???????O???eW????????i/aI$"<#??3-8}}?)???R??\????r|???-???.??-K?c{???4??Q??}$ [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/phylobase -r 845 From noreply at r-forge.r-project.org Wed Feb 12 19:45:24 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 12 Feb 2014 19:45:24 +0100 (CET) Subject: [Phylobase-commits] r846 - in pkg: R man Message-ID: <20140212184524.E2A1A18598B@r-forge.r-project.org> Author: francois Date: 2014-02-12 19:45:24 +0100 (Wed, 12 Feb 2014) New Revision: 846 Modified: pkg/R/readNCL.R pkg/man/readNCL.Rd Log: adding option convert.edge.length to readNCL to convert negative branch lengths to 0 so that objects can be imported into phylobase Modified: pkg/R/readNCL.R =================================================================== --- pkg/R/readNCL.R 2014-02-12 18:34:20 UTC (rev 845) +++ pkg/R/readNCL.R 2014-02-12 18:45:24 UTC (rev 846) @@ -8,11 +8,12 @@ levels.uniform=FALSE, quiet=TRUE, check.node.labels=c("keep", "drop", "asdata"), return.labels=TRUE, file.format=c("nexus", "newick"), - check.names=TRUE, ...) { + check.names=TRUE, convert.edge.length=FALSE, ...) { ## turn on to TRUE to test new way of building trees in NCL experimental <- FALSE + file <- path.expand(file) type <- match.arg(type) check.node.labels <- match.arg(check.node.labels) file.format <- match.arg(file.format) @@ -144,6 +145,9 @@ tr$tip.label <- ncl$taxaNames[as.numeric(tr$tip.label)] } else stop("phylobase doesn't deal with multiple taxa block at this time.") + if (convert.edge.length) { + tr$edge.length[tr$edge.length < 0] <- 0 + } if (is.null(tr$node.label)) { if (check.node.labels == "asdata") { warning("Could not use value \"asdata\" for ", @@ -169,6 +173,9 @@ edgeMat <- cbind(ncl$parentVector, c(1:length(ncl$parentVector))) edgeLgth <- ncl$branchLengthVector edgeLgth[edgeLgth == -1] <- NA + if (convert.edge.length) { + edgeLgth[edgeLgth < 0] <- 0 + } if (length(ncl$taxaNames) != min(ncl$parentVector)-1) { stop("phylobase doesn't deal with multiple taxa block at this time.") } @@ -224,18 +231,21 @@ char.all=FALSE, polymorphic.convert=TRUE, levels.uniform=FALSE, quiet=TRUE, check.node.labels=c("keep", "drop", "asdata"), - return.labels=TRUE, check.names=TRUE, ...) { + return.labels=TRUE, check.names=TRUE, convert.edge.length=FALSE, + ...) { return(readNCL(file=file, simplify=simplify, type=type, char.all=char.all, polymorphic.convert=polymorphic.convert, levels.uniform=levels.uniform, quiet=quiet, check.node.labels=check.node.labels, return.labels=return.labels, file.format="nexus", - check.names=check.names, ...)) + check.names=check.names, convert.edge.length=convert.edge.length, ...)) } readNewick <- function(file, simplify=FALSE, quiet=TRUE, - check.node.labels=c("keep", "drop", "asdata"), ...) { + check.node.labels=c("keep", "drop", "asdata"), + convert.edge.length=FALSE, ...) { return(readNCL(file=file, simplify=simplify, quiet=quiet, - check.node.labels=check.node.labels, file.format="newick", ...)) + check.node.labels=check.node.labels, file.format="newick", + convert.edge.length=convert.edge.length, ...)) } Modified: pkg/man/readNCL.Rd =================================================================== --- pkg/man/readNCL.Rd 2014-02-12 18:34:20 UTC (rev 845) +++ pkg/man/readNCL.Rd 2014-02-12 18:45:24 UTC (rev 846) @@ -19,10 +19,12 @@ readNexus(file, simplify=FALSE, type=c("all", "tree", "data"), char.all=FALSE, polymorphic.convert=TRUE, levels.uniform=FALSE, quiet=TRUE, check.node.labels=c("keep", "drop", "asdata"), - return.labels=TRUE, check.names=TRUE, ...) + return.labels=TRUE, check.names=TRUE, convert.edge.length=FALSE, + ...) readNewick(file, simplify=FALSE, quiet=TRUE, - check.node.labels=c("keep", "drop", "asdata"), ...) + check.node.labels=c("keep", "drop", "asdata"), + convert.edge.length=FALSE, ...) } @@ -63,6 +65,12 @@ are syntactically valid variable names and are not duplicated. If necessary they are adjusted (by \sQuote{make.names}) so that they are.} + + \item{convert.edge.length}{logical. If \sQuote{TRUE} negative edge + lengths are replaced with 0. At this time \code{phylobase} does not + accept objects with negative branch lengths, this workaround allows + to still use trees with negative branch lengths are an artifact of + the method used to build the tree.} \item{\dots}{Additional arguments to be passed to phylo4 or phylo4d constructor (see Details)} From noreply at r-forge.r-project.org Wed Feb 12 20:38:27 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 12 Feb 2014 20:38:27 +0100 (CET) Subject: [Phylobase-commits] r847 - pkg/src Message-ID: <20140212193827.B6735186C06@r-forge.r-project.org> Author: francois Date: 2014-02-12 20:38:27 +0100 (Wed, 12 Feb 2014) New Revision: 847 Modified: pkg/src/Makevars pkg/src/Makevars.win Log: changes to reflect new flags with using Rcpp 0.11.0 Modified: pkg/src/Makevars =================================================================== --- pkg/src/Makevars 2014-02-12 18:45:24 UTC (rev 846) +++ pkg/src/Makevars 2014-02-12 19:38:27 UTC (rev 847) @@ -1,2 +1,2 @@ PKG_CPPFLAGS=-I. -DHAVE_INTTYPES_H -DASSERTS_TO_EXCEPTIONS -PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` +#PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` Modified: pkg/src/Makevars.win =================================================================== --- pkg/src/Makevars.win 2014-02-12 18:45:24 UTC (rev 846) +++ pkg/src/Makevars.win 2014-02-12 19:38:27 UTC (rev 847) @@ -1,6 +1,6 @@ ## PKG_LIBS = -s $(shell Rscript -e 'Rcpp:::LdFlags()') -L"$(RHOME)/bin" -lR --no-export-all-symbols --add-stdcall-alias PKG_CXXFLAGS = -I. -DHAVE_INTTYPES_H -DASSERTS_TO_EXCEPTIONS -PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()") +## PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()") From noreply at r-forge.r-project.org Wed Feb 12 20:40:48 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 12 Feb 2014 20:40:48 +0100 (CET) Subject: [Phylobase-commits] r848 - in pkg: . R src Message-ID: <20140212194048.EBB14181360@r-forge.r-project.org> Author: francois Date: 2014-02-12 20:40:48 +0100 (Wed, 12 Feb 2014) New Revision: 848 Added: pkg/R/RcppExports.R pkg/src/RcppExports.cpp pkg/src/checkPhylo4.cpp pkg/src/symbols.rds Modified: pkg/DESCRIPTION pkg/R/checkdata.R pkg/R/class-phylo4.R pkg/R/methods-phylo4.R Log: convert checkdata to C++ to make it faster. Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2014-02-12 19:38:27 UTC (rev 847) +++ pkg/DESCRIPTION 2014-02-12 19:40:48 UTC (rev 848) @@ -1,13 +1,13 @@ Package: phylobase Type: Package Title: Base package for phylogenetic structures and comparative data -Version: 0.6.5.2 -Date: 2013-04-29 +Version: 0.6.6 +Date: 2014-02-11 Depends: methods, grid, ape(>= 2.1), - Rcpp (>= 0.10.0) + Rcpp (>= 0.11.0) Imports: ade4 LinkingTo: Rcpp Suggests: @@ -22,6 +22,7 @@ one or more trees and trait data License: GPL (>= 2) Collate: + 'RcppExports.R' 'phylo4.R' 'checkdata.R' 'formatData.R' Added: pkg/R/RcppExports.R =================================================================== --- pkg/R/RcppExports.R (rev 0) +++ pkg/R/RcppExports.R 2014-02-12 19:40:48 UTC (rev 848) @@ -0,0 +1,87 @@ +# This file was generated by Rcpp::compileAttributes +# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +isLabelName <- function(lblToCheck, lbl) { + .Call('phylobase_isLabelName', PACKAGE = 'phylobase', lblToCheck, lbl) +} + +nRoots <- function(ances) { + .Call('phylobase_nRoots', PACKAGE = 'phylobase', ances) +} + +tabulateTips <- function(ances) { + .Call('phylobase_tabulateTips', PACKAGE = 'phylobase', ances) +} + +nTipsSafe <- function(ances) { + .Call('phylobase_nTipsSafe', PACKAGE = 'phylobase', ances) +} + +nTipsFastCpp <- function(ances) { + .Call('phylobase_nTipsFastCpp', PACKAGE = 'phylobase', ances) +} + +hasSingleton <- function(ances) { + .Call('phylobase_hasSingleton', PACKAGE = 'phylobase', ances) +} + +hasPolytomy <- function(ances) { + .Call('phylobase_hasPolytomy', PACKAGE = 'phylobase', ances) +} + +tipsSafe <- function(ances, desc) { + .Call('phylobase_tipsSafe', PACKAGE = 'phylobase', ances, desc) +} + +tipsFast <- function(ances) { + .Call('phylobase_tipsFast', PACKAGE = 'phylobase', ances) +} + +getAllNodesSafe <- function(edge) { + .Call('phylobase_getAllNodesSafe', PACKAGE = 'phylobase', edge) +} + +getAllNodesFast <- function(edge) { + .Call('phylobase_getAllNodesFast', PACKAGE = 'phylobase', edge) +} + +testNodes <- function(edge) { + .Call('phylobase_testNodes', PACKAGE = 'phylobase', edge) +} + +testEqInt <- function(x, y) { + .Call('phylobase_testEqInt', PACKAGE = 'phylobase', x, y) +} + +getInternalNodes <- function(edge) { + .Call('phylobase_getInternalNodes', PACKAGE = 'phylobase', edge) +} + +all_naC <- function(x) { + .Call('phylobase_all_naC', PACKAGE = 'phylobase', x) +} + +any_naC <- function(x) { + .Call('phylobase_any_naC', PACKAGE = 'phylobase', x) +} + +nb_naC <- function(x) { + .Call('phylobase_nb_naC', PACKAGE = 'phylobase', x) +} + +getRange <- function(x, na_rm) { + .Call('phylobase_getRange', PACKAGE = 'phylobase', x, na_rm) +} + +hasDuplicatedLabelsCpp <- function(label) { + .Call('phylobase_hasDuplicatedLabelsCpp', PACKAGE = 'phylobase', label) +} + +edgeIdCpp <- function(edge, type) { + .Call('phylobase_edgeIdCpp', PACKAGE = 'phylobase', edge, type) +} + +checkTreeCpp <- function(obj, opts) { + .Call('phylobase_checkTreeCpp', PACKAGE = 'phylobase', obj, opts) +} + Modified: pkg/R/checkdata.R =================================================================== --- pkg/R/checkdata.R 2014-02-12 19:38:27 UTC (rev 847) +++ pkg/R/checkdata.R 2014-02-12 19:40:48 UTC (rev 848) @@ -10,7 +10,69 @@ } checkTree <- function(object) { + + ## case of empty phylo4 object + if(nrow(object at edge) == 0 && length(object at edge.length) == 0 && + length(object at label) == 0 && length(object at edge.label) == 0) + return(TRUE) + ## get options + opt <- phylobase.options() + + ## Storage of error/warning messages + err <- wrn <- character(0) + + ## Matrix is integer + if (!is.integer(object at edge)) { + err <- c(err, "Edge matrix needs to be integer.") + } + + ## Matrix doesn't have NAs + if (any(is.na(object at edge))) { + err <- c(err, "Edge matrix cannot have NAs at this time.", + "This could only happen if singletons were allowed", + "but this is not supported by phylobase yet.") + } + + ## Having non-integer or NAs cause cryptic messages, so stop here + ## if it's the case + if (length(err)) return(err) + + ## Named slots + if (is.null(attributes(object at label)$names)) { + err <- c(err, "The label slot needs to be a named vector.") + attributes(object at label) <- list(names=character(0)) + } + if (is.null(attributes(object at edge.length)$names)) { + err <- c(err, "The edge.length slot needs to be a named vector.") + attributes(object at edge.length) <- list(names=character(0)) + } + if (is.null(attributes(object at edge.label)$names)) { + err <- c(err, "The edge.label slot needs to be a named vector.") + attributes(object at edge.label) <- list(names=character(0)) + } + + res <- checkTreeCpp(object, opts=opt) + + err <- ifelse(nzchar(res[[1]]), c(err, res[[1]]), err) + wrn <- ifelse(nzchar(res[[2]]), c(wrn, res[[2]]), wrn) + + if (!is.na(wrn)) { + wrn <- paste(wrn, collapse=", ") + warning(wrn) + } + if (!is.na(err)) { + err <- paste(err, collapse=", ") + return(err) #failures are returned as text + } + else { + return(TRUE) + } + +} + +checkTreeOld <- function(object) { + ## case of empty phylo4 object if(nrow(object at edge) == 0 && length(object at edge.length) == 0 && length(object at label) == 0 && length(object at edge.label) == 0) @@ -29,18 +91,17 @@ tips <- unique(sort(E[,2][!E[,2] %in% E[,1]])) nodes <- unique(sort(c(E))) intnodes <- nodes[!nodes %in% tips] - roots <- E[which(is.na(E[,1])),2] - nRoots <- length(roots) + nRoots <- length(which(E[,1] == 0)) ## Check edge lengths if (hasEdgeLength(object)) { if (length(object at edge.length) != nedges) err <- c(err, "edge lengths do not match number of edges") - if(!is.numeric(object at edge.length)) - err <- c(err, "edge lengths are not numeric") + ##if(!is.numeric(object at edge.length)) # not needed + ## err <- c(err, "edge lengths are not numeric") ## presumably we shouldn't allow NAs mixed ## with numeric branch lengths except at the root - if (sum(is.na(object at edge.length)) > 1) + if (sum(is.na(object at edge.length)) > (nRoots + 1)) err <- c(err, "NAs in edge lengths") ## Strip root edge branch length (if set to NA) if (any(object at edge.length[!is.na(object at edge.length)] < 0)) Modified: pkg/R/class-phylo4.R =================================================================== --- pkg/R/class-phylo4.R 2014-02-12 19:38:27 UTC (rev 847) +++ pkg/R/class-phylo4.R 2014-02-12 19:40:48 UTC (rev 848) @@ -109,7 +109,7 @@ ## edge edge <- x mode(edge) <- "integer" - #if(any(is.na(edge))) stop("NA are not allowed in edge matrix") + #if(any(is.na(edge))) stop("NA are not allowed in edge matrix") ## taken care by checkTree if(ncol(edge) > 2) warning("The edge matrix has more than two columns, ", "only the first two columns are considered.") @@ -125,9 +125,12 @@ ntips <- nTips(res) nnodes <- nNodes(res) - ## edge.length (drop elements if all are NA) + ## edge.length (drop elements if all are NA but keep the vector named) edge.length <- .createEdge(value=edge.length, edgeMat=edge, type="lengths", use.names=FALSE) - if (all(is.na(edge.length))) edge.length <- numeric() + if (all(is.na(edge.length))) { + edge.length <- numeric() + attributes(edge.length) <- list(names=character(0)) + } ## edge.label (drop NA elements) edge.label <- .createEdge(value=edge.label, edgeMat=edge, type="labels", use.names=FALSE) Modified: pkg/R/methods-phylo4.R =================================================================== --- pkg/R/methods-phylo4.R 2014-02-12 19:38:27 UTC (rev 847) +++ pkg/R/methods-phylo4.R 2014-02-12 19:40:48 UTC (rev 848) @@ -63,13 +63,10 @@ if(nrow(E) == 0) return(0) else { - ## doesn't handle reticulated networks - ## res <- sum(!E[, 2] %in% E[, 1]) - res <- sum(tabulate(na.omit(E[,1])) == 0) ## twice as fast as ... - ## change suggested by Aaron Mackey, handles reticulated networks better - ## res <- sum(!(unique(E[,2]) %in% E[,1])) - return(res) - } + ## at this time NAs are not allowed in edge matrix + ## sum(tabulate(E[, 1]) == 0) + nTipsFastCpp(E[, 1]) + } }) ## hack to ensure ape compatibility @@ -388,7 +385,7 @@ setReplaceMethod("edgeLabels", signature(x="phylo4", value="character"), function(x, ..., value) { - lbl <- .createEdge(value, x at edge, type="labels") + lbl <- .createEdge(value, x at edge, type="labels") x at edge.label <- lbl[!is.na(lbl)] if(is.character(checkval <- checkPhylo4(x))) stop(checkval) x Added: pkg/src/RcppExports.cpp =================================================================== --- pkg/src/RcppExports.cpp (rev 0) +++ pkg/src/RcppExports.cpp 2014-02-12 19:40:48 UTC (rev 848) @@ -0,0 +1,328 @@ +// This file was generated by Rcpp::compileAttributes +// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +#include + +using namespace Rcpp; + +// isLabelName +bool isLabelName(Rcpp::CharacterVector lblToCheck, Rcpp::CharacterVector lbl); +RcppExport SEXP phylobase_isLabelName(SEXP lblToCheckSEXP, SEXP lblSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::CharacterVector >::type lblToCheck(lblToCheckSEXP ); + Rcpp::traits::input_parameter< Rcpp::CharacterVector >::type lbl(lblSEXP ); + bool __result = isLabelName(lblToCheck, lbl); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// nRoots +int nRoots(Rcpp::IntegerVector ances); +RcppExport SEXP phylobase_nRoots(SEXP ancesSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type ances(ancesSEXP ); + int __result = nRoots(ances); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// tabulateTips +std::vector tabulateTips(Rcpp::IntegerVector ances); +RcppExport SEXP phylobase_tabulateTips(SEXP ancesSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type ances(ancesSEXP ); + std::vector __result = tabulateTips(ances); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// nTipsSafe +int nTipsSafe(Rcpp::IntegerVector ances); +RcppExport SEXP phylobase_nTipsSafe(SEXP ancesSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type ances(ancesSEXP ); + int __result = nTipsSafe(ances); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// nTipsFastCpp +int nTipsFastCpp(Rcpp::IntegerVector ances); +RcppExport SEXP phylobase_nTipsFastCpp(SEXP ancesSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type ances(ancesSEXP ); + int __result = nTipsFastCpp(ances); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// hasSingleton +bool hasSingleton(Rcpp::IntegerVector ances); +RcppExport SEXP phylobase_hasSingleton(SEXP ancesSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type ances(ancesSEXP ); + bool __result = hasSingleton(ances); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// hasPolytomy +bool hasPolytomy(Rcpp::IntegerVector ances); +RcppExport SEXP phylobase_hasPolytomy(SEXP ancesSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type ances(ancesSEXP ); + bool __result = hasPolytomy(ances); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// tipsSafe +Rcpp::IntegerVector tipsSafe(Rcpp::IntegerVector ances, Rcpp::IntegerVector desc); +RcppExport SEXP phylobase_tipsSafe(SEXP ancesSEXP, SEXP descSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type ances(ancesSEXP ); + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type desc(descSEXP ); + Rcpp::IntegerVector __result = tipsSafe(ances, desc); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// tipsFast +Rcpp::IntegerVector tipsFast(Rcpp::IntegerVector ances); +RcppExport SEXP phylobase_tipsFast(SEXP ancesSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type ances(ancesSEXP ); + Rcpp::IntegerVector __result = tipsFast(ances); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// getAllNodesSafe +Rcpp::IntegerVector getAllNodesSafe(Rcpp::IntegerMatrix edge); +RcppExport SEXP phylobase_getAllNodesSafe(SEXP edgeSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type edge(edgeSEXP ); + Rcpp::IntegerVector __result = getAllNodesSafe(edge); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// getAllNodesFast +Rcpp::IntegerVector getAllNodesFast(Rcpp::IntegerMatrix edge); +RcppExport SEXP phylobase_getAllNodesFast(SEXP edgeSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type edge(edgeSEXP ); + Rcpp::IntegerVector __result = getAllNodesFast(edge); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// testNodes +Rcpp::List testNodes(Rcpp::IntegerMatrix edge); +RcppExport SEXP phylobase_testNodes(SEXP edgeSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type edge(edgeSEXP ); + Rcpp::List __result = testNodes(edge); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// testEqInt +Rcpp::List testEqInt(Rcpp::IntegerVector x, Rcpp::IntegerVector y); +RcppExport SEXP phylobase_testEqInt(SEXP xSEXP, SEXP ySEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type x(xSEXP ); + Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type y(ySEXP ); + Rcpp::List __result = testEqInt(x, y); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// getInternalNodes +Rcpp::IntegerVector getInternalNodes(Rcpp::IntegerMatrix edge); +RcppExport SEXP phylobase_getInternalNodes(SEXP edgeSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type edge(edgeSEXP ); + Rcpp::IntegerVector __result = getInternalNodes(edge); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// all_naC +bool all_naC(Rcpp::NumericVector x); +RcppExport SEXP phylobase_all_naC(SEXP xSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::NumericVector >::type x(xSEXP ); + bool __result = all_naC(x); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// any_naC +bool any_naC(Rcpp::NumericVector x); +RcppExport SEXP phylobase_any_naC(SEXP xSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::NumericVector >::type x(xSEXP ); + bool __result = any_naC(x); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// nb_naC +int nb_naC(Rcpp::NumericVector x); +RcppExport SEXP phylobase_nb_naC(SEXP xSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::NumericVector >::type x(xSEXP ); + int __result = nb_naC(x); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// getRange +Rcpp::NumericVector getRange(Rcpp::NumericVector x, const bool na_rm); +RcppExport SEXP phylobase_getRange(SEXP xSEXP, SEXP na_rmSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::NumericVector >::type x(xSEXP ); + Rcpp::traits::input_parameter< const bool >::type na_rm(na_rmSEXP ); + Rcpp::NumericVector __result = getRange(x, na_rm); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// hasDuplicatedLabelsCpp +bool hasDuplicatedLabelsCpp(Rcpp::CharacterVector label); +RcppExport SEXP phylobase_hasDuplicatedLabelsCpp(SEXP labelSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::CharacterVector >::type label(labelSEXP ); + bool __result = hasDuplicatedLabelsCpp(label); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// edgeIdCpp +Rcpp::CharacterVector edgeIdCpp(Rcpp::IntegerMatrix edge, std::string type); +RcppExport SEXP phylobase_edgeIdCpp(SEXP edgeSEXP, SEXP typeSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type edge(edgeSEXP ); + Rcpp::traits::input_parameter< std::string >::type type(typeSEXP ); + Rcpp::CharacterVector __result = edgeIdCpp(edge, type); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} +// checkTreeCpp +Rcpp::List checkTreeCpp(Rcpp::S4 obj, Rcpp::List opts); +RcppExport SEXP phylobase_checkTreeCpp(SEXP objSEXP, SEXP optsSEXP) { +BEGIN_RCPP + SEXP __sexp_result; + { + Rcpp::RNGScope __rngScope; + Rcpp::traits::input_parameter< Rcpp::S4 >::type obj(objSEXP ); + Rcpp::traits::input_parameter< Rcpp::List >::type opts(optsSEXP ); + Rcpp::List __result = checkTreeCpp(obj, opts); + PROTECT(__sexp_result = Rcpp::wrap(__result)); + } + UNPROTECT(1); + return __sexp_result; +END_RCPP +} Added: pkg/src/checkPhylo4.cpp =================================================================== --- pkg/src/checkPhylo4.cpp (rev 0) +++ pkg/src/checkPhylo4.cpp 2014-02-12 19:40:48 UTC (rev 848) @@ -0,0 +1,393 @@ + +#include +#include // std::cout +#include // std::count_if +#include // std::vector +#include // +#include + +template +std::string NumberToString ( T Number ) { + std::ostringstream ss; + ss << Number; + return ss.str(); +} + +bool isZero(int i) { return (i == 0); } +bool isOne(int i) { return ( i == 1); } +bool isSupTwo(int i) { return (i > 2); } +bool isEqual(int i, int j) { return (i == j); } + +Rcpp::IntegerVector getAnces(Rcpp::IntegerMatrix obj) { +// returns the first column (ancestors) of the edge matrix + Rcpp::IntegerMatrix::Column out = obj( Rcpp::_ , 0); + return out; +} + +Rcpp::IntegerVector getDesc(Rcpp::IntegerMatrix obj) { +// returns the second column (descendants) of the edge matrix + Rcpp::IntegerMatrix::Column out = obj( Rcpp::_ , 1); + return out; +} + +//[[Rcpp::export]] +bool isLabelName(Rcpp::CharacterVector lblToCheck, + Rcpp::CharacterVector lbl ) { + + Rcpp::CharacterVector noLbl = Rcpp::setdiff(lblToCheck, lbl); + return noLbl.size() == 0; +} + +//[[Rcpp::export]] +int nRoots (Rcpp::IntegerVector ances) { + int ans = std::count (ances.begin(), ances.end(), 0); + return ans; +} + +//[[Rcpp::export]] +std::vector tabulateTips (Rcpp::IntegerVector ances) { +// tabulates ancestor nodes that are not the root. + int n = ances.size(); + std::vector ans(n); + for (Rcpp::IntegerVector::iterator it = ances.begin(); it != ances.end(); ++it) { + if (*it > 0) ans[*it - 1]++; + } + return ans; +} + +//[[Rcpp::export]] +int nTipsSafe (Rcpp::IntegerVector ances) { +// count how many zeros are in the tabulated vector of ancestors +// this gives the number of tips + std::vector tabTips = tabulateTips(ances); + int j = count_if (tabTips.begin(), tabTips.end(), isZero); + return j; +} + +//[[Rcpp::export]] +int nTipsFastCpp (Rcpp::IntegerVector ances) { +// if nodes are correctly numbered min(ances) - 1 = nb of tips +// (after removing the root, which is equal to 0). + int nroots = nRoots(ances); + if (nroots > 0) { + int whichRoot = Rcpp::which_min(ances); + ances.erase(whichRoot); + } + int tmp = Rcpp::min(ances); + return tmp - 1; +} + +//[[Rcpp::export]] +bool hasSingleton (Rcpp::IntegerVector ances) { + std::vector tabTips = tabulateTips(ances); + int j = count_if (tabTips.begin(), tabTips.end(), isOne); + return j > 0; +} + +//[[Rcpp::export]] +bool hasPolytomy (Rcpp::IntegerVector ances) { + std::vector tabTips = tabulateTips(ances); + int j = count_if (tabTips.begin(), tabTips.end(), isSupTwo); + return j > 0; +} + + +//[[Rcpp::export]] +Rcpp::IntegerVector tipsSafe (Rcpp::IntegerVector ances, Rcpp::IntegerVector desc) { + Rcpp::IntegerVector res = Rcpp::match(desc, ances); + Rcpp::LogicalVector istip = Rcpp::is_na(res); + int nedge = ances.size(); + std::vector y(nedge); + int j = 0; + for(int i = 0; i < nedge; i++) { + if (istip[i]) { + y[j] = desc[i]; + j++; + } + } + Rcpp::IntegerVector ans(j); + std::copy (y.begin(), y.begin()+j, ans.begin()); + std::sort (ans.begin(), ans.end()); + return ans; +} + +//[[Rcpp::export]] +Rcpp::IntegerVector tipsFast (Rcpp::IntegerVector ances) { + int ntips = nTipsFastCpp(ances); + Rcpp::IntegerVector ans = Rcpp::seq_len(ntips); + return ans; +} + + +//[[Rcpp::export]] +Rcpp::IntegerVector getAllNodesSafe (Rcpp::IntegerMatrix edge) { + Rcpp::IntegerVector ans = Rcpp::as_vector(edge); + Rcpp::IntegerVector tmp = Rcpp::unique(ans); + std::sort(tmp.begin(), tmp.end()); + return tmp; +} + +//[[Rcpp::export]] +Rcpp::IntegerVector getAllNodesFast (Rcpp::IntegerMatrix edge) { + Rcpp::IntegerVector tmp = Rcpp::as_vector(edge); + Rcpp::IntegerVector maxN = Rcpp::range(tmp); + Rcpp::IntegerVector ans = Rcpp::seq_len(maxN[1] + 1); + return ans - 1; +} + +//[[Rcpp::export]] +Rcpp::List testNodes (Rcpp::IntegerMatrix edge) { + Rcpp::IntegerVector allNodes = Rcpp::as_vector(edge); + allNodes = Rcpp::unique(allNodes); + std::sort (allNodes.begin(), allNodes.end()); + Rcpp::IntegerVector supposedNodes = getAllNodesFast(edge); + Rcpp::IntegerVector test = Rcpp::setdiff(supposedNodes, allNodes); + Rcpp::LogicalVector res = supposedNodes == allNodes; + return Rcpp::List::create(supposedNodes, allNodes, test, res); +} + +//[[Rcpp::export]] +Rcpp::List testEqInt (Rcpp::IntegerVector x, Rcpp::IntegerVector y) { + Rcpp::LogicalVector xy = x == y; + Rcpp::LogicalVector yx = y == x; + return Rcpp::List::create(xy, yx); +} + + +//[[Rcpp::export]] +Rcpp::IntegerVector getInternalNodes (Rcpp::IntegerMatrix edge) { + Rcpp::IntegerVector ances = getAnces(edge); + Rcpp::IntegerVector allNodes = getAllNodesFast(edge); + Rcpp::IntegerVector tips = tipsFast(ances); + Rcpp::IntegerVector intNodes = Rcpp::setdiff(allNodes, tips); + intNodes.erase(intNodes.begin()); + return intNodes; +} + +//[[Rcpp::export]] +bool all_naC (Rcpp::NumericVector x) { + return is_true(all(is_na(x))); +} + +//[[Rcpp::export]] +bool any_naC (Rcpp::NumericVector x) { + return is_true(any(is_na(x))); +} + +//[[Rcpp::export]] +int nb_naC (Rcpp::NumericVector x) { + return sum(is_na(x)); +} + + +//[[Rcpp::export]] +Rcpp::NumericVector getRange(Rcpp::NumericVector x, const bool na_rm) { + Rcpp::NumericVector out(2); + out[0] = R_PosInf; + out[1] = R_NegInf; + + int n = x.length(); + for(int i = 0; i < n; ++i) { + if (!na_rm && R_IsNA(x[i])) { + out[0] = NA_REAL; + out[1] = NA_REAL; + return(out); + } + + if (x[i] < out[0]) out[0] = x[i]; + if (x[i] > out[1]) out[1] = x[i]; + } + + return(out); +} + +//[[Rcpp::export]] +bool hasDuplicatedLabelsCpp (Rcpp::CharacterVector label) { + return is_true(any(Rcpp::duplicated(label))); +} + +std::string edgeIdCppInternal (int tmp1, int tmp2) { + std::string tmp1S = static_cast( &(std::ostringstream() << tmp1) )->str(); + std::string tmp2S = static_cast( &(std::ostringstream() << tmp2) )->str(); + tmp1S.append("-"); + tmp1S.append(tmp2S); + return tmp1S; +} + +//[[Rcpp::export]] +Rcpp::CharacterVector edgeIdCpp (Rcpp::IntegerMatrix edge, std::string type) { + Rcpp::IntegerVector ances = getAnces(edge); + Rcpp::IntegerVector desc = getDesc(edge); + + if (type == "tip" || type == "internal") { + Rcpp::IntegerVector tips = tipsFast(ances); + int ntips = tips.size(); + Rcpp::IntegerVector ans = match(tips, desc); + if (type == "tip") { + Rcpp::CharacterVector c1(ntips); + for (int j = 0; j < ntips; j++) { + int tmp1 = ances[ans[j]-1]; + int tmp2 = desc[ans[j]-1]; + c1[j] = edgeIdCppInternal(tmp1, tmp2); + } + return c1; + } + else if (type == "internal") { + int nedge = ances.size(); + Rcpp::IntegerVector idEdge = Rcpp::seq_len(nedge); + Rcpp::IntegerVector intnd = Rcpp::setdiff(idEdge, ans); + int nnd = intnd.size(); + Rcpp::CharacterVector c1(nnd); + for (int j = 0; j < nnd; j++) { + int tmp1 = ances[intnd[j]-1]; + int tmp2 = desc[intnd[j]-1]; + c1[j] = edgeIdCppInternal(tmp1, tmp2); + } + return c1; + } + } + else { + int nedge = ances.size(); + Rcpp::CharacterVector c1(nedge); + for (int j = 0; j < nedge; j++) { + int tmp1 = ances[j]; + int tmp2 = desc[j]; + c1[j] = edgeIdCppInternal(tmp1, tmp2); + } + return c1; + } +} + +//[[Rcpp::export]] +Rcpp::List checkTreeCpp(Rcpp::S4 obj, Rcpp::List opts) { + + std::string err, wrn; + Rcpp::IntegerMatrix ed = obj.slot("edge"); + int nrow = ed.nrow(); + Rcpp::IntegerVector ances = getAnces(ed); + //Rcpp::IntegerVector desc = getDesc(ed); + Rcpp::NumericVector edLength = obj.slot("edge.length"); + Rcpp::CharacterVector edLengthNm = edLength.names(); + Rcpp::CharacterVector label = obj.slot("label"); + Rcpp::CharacterVector labelNm = label.names(); + Rcpp::CharacterVector edLabel = obj.slot("edge.label"); + Rcpp::CharacterVector edLabelNm = edLabel.names(); + Rcpp::IntegerVector allnodesSafe = getAllNodesSafe(ed); + Rcpp::IntegerVector allnodesFast = getAllNodesFast(ed); + int nEdLength = edLength.size(); + int nLabel = label.size(); + int nEdLabel = edLabel.size(); + int nEdges = nrow; + bool hasEdgeLength = !all_naC(edLength); + int nroots = nRoots(ances); + + // check tips + int ntipsSafe = nTipsSafe(ances); + int ntipsFast = nTipsFastCpp(ances); + bool testnTips = ntipsFast == ntipsSafe; + if (! testnTips) { + err.append("Tips incorrectly labeled. "); + } + + //check internal nodes + bool testNodes = Rcpp::all(allnodesSafe == allnodesFast).is_true() && // is both ways comparison needed? + Rcpp::all(allnodesFast == allnodesSafe).is_true(); + if (! testNodes) { + err.append("Nodes incorrectly labeled. "); + } + + // check edge lengths + if (hasEdgeLength) { + if (nEdLength != nEdges) { + err.append("Number of edge lengths do not match number of edges. "); + } + if (nb_naC(edLength) > (nroots + 1)) { + err.append("Only the root should have NA as an edge length. "); + } + if (getRange(edLength, TRUE)[0] < 0) { + err.append("Edge lengths must be non-negative. "); + } + Rcpp::CharacterVector edgeLblSupp = edgeIdCpp(ed, "all"); + Rcpp::CharacterVector edgeLblDiff = Rcpp::setdiff(edLengthNm, edgeLblSupp); + if ( edgeLblDiff.size() != 0 ) { + err.append("Edge lengths incorrectly labeled. "); + } + } + + // check label names + Rcpp::CharacterVector chrLabelNm = Rcpp::as(allnodesFast); + int j = 0; + while (j < nroots) { //remove root(s) + chrLabelNm.erase(0); + j++; + } + bool testLabelNm = isLabelName(labelNm, chrLabelNm); + if (!testLabelNm) { + err.append("Tip and node labels must be a named vector, the names must match the node IDs. "); + err.append("Use tipLabels<- and/or nodeLabels<- to update them. "); + } + + // check that tips have labels + Rcpp::CharacterVector tiplabel(ntipsFast); + std::copy (label.begin(), label.begin()+ntipsFast, tiplabel.begin()); + bool emptyTipLabel = is_true(any(Rcpp::is_na(tiplabel))); + if ( emptyTipLabel ) { + err.append("All tips must have a label."); + } + + // check edgeLabels + Rcpp::CharacterVector chrEdgeLblNm = edgeIdCpp(ed, "all"); + bool testEdgeLblNm = isLabelName(edLabelNm, chrEdgeLblNm); + if (!testEdgeLblNm) { + err.append("Edge labels are not labelled correctly. Use the function edgeLabels<- to update them. "); + } + + // make sure that tips and node labels are unique + if (hasDuplicatedLabelsCpp(label)) { + std::string labOpt = opts["allow.duplicated.labels"]; + if (labOpt == "fail") { + err.append("Labels are not unique. "); + } + if (labOpt == "warn") { + wrn.append("Labels are not unique. "); + } + } + + // check for polytomies + if (hasPolytomy(ances)) { + std::string msgPoly = "Tree includes polytomies. "; + std::string polyOpt = opts["poly"]; + if (polyOpt == "fail") { + err.append(msgPoly); + } + if (polyOpt == "warn") { + wrn.append(msgPoly); + } + } + + // check number of roots + if (nroots > 1) { + std::string msgRoot = "Tree has more than one root. "; + std::string rootOpt = opts["multiroot"]; + if (rootOpt == "fail") { + err.append(msgRoot); + } + if (rootOpt == "warn") { + wrn.append(msgRoot); + } + } + + // check for singletons + if (hasSingleton(ances)) { + std::string msgSing = "Tree contains singleton nodes. "; + std::string singOpt = opts["singleton"]; + if (singOpt == "fail") { + err.append(msgSing); + } + if (singOpt == "warn") { + wrn.append(msgSing); + } + } + + return Rcpp::List::create(err, wrn); +} Added: pkg/src/symbols.rds =================================================================== (Binary files differ) Property changes on: pkg/src/symbols.rds ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From noreply at r-forge.r-project.org Thu Feb 13 17:12:22 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 13 Feb 2014 17:12:22 +0100 (CET) Subject: [Phylobase-commits] r849 - pkg/inst/nexusfiles Message-ID: <20140213161222.7EE1518502B@r-forge.r-project.org> Author: francois Date: 2014-02-13 17:12:22 +0100 (Thu, 13 Feb 2014) New Revision: 849 Added: pkg/inst/nexusfiles/NastyLabels.nex pkg/inst/nexusfiles/NastyLabels2.nex pkg/inst/nexusfiles/minNex.nex pkg/inst/nexusfiles/minSeq.nex pkg/inst/nexusfiles/shorebird_underscore.nex pkg/inst/nexusfiles/treeWithSpecialCharacters.nex Log: updating nexus files, not sure if needed Added: pkg/inst/nexusfiles/NastyLabels.nex =================================================================== --- pkg/inst/nexusfiles/NastyLabels.nex (rev 0) +++ pkg/inst/nexusfiles/NastyLabels.nex 2014-02-13 16:12:22 UTC (rev 849) @@ -0,0 +1,56 @@ +#NEXUS +[Data from Gavin Thomas] +BEGIN TAXA; + DIMENSIONS NTAX = 11; + TAXLABELS + subterraneus + Mus_musculus + H._sapiens + 'H. sapiens #429' + 'Fred''s new sp.' + 'rusticus (1)' + '"shoal bass"' + AMNION + _23 + x21.02 + myType + ; +end; + +BEGIN CHARACTERS; + DIMENSIONS NCHAR=1; + FORMAT DATATYPE = STANDARD SYMBOLS="0 1"; + CHARSTATELABELS + 1 aCharacter / on off; + MATRIX + subterraneus 0 + Mus_musculus 1 + H._sapiens 0 + 'H. sapiens #429' 1 + 'Fred''s new sp.' 0 + 'rusticus (1)' 1 + '"shoal bass"' 0 + AMNION 1 + _23 0 + x21.02 1 + myType 0 + ; +END; + +BEGIN TREES; + TRANSLATE + 1 subterraneus, + 2 Mus_musculus, + 3 H._sapiens, + 4 'H. sapiens #429', + 5 'Fred''s new sp.', + 6 'rusticus (1)', + 7 '"shoal bass"', + 8 AMNION, + 9 _23, + 10 x21.02, + 11 myType + ; + TREE * COMB = (1,(2,(3,(4,(5,(6,(7,(8,(9,(10,11)))))))))); +end; + Added: pkg/inst/nexusfiles/NastyLabels2.nex =================================================================== --- pkg/inst/nexusfiles/NastyLabels2.nex (rev 0) +++ pkg/inst/nexusfiles/NastyLabels2.nex 2014-02-13 16:12:22 UTC (rev 849) @@ -0,0 +1,52 @@ +#NEXUS + + +begin data; + dimensions ntax=17 nchar=432; + format datatype=dna missing=?; + matrix + 'h uman' ctgactcctgaggagaagtctgccgttactgccctgtggggcaaggtgaacgtggatgaagttggtggtgaggccctgggcaggctgctggtggtctacccttggacccagaggttctttgagtcctttggggatctgtccactcctgatgctgttatgggcaaccctaaggtgaaggctcatggcaagaaagtgctcggtgcctttagtgatggcctggctcacctggacaacctcaagggcacctttgccacactgagtgagctgcactgtgacaagctgcacgtggatcctgagaacttcaggctcctgggcaacgtgctggtctgtgtgctggcccatcactttggcaaagaattcaccccaccagtgcaggctgcctatcagaaagtggtggctggtgtggctaatgccctggcccacaagtatcac + t_arsier ctgactgctgaagagaaggccgccgtcactgccctgtggggcaaggtagacgtggaagatgttggtggtgaggccctgggcaggctgctggtcgtctacccatggacccagaggttctttgactcctttggggacctgtccactcctgccgctgttatgagcaatgctaaggtcaaggcccatggcaaaaaggtgctgaacgcctttagtgacggcatggctcatctggacaacctcaagggcacctttgctaagctgagtgagctgcactgtgacaaattgcacgtggatcctgagaatttcaggctcttgggcaatgtgctggtgtgtgtgctggcccaccactttggcaaagaattcaccccgcaggttcaggctgcctatcagaaggtggtggctggtgtggctactgccttggctcacaagtaccac + 'b_ushbaby' ctgactcctgatgagaagaatgccgtttgtgccctgtggggcaaggtgaatgtggaagaagttggtggtgaggccctgggcaggctgctggttgtctacccatggacccagaggttctttgactcctttggggacctgtcctctccttctgctgttatgggcaaccctaaagtgaaggcccacggcaagaaggtgctgagtgcctttagcgagggcctgaatcacctggacaacctcaagggcacctttgctaagctgagtgagctgcattgtgacaagctgcacgtggaccctgagaacttcaggctcctgggcaacgtgctggtggttgtcctggctcaccactttggcaaggatttcaccccacaggtgcaggctgcctatcagaaggtggtggctggtgtggctactgccctggctcacaaataccac + 'ha re' ctgtccggtgaggagaagtctgcggtcactgccctgtggggcaaggtgaatgtggaagaagttggtggtgagaccctgggcaggctgctggttgtctacccatggacccagaggttcttcgagtcctttggggacctgtccactgcttctgctgttatgggcaaccctaaggtgaaggctcatggcaagaaggtgctggctgccttcagtgagggtctgagtcacctggacaacctcaaaggcaccttcgctaagctgagtgaactgcattgtgacaagctgcacgtggatcctgagaacttcaggctcctgggcaacgtgctggttattgtgctgtctcatcactttggcaaagaattcactcctcaggtgcaggctgcctatcagaaggtggtggctggtgtggccaatgccctggctcacaaataccac + 'ra\bbit' ctgtccagtgaggagaagtctgcggtcactgccctgtggggcaaggtgaatgtggaagaagttggtggtgaggccctgggcaggctgctggttgtctacccatggacccagaggttcttcgagtcctttggggacctgtcctctgcaaatgctgttatgaacaatcctaaggtgaaggctcatggcaagaaggtgctggctgccttcagtgagggtctgagtcacctggacaacctcaaaggcacctttgctaagctgagtgaactgcactgtgacaagctgcacgtggatcctgagaacttcaggctcctgggcaacgtgctggttattgtgctgtctcatcattttggcaaagaattcactcctcaggtgcaggctgcctatcagaaggtggtggctggtgtggccaatgccctggctcacaaataccac + 'co''w' ctgactgctgaggagaaggctgccgtcaccgccttttggggcaaggtgaaagtggatgaagttggtggtgaggccctgggcaggctgctggttgtctacccctggactcagaggttctttgagtcctttggggacttgtccactgctgatgctgttatgaacaaccctaaggtgaaggcccatggcaagaaggtgctagattcctttagtaatggcatgaagcatctcgatgacctcaagggcacctttgctgcgctgagtgagctgcactgtgataagctgcatgtggatcctgagaacttcaagctcctgggcaacgtgctagtggttgtgctggctcgcaattttggcaaggaattcaccccggtgctgcaggctgactttcagaaggtggtggctggtgtggccaatgccctggcccacagatatcat + 'sh"eep' ctgactgctgaggagaaggctgccgtcaccggcttctggggcaaggtgaaagtggatgaagttggtgctgaggccctgggcaggctgctggttgtctacccctggactcagaggttctttgagcactttggggacttgtccaatgctgatgctgttatgaacaaccctaaggtgaaggcccatggcaagaaggtgctagactcctttagtaacggcatgaagcatctcgatgacctcaagggcacctttgctcagctgagtgagctgcactgtgataagctgcacgtggatcctgagaacttcaggctcctgggcaacgtgctggtggttgtgctggctcgccaccatggcaatgaattcaccccggtgctgcaggctgactttcagaaggtggtggctggtgttgccaatgccctggcccacaaatatcac + pig ctgtctgctgaggagaaggaggccgtcctcggcctgtggggcaaagtgaatgtggacgaagttggtggtgaggccctgggcaggctgctggttgtctacccctggactcagaggttcttcgagtcctttggggacctgtccaatgccgatgccgtcatgggcaatcccaaggtgaaggcccacggcaagaaggtgctccagtccttcagtgacggcctgaaacatctcgacaacctcaagggcacctttgctaagctgagcgagctgcactgtgaccagctgcacgtggatcctgagaacttcaggctcctgggcaacgtgatagtggttgttctggctcgccgccttggccatgacttcaacccgaatgtgcaggctgcttttcagaaggtggtggctggtgttgctaatgccctggcccacaagtaccac + elephseal ttgacggcggaggagaagtctgccgtcacctccctgtggggcaaagtgaaggtggatgaagttggtggtgaagccctgggcaggctgctggttgtctacccctggactcagaggttctttgactcctttggggacctgtcctctcctaatgctattatgagcaaccccaaggtcaaggcccatggcaagaaggtgctgaattcctttagtgatggcctgaagaatctggacaacctcaagggcacctttgctaagctcagtgagctgcactgtgaccagctgcatgtggatcccgagaacttcaagctcctgggcaatgtgctggtgtgtgtgctggcccgccactttggcaaggaattcaccccacagatgcagggtgcctttcagaaggtggtagctggtgtggccaatgccctcgcccacaaatatcac + rat ctaactgatgctgagaaggctgctgttaatgccctgtggggaaaggtgaaccctgatgatgttggtggcgaggccctgggcaggctgctggttgtctacccttggacccagaggtactttgatagctttggggacctgtcctctgcctctgctatcatgggtaaccctaaggtgaaggcccatggcaagaaggtgataaacgccttcaatgatggcctgaaacacttggacaacctcaagggcacctttgctcatctgagtgaactccactgtgacaagctgcatgtggatcctgagaacttcaggctcctgggcaatatgattgtgattgtgttgggccaccacctgggcaaggaattcaccccctgtgcacaggctgccttccagaaggtggtggctggagtggccagtgccctggctcacaagtaccac + mouse ctgactgatgctgagaagtctgctgtctcttgcctgtgggcaaaggtgaaccccgatgaagttggtggtgaggccctgggcaggctgctggttgtctacccttggacccagcggtactttgatagctttggagacctatcctctgcctctgctatcatgggtaatcccaaggtgaaggcccatggcaaaaaggtgataactgcctttaacgagggcctgaaaaacctggacaacctcaagggcacctttgccagcctcagtgagctccactgtgacaagctgcatgtggatcctgagaacttcaggctcctaggcaatgcgatcgtgattgtgctgggccaccacctgggcaaggatttcacccctgctgcacaggctgccttccagaaggtggtggctggagtggccactgccctggctcacaagtaccac + hamster ctgactgatgctgagaaggcccttgtcactggcctgtggggaaaggtgaacgccgatgcagttggcgctgaggccctgggcaggttgctggttgtctacccttggacccagaggttctttgaacactttggagacctgtctctgccagttgctgtcatgaataacccccaggtgaaggcccatggcaagaaggtgatccactccttcgctgatggcctgaaacacctggacaacctgaagggcgccttttccagcctgagtgagctccactgtgacaagctgcacgtggatcctgagaacttcaagctcctgggcaatatgatcatcattgtgctgatccacgacctgggcaaggacttcactcccagtgcacagtctgcctttcataaggtggtggctggtgtggccaatgccctggctcacaagtaccac + marsupial ttgacttctgaggagaagaactgcatcactaccatctggtctaaggtgcaggttgaccagactggtggtgaggcccttggcaggatgctcgttgtctacccctggaccaccaggttttttgggagctttggtgatctgtcctctcctggcgctgtcatgtcaaattctaaggttcaagcccatggtgctaaggtgttgacctccttcggtgaagcagtcaagcatttggacaacctgaagggtacttatgccaagttgagtgagctccactgtgacaagctgcatgtggaccctgagaacttcaagatgctggggaatatcattgtgatctgcctggctgagcactttggcaaggattttactcctgaatgtcaggttgcttggcagaagctcgtggctggagttgcccatgccctggcccacaagtaccac + duck tggacagccgaggagaagcagctcatcaccggcctctggggcaaggtcaatgtggccgactgtggagctgaggccctggccaggctgctgatcgtctacccctggacccagaggttcttcgcctccttcgggaacctgtccagccccactgccatccttggcaaccccatggtccgtgcccatggcaagaaagtgctcacctccttcggagatgctgtgaagaacctggacaacatcaagaacaccttcgcccagctgtccgagctgcactgcgacaagctgcacgtggaccctgagaacttcaggctcctgggtgacatcctcatcatcgtcctggccgcccacttcaccaaggatttcactcctgactgccaggccgcctggcagaagctggtccgcgtggtggcccacgctctggcccgcaagtaccac + chicken tggactgctgaggagaagcagctcatcaccggcctctggggcaaggtcaatgtggccgaatgtggggccgaagccctggccaggctgctgatcgtctacccctggacccagaggttctttgcgtcctttgggaacctctccagccccactgccatccttggcaaccccatggtccgcgcccacggcaagaaagtgctcacctcctttggggatgctgtgaagaacctggacaacatcaagaacaccttctcccaactgtccgaactgcattgtgacaagctgcatgtggaccccgagaacttcaggctcctgggtgacatcctcatcattgtcctggccgcccacttcagcaaggacttcactcctgaatgccaggctgcctggcagaagctggtccgcgtggtggcccatgccctggctcgcaagtaccac + xenlaev tggacagctgaagagaaggccgccatcacttctgtatggcagaaggtcaatgtagaacatgatggccatgatgccctgggcaggctgctgattgtgtacccctggacccagagatacttcagtaactttggaaacctctccaattcagctgctgttgctggaaatgccaaggttcaagcccatggcaagaaggttctttcagctgttggcaatgccattagccatattgacagtgtgaagtcctctctccaacaactcagtaagatccatgccactgaactgtttgtggaccctgagaactttaagcgttttggtggagttctggtcattgtcttgggtgccaaactgggaactgccttcactcctaaagttcaggctgcttgggagaaattcattgcagttttggttgatggtcttagccagggctataac + xentrop tggacagctgaagaaaaagcaaccattgcttctgtgtgggggaaagtcgacattgaacaggatggccatgatgcattatccaggctgctggttgtttatccctggactcagaggtacttcagcagttttggaaacctctccaatgtctccgctgtctctggaaatgtcaaggttaaagcccatggaaataaagtcctgtcagctgttggcagtgcaatccagcatctggatgatgtgaagagccaccttaaaggtcttagcaagagccatgctgaggatcttcatgtggatcccgaaaacttcaagcgccttgcggatgttctggtgatcgttctggctgccaaacttggatctgccttcactccccaagtccaagctgtctgggagaagctcaatgcaactctggtggctgctcttagccatggctacttc + ; +end; + + +begin mrbayes; + [The following block illustrates how to set up two data partitions + and use different models for the different partitions.] + charset non_coding = 1-90 358-432; + charset coding = 91-357; + partition region = 2:non_coding,coding; + set partition = region; + + [The following lines set a codon model for the second data partition (coding) and + allows the non_coding and coding partitions to have different overall rates.] + lset applyto=(2) nucmodel=codon; + prset ratepr=variable; + + [Codon models are computationally complex so the following lines set the parameters + of the MCMC such that only 1 chain is run for 100 generations and results are printed + to screen and to file every tenth generation. To start this chain, you need to type + 'mcmc' after executing this block. You need to run the chain longer to get adequate + convergence.] + mcmcp ngen=100 nchains=1 printfreq=10 samplefreq=10; +end; + + + + Added: pkg/inst/nexusfiles/minNex.nex =================================================================== --- pkg/inst/nexusfiles/minNex.nex (rev 0) +++ pkg/inst/nexusfiles/minNex.nex 2014-02-13 16:12:22 UTC (rev 849) @@ -0,0 +1,56 @@ +#NEXUS + +BEGIN TAXA; + DIMENSIONS NTAX=4; + TAXLABELS + spA spB spC spD + ; + +END; + +BEGIN TREES; + TRANSLATE + 1 spA, + 2 spB, + 3 spC, + 4 spD; + TREE testTree = (1,(2,(3,4))); +END; + +BEGIN CHARACTERS; + TITLE 'TestContinuous'; + DIMENSIONS NCHAR=3; + FORMAT DATATYPE = CONTINUOUS; + CHARSTATELABELS + 1 char1, + 2 char2, + 3 char3; + MATRIX + spB 0.21 0.22 0.23 + spA 0.11 0.12 0.13 + spD 0.41 0.42 0.43 + spC 0.31 0.32 0.33 + ; +END; + +BEGIN CHARACTERS; + TITLE 'TestStd'; + DIMENSIONS NCHAR=3; + FORMAT DATATYPE = STANDARD + MISSING = ? + SYMBOLS = "0 1 2"; + CHARSTATELABELS + 1 char1 / state11 state12 state13, + 2 char2 / state21 state22 state23, + 3 char3 / state31 state32 state33; + MATRIX + spA 1 (0 1) ? + spB 2 (1 2) 0 + spC 0 (0 1 2) 1 + spD 1 2 0 + ; +END; + +[BEGIN ASSUMPTIONS; + EXSET * UNTITLED = 3; +END;] Added: pkg/inst/nexusfiles/minSeq.nex =================================================================== --- pkg/inst/nexusfiles/minSeq.nex (rev 0) +++ pkg/inst/nexusfiles/minSeq.nex 2014-02-13 16:12:22 UTC (rev 849) @@ -0,0 +1,12 @@ +#NEXUS + + +begin data; + dimensions ntax=3 nchar=4; + format datatype=dna missing=?; + matrix + seq1 atcg + seq2 tcga + seq3 cgat + ; +end; Added: pkg/inst/nexusfiles/shorebird_underscore.nex =================================================================== --- pkg/inst/nexusfiles/shorebird_underscore.nex (rev 0) +++ pkg/inst/nexusfiles/shorebird_underscore.nex 2014-02-13 16:12:22 UTC (rev 849) @@ -0,0 +1,321 @@ +#NEXUS +[Data from Gavin Thomas] +BEGIN TAXA; + DIMENSIONS NTAX = 71; + TAXLABELS + Catoptrophorus_semipalmatus + Tringa_ochropus + Tringa_stagnatilis + Tringa_flavipes + Tringa_nebularia + Tringa_totanus + Tringa_erythropus + Tringa_melanoleuca + Tringa_glareola + Steganopus_tricolor + Phalaropus_lobatus + Phalaropus_fulicaria + Micropalama_himantopus + Eurynorhynchus_pygmeus + Aphriza_virgata + Calidris_canutus + Calidris_tenuirostris + Calidris_temminckii + Calidris_maritima + Calidris_ptilocnemis + Calidris_mauri + Calidris_alba + Calidris_alpina + Calidris_bairdii + Calidris_minutilla + Calidris_pusilla + Calidris_minuta + Calidris_ruficollis + Calidris_subminuta + Arenaria_interpres + Arenaria_melanocephala + Tringa_hypoleucos + Tringa_macularia + Limnodromus_griseus + Gallinago_gallinago + Coenocorypha_aucklandica + Coenocorypha_pusilla + Limosa_fedoa + Limosa_haemastica + Limosa_limosa + Limosa_lapponica + Bartramia_longicauda + Numenius_tahitiensis + Numenius_phaeopus + Numenius_arquata + Numenius_americanus + Rostratula_benghalensis + Jacana_spinosa + Jacana_jacana + Metopidius_indicus + Actophilornis_africanus + Pedionomus_torquatus + Pluvialis_apricaria + Pluvialis_dominica + Eudromias_morinellus + Charadrius_montanus + Charadrius_vociferus + Charadrius_wilsonia + Charadrius_dubius + Charadrius_hiaticula + Charadrius_melodus + Vanellus_vanellus + Vanellus_lugubris + Vanellus_armatus + Recurvirostra_avosetta + Haematopus_longirostris + Haematopus_fuliginosus + Haematopus_moquini + Haematopus_ostralegus + Haematopus_unicolor + Haematopus_finschi + ; +END; + +BEGIN CHARACTERS; + TITLE MassClutchSize; + DIMENSIONS NCHAR=4; + FORMAT DATATYPE = CONTINUOUS; + CHARSTATELABELS + 1 malemass, + 2 femalemass, + 3 eggmass, + 4 clutchsize; + MATRIX + Actophilornis_africanus 143.2 260.7 8.6 4.00 + Aphriza_virgata 186.3 216.3 22.4 4.00 + Arenaria_interpres 108.0 113.0 17.9 3.50 + Arenaria_melanocephala 113.6 124.2 17.3 4.00 + Bartramia_longicauda 151.0 164.0 23.5 3.99 + Calidris_alba 52.8 55.4 11.2 3.90 + Calidris_alpina 41.0 45.1 10.7 3.90 + Calidris_bairdii 39.3 39.7 9.6 4.00 + Calidris_canutus 126.0 148.0 19.3 3.70 + Calidris_maritima 67.6 76.3 13.3 3.90 + Calidris_mauri 28.0 31.0 7.5 3.90 + Calidris_minuta 24.0 27.1 6.3 3.80 + Calidris_minutilla 20.3 22.2 6.4 3.90 + Calidris_ptilocnemis 76.3 83.0 14.2 4.00 + Calidris_pusilla 25.0 27.0 6.9 4.00 + Calidris_ruficollis 25.7 26.6 8.3 4.00 + Calidris_subminuta 29.0 32.0 7.5 4.00 + Calidris_temminckii 24.3 27.8 5.8 4.00 + Calidris_tenuirostris 156.0 174.0 22.0 4.00 + Catoptrophorus_semipalmatus 273.0 301.4 39.5 4.00 + Charadrius_dubius 38.3 39.2 7.7 3.90 + Charadrius_hiaticula 63.5 64.7 10.9 3.80 + Charadrius_melodus 54.9 55.6 9.4 3.30 + Charadrius_montanus 102.0 114.0 16.5 3.00 + Charadrius_vociferus 92.1 101.0 14.5 4.00 + Charadrius_wilsonia 59.0 63.0 12.4 3.00 + Coenocorypha_aucklandica 101.2 116.1 23.7 2.00 + Coenocorypha_pusilla 75.9 85.4 16.1 2.10 + Eudromias_morinellus 100.0 117.0 17.0 2.90 + Eurynorhynchus_pygmeus 31.0 34.6 8.0 4.00 + Gallinago_gallinago 111.0 128.0 16.5 3.90 + Haematopus_finschi 517.0 554.0 44.2 2.33 + Haematopus_fuliginosus 740.3 778.5 69.5 2.00 + Haematopus_longirostris 602.3 626.3 49.0 2.50 + Haematopus_moquini 668.0 730.0 55.8 1.70 + Haematopus_ostralegus 500.0 536.0 46.7 2.80 + Haematopus_unicolor 717.0 734.0 48.2 2.40 + Jacana_jacana 108.3 142.8 9.7 3.50 + Jacana_spinosa 86.9 145.4 8.3 4.00 + Limnodromus_griseus 111.0 116.0 17.5 4.10 + Limosa_fedoa 320.0 421.0 44.5 4.10 + Limosa_haemastica 222.0 289.0 37.5 4.00 + Limosa_lapponica 313.0 354.0 37.0 3.72 + Limosa_limosa 264.0 315.0 39.0 3.90 + Metopidius_indicus 176.2 282.4 11.9 4.00 + Micropalama_himantopus 55.8 60.4 11.2 3.90 + Numenius_americanus 640.1 758.6 73.0 4.00 + Numenius_arquata 662.0 788.0 76.0 3.90 + Numenius_phaeopus 368.0 398.0 50.0 3.90 + Numenius_tahitiensis 378.0 489.0 54.8 4.00 + Pedionomus_torquatus 54.0 72.4 10.0 3.60 + Phalaropus_fulicaria 50.8 61.0 7.5 3.80 + Phalaropus_lobatus 32.4 37.4 6.3 4.00 + Pluvialis_apricaria 175.0 176.0 32.8 3.90 + Pluvialis_dominica 145.0 146.0 26.0 4.00 + Recurvirostra_avosetta 258.0 288.0 31.7 3.90 + Rostratula_benghalensis 146.0 159.0 12.4 4.00 + Steganopus_tricolor 50.2 68.1 9.4 4.00 + Tringa_erythropus 142.0 161.0 24.5 4.00 + Tringa_flavipes 80.0 83.7 17.4 4.00 + Tringa_glareola 62.0 73.0 13.5 4.00 + Tringa_hypoleucos 45.5 50.0 12.5 3.90 + Tringa_macularia 36.9 48.0 9.0 4.00 + Tringa_melanoleuca 164.0 176.0 27.9 3.70 + Tringa_nebularia 172.0 175.0 30.5 3.90 + Tringa_ochropus 75.0 85.0 15.5 3.90 + Tringa_stagnatilis 67.1 76.0 14.0 4.00 + Tringa_totanus 123.0 135.0 22.3 4.00 + Vanellus_armatus 162.0 167.0 16.5 3.10 + Vanellus_lugubris 109.5 113.0 13.7 3.00 + Vanellus_vanellus 211.0 226.0 25.5 3.90 + ; +END; + +BEGIN CHARACTERS; + TITLE MatingSystem; + DIMENSIONS NCHAR=1; + FORMAT DATATYPE = STANDARD SYMBOLS="0 1 2"; + CHARSTATELABELS + 1 matingSystem / Monogamous Polygynous Polyandrous; + MATRIX + Actophilornis_africanus 2 + Aphriza_virgata 0 + Arenaria_interpres 0 + Arenaria_melanocephala 0 + Bartramia_longicauda 0 + Calidris_alba 2 + Calidris_alpina 0 + Calidris_bairdii 0 + Calidris_canutus 0 + Calidris_maritima 0 + Calidris_mauri 0 + Calidris_minuta 2 + Calidris_minutilla 0 + Calidris_ptilocnemis 0 + Calidris_pusilla 0 + Calidris_ruficollis 0 + Calidris_subminuta 0 + Calidris_temminckii 2 + Calidris_tenuirostris 0 + Catoptrophorus_semipalmatus 0 + Charadrius_dubius 0 + Charadrius_hiaticula 0 + Charadrius_melodus 0 + Charadrius_montanus 2 + Charadrius_vociferus 0 + Charadrius_wilsonia 0 + Coenocorypha_aucklandica 1 + Coenocorypha_pusilla 0 + Eudromias_morinellus 2 + Eurynorhynchus_pygmeus 0 + Gallinago_gallinago 0 + Haematopus_finschi 0 + Haematopus_fuliginosus 0 + Haematopus_longirostris 0 + Haematopus_moquini 0 + Haematopus_ostralegus 0 + Haematopus_unicolor 0 + Jacana_jacana 2 + Jacana_spinosa 2 + Limnodromus_griseus 0 + Limosa_fedoa 0 + Limosa_haemastica 0 + Limosa_lapponica 0 + Limosa_limosa 0 + Metopidius_indicus 2 + Micropalama_himantopus 0 + Numenius_americanus 0 + Numenius_arquata 0 + Numenius_phaeopus 0 + Numenius_tahitiensis 0 + Pedionomus_torquatus 2 + Phalaropus_fulicaria 2 + Phalaropus_lobatus 2 + Pluvialis_apricaria 0 + Pluvialis_dominica 0 + Recurvirostra_avosetta 0 + Rostratula_benghalensis 2 + Steganopus_tricolor 2 + Tringa_erythropus 0 + Tringa_flavipes 0 + Tringa_glareola 0 + Tringa_hypoleucos 0 + Tringa_macularia 2 + Tringa_melanoleuca 0 + Tringa_nebularia 0 + Tringa_ochropus 0 + Tringa_stagnatilis 0 + Tringa_totanus 0 + Vanellus_armatus 0 + Vanellus_lugubris 0 + Vanellus_vanellus 1 + ; +END; + + +BEGIN TREES; + TRANSLATE + 1 Catoptrophorus_semipalmatus, + 2 Tringa_ochropus, + 3 Tringa_stagnatilis, + 4 Tringa_flavipes, + 5 Tringa_nebularia, + 6 Tringa_totanus, + 7 Tringa_erythropus, + 8 Tringa_melanoleuca, + 9 Tringa_glareola, + 10 Steganopus_tricolor, + 11 Phalaropus_lobatus, + 12 Phalaropus_fulicaria, + 13 Micropalama_himantopus, + 14 Eurynorhynchus_pygmeus, + 15 Aphriza_virgata, + 16 Calidris_canutus, + 17 Calidris_tenuirostris, + 18 Calidris_temminckii, + 19 Calidris_maritima, + 20 Calidris_ptilocnemis, + 21 Calidris_mauri, + 22 Calidris_alba, + 23 Calidris_alpina, + 24 Calidris_bairdii, + 25 Calidris_minutilla, + 26 Calidris_pusilla, + 27 Calidris_minuta, + 28 Calidris_ruficollis, + 29 Calidris_subminuta, + 30 Arenaria_interpres, + 31 Arenaria_melanocephala, + 32 Tringa_hypoleucos, + 33 Tringa_macularia, + 34 Limnodromus_griseus, + 35 Gallinago_gallinago, + 36 Coenocorypha_aucklandica, + 37 Coenocorypha_pusilla, + 38 Limosa_fedoa, + 39 Limosa_haemastica, + 40 Limosa_limosa, + 41 Limosa_lapponica, + 42 Bartramia_longicauda, + 43 Numenius_tahitiensis, + 44 Numenius_phaeopus, + 45 Numenius_arquata, + 46 Numenius_americanus, + 47 Rostratula_benghalensis, + 48 Jacana_spinosa, + 49 Jacana_jacana, + 50 Metopidius_indicus, + 51 Actophilornis_africanus, + 52 Pedionomus_torquatus, + 53 Pluvialis_apricaria, + 54 Pluvialis_dominica, + 55 Eudromias_morinellus, + 56 Charadrius_montanus, + 57 Charadrius_vociferus, + 58 Charadrius_wilsonia, + 59 Charadrius_dubius, + 60 Charadrius_hiaticula, + 61 Charadrius_melodus, + 62 Vanellus_vanellus, + 63 Vanellus_lugubris, + 64 Vanellus_armatus, + 65 Recurvirostra_avosetta, + 66 Haematopus_longirostris, + 67 Haematopus_fuliginosus, + 68 Haematopus_moquini, + 69 Haematopus_ostralegus, + 70 Haematopus_unicolor, + 71 Haematopus_finschi + ; + TREE * UNTITLED = [&R] ((((((((1:19.701,(2:19.086,((3:13.762,4:13.762,5:13.762,6:13.762,(7:5.324,8:5.324):8.438):3.114,9:16.876):2.21):0.615):2.499,(10:3.42,(11:2.158,12:2.158):1.262):18.78):9.9,((13:17.413,14:17.413,(15:6.019,(16:3.798,17:3.798):2.221):11.394,(18:10.013,((19:2.588,20:2.588):6.989,(21:9.142,(22:8.707,((23:7.836,(24:7.4,(25:6.965,(26:3.483,27:3.483):3.482):0.435):0.436):0.435,(28:2.609,29:2.609):5.662):0.436):0.435):0.435):0.436):7.4):9.287,(30:5.68,31:5.68):21.02):5.4,(32:5.779,33:5.779):26.320999):2.3,(34:23.8,(35:22.8,(36:4.91,37:4.91):17.889999):1):10.6):2.6,(38:11.739,(39:9.303,(40:5.869,41:5.869):3.434):2.436):25.261):13.4,(42:20.299,(43:14.869,(44:10.15,(45:6.404,46:6.404):3.746):4.719):5.43):30.101):13.4,((47:43.3,((48:10.8,49:10.8):21.6,(50:19.845,51:19.845):12.555):10.9):8.8,52:52.099999):11.7):18.072,(((53:8.33,54:8.33):23.437001,((55:26.700001,(56:22.991999,((57:5.548,58:5.548):10.027,(59:12.882,(60:8.793,61:8.793):4.089):2.693):7.417):3.708):3,(62:22.961,63:22.960999,64:22.961):6.739):2.067):1.033,(65:19.1,(66:14.817,(67:12.849,(68:11.072,(69:4.283,70:4.283):6.789,71:11.072):1.777):1.968):4.283):13.7):49.071998); +END; Added: pkg/inst/nexusfiles/treeWithSpecialCharacters.nex =================================================================== --- pkg/inst/nexusfiles/treeWithSpecialCharacters.nex (rev 0) +++ pkg/inst/nexusfiles/treeWithSpecialCharacters.nex 2014-02-13 16:12:22 UTC (rev 849) @@ -0,0 +1,35 @@ +#NEXUS + +BEGIN TAXA; + DIMENSIONS NTAX=6; + TAXLABELS + Species_1 'Species 2' 'Species 3' 'Species/4' 'Species\5' 'Species"6' + ; +END; + +BEGIN CHARACTERS; + TITLE TestCharacters; + DIMENSIONS NCHAR=2; + FORMAT DATATYPE = STANDARD GAP = - MISSING = ? SYMBOLS = " 0 1"; + CHARSTATELABELS + 1 character1 / state1.1 'state 1.2', 2 character2 / state2.1 'state 2 2'; + MATRIX + Species_1 01 + 'Species 2' 10 + 'Species 3' 11 + 'Species/4' 00 + 'Species\5' 01 + 'Species"6' ?1 + ; +END; + +BEGIN TREES; + TRANSLATE + 1 Species_1, + 2 'Species 2', + 3 'Species 3', + 4 'Species/4', + 5 'Species\5', + 6 'Species"6'; + TREE tree1 = ((((1,2),3),4),5); +END; From noreply at r-forge.r-project.org Thu Feb 13 17:13:48 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 13 Feb 2014 17:13:48 +0100 (CET) Subject: [Phylobase-commits] r850 - pkg/inst/doc Message-ID: <20140213161349.1DFCD1860B6@r-forge.r-project.org> Author: francois Date: 2014-02-13 17:13:48 +0100 (Thu, 13 Feb 2014) New Revision: 850 Modified: pkg/inst/doc/ Log: new ignore for pdf files. Property changes on: pkg/inst/doc ___________________________________________________________________ Modified: svn:ignore - technotes.pdf phylobase.pdf developer.pdf developer.toc developer.out .build.timestamp + technotes.pdf phylobase.pdf developer.pdf developer.toc developer.out .build.timestamp *.pdf From noreply at r-forge.r-project.org Thu Feb 13 17:14:55 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 13 Feb 2014 17:14:55 +0100 (CET) Subject: [Phylobase-commits] r851 - pkg/inst/unitTests Message-ID: <20140213161455.102BD1862B6@r-forge.r-project.org> Author: francois Date: 2014-02-13 17:14:54 +0100 (Thu, 13 Feb 2014) New Revision: 851 Modified: pkg/inst/unitTests/runit.methods-phylo4.R Log: updates to formatting and updates tests to reflect new checks. Modified: pkg/inst/unitTests/runit.methods-phylo4.R =================================================================== --- pkg/inst/unitTests/runit.methods-phylo4.R 2014-02-13 16:13:48 UTC (rev 850) +++ pkg/inst/unitTests/runit.methods-phylo4.R 2014-02-13 16:14:54 UTC (rev 851) @@ -1,4 +1,4 @@ -# + # # --- Test methods-phylo4.R --- # @@ -117,70 +117,92 @@ } test.edgeLength.phylo4 <- function() { - # all edge lengths - checkIdentical(edgeLength(phy.alt), setNames(elen, eid)) - # one edge length, by label - checkEquals(edgeLength(phy.alt, "t1"), c(`7-1`=0.1)) - # one edge length, by node ID - checkEquals(edgeLength(phy.alt, 1), c(`7-1`=0.1)) - # non-existent edge, by label - ans <- structure(NA_real_, .Names = NA_character_) - checkEquals(suppressWarnings(edgeLength(phy.alt, "xxx")), ans) - # non-existent edge, by number - checkEquals(suppressWarnings(edgeLength(phy.alt, 999)), ans) + ## all edge lengths + checkIdentical(edgeLength(phy.alt), setNames(elen, eid)) + ## one edge length, by label + checkEquals(edgeLength(phy.alt, "t1"), c(`7-1`=0.1)) + ## one edge length, by node ID + checkEquals(edgeLength(phy.alt, 1), c(`7-1`=0.1)) + ## non-existent edge, by label + ans <- structure(NA_real_, .Names = NA_character_) + checkEquals(suppressWarnings(edgeLength(phy.alt, "xxx")), ans) + ## non-existent edge, by number + checkEquals(suppressWarnings(edgeLength(phy.alt, 999)), ans) + ## wrong number of edge lengths + phy.tmp1 <- phy.alt + phy.tmp1 at edge.length <- phy.alt at edge.length[-1] + checkTrue(nzchar(checkPhylo4(phy.tmp1))) + phy.tmp1 <- phy.alt + phy.tmp1 at edge.length <- c(phy.alt at edge.length, 1) + checkTrue(nzchar(checkPhylo4(phy.tmp1))) + ## negative edge lengths + phy.tmp1 <- phy.alt + phy.tmp1 at edge.length[3] <- -1 + checkTrue(nzchar(checkPhylo4(phy.tmp1))) + ## edge incorrectly labeled + phy.tmp1 <- phy.alt + names(phy.tmp1 at edge.length)[1] <- "9-10" + checkTrue(nzchar(checkPhylo4(phy.tmp1))) } test.Replace.edgeLength.phylo4 <- function() { - #TODO function(x, use.names=TRUE, ..., value) - ## dropping all should produce empty slot - edgeLength(phy.alt) <- numeric() - checkIdentical(edgeLength(phy.alt), setNames(rep(NA_real_, 9), eid)) - checkIdentical(phy.alt at edge.length, numeric()) - edgeLength(phy.alt) <- NA_real_ - checkIdentical(edgeLength(phy.alt), setNames(rep(NA_real_, 9), eid)) - checkIdentical(phy.alt at edge.length, numeric()) + emptyVec <- numeric() + attributes(emptyVec) <- list(names=character(0)) + + ## dropping all should produce empty slot + edgeLength(phy.alt) <- numeric() + checkIdentical(edgeLength(phy.alt), setNames(rep(NA_real_, 9), edgeId(phy.alt, "all"))) + checkIdentical(phy.alt at edge.length, emptyVec) + edgeLength(phy.alt) <- NA_real_ + checkIdentical(edgeLength(phy.alt), setNames(rep(NA_real_, 9), edgeId(phy.alt, "all"))) + checkIdentical(phy.alt at edge.length, emptyVec) - # - # complete replacement - # + ## + ## complete replacement + ## - # vector with reversed names, which get matched by default - edgeLength(phy.alt) <- numeric() - edgeLength(phy.alt) <- setNames(elen, rev(eid)) - checkIdentical(edgeLength(phy.alt), setNames(rev(elen), eid)) - # vector with reversed names, but specify no matching - edgeLength(phy.alt) <- numeric() - edgeLength(phy.alt, use.names=FALSE) <- setNames(elen, rev(eid)) - checkIdentical(edgeLength(phy.alt), setNames(elen, eid)) - # vector with no names, should match to edgeId order - edgeLength(phy.alt) <- numeric() - edgeLength(phy.alt) <- elen - checkIdentical(edgeLength(phy.alt), setNames(elen, eid)) + ## vector with reversed names, which get matched by default + edgeLength(phy.alt) <- numeric() + revElen <- setNames(elen, rev(eid)) + edgeLength(phy.alt) <- revElen + checkIdentical(edgeLength(phy.alt), revElen[edgeId(phy.alt, "all")]) + ## vector with reversed names, but specify no matching + edgeLength(phy.alt) <- numeric() + edgeLength(phy.alt, use.names=FALSE) <- revElen + elen1 <- elen + checkIdentical(edgeLength(phy.alt), setNames(elen1, edgeId(phy.alt, "all"))) + ## vector with no names, should match to edgeId order + edgeLength(phy.alt) <- numeric() + edgeLength(phy.alt) <- elen + elen2 <- elen + checkIdentical(edgeLength(phy.alt), setNames(elen2, edgeId(phy.alt, "all"))) - # recycling applies if fewer the nEdges elements are supplied - # (duplicate edge length are okay) - edgeLength(phy.alt) <- 1 - checkIdentical(edgeLength(phy.alt), setNames(rep(1, 9), eid)) + ## recycling applies if fewer the nEdges elements are supplied + ## (duplicate edge length are okay) + edgeLength(phy.alt) <- 1 + checkIdentical(edgeLength(phy.alt), setNames(rep(1, 9), edgeId(phy.alt, "all"))) - # - # partial replacement - # + ## + ## partial replacement + ## - edgeLength(phy.alt) <- elen - # replace an edge length using numeric index - edgeLength(phy.alt)[9] <- 83 - checkIdentical(edgeLength(phy.alt), setNames(c(elen[1:8], 83), eid)) - # and back again, now using character index - edgeLength(phy.alt)["8-3"] <- 0.3 - checkIdentical(edgeLength(phy.alt), setNames(elen, eid)) - # error to add length for edges that don't exist - checkException(edgeLength(phy.alt)["fake"] <- 999) - checkException(edgeLength(phy.alt)[999] <- 999) - # NAs permitted only for root edge (or for *all* edges) - edgeLength(phy.alt)[edgeId(phy.alt, "root")] <- NA - checkIdentical(edgeLength(phy.alt), setNames(c(NA, elen[2:9]), eid)) - checkException(edgeLength(phy.alt)["8-3"] <- NA) + edgeLength(phy.alt) <- elen + ## replace an edge length using numeric index + edgeLength(phy.alt)[9] <- 83 + checkIdentical(edgeLength(phy.alt), setNames(c(elen[1:8], 83), edgeId(phy.alt, "all"))) + ## and back again, now using character index + edgeLength(phy.alt)["8-3"] <- 0.3 + elen3 <- elen + checkIdentical(edgeLength(phy.alt), setNames(elen3, edgeId(phy.alt, "all"))) + ## error to add length for edges that don't exist + checkException(edgeLength(phy.alt)["fake"] <- 999) + checkException(edgeLength(phy.alt)[999] <- 999) + ## NAs permitted only for root edge (or for *all* edges) + edgeLength(phy.alt)[edgeId(phy.alt, "root")] <- NA + checkIdentical(edgeLength(phy.alt), setNames(c(NA, elen[2:9]), edgeId(phy.alt, "all"))) + edgeLength(phy.alt) <- elen + checkException(edgeLength(phy.alt)["8-3"] <- NA) } test.sumEdgeLength.phylo4 <- function() { From noreply at r-forge.r-project.org Thu Feb 13 17:19:32 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 13 Feb 2014 17:19:32 +0100 (CET) Subject: [Phylobase-commits] r852 - in pkg: R src Message-ID: <20140213161933.01C4F186B73@r-forge.r-project.org> Author: francois Date: 2014-02-13 17:19:32 +0100 (Thu, 13 Feb 2014) New Revision: 852 Modified: pkg/R/RcppExports.R pkg/R/checkdata.R pkg/R/methods-phylo4.R pkg/src/RcppExports.cpp pkg/src/checkPhylo4.cpp Log: updates to checkPhylo4Cpp (removed unncessary functions), fixed case of non-rooted tree for node generation, fixed test for NA edge lengths, fixed edge length must be a named vector (even if empty), fixed omission of test on valid ordering. Modified: pkg/R/RcppExports.R =================================================================== --- pkg/R/RcppExports.R 2014-02-13 16:14:54 UTC (rev 851) +++ pkg/R/RcppExports.R 2014-02-13 16:19:32 UTC (rev 852) @@ -41,22 +41,14 @@ .Call('phylobase_getAllNodesSafe', PACKAGE = 'phylobase', edge) } -getAllNodesFast <- function(edge) { - .Call('phylobase_getAllNodesFast', PACKAGE = 'phylobase', edge) +getAllNodesFast <- function(edge, rooted) { + .Call('phylobase_getAllNodesFast', PACKAGE = 'phylobase', edge, rooted) } -testNodes <- function(edge) { - .Call('phylobase_testNodes', PACKAGE = 'phylobase', edge) -} - testEqInt <- function(x, y) { .Call('phylobase_testEqInt', PACKAGE = 'phylobase', x, y) } -getInternalNodes <- function(edge) { - .Call('phylobase_getInternalNodes', PACKAGE = 'phylobase', edge) -} - all_naC <- function(x) { .Call('phylobase_all_naC', PACKAGE = 'phylobase', x) } Modified: pkg/R/checkdata.R =================================================================== --- pkg/R/checkdata.R 2014-02-13 16:14:54 UTC (rev 851) +++ pkg/R/checkdata.R 2014-02-13 16:19:32 UTC (rev 852) @@ -51,9 +51,20 @@ err <- c(err, "The edge.label slot needs to be a named vector.") attributes(object at edge.label) <- list(names=character(0)) } - + res <- checkTreeCpp(object, opts=opt) + if (hasEdgeLength(object) && any(is.na(edgeLength(object)))) { + naElen <- names(which(is.na(object at edge.length))) + if (! identical(naElen, edgeId(object, "root"))) + err <- c(err, "Only the root can have NA as edge length. ") + } + + if (!object at order %in% phylo4_orderings) { + err <- c(err, paste("unknown order: allowed values are", + paste(phylo4_orderings,collapse=","))) + } + err <- ifelse(nzchar(res[[1]]), c(err, res[[1]]), err) wrn <- ifelse(nzchar(res[[2]]), c(wrn, res[[2]]), wrn) Modified: pkg/R/methods-phylo4.R =================================================================== --- pkg/R/methods-phylo4.R 2014-02-13 16:14:54 UTC (rev 851) +++ pkg/R/methods-phylo4.R 2014-02-13 16:19:32 UTC (rev 852) @@ -226,7 +226,9 @@ len <- .createEdge(value, x at edge, type="lengths", use.names) ## return empty vector if all values are NA if (all(is.na(len))) { - x at edge.length <- numeric() + emptyVec <- numeric() + attributes(emptyVec) <- list(names=character(0)) + x at edge.length <- emptyVec } else { x at edge.length <- len } Modified: pkg/src/RcppExports.cpp =================================================================== --- pkg/src/RcppExports.cpp 2014-02-13 16:14:54 UTC (rev 851) +++ pkg/src/RcppExports.cpp 2014-02-13 16:19:32 UTC (rev 852) @@ -158,35 +158,21 @@ END_RCPP } // getAllNodesFast -Rcpp::IntegerVector getAllNodesFast(Rcpp::IntegerMatrix edge); -RcppExport SEXP phylobase_getAllNodesFast(SEXP edgeSEXP) { +Rcpp::IntegerVector getAllNodesFast(Rcpp::IntegerMatrix edge, bool rooted); +RcppExport SEXP phylobase_getAllNodesFast(SEXP edgeSEXP, SEXP rootedSEXP) { BEGIN_RCPP SEXP __sexp_result; { Rcpp::RNGScope __rngScope; Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type edge(edgeSEXP ); - Rcpp::IntegerVector __result = getAllNodesFast(edge); + Rcpp::traits::input_parameter< bool >::type rooted(rootedSEXP ); + Rcpp::IntegerVector __result = getAllNodesFast(edge, rooted); PROTECT(__sexp_result = Rcpp::wrap(__result)); } UNPROTECT(1); return __sexp_result; END_RCPP } -// testNodes -Rcpp::List testNodes(Rcpp::IntegerMatrix edge); -RcppExport SEXP phylobase_testNodes(SEXP edgeSEXP) { -BEGIN_RCPP - SEXP __sexp_result; - { - Rcpp::RNGScope __rngScope; - Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type edge(edgeSEXP ); - Rcpp::List __result = testNodes(edge); - PROTECT(__sexp_result = Rcpp::wrap(__result)); - } - UNPROTECT(1); - return __sexp_result; -END_RCPP -} // testEqInt Rcpp::List testEqInt(Rcpp::IntegerVector x, Rcpp::IntegerVector y); RcppExport SEXP phylobase_testEqInt(SEXP xSEXP, SEXP ySEXP) { @@ -203,21 +189,6 @@ return __sexp_result; END_RCPP } -// getInternalNodes -Rcpp::IntegerVector getInternalNodes(Rcpp::IntegerMatrix edge); -RcppExport SEXP phylobase_getInternalNodes(SEXP edgeSEXP) { -BEGIN_RCPP - SEXP __sexp_result; - { - Rcpp::RNGScope __rngScope; - Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type edge(edgeSEXP ); - Rcpp::IntegerVector __result = getInternalNodes(edge); - PROTECT(__sexp_result = Rcpp::wrap(__result)); - } - UNPROTECT(1); - return __sexp_result; -END_RCPP -} // all_naC bool all_naC(Rcpp::NumericVector x); RcppExport SEXP phylobase_all_naC(SEXP xSEXP) { Modified: pkg/src/checkPhylo4.cpp =================================================================== --- pkg/src/checkPhylo4.cpp 2014-02-13 16:14:54 UTC (rev 851) +++ pkg/src/checkPhylo4.cpp 2014-02-13 16:19:32 UTC (rev 852) @@ -128,24 +128,30 @@ } //[[Rcpp::export]] -Rcpp::IntegerVector getAllNodesFast (Rcpp::IntegerMatrix edge) { +Rcpp::IntegerVector getAllNodesFast (Rcpp::IntegerMatrix edge, bool rooted) { Rcpp::IntegerVector tmp = Rcpp::as_vector(edge); Rcpp::IntegerVector maxN = Rcpp::range(tmp); Rcpp::IntegerVector ans = Rcpp::seq_len(maxN[1] + 1); - return ans - 1; + if (rooted) { + return ans - 1; + } + else { + ans.erase(0); + return ans - 1; + } } -//[[Rcpp::export]] -Rcpp::List testNodes (Rcpp::IntegerMatrix edge) { - Rcpp::IntegerVector allNodes = Rcpp::as_vector(edge); - allNodes = Rcpp::unique(allNodes); - std::sort (allNodes.begin(), allNodes.end()); - Rcpp::IntegerVector supposedNodes = getAllNodesFast(edge); - Rcpp::IntegerVector test = Rcpp::setdiff(supposedNodes, allNodes); - Rcpp::LogicalVector res = supposedNodes == allNodes; - return Rcpp::List::create(supposedNodes, allNodes, test, res); -} +// Rcpp::List testNodes (Rcpp::IntegerMatrix edge, bool rooted) { +// Rcpp::IntegerVector allNodes = Rcpp::as_vector(edge); +// allNodes = Rcpp::unique(allNodes); +// std::sort (allNodes.begin(), allNodes.end()); +// Rcpp::IntegerVector supposedNodes = getAllNodesFast(edge, rooted); +// Rcpp::IntegerVector test = Rcpp::setdiff(supposedNodes, allNodes); +// Rcpp::LogicalVector res = supposedNodes == allNodes; +// return Rcpp::List::create(supposedNodes, allNodes, test, res); +// } + //[[Rcpp::export]] Rcpp::List testEqInt (Rcpp::IntegerVector x, Rcpp::IntegerVector y) { Rcpp::LogicalVector xy = x == y; @@ -153,18 +159,16 @@ return Rcpp::List::create(xy, yx); } +// Rcpp::IntegerVector getInternalNodes (Rcpp::IntegerMatrix edge, bool rooted) { +// Rcpp::IntegerVector ances = getAnces(edge); +// Rcpp::IntegerVector allNodes = getAllNodesFast(edge, rooted); +// Rcpp::IntegerVector tips = tipsFast(ances); +// Rcpp::IntegerVector intNodes = Rcpp::setdiff(allNodes, tips); +// intNodes.erase(intNodes.begin()); +// return intNodes; +// } //[[Rcpp::export]] -Rcpp::IntegerVector getInternalNodes (Rcpp::IntegerMatrix edge) { - Rcpp::IntegerVector ances = getAnces(edge); - Rcpp::IntegerVector allNodes = getAllNodesFast(edge); - Rcpp::IntegerVector tips = tipsFast(ances); - Rcpp::IntegerVector intNodes = Rcpp::setdiff(allNodes, tips); - intNodes.erase(intNodes.begin()); - return intNodes; -} - -//[[Rcpp::export]] bool all_naC (Rcpp::NumericVector x) { return is_true(all(is_na(x))); } @@ -266,6 +270,8 @@ int nrow = ed.nrow(); Rcpp::IntegerVector ances = getAnces(ed); //Rcpp::IntegerVector desc = getDesc(ed); + int nroots = nRoots(ances); + bool rooted = nroots > 0; Rcpp::NumericVector edLength = obj.slot("edge.length"); Rcpp::CharacterVector edLengthNm = edLength.names(); Rcpp::CharacterVector label = obj.slot("label"); @@ -273,13 +279,12 @@ Rcpp::CharacterVector edLabel = obj.slot("edge.label"); Rcpp::CharacterVector edLabelNm = edLabel.names(); Rcpp::IntegerVector allnodesSafe = getAllNodesSafe(ed); - Rcpp::IntegerVector allnodesFast = getAllNodesFast(ed); + Rcpp::IntegerVector allnodesFast = getAllNodesFast(ed, rooted); int nEdLength = edLength.size(); int nLabel = label.size(); int nEdLabel = edLabel.size(); int nEdges = nrow; bool hasEdgeLength = !all_naC(edLength); - int nroots = nRoots(ances); // check tips int ntipsSafe = nTipsSafe(ances); @@ -297,13 +302,13 @@ } // check edge lengths - if (hasEdgeLength) { + if (hasEdgeLength) { if (nEdLength != nEdges) { err.append("Number of edge lengths do not match number of edges. "); } - if (nb_naC(edLength) > (nroots + 1)) { - err.append("Only the root should have NA as an edge length. "); - } + // if (nb_naC(edLength) > nroots) { // not enough! -- best done in R + // err.append("Only the root should have NA as an edge length. "); + // } if (getRange(edLength, TRUE)[0] < 0) { err.append("Edge lengths must be non-negative. "); } From noreply at r-forge.r-project.org Thu Feb 13 17:20:11 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 13 Feb 2014 17:20:11 +0100 (CET) Subject: [Phylobase-commits] r853 - pkg Message-ID: <20140213162011.6D97A186B7E@r-forge.r-project.org> Author: francois Date: 2014-02-13 17:20:11 +0100 (Thu, 13 Feb 2014) New Revision: 853 Modified: pkg/NAMESPACE Log: update NAMESPACE with new Rcpp requirements. Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2014-02-13 16:19:32 UTC (rev 852) +++ pkg/NAMESPACE 2014-02-13 16:20:11 UTC (rev 853) @@ -8,6 +8,7 @@ importFrom(graphics, plot) importFrom(stats, reorder) importFrom(utils, head, tail) +importFrom(Rcpp, evalCpp) #----------------------------------------------------------------------