[R-sig-phylo] Fwd: Postdoc Position: Phylogenetic Climate Modeling & 3D Morphometrics

2022-08-05 Thread David Bapst
Please see the job ad below -- this postdoc at A looks like it might
be of interest for those here on R-Sig-Phylo.
-Dave

-- Forwarded message -
From: Michelle Lawing 
Date: Thu, Jul 14, 2022 at 9:06 AM
Subject: Postdoc Position: Phylogenetic Climate Modeling & 3D Morphometrics
To: 


Dear friends and colleagues,

I’m recruiting a postdoc to work on a recently funded NSF project with
Dr. Emília Martins (Arizona State University), Dr. Julio Rivera (Henry
M. Jackson Foundation), and Dr. Jaime Zúñiga-Vega (Universidad
Nacional Autónoma de México). Please share this opportunity widely
with students, postdocs, and other colleagues!

See the NSF grant abstract (here:
https://nsf.gov/awardsearch/showAward?AWD_ID=2154898) to learn more
about our jointly funded NSF award titled “Inferring the impacts of
closely-related species on phenotypic evolution.”

The ideal candidate would have strong interest in research topics at
the intersection of ecology, evolution, and biogeography, strong
interpersonal skills, proficient knowledge of coding in R, proficient
knowledge of phylogenetic comparative methods, previous experience in
assembling and analyzing large datasets, and previous experience with
analysis of climate data. Adequate knowledge of skeletal morphology of
lizards is a plus.

The candidate will subscribe to and support our commitment to
Inclusion, Diversity, Equity and Accountability (IDEA).

Required Documents to Submit: Applicants should upload a single pdf,
which should include: (1) Cover letter stating your interest in this
position, your fit and your previous experience related to this
position description, including scientific goals and interests, (2)
CV, (3) Names and contact information for three persons willing to
provide a recommendation.

If the description of this position sounds interesting to you, even if
you do not possess all skills listed, we strongly encourage you to
apply to be considered for this opportunity. For further information
and to submit your application see: https://tinyurl.com/33u27xdz. We
will begin reviewing applications at the end of July and continue
until the position is filled. The ideal start date is September 1st
(negotiable). It is a two-year position with adequate performance and
salary is $50,000 per year with additional benefits and a budgeted
annual raise.

Please contact Dr. Michelle Lawing (alaw...@tamu.edu) if you have any questions.

Best wishes,
Michelle

-- 

A. Michelle Lawing, PhD (she/her/hers)
Associate Professor
Paleobiology, Evolution, and Climate Lab
Department of Ecology and Conservation Biology
College of Agriculture and Life Sciences
Texas A University
2120 TAMU, WFES 322
College Station, TX 77843

Editorial Board, Communications Biology
An open access journal from Nature Research

Visiting Fellow, Department of Biology
University of Pisa, Italy

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Model Selection and PGLS

2021-06-29 Thread David Bapst
Hi all, Russell, Nate,

I took an interest with some of the commentary here, so here's my two cents.

> I was surprised that AIC would vary this much in a dataset where the trait 
> data, number of tips, and branching
> topology used to compute the model are more or less constant between trees.

I am not surprised to hear of substantial variation in model support.
In my experience, model support can vary wildly among trees that share
the same taxa and the overall structure (they'd all more or less look
like the same tree if printed on a conference poster without
tip-labels). Most of the information is constrained by where the short
edges are in the tree, especially short terminal edges that connect to
tips. Varying which terminal edges are very short, or varying their
placement can produce a lot of variation in which model is best
supported by any information criterion.

All of this especially applies when we consider the OU (single optima)
model among our set of models, which is like a great big sponge that
likes to eat noise, but also applies just when considering between BM
or a signal-less white noise (OLS) model, or when evaluating really
any test that tries to ascertain if there is phylogenetic signal or
not.

And this all follows naturally. Obviously, if we are uncertain about
the timing of recent evolutionary divergences, we are uncertain how
rapid evolution has been recently. If recent change is very rapid,
then it will look like rates are accelerating (ala OU model) and/or
there is very poor phylogenetic signal (because old divergences in
trait-space do not correspond to the larger differences in the
dataset).

> ...given that it is logical to expect AIC to vary based on differences 
> between trees, how would one go about
> determining which regression model is the "optimal" one to use for further 
> analysis..?

I think this is a place where an unguided examination of the traits in
question cannot go any further. Frankly, you need to interrogate what
your expectation is: do you think these traits have phylogenetic
signal? Do they not? Looking at the trees, do you have any sense in
what edges, and what edge lengths are controlling the variation you
are seeing in model support?

I would not state it in the same null-model terms that Nate uses,
because referring to the PGLS (BM) as the null model means that in
some ways we are making implicit assumptions about what our default
assumptions are. I think it would be better to more carefully consider
what our expectations for this particular system is. Do you think
descendant populations are generally like their ancestors over
evolutionary time? Do you have some reason for thinking otherwise?

I would not give the OU model much consideration, unless you wish to
use it as a description of a phylogenetic process with decreased
phylogenetic signal (as Carl Boettiger once advocated in this eight
year old blog post that I still tell people to read:
https://www.carlboettiger.info/2013/10/11/is-it-time-to-retire-pagels-lambda.html).

Ultimately, though, it sounds like what you will find is a mixed
answer, so why not just take a model that allows phylogenetic signal
to scale from non-existent to very strong (like the lambda PGLS model
or the OU PGLS model), fit it to each tree in a large set, and then
you can look at how other model parameters vary with the apparent
strength of phylogenetic signal? Perhaps this may be more informative
to you than choosing a model based on a wildly varying information
criterion, or getting a 'yes' or 'no' to whether phylogenetic signal
exists in your data.

Cheers,
-Dave

On Tue, Jun 29, 2021 at 2:05 PM Nathan Upham  wrote:
>
> Hi Russell and all, sounds good.
>
> I’d suggest that the “null model” for fitting trait data to a phylogeny 
> should be single-rate Brownian motion, i.e., you’re assuming that given data 
> on the ancestor-to-descendant relationships of the species (and timing of 
> divergences), and assuming the trait is heritable, it is evolving at the same 
> random rate along each branch.  The burden of proof is on rejecting that null 
> hypothesis (not “accepting it”— sorry for earlier writing that incorrectly!). 
>  So if you do your AIC fitting across the 100 trees, summarize the results, 
> and find no clear signal of a model being obviously better than single-rate 
> Brownian, then that is what you should use for subsequent analyses.
>
> If anyone has a different perspective on this, please chime in.  The above 
> assumes that you’ve established heritability of the trait, for example by 
> doing a test for phylogenetic ’signal’.
>
> Does that help?  All the best
> —nate
>
>
>
> > On Jun 28, 2021, at 1:25 PM, Russell Engelman  
> > wrote:
> >
> > Dear Dr. Upham (and All),
> >
> > Please don't take my initial message the wrong way, this is not meant to be 
> > a dig at your 2019 study. I don’t think this is due to the birth-death tree 
> > specifically but would be present in any study where there are multiple 

Re: [R-sig-phylo] evolutionary rate for species with low phylogenetic signal

2020-09-24 Thread David Bapst
Karla et al.,

There isn't, necessarily, a good alternative. If phylogenetic signal
is very poor, our ability to estimate rates is extremely hindered.
There's no rate of evolution in a white noise model -- values are
simply assigned independently of phylogeny.

One thought I had is that you might be able to at least constrain a
hard *minimum* estimate of the rates of evolution by looking at pairs
of sister species. But that may not be very useful depending on what
question is motivating you to measure evolutionary rate. It may not
even be meaningful in terms of capturing any sort of realistic
estimate of a real world process.

The problem here is that rate, in and of itself, is part of our
assumptions about the process being gradual and accruing variance over
time. If change was instead entirely limited to short punctuations,
and punctuations were randomly distributed in time, then asking how
much change there was over some interval of time (i.e. the rate) would
be rather nonsensical. You could 'measure' the rate but it wouldn't
have anything to do with the process generating the data. Perhaps the
thing to consider is, why do you think this data has such poor
phylogenetic signal to begin with?

In addition to Ted's reading list, these concepts were particularly
clarified for me by Gene Hunt's 2012 paper in Paleobiology on the
inseparability of measures of rate from our assumptions about mode:

https://www.cambridge.org/core/journals/paleobiology/article/measuring-rates-of-phenotypic-evolution-and-the-inseparability-of-tempo-and-mode/2906747B67D16EF002DC8B12CCF96B15

I hope this helps,
-Dave B

On Wed, Sep 23, 2020 at 8:42 PM Karla Shikev  wrote:
>
> Thanks, Liam! That was really helpful. But what would be an alternative to
> estimate evolutionary rates in those cases? Simply the sigsq estimate under
> a white noise model? (which I assume is simply the variance in the original
> data?)
>
> Karla
>
> On Wed, Sep 23, 2020 at 10:23 PM Liam J. Revell  wrote:
>
> > Hi Karla.
> >
> >  > I just wanted to make sure that the estimate of sigma^2 in a BM model
> >  > in fitContinuous is a meaningful measure of the rate of evolution of
> >  > the trait even if its phylogenetic signal is low.
> >
> > I would say that the answer to this question (if it were posed as one)
> > is 'no.' Another way to put this is that sigma^2 is probably not a
> > meaningful measure of the rate of evolution for your character if
> > Brownian motion is a (very) poor fit to your data.
> >
> > It's kind of equivalent to saying 'is the slope of a fitted linear
> > regression a good measure of the rate of change in y as a function of x
> > if a linear model is a very poor fit to my data?' (That is, you can
> > still find a value of the slope that maximizes the probability of your
> > data under a linear model, and this slope accurately give the mean
> > effect of x on y over the range of your observations for x - but it may
> > not mean a whole lot about how x & y genuinely co-vary.)
> >
> > All the best, Liam
> >
> > Liam J. Revell
> > University of Massachusetts Boston
> > Universidad Católica de la Ssma Concepción
> > web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org
> >
> > Academic Director UMass Boston Chile Abroad:
> > https://www.umb.edu/academics/caps/international/biology_chile
> >
> > On 9/23/2020 9:36 PM, Karla Shikev wrote:
> > > **[EXTERNAL SENDER]
> > >
> > > Dear All,
> > >
> > > Thanks for your fantastic feedback. Just a bit more background: I'm
> > > interested both in the phylogenetic signal and the evolutionary rate. I
> > > just wanted to make sure that the estimate of sigma^2 in a BM model in
> > > fitContinuous is a meaningful measure of the rate of evolution of the
> > > trait even if its phylogenetic signal is low.
> > >
> > > thanks again!
> > >
> > > Karla
> > >
> > > On Wed, Sep 23, 2020 at 8:45 PM Theodore Garland
> > > mailto:theodore.garl...@ucr.edu>> wrote:
> > >
> > > Carla, I can also suggest looking at some of the papers on this,
> > > such as:
> > >
> > > Blomberg, S. P., T. Garland, Jr., and A. R. Ives. 2003. Testing for
> > > phylogenetic signal in comparative data: behavioral traits are more
> > > labile. Evolution 57:717–745.
> > >
> > >
> > > Ives, A. R., P. E. Midford, and T. Garland, Jr. 2007. Within-species
> > > variation and measurement error in phylogenetic comparative methods.
> > > Systematic Biology 56:252–270.
> > >
> > >
> > > Revell, L., L. Harmon, and D. Collar. 2008. Phylogenetic signal,
> > > evolutionary process, and rate. Systematic Biology 57:591–601.
> > >
> > >
> > > Hardy, O. J., and S. Pavoine. 2012. Assessing phylogenetic signal
> > > with measurement error: a comparison of Mantel tests, Blomberg et
> > > al.’s K, and phylogenetic distograms. Evolution 66:2614–2621.
> > >
> > >
> > > Cheers,
> > >
> > > Ted Garland
> > >
> > >
> > >
> > >
> > > On Wed, Sep 23, 2020 at 4:33 PM Liam J. Revell  > > 

Re: [R-sig-phylo] A test for valid phylo object (ape package) for package developers

2019-11-05 Thread David Bapst
Hi Elizabeth,

There's a lot of ways for trees to be wrong, and surely no
tree-checking or tree-fixing function can handle all possibilities.
Dating trees and simulating trees can be a messy business, so I used
to often hard-crash R with C++ errors all the time until I wrote
functions to try to avoid this. (At one point, now many years ago, and
probably not true anymore, but if you had a tree with nodes ordered in
a way opposite of what ape expected, you could cause your operating
system to blue-screen if you tried to plot the tree...).
`paleotree::testEdgeMat` tests the edge matrix, which is often the
source of problems, for inconsistencies. There is also paleotree
function `cleanNewPhylo` will try to clean a tree of any of the stuff
or misordered nodes that can cause a hard crash, particularly by
reading it out as a text string and reading it back in with write.tree
and read.tree.

I hope this helps,
-Dave

On Tue, Nov 5, 2019 at 2:54 PM Elizabeth Purdom
 wrote:
>
> Hello,
>
> I am working with the phylo object from the ape package in my own package in 
> which I am manipulating the trees. I would like to check that I have 
> successfully created a valid ape object, but the `checkValidPhylo` function 
> appears to be solely interactive — it prints out a display, and always 
> returns NULL.
>
> Is there a function in the ape package (or can there be?) that would do the 
> checks, but return the results in a way that I can then process in my 
> function? (e.g. return a vector of each of the checks as TRUE/FALSE) And I 
> don’t want anything printed out, since I don’t want that output to be printed 
> for users of my function).
>
> I see the package `paleotree` has ported some of those checks into a test, so 
> I’m guessing such a function doesn’t exist in ape — and I don’t really want a 
> dependency on another package just for these checks.
>
> Thanks,
> Elizabeth Purdom
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Assistant Instructional Professor
Geology & Geophysics
Texas A & M University
https://github.com/dwbapst/paleotree

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Phylogenetic Paleobiology Short Course at GSA 2019 - This Saturday in Phoenix, AZ - Sponsored by PaleoSoc

2019-09-17 Thread David Bapst
Howdy y'all,

We would like to give a short reminder about the upcoming 2019
Paleontological Society Short Course, “Quantitative Methods in Phylogenetic
Paleobiology”. Our short course will be held this Saturday, September 21st,
from 8:00 AM to 5:00 PM (local Arizona time), in the ‘Valley of the Sun’
ballroom at the Sheraton Phoenix Downtown Hotel.

Participation in this short course is free of charge to any interested
individuals, including those who may not be registered for GSA. We request
that all of those who plan on attending to register via our Google Form, if
they have not done so, even on the day of the workshop itself. We will be
able to best aim our instruction if we have accurate information on the
background and interests of our participants. Registering will also add you
to our email list so that you can get future updates about the workshop
later in the week. Please feel free to share this information and invite
anyone in the Phoenix area who might be interested in participating,
including non-paleontologists.

https://docs.google.com/forms/d/1AsPgZNraGV6htmveMK5Yebx3q1_Eew_BaML6MLYdHQU/viewform?ts=5c989fd5

You can find more information including the workshop schedule, data files
and other workshop materials as we continue to post them, and a short
reading list at the main course website:

https://dwbapst.github.io/PaleoSoc_phylo_short_course_2019

Please note that we will be expecting all who are attending the short
course to behave as described in our Expectations of Conduct statement,
available at our website.

As this will be a “hands on” workshop, participants are encouraged to bring
their personal computer (and power cord!), with several pieces of free
software downloaded and installed beforehand.  Instructions for installing
these programs on various operating systems can be found at the following
link:

https://dwbapst.github.io/PaleoSoc_phylo_short_course_2019/articles/install_main.html

We will have a pre-workshop meetup this Friday evening, before the Short
Course, where several of us will be present to help people with
troubleshooting the installation of these programs on their personal
devices. Currently, we are planning on tentatively meeting at 6:00 PM in
the lobby of the Sheraton hotel, but we may change the time and location of
this meeting depending on demand.

>From Your 2019 Short Course Organizers,
Sandra Carlson, Peter Wagner, April Wright, David Wright, Laura Soul,
Rachel Warnock,  & David Bapst


-- 
David W. Bapst, PhD
Assistant Instructional Professor
Geology & Geophysics
Texas A & M University
https://github.com/dwbapst/paleotree

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] 2019 Paleo Society Short Course: Quant Methods in Phylogenetic Paleo - Sept 21st, 2019 - Phoenix, AZ

2019-04-24 Thread David Bapst
Please see the forwarded message (with slight edits) below from Pete
Wagner, announcing a short course on paleo-phylo methods in RevBayes
at the Geological Society of America meeting in held in Phoenix,
Arizona, on September 21st, 2019. I trust it may be of interest to
some members of this list-serv.

Cheers,
-Dave Bapst



##

We are pleased to announce the 2019 Paleontological Society Short
Course, “Quantitative Methods in Phylogenetic Paleobiology,” organized
by David Bapst, Sandy Carlson, Laura Soul, Peter Wagner, Rachel
Warnock, April Wright & Davey Wright. This will be an all day event,
held September 21st, in Phoenix, Arizona, the day before oral and
poster sessions begin at the national Geological Society of America
conference.  Following the example set in the 2018 “Pedagogy and
Technology in the Modern Paleontology Classroom” short course, the
2019 short course will be a workshop in which presentations about
phylogenetic methods will be interspersed with hands-on exercises for
the attendees to perform.

The short course will encompass three broad (albeit connected) topics:

1) tactics for recognizing and coding anatomical characters and
character states;

2) models of morphological evolution; and,

3) estimation of divergence times among fossil taxa given morphology,
and rates of change, diversification, and sampling.

Our intent is to make connections between the important parameters for
phylogenetic analysis and macroevolutionary theory of the sort that
paleontologists study, as these commonalities often are overlooked.
Another intent is to communicate how we deal with uncertainties in
relevant rate parameters and even phylogenetic topologies themselves
when making tree-based macroevolutionary inferences.  Our goal is to
work to embrace these uncertainties rather than to either ignore them
or dismiss important questions as unanswerable because of
uncertainties.

For much of the short course, we will use a single dataset for our
examples, with that dataset and appropriate computer programs
distributed prior to the short course.  This will allow each
participant to work through steps from loading files to conducting
basic analyses. (A short workshop to help people download appropriate
files will be held on Friday before the short course.)

We are aiming the short course at a wide audience.  We will introduce
current methods and tools to young researchers interested in pursuing
phylogenetic analyses.  However, this will also be a “refresher”
course for more veteran workers who have done phylogenetics in the
past, but who might not have kept up with recent developments.  The
course contents will also be be useful for individuals who themselves
do little or no phylogenetic work, but who might mentor interns or
students interested in phylogenetics and/or who might collaborate with
phylogeneticists.

The workshop will take place at the Sheraton Grand Phoenix Hotel (two
blocks from the Convention Center) on Saturday the 21st of September
8:00 - 17:00 (with several short breaks and a lunch break). A short
workshop for installing relevant software will be held Friday late
afternoon to early evening at the Convention center, with the exact
times and location to be announced. We emphasize that because this
short course is being conducted as a workshop rather than a day-long
symposium, attendees will get the most out of the course by attending
the entire session.

In order to estimate the audience size and pre-existing levels of
expertise, we ask the interested attendees fill out a
short-registration form at:

https://docs.google.com/forms/d/1AsPgZNraGV6htmveMK5Yebx3q1_Eew_BaML6MLYdHQU/viewform?ts=5c989fd5

(Note that this is an informal registration; registrants are not
committed to attending and non-registrants are free to attend.)

There is *NO* fee for attending this course! The Paleo Society short
course is held the day before sessions begin at the national
Geological Society of America (GSA) meeting, and is open to all that
wish to attend. However, if you register for the GSA meeting, then you
can see the "Phylogenetic Paleobiology: Good Things Come in Trees"
session on Sunday, plus many other great paleo-related sessions.

Sincerely,
Pete

co-signed,
David W. Bapst (Texas A)
Sandra J. Carlson (UC Davis)
Laura C. Soul (NMNH)
Peter J. Wagner (U. Nebraska, Lincoln)
Rachel C. M. Warnock (ETH Zurich)
April M. Wright (Southeastern Louisiana)
David F. Wright (AMNH)

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Logarithmic Scales for Plotting Dated Phyogenies (e.g. Log of Time Axis?)

2019-01-02 Thread David Bapst
Hi all,

I've been dealing with a tree with one very deep divergence and many
very shallow divergences recently, and I was curious if there was an R
plotting capability that allows for the depth axis of the tree to be
non-linear or logarithmic - helpful if there can be a time axis bar as
well, as with axisPhylo(). Logging the axis directly with par seems to
break plot.phylo, presumably because its trying to plot something at a
negative coordinate.

It seems like a simple thing, but oddly I haven't come upon anything
yet that can do this. Any thoughts?

Cheers,
-Dave

PS: Tangential to that, is there a ladderize function that also takes
into account the edge length on non-ultrametric trees? I just noticed
that ladderize doesn't do much for a tree with a large polytomy
consisting of branches of very different length.

PPS: Happy New Years, all! I just checked and its now been nine years
I've been following this listserv...

-- 
David W. Bapst, PhD
Asst Research Professor, Geology & Geophysics, Texas A & M University
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
https://github.com/dwbapst/paleotree

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] mixing trait values from distinct models of evolution to reconstruct null morphospace

2018-12-21 Thread David Bapst
My biggest issue with this setup, as you give it, is that it isn't
clear how you'll make this into a test - is there some summary
statistic of the null morphospace you'll be generating many times, and
then comparing that distribution to the observed value of the
observed, real data? I would suggest thinking more about this aspect.

I hope this helps,
-Dave

On Sun, Dec 16, 2018 at 5:35 PM françois RIGAL  wrote:
>
> Hi all
> I have a conceptual question related to the use of separate models of 
> evolution to reconstruct a morphospace.
> Ok let’s consider that I have 6 endemic species on an island-like habitats 
> for which I have morphological traits. I want to generate a null expectation 
> for the morphospace of this community keeping the phylogenetic structure 
> unchanged. These 6 species belong to 3 different clades (2 species each). 
> Let’s consider that I have the phylogeny and the traits for all the mainland 
> representative of those three clades. My null hypotheses behind would be that 
> endemic species evolve at the same rate/same direction that mainland species.
> My idea is the following: I fit different models of evolution to each clade 
> separately (endemic species included) e.g. BM, OU and use the parameters of 
> the best model to simulate random traits for each clade. I do 1000 runs and, 
> at each run, I pick up from my random clade-set of traits the 2 endemic 
> species, and re-create therefore a null morphospace for my community of 6 
> endemic species.
> So far, I cannot think about any possible “pitfalls”, but, since I did not 
> find any similar approaches in the literature, I am wondering whether it is 
> problematic to mix in the same null morphospace null trait values that have 
> been generated from distinct phylogenies and models of evolution.
> any comments / advices are welcome
> Many thanks
>
> François
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Asst Research Professor, Geology & Geophysics, Texas A & M University
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
https://github.com/dwbapst/paleotree

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] OU for non-ultrametric trees

2018-12-12 Thread David Bapst
Danielle,

Apologies for the late comment on this, but what do you mean by non-rooted?
Do you mean the tree is rooted, but has a three-way split with the outgroup
at the root node? You shouldn't do OU on a tree you can't assign a root to.

I'm also just a bit curious what gave you the sense that OU was
inappropriate for non-ultrametric trees. To my knowledge, this was only an
issue in one case, as highlighted by Slater (2014), that one particularly
(popular) algorithm for fitting evolutionary models doesn't work for OU on
non-ultrametric trees. I don't think this is as much of a concern in 2018,
as I think most/all packages that were doing such have fixed their code so
an alternative algorithm is used when a non-ultrametric tree is given (as
with a tree containing fossil taxa).

Cheers,
-Dave


On Thu, Dec 6, 2018 at 6:35 AM Danielle Miller 
wrote:

> Hi all,
>
> I have a non-rooted non-ultrametric tree and a corresponding set of a
> single trait values for each one of the tips.
> I’m interested whether it follows a BM model or an OU.
>
> Reading previous comments in the archive, I understood that running an OU
> process is inadequate in a case of non-ultrametric trees, however I did not
> fully understand why.
> As I use ouch package, what are the consequences of running an unrooted
> tree? And a non-ultrametric one?
>
> What would be the best way assessing this issue? Diversitree should be
> more reliable?
>
> I will appreciate any explanation and help,
> Danielle Miller
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at
> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>


-- 
David W. Bapst, PhD
Asst Research Professor, Geology & Geophysics, Texas A & M University
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
https://github.com/dwbapst/paleotree

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Extended Majority Consensus Topology (Allcompat Summary) in R? And some observations on ape's consensus() function

2018-10-27 Thread David Bapst
Hi all,

I was interested if anyone was familiar with R code that can estimate an
extended majority consensus tree (referred to as an 'allcompat' tree by the
sumt command in MrBayes)? This is a fully bifurcating summary of a tree
posterior, where each clade is maximally resolved by the split that is most
abundant in the considered post-burn-in posterior (i.e., that split which
has the plurality, if not the majority - the highest posterior probability
of any other competing, conflicting splits recovered within the posterior.
So, I guess one could also call these plurality consensus trees...).

The ape function `consensus` seemed promising at first, as it takes a `p`
argument which at 1 returns the strict consensus (the default), and at 0.5
returns the majority rule consensus (effectively the same as the
'halfcompat' option in MrBayes). So, I thought, I wonder what happens if I
set `p` below 0.5 - you could imagine that the extended majority consensus
is basically a similar threshold algorithm, but accepting solutions
(splits) of any frequency of occurrence in the tree set, so effectively
p~0.

Unfortunately, that is not how that works out, as `consensus` simply
assembles all splits with a frequency above the `p` value, but doesn't
discard conflicting splits. This means you can theoretically get more
resolved consensus trees below 0.5, but in practical terms your ability to
recover reasonable tree objects lasts until the frequency drops to the
point that you begin to accept conflicting splits.

Here's some code based off a phangorn example where I can do consensus to
get a more resolved tree as I delve into lower `p` values - you can see I
get a reasonable (if you think the extended majority rule ), more resolved
tree at `p = 0.4`, but at `p = 0.2` there are conflicting splits accepted,
such that the tree output no longer has a rational tree structure.

```
> library(ape)
> library(phangorn)
> data(Laurasiatherian)
> set.seed(42)
> bs <- bootstrap.phyDat(Laurasiatherian, FUN =
function(x)upgma(dist.hamming(x)),
+ bs=100)
>
> tA <- consensus(bs,p=1)
> tB <- consensus(bs, p=0.5)
> tC <- consensus(bs, p=0.45)
> tD <- consensus(bs, p=0.2)
>
> layout(matrix(1:4,2,2))
> plot(tA);plot(tB);plot(tC);plot(tD)
Error in plot.phylo(tD) :
  tree badly conformed; cannot plot. Check the edge matrix.
> str(tD)
List of 3
 $ edge : int [1:109, 1:2] 48 49 50 51 52 53 54 55 56 57 ...
 $ tip.label: chr [1:47] "GraySeal" "Vole" "Wallaroo" "Loris" ...
 $ Nnode: int 63
 - attr(*, "class")= chr "phylo"
Warning messages:
1: display list redraw incomplete
2: display list redraw incomplete
3: display list redraw incomplete
4: display list redraw incomplete
```
I'd be interested to know if anyone knows of an alternative way to do this
in R, or if perhaps I need to figure out how to modify `consensus` to
reject conflicting splits.

Cheers,
-Dave B

PS: Yes, I know there are real issues with such exhaustive consensus trees,
particularly they will likely agglomerate a combination of splits that
exists on no tree recovered within the posterior, but I have my reasons!

-- 
David W. Bapst, PhD
Asst Research Professor, Geology & Geophysics, Texas A & M University
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
https://github.com/dwbapst/paleotree

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] No PCOA Correction Applied but Corrected Eigenvalues Returned? (ape::pcoa)

2018-10-24 Thread David Bapst
Emmanuel, I'm familiar with the two typical corrections. I'm just curious
why or what `pcoa` is reporting as ` "Rel_corr_eig"` when no correction is
defined by the user.
-Dave

On Tue, Oct 23, 2018 at 10:26 PM Emmanuel Paradis 
wrote:

> Hi David,
>
> Have you tried one of the two possible corrections?
>
> R> res <- pcoa(dmat)
> R> res.lingoes <- pcoa(dmat, correction = "lingoes")
> R> res.lingoes$note
> [1] "Lingoes correction applied to negative eigenvalues: D' = -0.5*D^2 -
> 0.310850908498892 , except diagonal elements"
>
> The matrix $values of the output is different and contains the corrected
> eigenvalues in the second analysis:
>
> R> names(res$values)
> [1] "Eigenvalues""Relative_eig"   "Rel_corr_eig"   "Broken_stick"
> [5] "Cum_corr_eig"   "Cumul_br_stick"
> R> names(res.lingoes$values)
> [1] "Eigenvalues"  "Corr_eig" "Rel_corr_eig" "Broken_stick"
> [5] "Cum_corr_eig" "Cum_br_stick"
> R> any(res.lingoes$values$Corr_eig < 0)
> [1] FALSE
>
> Best,
>
> Emmanuel
>
> Le 23/10/2018 à 22:11, David Bapst a écrit :
> > Hi all,
> >
> > Not exactly phylogenetic, but I've recently uncovered some odd behavior
> > with `pcoa` in `ape` and I was curious if anyone understood what was
> > going on.
> >
> > Usually, if you don't have negative eigenvalues and aren't using a
> > correction, `pcoa` will return the raw eigenvalues. However, I've found
> > if there are negative eigenvalues and no correction is used, even though
> > no correction is applied, the function will still return some corrected
> > relative eigenvalues, and cumulative corrected eigenvalues. What
> > correction was used in this case is not clear.
> >
> > Here's some output using an example dataset from paleotree to
> > demonstrate the weirdness, both without correction argument specified
> > and with it specified as "none".
> >
> > ```
> >  > library(ape)
> >  > library(paleotree)
> >  >
> >  > data(graptDisparity)
> >  > dmat<-graptDistMat
> >  > res<-pcoa(dmat)
> >  > str(res)
> > List of 5
> >   $ correction: chr [1:2] "none" "1"
> >   $ note  : chr "No correction was applied to the negative
> eigenvalues"
> >   $ values:'data.frame': 183 obs. of  6 variables:
> >..$ Eigenvalues   : num [1:183] 3.22 2.72 1.9 1.74 1.41 ...
> >..$ Relative_eig  : num [1:183] 0.217 0.183 0.128 0.117 0.095 ...
> >..$ Rel_corr_eig  : num [1:183] 0.0495 0.0424 0.031 0.0287 0.0241 ...
> >..$ Broken_stick  : num [1:183] 0.0319 0.0264 0.0236 0.0218 0.0204 ...
> >..$ Cum_corr_eig  : num [1:183] 0.0495 0.0919 0.1229 0.1517 0.1758 ...
> >..$ Cumul_br_stick: num [1:183] 0.0319 0.0583 0.082 0.1038 0.1242 ...
> >   $ vectors   : num [1:183, 1:72] 0.0143 -0.1818 -0.1011 0.104 0.101 ...
> >..- attr(*, "dimnames")=List of 2
> >.. ..$ : chr [1:183] "'Bulmanograptus' macilentus" "'Monograptus'
> > arciformis" "'Monograptus' austerus" "'Paramplexograptus' kiliani" ...
> >.. ..$ : chr [1:72] "Axis.1" "Axis.2" "Axis.3" "Axis.4" ...
> >   $ trace : num 14.8
> >   - attr(*, "class")= chr "pcoa"
> >  >
> >  > data(graptDisparity)
> >  > dmat<-graptDistMat
> >  > res<-pcoa(dmat,correction="none")
> >  > str(res)
> > List of 5
> >   $ correction: chr [1:2] "none" "1"
> >   $ note  : chr "No correction was applied to the negative
> eigenvalues"
> >   $ values:'data.frame': 183 obs. of  6 variables:
> >..$ Eigenvalues   : num [1:183] 3.22 2.72 1.9 1.74 1.41 ...
> >..$ Relative_eig  : num [1:183] 0.217 0.183 0.128 0.117 0.095 ...
> >..$ Rel_corr_eig  : num [1:183] 0.0495 0.0424 0.031 0.0287 0.0241 ...
> >..$ Broken_stick  : num [1:183] 0.0319 0.0264 0.0236 0.0218 0.0204 ...
> >..$ Cum_corr_eig  : num [1:183] 0.0495 0.0919 0.1229 0.1517 0.1758 ...
> >..$ Cumul_br_stick: num [1:183] 0.0319 0.0583 0.082 0.1038 0.1242 ...
> >   $ vectors   : num [1:183, 1:72] 0.0143 -0.1818 -0.1011 0.104 0.101 ...
> >..- attr(*, "dimnames")=List of 2
> >.. ..$ : chr [1:183] "'Bulmanograptus' macilentus" "'Monograptus'
> > arciformis" "'Monograptus' austerus" "'Paramplexograptus' kiliani" ...
> >   

[R-sig-phylo] No PCOA Correction Applied but Corrected Eigenvalues Returned? (ape::pcoa)

2018-10-23 Thread David Bapst
Hi all,

Not exactly phylogenetic, but I've recently uncovered some odd behavior
with `pcoa` in `ape` and I was curious if anyone understood what was going
on.

Usually, if you don't have negative eigenvalues and aren't using a
correction, `pcoa` will return the raw eigenvalues. However, I've found if
there are negative eigenvalues and no correction is used, even though no
correction is applied, the function will still return some corrected
relative eigenvalues, and cumulative corrected eigenvalues. What correction
was used in this case is not clear.

Here's some output using an example dataset from paleotree to demonstrate
the weirdness, both without correction argument specified and with it
specified as "none".

```
> library(ape)
> library(paleotree)
>
> data(graptDisparity)
> dmat<-graptDistMat
> res<-pcoa(dmat)
> str(res)
List of 5
 $ correction: chr [1:2] "none" "1"
 $ note  : chr "No correction was applied to the negative eigenvalues"
 $ values:'data.frame': 183 obs. of  6 variables:
  ..$ Eigenvalues   : num [1:183] 3.22 2.72 1.9 1.74 1.41 ...
  ..$ Relative_eig  : num [1:183] 0.217 0.183 0.128 0.117 0.095 ...
  ..$ Rel_corr_eig  : num [1:183] 0.0495 0.0424 0.031 0.0287 0.0241 ...
  ..$ Broken_stick  : num [1:183] 0.0319 0.0264 0.0236 0.0218 0.0204 ...
  ..$ Cum_corr_eig  : num [1:183] 0.0495 0.0919 0.1229 0.1517 0.1758 ...
  ..$ Cumul_br_stick: num [1:183] 0.0319 0.0583 0.082 0.1038 0.1242 ...
 $ vectors   : num [1:183, 1:72] 0.0143 -0.1818 -0.1011 0.104 0.101 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:183] "'Bulmanograptus' macilentus" "'Monograptus'
arciformis" "'Monograptus' austerus" "'Paramplexograptus' kiliani" ...
  .. ..$ : chr [1:72] "Axis.1" "Axis.2" "Axis.3" "Axis.4" ...
 $ trace : num 14.8
 - attr(*, "class")= chr "pcoa"
>
> data(graptDisparity)
> dmat<-graptDistMat
> res<-pcoa(dmat,correction="none")
> str(res)
List of 5
 $ correction: chr [1:2] "none" "1"
 $ note  : chr "No correction was applied to the negative eigenvalues"
 $ values:'data.frame': 183 obs. of  6 variables:
  ..$ Eigenvalues   : num [1:183] 3.22 2.72 1.9 1.74 1.41 ...
  ..$ Relative_eig  : num [1:183] 0.217 0.183 0.128 0.117 0.095 ...
  ..$ Rel_corr_eig  : num [1:183] 0.0495 0.0424 0.031 0.0287 0.0241 ...
  ..$ Broken_stick  : num [1:183] 0.0319 0.0264 0.0236 0.0218 0.0204 ...
  ..$ Cum_corr_eig  : num [1:183] 0.0495 0.0919 0.1229 0.1517 0.1758 ...
  ..$ Cumul_br_stick: num [1:183] 0.0319 0.0583 0.082 0.1038 0.1242 ...
 $ vectors   : num [1:183, 1:72] 0.0143 -0.1818 -0.1011 0.104 0.101 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:183] "'Bulmanograptus' macilentus" "'Monograptus'
arciformis" "'Monograptus' austerus" "'Paramplexograptus' kiliani" ...
  .. ..$ : chr [1:72] "Axis.1" "Axis.2" "Axis.3" "Axis.4" ...
 $ trace : num 14.8
 - attr(*, "class")= chr "pcoa"
```

Obviously if there are negative eigenvalues, a correction should probably
be applied (although perhaps this is a bit of a philosophical matter), but
still its unclear why the corrected eigenvalues are calculated, or how they
are calculated. They are clearly different from the uncorrected values.

Cheers,
-Dave Bapst


-- 
David W. Bapst, PhD
Asst Research Professor, Geology & Geophysics, Texas A & M University
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
https://github.com/dwbapst/paleotree

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Measuring Phylogenetic Signal

2018-07-13 Thread David Bapst
Alyson-

Following off of what Liam said, one thing to consider is as most measures
of phylogenetic signal aren't relative to the units of the traits
considered, any transformation of the data should be about equally
interpretable. To take a spin with Liam's example, if , if the log-scale
trait had high phylogenetic signal, you would infer that large things
(Liam's whales) really are more likely to be related to other large things
(and the same for small things), in the case where you reduce variation
among the bigger things (whales), and treat the smaller things (mice) as if
they had more variance.

For example, you might think the large size of 'whales' in your dataset
reflects signal (evolutionary conservatism - simply that they are all big
partly because they share common ancestors that had a big size), but if the
sizes of large things (whales) vary much more than all the variation among
your small things ('mice'), a measurement of signal on a raw scale might
think that maybe that is not very good signal, as much more evolution
change had to occur along the branches linking large/'whale' species than
the branches linking related 'mice'. This is a pretty typical situation.

I suppose one might not want to log scale if they thought that there was
not much evolutionary difference among big things, but a lot among small
things, but this just reflected higher rates of change between small
things. So, to defend not log-scaling, you'd basically need to argue that
evolutionary size change *doesn't* scale with size (or doesn't scale
positively, at least), but evolution-scales-with-size seems like one of
those things we generally assume prima facie is true in biology, so I
suppose you'd need to have a pretty good explanation why that would be.

Uh, I hope that philosophizing made sense.

(And yeah, I'm sure someone in the peanut gallery will point out that our
choice of a log scaling is entirely arbitrary, because who really knows
what the proper scaling of biological data along size gradients are
anyway)

-Dave Bapst
Geology & Geophysics, Texas A & M University




On Fri, Jul 13, 2018 at 1:07 PM, Alyson Brokaw  wrote:

> Hello Everyone,
>
> I am working with a comparative dataset using bat morphometrics. As part of
> my analysis, I want to estimate the phylogenetic signal of my variables. I
> understand how to do this using R. My question is more specifically about
> what kind of data I should be using when calculating the estimates.
>
> For the purposes of my other analyses (linear regressions), I have
> log-transformed my data to meet assumptions for normality. When estimating
> phylogenetic signal, should I use my non-transformed, raw variables or the
> transformed variables? I get slightly different outputs if I run both on
> the same measure. My intuition is that using the raw values is more
> interpretable, but figured I would ask some people with more experience.
>
> Thank you for your time.
>
> -Alyson
> 
>
> Alyson Brokaw
> M.S. Candidate: Biology, Humboldt State University
> Cornell University '11, Ecology and Evolutionary Biology
>
> LinkedIn Profile 
> Follow my research journey here! 
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-
> sig-ph...@r-project.org/
>



-- 
David W. Bapst, PhD
Asst Research Professor, Geology & Geophysics, Texas A & M University
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
https://github.com/dwbapst/paleotree
Google Calendar: https://goo.gl/EpiM4J

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] estimate ancestral state with OUwie models

2018-06-20 Thread David Bapst
That sounds pretty different from doing ancestral reconstruction with some
fossil data, and hoping the resulting node estimates will reflect reality,
because fossil data is now involved. Look, I think every method has its
uses; I'm just railing against the idea that the concerns of any particular
method go away by tapping into the fossil record.

Personally I have a work-in-progess myself that involves parsimony
ancestral state reconstruction of some very slow-evolving discrete traits
in a fossil-rich group. I think in that particular case, I can defend my
approach, but I don't think it'd be applicable in many other cases, even
with other fossil-rich groups.

Cheers,
-Dave

On Thu, Jun 14, 2018 at 11:08 AM, Jacob Berv  wrote:

> What about situations in which fossil calibrations are used as priors to
> inform reconstructions for uncalibrated important/interesting nodes? Sure,
> there is great uncertainty, but that doesn’t necessarily imply we should
> entirely abandon hypothesis testing using this approach, does it? I like
> the idea of using priors to constrain different scenarios and then using
> model testing to compare alternative histories (though one’s model ranking
> may change depending on the underlying models too, I guess).
>
> Jake
>
>
> > On Jun 14, 2018, at 9:32 AM, David Bapst  wrote:
> >
> > Simone, Marguerite, others,
> >
> > I'll also add that I think there's a great deal to be skeptical of
> > ancestral trait reconstruction even when large amounts of fossil data is
> > available. You can try the exercise yourself: simulate pure BM on a
> > non-ultrametric tree with lots of 'extinct' tips, and you'll still find
> > pretty large confidence intervals on the estimates of the trait values.
> > What does it mean to do ancestral trait reconstruction, if our
> calculations
> > of uncertainty are that broad?
> >
> > That said, in the era of sampled-ancestor phylogenetics for fossil data,
> > the ability to examine quantitative support for ancestor-descendant
> > relationships among fossil taxa may allow alternative routes to
> considering
> > this issue.
> >
> > Cheers,
> > -Dave
> >
> > On Tue, Jun 12, 2018 at 2:43 AM, Simone Blomberg 
> > wrote:
> >
> >> I would add an extra caveat to Marguerite’s excellent post: Most
> >> researchers work with extant taxa only, ignoring extinction. This
> causes a
> >> massive ascertainment bias, and the character states of the extinct taxa
> >> can often be very different to the ancestral state reconstructions,
> >> particularly if the evolutionary model is wrong. Eg. there has been an
> >> evolutionary trend for example. Ancestral state reconstructions based
> only
> >> on extant taxa should be treated as hypotheses to be tested with fossil
> >> data. I wouldn’t rely on them for much more.
> >>
> >> Cheers,
> >> Simone.
> >>
> >> Sent from my iPhone
> >>
> >> On 12 Jun 2018, at 4:59 pm, Marguerite Butler 
> >> wrote:
> >>
> >> Aloha all,
> >>
> >> There is no requirement for an ultra metric tree in the formulae
> reported
> >> in Butler-King 2004. Interested investigators should in particular read
> the
> >> supplementary materials where the mathematical details are worked out.
> >>
> >> We do generally use ultrametric trees because as comparative biologists,
> >> it is more straightforward to think about evolution in units of time
> rather
> >> than in terms of mutational units, etc. However this is by choice, not
> any
> >> methodological limitation.
> >>
> >> Once the model parameters are found, the phylogenetic
> variance-covariance
> >> matrix defined by the alpha, thetas, and sigmas can be used to compute
> >> ancestral states using a weighted least squares reconstruction method
> >> (instead of the typical BM var-cov matrix). The mapping of the alphas,
> >> thetas, and sigmas onto the tree are incorporated into this V-COV
> matrix,
> >> so that accounts for the OU model.
> >>
> >> NOTES:
> >> 1) without knowing why you are doing this, I do feel compelled to warn
> you
> >> that it is unclear why one would want to estimate ancestral states for
> >> poorly-fitting models. Be careful!
> >>
> >> 2) I hope you realize that ancestral states are in general poorly
> >> estimated, even assuming the “correct” model. This is because there is
> less
> >> and less information to anchor the values as you get farther from the
> tips,
> >> similar to the root estimation pr

Re: [R-sig-phylo] estimate ancestral state with OUwie models

2018-06-14 Thread David Bapst
chluter, D., T. Price, A. O. Mooers, and D. Ludwig. 1997. Likelihood of
> ancestor states in adaptive radiation. Evolution 51:1699–1711.
>
> Butler, M. A., and J. B. Losos. 1997. Testing for unequal amounts of
> evolution in a continuous character on dif- ferent branches of a
> phylogenetic tree using linear and squared-change parsimony: an example
> using Lesser Antillean Anolis lizards. Evolution 51:1623–1635.
>
> Hansen T.F., Pienaar J., Orzack S.H. 2008. A comparative method for
> studying adaptation to a randomly evolving environment. Evolution
> 62:1965–1977.
>
> Ho L.S.T., Ané C.. 2014. Intrinsic inference difficulties for trait
> evolution with Ornstein-Uhlenbeck models. Methods Ecol. Evol. 2:1133–1146.
>
> Cressler C., Butler M.A., and King A. A. (2015) Detecting adaptive
> evolution in phylogenetic comparative analysis using the Ornstein-Uhlenbeck
> model.  Sys. Bio. 64(6):953-968. DOI: 10.1093/sysbio/syv043
>
> Boettiger C., Coop G., Ralph P. 2012. Is your phylogeny informative?
> Measuring the power of comparative methods. Evolution 66: 2240–2251.
> 
> Marguerite A. Butler
> Professor
>
> Department of Biology
> 2538 McCarthy Mall, Edmondson Hall 216
> Honolulu, HI 96822
>
> Office: 808-956-4713
> Dept: 808-956-8617
> Lab:  808-956-5867
> FAX:   808-956-4745
> http://butlerlab.org
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__butlerlab.org=DwMGaQ=ODFT-G5SujMiGrKuoJJjVg=bm-Cvhz5zv2wG5pZT4ATCg=XIxoaHi_ImxCh5QSrmEwsVni8p58-9Xpxcc2aQgYVVI=wCJc2Wt5C_3_9p68keEdKURQw1DgMPgzYSroUns4EgU=>
> http://manoa.hawaii.edu/biology/people/marguerite-butler
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__manoa.hawaii.edu_biology_people_marguerite-2Dbutler=DwMGaQ=ODFT-G5SujMiGrKuoJJjVg=bm-Cvhz5zv2wG5pZT4ATCg=XIxoaHi_ImxCh5QSrmEwsVni8p58-9Xpxcc2aQgYVVI=kjcIRTrUHxUQV36VKJBe2PFbPgsjX97DHi6mXwRRy_8=>
> http://www2.hawaii.edu/~mbutler
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www2.hawaii.edu_-7Embutler=DwMGaQ=ODFT-G5SujMiGrKuoJJjVg=bm-Cvhz5zv2wG5pZT4ATCg=XIxoaHi_ImxCh5QSrmEwsVni8p58-9Xpxcc2aQgYVVI=a0SwA8yTo1qWJZLpuWR9cVHuO_cxYqknynO9BdyATbs=>
>
>
> On Jun 11, 2018, at 7:33 PM, Simone Blomberg 
> wrote:
>
> This sounded wrong to me, as the OU process should be agnostic to the
> dataset: There are no restrictions inherent in the OU process that apply
> particularly to phylogenetic data, whether the tree is ultrametric or not.
> I re-read Slater 2014 and it is clear that you can use branch length
> transformations with OU, so long as you use the (correct) Hansen formula,
> not the Butler-king formula, which does indeed require an ultrametric tree.
>
> Cheers,
>
> Simone.
>
> Sent from my iPhone
>
> On 12 Jun 2018, at 8:01 am, David Bapst  wrote:
>
> Just to follow off what Lucas said, but please note you cannot rescale
> branches of a phylogeny using an OU model when the tree is
> non-ultrametric (such as when it contains extinct, fossil taxa as
> tips). Slater (2014, MEE) discusses this more in a brief correction to
> Slater (2013).
>
> I don't know if anyone in this conversation has a non-ultrametric
> tree, but I wanted to make that clear for anyone who stumbles on this
> thread n the future using a google search.
> -Dave
>
>
>
> On Sun, Jun 10, 2018 at 12:25 PM, Lucas Jardim 
> wrote:
> Hi Bruno,
>
> You can transform the branches of your phylogeny using the estimated
> parameters of OU models. Then, if those models describe the observed data
> adequatly, the transformed tree should model the observed data as a
> Brownian motion model. So you can use an ancestral state reconstruction
> based on Brownian motion model. However, I do not know if that is the best
> approach as optimum values would not be included into the reconstruction
> process.
>
> Best,
> --
> Lucas Jardim
> Doutor em Ecologia e Evolução
> Bolsista do INCT-EECBio (Ecologia, Evolução e Conservação da
> Biodiversidade)
> Instituto de Ciências Biológicas
> Laboratório de Ecologia Teórica e Síntese
> Universidade Federal de Goiás
> http://dinizfilho.wix.com/dinizfilholab
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__dinizfilho.wix.com_dinizfilholab=DwMGaQ=ODFT-G5SujMiGrKuoJJjVg=bm-Cvhz5zv2wG5pZT4ATCg=XIxoaHi_ImxCh5QSrmEwsVni8p58-9Xpxcc2aQgYVVI=hmSpj_Jqi4ORoecbP03Rbwo9Rev08deDEcSe7sCS0ts=>
>
>   [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dphylo=DwMGaQ=ODFT-G5SujMiGrKuoJJjVg=bm-Cvhz5zv2wG5pZT4ATCg=XIxoaHi_ImxCh5Q

Re: [R-sig-phylo] estimate ancestral state with OUwie models

2018-06-14 Thread David Bapst
Simone, others,

Perhaps I misunderstand, but I believe Slater (2014) shows that there is no
correct branch length transformation for a non-ultrametric tree under an OU
process. The correct transformation that Slater applies is Hansen's, yes,
but to the VCV matrix. Slater does point out there is one VCV-free approach
that does work for non-ultrametric trees, and that is the pruning-algorithm
that was at the time implemented in diversitree.

Some quotes from Slater (2014):

"The time-dependent decay in covariance that accrues after divergence under
OU results in the rather unique phenomenon that non-ultrametric trees
cannot be rescaled according to an OU process as ultrametric trees can."

"This is a necessary error, because a treelike structure cannot be
represented with different shared path lengths for pairs of descendents
that branch from the same ancestor. However, using Hansen’s (1997) formula
to directly transform V results in the correct pattern (Fig. 1d); Vt4,t1 is
higher than Vt4,t2 because the phylogenetic distance between t1 and t4, and
thus the time available for covariance decay, is lower as a result of t1
going extinct before the present. It is additionally worth noting that
branch length scaling results in underestimated variances for fossil taxa
(upper left diagonal of 1b, c, and d); branch length transformation reduces
the variance of t1 compared with that of the other species, while direct
matrix scaling increases the variance of the fossil taxon to a similar
value as in the extant species."

"For example, although problems with branch length rescaling render
Freckleton’s (2012) approach inappropriate, it is still possible to use
VCV-free approaches to rapidly compute likelihoods with non-ultrametric
data. The pruning algorithm used by FitzJohn (2012) in his DIVERSITREE
package, which is based on Felsenstein (1973, 1981), can be used to fit OU
models to non-ultrametric trees because it works on per branch basis,
rather than by scaling all branch lengths simultaneously."

Again, this is (I think) common knowledge that OU
branch-length-transformations cannot be safely applied to non-ultrametric
trees, in our post-Slater-2014 world. However, following Lucas's comment, I
wanted to make sure the record is correct for those who stumble on this
thread later. As Slater (2014) points out, us paleontologists are ever
increasingly users of phylogenetic comparative methods, and so as
methods-developers, we should always take into account the possibility that
a user's dataset may include fossil tips.

Cheers,
-Dave

PS: I've cc'd Graham so he can rebuke me if I'm way off-the-mark here.





On Tue, Jun 12, 2018 at 12:33 AM, Simone Blomberg 
wrote:

> This sounded wrong to me, as the OU process should be agnostic to the
> dataset: There are no restrictions inherent in the OU process that apply
> particularly to phylogenetic data, whether the tree is ultrametric or not.
> I re-read Slater 2014 and it is clear that you can use branch length
> transformations with OU, so long as you use the (correct) Hansen formula,
> not the Butler-king formula, which does indeed require an ultrametric tree.
>
> Cheers,
>
> Simone.
>
> Sent from my iPhone
>
> > On 12 Jun 2018, at 8:01 am, David Bapst  wrote:
> >
> > Just to follow off what Lucas said, but please note you cannot rescale
> > branches of a phylogeny using an OU model when the tree is
> > non-ultrametric (such as when it contains extinct, fossil taxa as
> > tips). Slater (2014, MEE) discusses this more in a brief correction to
> > Slater (2013).
> >
> > I don't know if anyone in this conversation has a non-ultrametric
> > tree, but I wanted to make that clear for anyone who stumbles on this
> > thread n the future using a google search.
> > -Dave
> >
> >
> >
> >> On Sun, Jun 10, 2018 at 12:25 PM, Lucas Jardim <
> lucas.ljard...@gmail.com> wrote:
> >> Hi Bruno,
> >>
> >> You can transform the branches of your phylogeny using the estimated
> >> parameters of OU models. Then, if those models describe the observed
> data
> >> adequatly, the transformed tree should model the observed data as a
> >> Brownian motion model. So you can use an ancestral state reconstruction
> >> based on Brownian motion model. However, I do not know if that is the
> best
> >> approach as optimum values would not be included into the reconstruction
> >> process.
> >>
> >> Best,
> >> --
> >> Lucas Jardim
> >> Doutor em Ecologia e Evolução
> >> Bolsista do INCT-EECBio (Ecologia, Evolução e Conservação da
> >> Biodiversidade)
> >> Instituto de Ciências Biológicas
> >> Laboratório de Ecologia Teórica e Síntese
> >> Universidade Fede

Re: [R-sig-phylo] estimate ancestral state with OUwie models

2018-06-11 Thread David Bapst
Just to follow off what Lucas said, but please note you cannot rescale
branches of a phylogeny using an OU model when the tree is
non-ultrametric (such as when it contains extinct, fossil taxa as
tips). Slater (2014, MEE) discusses this more in a brief correction to
Slater (2013).

I don't know if anyone in this conversation has a non-ultrametric
tree, but I wanted to make that clear for anyone who stumbles on this
thread n the future using a google search.
-Dave



On Sun, Jun 10, 2018 at 12:25 PM, Lucas Jardim  wrote:
> Hi Bruno,
>
> You can transform the branches of your phylogeny using the estimated
> parameters of OU models. Then, if those models describe the observed data
> adequatly, the transformed tree should model the observed data as a
> Brownian motion model. So you can use an ancestral state reconstruction
> based on Brownian motion model. However, I do not know if that is the best
> approach as optimum values would not be included into the reconstruction
> process.
>
> Best,
> --
> Lucas Jardim
> Doutor em Ecologia e Evolução
> Bolsista do INCT-EECBio (Ecologia, Evolução e Conservação da
> Biodiversidade)
> Instituto de Ciências Biológicas
> Laboratório de Ecologia Teórica e Síntese
> Universidade Federal de Goiás
> http://dinizfilho.wix.com/dinizfilholab
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Asst Research Professor, Geology & Geophysics, Texas A & M University
https://github.com/dwbapst/paleotree
Google Calendar: https://goo.gl/EpiM4J

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Problem with negative ages in OUwie.boot?

2018-05-07 Thread David Bapst
Interesting, Rafael. Perhaps it is just barely within tolerance for
force.ultrametric, but not within the zone to avoid issues with
branching.times?

What did

node.depth.edgelength(tree)

return? That should give us an idea how far each tip is from the root.

As a note, Eliot, I don't think I've seen branching.times have
problems with tree with zero-length branches, although that is pretty
unusual with the ultrametric trees valid with branching.times.

Cheers,
-Dave

On Fri, May 4, 2018 at 8:32 AM, Rafael S Marcondes
<raf.marcon...@gmail.com> wrote:
> Hi Elliot et al,
>
> Thanks for all the helpful answers, and sorry for my delay in getting back.
> min(tree$edge.length) returns a nonzero positive number, but running
> force.ultrametric on the tr did not cause that warning message to go away...
>
> --
> Rafael Sobral Marcondes
> PhD Candidate (Systematics, Ecology and Evolution/Ornithology)
>
> Museum of Natural Science
> Louisiana State University
> 119 Foster Hall
> Baton Rouge, LA 70803, USA
>
> Twitter: @brown_birds
>
>
>
> On Fri, May 4, 2018 at 8:22 AM Eliot Miller <eliot.is...@gmail.com> wrote:
>>
>> I suggest calling min(tree$edge.length) on any tree you plan to use for
>> comparative methods, including the one you're having trouble with Rafael. If
>> you get a negative value, then something is really funny and you need to
>> solve it. If you get a zero then various comparative methods will throw
>> errors, but it's not the end of the world--there are workarounds. If neither
>> of these things is true, and the tree is still returning FALSE to
>> is.ultrametric, then assuming the tree is supposed to be ultrametric, it's
>> almost certainly a tolerance thing (which you can check directly by tweaking
>> the tol method in the is.ultrametric function). In that case, I've had good
>> experiences using the phangorn/phytools approach to force the tree
>> ultrametric.
>>
>> Eliot
>>
>> On Thu, May 3, 2018 at 5:08 PM, Liam J. Revell <liam.rev...@umb.edu>
>> wrote:
>>>
>>> Just to clarify, force.ultrametric is not a formal rate-smoothing method
>>> or anything like that. It is intended only for use to resolve numerical
>>> precision issues such as the one raised in this thread.
>>>
>>> Liam J. Revell, Associate Professor of Biology
>>> University of Massachusetts Boston
>>> & Profesor Asociado, Programa de Biología
>>> Universidad del Rosario
>>> web: http://faculty.umb.edu/liam.revell/
>>>
>>> On 5/3/2018 4:21 PM, Theodore Garland wrote:
>>>>
>>>> I'll just add that it is always a really good idea to view the trees you
>>>> (think you) are using, not just rely on the variance-covariance matrices
>>>> derived from them and used in PGLS analyses, etc.  Several times when I was
>>>> compiling trees and data from the literature authors sent me tree files
>>>> (e.g., Nexus) that did not match what they showed in a paper or described 
>>>> in
>>>> the methods.  Sometimes this was because the default display in Mesquite is
>>>> NOT "branches proportional to lengths," but I am sure potentially 
>>>> misleading
>>>> displays occur in some other programs as well.
>>>>
>>>> If one does force a tree to become ultrametric, then make sure you
>>>> provide that tree and the original in the Online Supplemental Material or
>>>> whatever, and clearly say what you did.
>>>>
>>>> Cheers,
>>>> Ted
>>>>
>>>>
>>>>
>>>> Theodore Garland, Jr., Distinguished Professor
>>>>
>>>> Department of Evolution, Ecology, and Organismal Biology (EEOB)
>>>>
>>>> University of California, Riverside
>>>>
>>>> Riverside, CA 92521
>>>>
>>>> Office Phone: (951) 827-3524 <tel:%28951%29%20827-3524>
>>>>
>>>> Facsimile: (951) 827-4286 <tel:%28951%29%20827-4286> (not confidential)
>>>>
>>>> Email: tgarl...@ucr.edu <mailto:tgarl...@ucr.edu>
>>>>
>>>> http://www.biology.ucr.edu/people/faculty/Garland.html
>>>>
>>>> http://scholar.google.com/citations?hl=en=iSSbrhwJ
>>>>
>>>>
>>>> Director, UCR Institute for the Development of
>>>> <http://idea.ucr.edu/>Educational Applications <http://idea.ucr.edu/>
>>>>
>>>>
>>>> Editor in Chief, /Physiological and Biochemical Zoology
>>>> <http

Re: [R-sig-phylo] Problem with negative ages in OUwie.boot?

2018-05-03 Thread David Bapst
Hmm. I hope that isn't the case - branching.times() is used pretty
widely in ape-dependent packages for getting node ages from dated
ultrametric trees, and if such minimally non-ultrametric trees can
cause branching.times throw negative node ages, then I'm really
concerned what impact that might have elsewhere in the R-phylo
universe.
-Dave

On Wed, May 2, 2018 at 2:30 PM, Brian O'Meara <bome...@utk.edu> wrote:
> On Wed, May 2, 2018 at 2:53 PM, David Bapst <dwba...@tamu.edu> wrote:
>>
>> Given that your tree appears to be non-ultrametric enough to cause
>> branching.times to throw some nonsensical node ages, if it is supposed
>> to be ultrametric. I recommend checking it carefully to figure out why
>> the tips seem to not quite be at the same distance from the root.
>>
>
>  Sometimes this happens with tree import from a file -- it could be a newick
> tree with branch lengths precise to the hundredths but a lot of the R
> ultrametric tests by default use higher precision (1e-08, iirc).
>
> Best,
> Brian
>



-- 
David W. Bapst, PhD
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
Lecturer, Geology & Geophysics, Texas A & M University
https://github.com/dwbapst/paleotree
Google Calender: https://goo.gl/EpiM4J

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Problem with negative ages in OUwie.boot?

2018-05-02 Thread David Bapst
Hi Rafael,

I found the source of the error, I think, and filed an issue at github
on the OUwie repo. There are issues with how the code in OUwie handles
non-ultrametric trees if a root.age isn't given by the user, causing
problems for the paleotree function dateNodes, and your tree is
apparently non-ultrametric enough to run afoul of these issues.

https://github.com/thej022214/OUwie/issues/3

Given that your tree appears to be non-ultrametric enough to cause
branching.times to throw some nonsensical node ages, if it is supposed
to be ultrametric. I recommend checking it carefully to figure out why
the tips seem to not quite be at the same distance from the root.

Cheers,
-Dave.

On Wed, May 2, 2018 at 1:35 PM, David Bapst <dwba...@tamu.edu> wrote:
> Rafael,
>
> That error message is from paleotree's dateNodes function, which is
> called as part of OUwie's approach to getting node dates. I think I
> see what Elliot is trying to get at, but this might be quicker:
>
> node.depth.edgelength(tree)
>
> That should tell us how far each node, including the tips, are from the root.
>
> Cheers,
> -Dave
>
> On Wed, May 2, 2018 at 1:26 PM, Eliot Miller <eliot.is...@gmail.com> wrote:
>> What does: min(tree$edge.length) say?
>>
>> Eliot
>>
>> On Wed, May 2, 2018 at 2:22 PM, Rafael S Marcondes <raf.marcon...@gmail.com>
>> wrote:
>>
>>> Here's a little more info that may be relevant: the tree is not supposed to
>>> have negative dates. Although when I do is.ultrametric(tr) I get FALSE, I
>>> have always been just ascribing that to lack of precision, in part because
>>> it has never been a problem with OUwie().
>>>
>>>
>>> *--*
>>> *Rafael Sobral Marcondes*
>>> PhD Candidate (Systematics, Ecology and Evolution/Ornithology)
>>>
>>> Museum of Natural Science <http://sites01.lsu.edu/wp/mns/>
>>> Louisiana State University
>>> 119 Foster Hall
>>> Baton Rouge, LA 70803, USA
>>>
>>> Twitter: @brown_birds <https://twitter.com/brown_birds>
>>>
>>>
>>>
>>> On Wed, May 2, 2018 at 1:08 PM Rafael S Marcondes <raf.marcon...@gmail.com
>>> >
>>> wrote:
>>>
>>> > Hi all,
>>> >
>>> > I need some help with a warning message I've been getting when running
>>> > parametric bootstrapping in OUwie.
>>> >
>>> > >OUwie.boot(nboot=1, simmap.tree=F...)
>>> > Beginning parametric bootstrap -- performing 1 replicates
>>> > Warning: Some dates are negative? rootAge may be incorrectly defined or
>>> > you are using a time-scaling method that warps the tree, like aba or
>>> zbla.
>>> > Initializing...
>>> > Finished. Begin thorough search...
>>> > Finished. Summarizing results.
>>> >
>>> > Initially I didn't give it much thought, but my bootstrapping results are
>>> > quite unexpected, and I'm starting to think that may be related to that
>>> > warning.
>>> >
>>> > I don't get that warning when I run OUwie() with the same
>>> > tree/dataset/settings, and I've been able to trace it to the function
>>> > dateNodes in the package paleotree, but haven't been able to go any
>>> further
>>> > than that.
>>> >
>>> > Thanks in advance for any help!
>>> >
>>> >
>>> >
>>> > *--*
>>> > *Rafael Sobral Marcondes*
>>> > PhD Candidate (Systematics, Ecology and Evolution/Ornithology)
>>> >
>>> > Museum of Natural Science <http://sites01.lsu.edu/wp/mns/>
>>> > Louisiana State University
>>> > 119 Foster Hall
>>> > Baton Rouge, LA 70803, USA
>>> >
>>> > Twitter: @brown_birds <https://twitter.com/brown_birds>
>>> >
>>> >
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ___
>>> R-sig-phylo mailing list - R-sig-phylo@r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>>> Searchable archive at http://www.mail-archive.com/r-
>>> sig-ph...@r-project.org/
>>>
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-sig-phylo mailing list - R-sig-phylo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
>
>
>
> --
> David W. Bapst, PhD
> Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
> Lecturer, Geology & Geophysics, Texas A & M University
> https://github.com/dwbapst/paleotree
> Google Calender: https://goo.gl/EpiM4J



-- 
David W. Bapst, PhD
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
Lecturer, Geology & Geophysics, Texas A & M University
https://github.com/dwbapst/paleotree
Google Calender: https://goo.gl/EpiM4J

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Problem with negative ages in OUwie.boot?

2018-05-02 Thread David Bapst
Rafael,

That error message is from paleotree's dateNodes function, which is
called as part of OUwie's approach to getting node dates. I think I
see what Elliot is trying to get at, but this might be quicker:

node.depth.edgelength(tree)

That should tell us how far each node, including the tips, are from the root.

Cheers,
-Dave

On Wed, May 2, 2018 at 1:26 PM, Eliot Miller  wrote:
> What does: min(tree$edge.length) say?
>
> Eliot
>
> On Wed, May 2, 2018 at 2:22 PM, Rafael S Marcondes 
> wrote:
>
>> Here's a little more info that may be relevant: the tree is not supposed to
>> have negative dates. Although when I do is.ultrametric(tr) I get FALSE, I
>> have always been just ascribing that to lack of precision, in part because
>> it has never been a problem with OUwie().
>>
>>
>> *--*
>> *Rafael Sobral Marcondes*
>> PhD Candidate (Systematics, Ecology and Evolution/Ornithology)
>>
>> Museum of Natural Science 
>> Louisiana State University
>> 119 Foster Hall
>> Baton Rouge, LA 70803, USA
>>
>> Twitter: @brown_birds 
>>
>>
>>
>> On Wed, May 2, 2018 at 1:08 PM Rafael S Marcondes > >
>> wrote:
>>
>> > Hi all,
>> >
>> > I need some help with a warning message I've been getting when running
>> > parametric bootstrapping in OUwie.
>> >
>> > >OUwie.boot(nboot=1, simmap.tree=F...)
>> > Beginning parametric bootstrap -- performing 1 replicates
>> > Warning: Some dates are negative? rootAge may be incorrectly defined or
>> > you are using a time-scaling method that warps the tree, like aba or
>> zbla.
>> > Initializing...
>> > Finished. Begin thorough search...
>> > Finished. Summarizing results.
>> >
>> > Initially I didn't give it much thought, but my bootstrapping results are
>> > quite unexpected, and I'm starting to think that may be related to that
>> > warning.
>> >
>> > I don't get that warning when I run OUwie() with the same
>> > tree/dataset/settings, and I've been able to trace it to the function
>> > dateNodes in the package paleotree, but haven't been able to go any
>> further
>> > than that.
>> >
>> > Thanks in advance for any help!
>> >
>> >
>> >
>> > *--*
>> > *Rafael Sobral Marcondes*
>> > PhD Candidate (Systematics, Ecology and Evolution/Ornithology)
>> >
>> > Museum of Natural Science 
>> > Louisiana State University
>> > 119 Foster Hall
>> > Baton Rouge, LA 70803, USA
>> >
>> > Twitter: @brown_birds 
>> >
>> >
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-sig-phylo mailing list - R-sig-phylo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>> Searchable archive at http://www.mail-archive.com/r-
>> sig-ph...@r-project.org/
>>
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
Lecturer, Geology & Geophysics, Texas A & M University
https://github.com/dwbapst/paleotree
Google Calender: https://goo.gl/EpiM4J

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] threshDIC value error: Inf for DIC Values

2017-12-18 Thread David Bapst
Do you have any zero-length branches in your tree, Aja?

Cheers,
-Dave Bapst

On Mon, Dec 18, 2017 at 3:22 PM, Aja Carter  wrote:
> I am using the ancThresh model in the phytools package for 172 taxa. For
> model we  have the liabilities, parameters, MCMC and alpha values output.
> When I tried getting DIC values from the threshDIC function I got Infs for
> both the OU model and the Lambda model.The error output I have been
> receiving is posted below:
>
>> BMThreshDIC <-threshDIC(scaled.tree, AT.data, ancestralBM, burnin=200)
>  NOTE: no sequence provided, column order in x
>> OUThreshDIC
> Dbar Dhat   pD  DIC
> 2109.678  Inf -Inf -Inf
>
> Has anyone experienced this error before? Any advice on how to fix this
> error would be greatly appreciated.
>
>
> --
> Aja Carter
> PhD Candidate
>
> Department of Earth and Environmental Sciences
>
> University of Pennsylvania
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
Lecturer, Geology & Geophysics, Texas A & M University
https://github.com/dwbapst/paleotree
Google Calender: https://goo.gl/EpiM4J

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Unable to install ape on R-devel?

2017-10-24 Thread David Bapst
Hi all,

I know R-devel is meant to be unstable, but I was curious if anyone
else has had issues with getting ape v4.1, installed as a binary from
CRAN, to work with R-devel recently on Windows (3.5.0 pre-release,
timestamp: 2017-10-19 r73560, specifically Windows 10, although I
don't think its Windows version specific).

As we can see, it appears that ape installs correctly:

```
> install.packages("ape")
Warning: unable to access index for repository
http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.5:
  cannot open URL
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.5/PACKAGES'
trying URL 'https://mirrors.ebi.ac.uk/CRAN/bin/windows/contrib/3.5/ape_4.1.zip'
Content type 'application/zip' length 1505138 bytes (1.4 MB)
downloaded 1.4 MB

package ‘ape’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\adminosaur\AppData\Local\Temp\RtmpO8VG9v\downloaded_packages
```

The issue is when we go to go load it:

```
> library(ape)
Error: package ‘ape’ was installed by an R version with different
internals; it needs to be reinstalled for use with this R version
```

I tried this with half a dozen mirrors to no avail. Oddly I can see
that ape seems to be functioning just fine on the CRAN Windows testing
machines that use R-devel. So... What's going on?

-Dave

PS: Hopefully this is a question with a less obvious answer than my
question from last week. ;)

-- 
David W. Bapst, PhD
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
Lecturer, Geology & Geophysics, Texas A & M University
https://github.com/dwbapst/paleotree
Google Calender: https://goo.gl/EpiM4J

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Re: [R-sig-phylo] Why does ace set a random number generator seed?

2017-10-20 Thread David Bapst
Thanks, Emmanuel. I was not familiar with .Random.seed objects until R
CHECK started complaining about such elements in saved workspaces
within .rdata files within packages (requiring rm to remove them), and
then was mainly familiar with them regarding set.seed() (and so I
thought ace must be setting a seed, not just initializing one). It
makes sense that any random number generation would incur a seed, and
apparently fresh R sessions do not immediately initialize a seed.

Thanks to everyone who helped me see my confusion! Just me missing a
basic comp sci concept.
-Dave

On Fri, Oct 20, 2017 at 4:26 AM, Emmanuel Paradis
<emmanuel.para...@ird.fr> wrote:
> Hi Dave,
>
> The seed is created every time you generate random data (see details in
> ?.Random.seed):
>
> R> exists(".Random.seed")
> [1] FALSE
> R> sample(1)
> [1] 1
> R> exists(".Random.seed")
> [1] TRUE
>
> So in your code below the seed is created by calling rtree(). Indeed, with
> ape 4.1:
>
> R> rm(".Random.seed")
> R> data(bird.orders)
> R> x <- 1:23
> R> exists(".Random.seed")
> [1] FALSE
> R> o <- ace(x, bird.orders)
> R> exists(".Random.seed")
> [1] FALSE
>
> However, with the new "soon-to-be-on-CRAN" version, a seed is created by the
> same code. The "culprit" is actually Rcpp: the new ape has C++ code linked
> to Rcpp. For a reason I ignore, it seems that a random seed is initialized
> when calling a function linked to Rcpp. Here is an example:
>
> R> rm(".Random.seed")
> R> library(RcppEigen)
> R> exists(".Random.seed")
> [1] FALSE
> R> o <- fastLm(1, 1)
> R> exists(".Random.seed")
> [1] TRUE
>
> The new C++ code in ape is called by reorder(phy, "postorder") which is used
> by many functions in ape (ace, pic, plot.phylo, vcv, ...).
>
> Best,
>
> Emmanuel
>
>
> Le 19/10/2017 à 21:00, David Bapst a écrit :
>>
>> Emmanuel, all-
>>
>> I noticed today that a workspace I was working with had a random
>> number seed set in it, but didn't remember setting one. Finally, I
>> discovered the culprit was ace. Here's a reproducible example,
>> demonstrating that a seed exists after running ace:
>>
>> library(ape)
>> tree<-rtree(10)
>> ace(1:10,tree)
>> .Random.seed
>>
>> I am using ape 4.1, and it doesn't seem to be addressed in the
>> forthcoming version, given my reading of the changes log (but I might
>> have missed it). What's going? Why is a random number seed being set?
>>
>> Cheers,
>> -Dave
>>
>



-- 
David W. Bapst, PhD
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
Lecturer, Geology & Geophysics, Texas A & M University
https://github.com/dwbapst/paleotree
Google Calender: https://goo.gl/EpiM4J

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

[R-sig-phylo] Why does ace set a random number generator seed?

2017-10-19 Thread David Bapst
Emmanuel, all-

I noticed today that a workspace I was working with had a random
number seed set in it, but didn't remember setting one. Finally, I
discovered the culprit was ace. Here's a reproducible example,
demonstrating that a seed exists after running ace:

library(ape)
tree<-rtree(10)
ace(1:10,tree)
.Random.seed

I am using ape 4.1, and it doesn't seem to be addressed in the
forthcoming version, given my reading of the changes log (but I might
have missed it). What's going? Why is a random number seed being set?

Cheers,
-Dave

-- 
David W. Bapst, PhD
Postdoc, Ecology & Evolutionary Biology, Univ of Tenn Knoxville
Lecturer, Geology & Geophysics, Texas A & M University
https://github.com/dwbapst/paleotree
Google Calender: https://goo.gl/EpiM4J

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Add terminal branches to tree

2017-06-28 Thread David Bapst
No problem. Glad someone other than me could make use of my function!

Cheers,
-Dave

On Tue, Jun 27, 2017 at 4:42 AM, Sergio Ferreira Cardoso
<sergio.ferreira-card...@umontpellier.fr> wrote:
> Hi Dave,
>
> Thanks a lot. It was exactly this I was trying to do.
> Thank you all for your advice.
>
> Cheers,
> Sérgio.
>
> - Mensagem original -
>> De: "David Bapst" <dwba...@gmail.com>
>> Para: "Sergio Ferreira Cardoso" <sergio.ferreira-card...@umontpellier.fr>
>> Cc: "Eliot Miller" <et...@cornell.edu>, "r-sig-phylo" 
>> <r-sig-phylo@r-project.org>
>> Enviadas: Terça-feira, 20 De Junho de 2017 0:11:02
>> Assunto: Re: [R-sig-phylo] Add terminal branches to tree
>
>> Hi Sergio,
>>
>> Sorry for being late to the party, but maybe expandTaxonTree in
>> paleotree does what you're looking for? I wrote it for turning trees
>> of genera into trees of species, with the resulting generic polytomies
>> collapsed or not (in case we know that the genera is paraphyletic).
>>
>> Cheers,
>> -Dave
>>
>> On Mon, Jun 19, 2017 at 9:36 AM, Sergio Ferreira Cardoso
>> <sergio.ferreira-card...@umontpellier.fr> wrote:
>>> Thank you all for your suggestions. I guess the more direct way is to use
>>> Megaptera. I tried and it worked (I added Man cra1, Man cra2, etc.).
>>> However, I wanted it to create a new node that would basically include all
>>> these taxa. I sthere any way to merge all the added species in a new node?
>>> Thank you all, once again.
>>>
>>> 
>>>
>>> De: "Eliot Miller" <et...@cornell.edu>
>>> Para: "Christoph Heibl" <christoph.he...@gmx.net>
>>> Cc: "Liam Revell" <liam.rev...@umb.edu>, "r-sig-phylo"
>>> <r-sig-phylo@r-project.org>, "Sergio Ferreira Cardoso"
>>> <sergio.ferreira-card...@umontpellier.fr>
>>> Enviadas: Segunda-feira, 19 De Junho de 2017 14:40:15
>>> Assunto: Re: [R-sig-phylo] Add terminal branches to tree
>>>
>>> Just to add to the slew of other good options, I have a small package up on
>>> GitHub (https://github.com/eliotmiller/addTaxa/tree/master/R) that is
>>> basically a big loop around Liam's bind.tip. There are examples included
>>> with the package. The main function you'd be interested in is
>>> randomlyAddTaxa(). It works fairly well last I checked, but there are some
>>> limitations and the package is in need of an overhaul. The main limitation
>>> is when two clades (A and B) are sister to one another and you intend to add
>>> a taxon into the clade (A+B); it's currently impossible to generate the
>>> topology (C,(A,B)), even though that's monophyletic and shouldn't be
>>> prohibited. I aim to fix this at some point within the next month or two if
>>> anyone's interested.
>>> Eliot
>>>
>>> On Mon, Jun 19, 2017 at 8:30 AM, Christoph Heibl <christoph.he...@gmx.net>
>>> wrote:
>>>>
>>>> Another possibility would be addSingleTip() and addTips() from the
>>>> megaptera package (https://github.com/heibl/megaptera). The latter function
>>>> can add any number of tips; the loop that Liam mentioned is already build
>>>> into that function. This is potentially very slow, but for your tree size 
>>>> it
>>>> should work. Note that you have to specify the 'tax' argument; it allows 
>>>> you
>>>> to add tips also to internal nodes of higher rank than genera. In your case
>>>> where you have only genera you can create 'tax' easily like this:
>>>>
>>>> ## 'species' is a vector of tip labels that you want to add
>>>> ## will work only if your tip labels are of the form
>>>> "Genus_epithet-or-any-other-string"
>>>> library(megaptera)
>>>> tax <- data.frame(genus = strip.spec(species),
>>>> species = species,
>>>> stringsAsFactors = FALSE)
>>>>
>>>>
>>>>
>>>> Christoph Heibl
>>>> An der Weiherleite 3
>>>> 86633 Neuburg an der Donau
>>>> 08431-53 96 534 (Festnetz)
>>>> 0176-23 86 57 92 (Mobil)
>>>> christoph.he...@gmx.net
>>>>
>>>>
>>>> Am 19.06.2017 um 14:06 schrieb Liam Revell:
>>>>
>>>> > The function add.species.to.genus may do what you want. It adds a single
>>>> > species t

Re: [R-sig-phylo] Add terminal branches to tree

2017-06-19 Thread David Bapst
Hi Sergio,

Sorry for being late to the party, but maybe expandTaxonTree in
paleotree does what you're looking for? I wrote it for turning trees
of genera into trees of species, with the resulting generic polytomies
collapsed or not (in case we know that the genera is paraphyletic).

Cheers,
-Dave

On Mon, Jun 19, 2017 at 9:36 AM, Sergio Ferreira Cardoso
 wrote:
> Thank you all for your suggestions. I guess the more direct way is to use
> Megaptera. I tried and it worked (I added Man cra1, Man cra2, etc.).
> However, I wanted it to create a new node that would basically include all
> these taxa. I sthere any way to merge all the added species in a new node?
> Thank you all, once again.
>
> 
>
> De: "Eliot Miller" 
> Para: "Christoph Heibl" 
> Cc: "Liam Revell" , "r-sig-phylo"
> , "Sergio Ferreira Cardoso"
> 
> Enviadas: Segunda-feira, 19 De Junho de 2017 14:40:15
> Assunto: Re: [R-sig-phylo] Add terminal branches to tree
>
> Just to add to the slew of other good options, I have a small package up on
> GitHub (https://github.com/eliotmiller/addTaxa/tree/master/R) that is
> basically a big loop around Liam's bind.tip. There are examples included
> with the package. The main function you'd be interested in is
> randomlyAddTaxa(). It works fairly well last I checked, but there are some
> limitations and the package is in need of an overhaul. The main limitation
> is when two clades (A and B) are sister to one another and you intend to add
> a taxon into the clade (A+B); it's currently impossible to generate the
> topology (C,(A,B)), even though that's monophyletic and shouldn't be
> prohibited. I aim to fix this at some point within the next month or two if
> anyone's interested.
> Eliot
>
> On Mon, Jun 19, 2017 at 8:30 AM, Christoph Heibl 
> wrote:
>>
>> Another possibility would be addSingleTip() and addTips() from the
>> megaptera package (https://github.com/heibl/megaptera). The latter function
>> can add any number of tips; the loop that Liam mentioned is already build
>> into that function. This is potentially very slow, but for your tree size it
>> should work. Note that you have to specify the 'tax' argument; it allows you
>> to add tips also to internal nodes of higher rank than genera. In your case
>> where you have only genera you can create 'tax' easily like this:
>>
>> ## 'species' is a vector of tip labels that you want to add
>> ## will work only if your tip labels are of the form
>> "Genus_epithet-or-any-other-string"
>> library(megaptera)
>> tax <- data.frame(genus = strip.spec(species),
>> species = species,
>> stringsAsFactors = FALSE)
>>
>>
>>
>> Christoph Heibl
>> An der Weiherleite 3
>> 86633 Neuburg an der Donau
>> 08431-53 96 534 (Festnetz)
>> 0176-23 86 57 92 (Mobil)
>> christoph.he...@gmx.net
>>
>>
>> Am 19.06.2017 um 14:06 schrieb Liam Revell:
>>
>> > The function add.species.to.genus may do what you want. It adds a single
>> > species to the group defined by the MRCA of members of a genus, according 
>> > to
>> > multiple criteria (randomly and so on). It can add only one species at a
>> > time, so you will need to write a for loop or something to iterate over the
>> > species that you‚d like to add.
>> >
>> > --
>> > Liam J. Revell, Associate Professor of Biology
>> > University of Massachusetts Boston
>> > web: http://faculty.umb.edu/liam.revell
>> > email: liam.rev...@umb.edu
>> >
>> > Sent from my Windows 10 phone
>> >
>> > From: Sergio Ferreira
>> > Cardoso
>> > Sent: Monday, June 19, 2017 6:58 AM
>> > To: r-sig-phylo
>> > Subject: [R-sig-phylo] Add terminal branches to tree
>> >
>> > Hello all,
>> >
>> > I'm using the package 'phytools' to try to add terminal branches to a
>> > tree (attached). I tried to use add.everywhere function to add terminal
>> > branches. I have 167 terminal taxa inside each of the 7 genera on my tree.
>> > Basically, I just wanted to add some dozens of specimens to the end of each
>> > branch, but I don't find a way to do it. Is there any tool that would allow
>> > me to do this? Like adding 30 branches to 'Phal', adding 25 to 'Phat', etc.
>> >
>> > Thanks in advance.
>> >
>> >
>> >
>> > --
>> > Institut des Sciences de l'Evolution
>> > UMR5554, CNRS, IRD, EPHE
>> > Université de Montpellier
>> > Place Eugène Bataillon
>> > 34095 Montpellier Cedex 05
>> > France
>> > Email: sergio.ferreira-card...@umontpellier.fr
>> > Tel: +33 (4 ) 67 14 46 52
>> >
>> >   [[alternative HTML version deleted]]
>> >
>> > ___
>> > R-sig-phylo mailing list - R-sig-phylo@r-project.org
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>> > Searchable archive at
>> > 

Re: [R-sig-phylo] How to test stratification of sampling across tree?

2017-03-14 Thread David Bapst
Ross,

An interesting question. I understand it as that you want to test if
the trait is overdispersed relative to phylogeny, which still makes me
think that measures of 'phylogenetic signal' might be still be useful,
even though the typical interpretation is 'signal' as 'heritability'.
I would try some toy examples with smallish trees and artificial data
and play with different signal measures; particularly your idea
regarding that the variance is high at the level of closest
relatedness suggests that you perhaps should investigate Blomberg's K
as a measure, rather than Pagel's lambda:

Blomberg, S. P., T. Garland, and A. R. Ives. 2003. Testing for
phylogenetic signal in comparative data: behavioral traits are more
labile. Evolution 57.

However, your soft polytomies are worrisome; I suggest using the MPT
or posterior tree sample, if such exists, or considering resolving
those polytomies somehow.

Cheers,
-Dave

On Tue, Mar 14, 2017 at 5:45 AM, Ross Mounce  wrote:
> Hi all,
>
> I'm interested in the distribution of a non-heritable binary
> trait/observation across a large tree 1000+ tip tree. The tree is
> non-distinct in shape and balance, it is neither fully pectinate nor fully
> balanced. It has many soft polytomies too.
>
> I believe the distribution of this trait to be significantly stratified
> such that just for the sake of explanation, every other tip is "present"
> for the trait. So essentially I'm interested in testing the evenness of
> distribution of "present" tips across the tree.
>
> In this instance it doesn't seem to me that I should be testing for
> "phylogenetic signal" or using models that do that, nor am I testing the
> randomicity of distribution of the trait.
> Specifically, I want to test if the observed distribution is significantly
> close to "perfect" stratification for the given number of "presences"
> (which is ~33% of the tips of the tree), on the given fixed tree shape.
>
> TL;DR
>
> How can I meaningfully test the evenness of the distribution of a binary
> trait across a tree, with R?
>
>
> Any ideas?
>
> Thanks,
>
> Ross
>
>
> --
> --
> -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-
> Ross Mounce, PhD
> Software Sustainability Institute Fellow
> Dept. of Plant Sciences, University of Cambridge
> www.rossmounce.co.uk 
> -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Plotting uncertainty in continuous ASR

2017-02-27 Thread David Bapst
That's really cool, Liam. Would it also be possible for one to do
multiple such error bars per node, for plotting ASRs for multiple
traits?
-Dave

On Mon, Feb 27, 2017 at 12:13 PM, Liam J. Revell  wrote:
> Hi Kevin.
>
> This is not automatic - but it is indeed fairly easy to do using phytools.
> To be honest, I thought this would look terrible - but it actually looks
> much better than I expected, at least for a relatively small tree. I have
> posted a demo to my blog here:
> http://blog.phytools.org/2017/02/adding-colorful-error-bars-to-internal.html.
>
> All the best, Liam
>
> Liam J. Revell, Associate Professor of Biology
> University of Massachusetts Boston
> web: http://faculty.umb.edu/liam.revell/
> email: liam.rev...@umb.edu
> blog: http://blog.phytools.org
>
>
> On 2/27/2017 11:16 AM, Arbuckle, Kevin wrote:
>>
>> Hi all,
>>
>> I was wondering about plotting the output of an ancestral state
>> 'reconstruction' of a continuous trait while incorporating at least some of
>> the uncertainty around the estimates.
>>
>> One approach I thought of was to map the ASR onto a tree in a standard
>> way, then at each node have essentially a mini-legend that is of a length
>> reflecting the width of the confidence interval of the estimate at that
>> node, and is coloured on the same colour-scale as the overall tree legend.
>> For instance, if the colour scheme for the tree goes from blue through
>> yellow to red as the value increases, then a node with a relatively precise
>> and high estimate will have a short bar only ranging through different
>> shades of red, whereas a highly uncertain low estimate will have a wider bar
>> coloured from (say) dark blue to orange/light red. I hope that description
>> makes sense.
>>
>> I was wondering if anyone is aware of a function that already implements
>> such an approach, otherwise I'll try to put one together myself. I am aware
>> of phytool's fancyTree(type="phenogram95") as a way of incorporating
>> uncertainty into a plotted ASR for continuous traits. However, this often
>> results in difficulty in distinguishing different nodes where estimates are
>> similar and also does not lend itself easily to, for instance, plotting pie
>> charts representing discrete trait ASRs onto a tree mapped with a continuous
>> trait. Hence I can imagine a more general approach as above but don't want
>> to duplicate effort if a function already exists (and also if others feel
>> this is a useful idea it can be added to existing packages If I share it as
>> above).
>>
>> Best wishes,
>> Kev
>> ___
>> R-sig-phylo mailing list - R-sig-phylo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>> Searchable archive at
>> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>>
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] A question about phylogenetic signal significance with 1000 trees

2016-12-08 Thread David Bapst
A deep thought on this topic, from a mind run aground amidst grading papers.

While I am a big fan of using multiple trees, we should keep in mind
that phylogenetic uncertainty makes signal into a rather snaky
concept. By this, I mean that there could have only been one true
history (which may or may not be captured within our sample of
potentially true-ish phylogenetic reconstructions). Thus, even if
phylogenetic signal was perfect in a given trait, we would
underestimate the extent of that signal on all trees except for the
true tree. It should be very hard for a trait with less than perfect
signal to appear to have higher amounts of signal than reality, as
that would require a phylogeny that perfectly matches the distortions
from the expectation under true signal. Thus, whatever distribution of
signal estimates we obtain from a distribution of trees, we should
probably expect the upper tail to be closer to reality than the mean
expectation.

(Something similar should also be true of rates, where inaccurate
trees are probably more likely to upwardly bias rate estimates, rather
than downward. Slow rates should be much harder to accurately measure.
In both cases, based on my experience looking at how parameter
estimates vary in simulations with different dating methods, I think
the effects will be partly exacerbated by variation in the dating
(i.e. branch lengths) and affected less by differences in topology
that don't greatly impact the divergence times.)

...Or maybe I'm just crazy.

Cheers,
-Dave Bapst



On Thu, Dec 8, 2016 at 9:53 AM, Brian O'Meara  wrote:
> Well, since 1000 are a sample, 100 sampled from those is a somewhat more
> manageable sample.
>
> As to using, say, an 80% cutoff is a valid procedure, one question is what
> you're doing this for. I'd be tempted to just show or report the
> distribution of K, lambda, and p values and talk about what they mean in
> terms of your biological question: "We don't know the tree exactly, but
> it's clear that for most feasible trees, related things are similar" or
> something like that. If it's a question of scaling trees for later
> analyses, you can just (using a script, or built in functions) choose the
> particular scaling to be appropriate for each tree, and so the distribution
> across them doesn't matter in that case.
>
> Best,
> Brian
>
> ___
> Brian O'Meara, http://www.brianomeara.info, especially Calendar
> , CV
> , and Feedback
> 
>
> Associate Professor, Dept. of Ecology & Evolutionary Biology, UT Knoxville
> Associate Head, Dept. of Ecology & Evolutionary Biology, UT Knoxville
> Associate Director for Postdoctoral Activities, National Institute for
> Mathematical & Biological Synthesis  (NIMBioS)
> Communication Director, Society of Systematic Biologists
>
> On Thu, Dec 8, 2016 at 11:26 AM, Carturan, Bruno 
> wrote:
>
>> Hello R-sig-phylo community,
>>
>> I am trying to measure the phylogenetic signal of functional traits with
>> the Blomberg’s K and Pagel’s λ methods. My problem is that I don’t have one
>> phylogenetic tree but 1000 (the trees were created by first combining
>> different molecular, morphologic and taxonomic trees, then by conducting a
>> MCMC analysis and finally by selecting the 1000 trees – work made by Huang
>> and Roy 2015).
>>
>> Is there a way to proceed to test the significance of the K and λ values
>> for each trait with these 1000 trees?
>>
>> An idea I have is to run the test and obtain a p value for each of the
>> 1000 trees, which would give me a distribution of p values, and then
>> consider that if 80% (for instance) of the p values are significant, the K
>> or λ value is significant. This is computationally very demanding (I have
>> 735 species) and I don’t know if this could be considered as a valid
>> procedure.
>>
>> I am looking forward for you answer.
>>
>> Bruno Carturan
>> PhD Candidate
>> Complex Environmental Systems Lab
>> University of British Columbia
>> Okanagan Campus
>>
>>
>> 
>> From: Liam J. Revell [liam.rev...@umb.edu]
>> Sent: Wednesday, December 07, 2016 6:54 AM
>> To: Carturan, Bruno
>> Subject: Re: A question about phylogenetic signal significance with 1000
>> trees
>>
>> Bruno.
>>
>> This is an interesting question. Since this doesn't pertain specifically
>> to phytools, perhaps you should pose it to the R-sig-phylo email
>> list-serve. You may get a good answer there.
>>
>> All the best,
>>
>> Liam J. Revell, Associate Professor of Biology
>> University of Massachusetts Boston
>> web: http://faculty.umb.edu/liam.revell/
>> email: liam.rev...@umb.edu
>> blog: http://blog.phytools.org
>>
>> On 12/6/2016 6:16 PM, Carturan, Bruno wrote:
>> > Hello Dr. Revell,
>> >
>> >
>> >
>> > I am a PhD student 

Re: [R-sig-phylo] fatal error plotting trees

2016-10-28 Thread David Bapst
Manabu-

Can you give us a reproducible example? Is it as simple as plotting
any tree does it or is it only particular trees?

Cheers,
-Dave

On Fri, Oct 28, 2016 at 7:53 AM, Manabu Sakamoto
 wrote:
> Dear List,
>
> I'm getting fatal errors when plotting phylo objects, which terminates the
> RStudio session.
> RStudio started showing me warnings from around last week or so, stating
> that something was wrong and that if it wasn't fixed, it will be fatal in
> the next update. I haven't updated R or RStudio but it's turned fatal.
>
> The following error message appears if I use just plain R and not RStudio:
>
>  *** caught segfault ***
> address 0x7fb99a1d8218, cause 'memory not mapped'
>
> Traceback:
>  1: .C(neworder_phylo, as.integer(nb.tip), as.integer(x$edge[, 1]),
> as.integer(x$edge[, 2]), as.integer(nb.edge), integer(nb.edge), io,
> NAOK = TRUE)
>  2: reorder.phylo(x, order = "postorder")
>  3: reorder(x, order = "postorder")
>  4: plot.phylo(tree, show.tip.label = F)
>  5: plot(tree, show.tip.label = F)
>
> Possible actions:
> 1: abort (with core dump, if enabled)
> 2: normal R exit
> 3: exit R without saving workspace
> 4: exit R saving workspace
>
> Has anyone been encountering this issue, or know what the cause is?
>
> thanks,
> Manabu
> --
> Manabu Sakamoto, PhD
> manabu.sakam...@gmail.com
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] ape functions to become generic

2016-10-04 Thread David Bapst
Thanks, Emmanuel. That answers my questions.

Cheers,
-Dave


On Tue, Oct 4, 2016 at 4:03 AM, Emmanuel Paradis
<emmanuel.para...@ird.fr> wrote:
> Hi David,
>
> Le 03/10/2016 à 17:25, David Bapst a écrit :
>>
>> Hi Emmanuel (and list!),
>>
>> These changes are appreciated, and will make dealing with multiPhylo
>> objects much easier. I know I certainly have blocks of code where I
>> need to 'carry' the multiPhylo class tag through every other line; it
>> always been a bit of a chore. However, two questions from the peanut
>> gallery.
>
>
> I did not mention that in my previous message, but, of course, you won't
> need to change your existing code or scripts: all previous or current
> commands will still be valid with the next release of ape.
>
>> 1) Does this change result in any change in speed? Have you tested
>> this? (My guess is no practical computational time change, but I was
>> curious.)
>
>
> There should not be a substantial increase in speed, but computations should
> be more efficient as all specific cases will be handled within the methods
> (e.g., compressed lists or not).
>
>> 2) Will those of us using these particular functions due to a
>> dependency or importing ape functions for our libraries need to alter
>> the way we call those particular functions? Have you tested this with
>> R CHECK?
>
>
> No tests have been done yet but you raise a very good point. We can
> reasonably expect that no change in your package(s) will be needed because
> ape exports everything, so the functions is.rooted.phylo,
> is.rooted.multiPhylo, ..., will not be hidden (and will be properly
> registered).
>
> Cheers,
>
> Emmanuel
>
>
>> Finally, thank you to you (and the rest of the ape authors) for
>> continuing to maintain and improve ape.
>>
>> Cheers,
>> -Dave
>>
>> On Mon, Oct 3, 2016 at 8:51 AM, Emmanuel Paradis
>> <emmanuel.para...@ird.fr> wrote:
>>>
>>> Dear all,
>>>
>>> We are planning to introduce a substantial change in ape: several
>>> functions
>>> operating on "phylo" objects will be made generic with methods for
>>> "phylo"
>>> and "multiPhylo" objects. The motivation is to make things simpler when
>>> working with lists of trees. For instance, for a list of trees TR,
>>> testing
>>> if each tree is rooted can be donc with:
>>>
>>> sapply(TR, is.rooted)
>>>
>>> With the new version, this would be:
>>>
>>> is.rooted(TR)
>>>
>>> which is similar than for a "phylo" object. With functions requiring
>>> additional arguments, e.g., to root all the trees with the same outgroup,
>>> the current code is slightly more complicated:
>>>
>>> TRr <- lapply(TR, root, outgroup = "platypus")
>>> class(TRr) <- class(TR)
>>>
>>> This is because lapply does not propagate the class of its first
>>> argument.
>>> The new code will be as simple as with a "phylo" object:
>>>
>>> TRr <- root(TR, "platypus")
>>>
>>> To summarize the future changes:
>>>
>>> 1/ Functions to become generic with methods for "phylo" and "multiPhylo":
>>>
>>> di2multi
>>> drop.tip
>>> is.binary (see below)
>>> is.rooted
>>> is.ultrametric
>>> ladderize
>>> multi2di
>>> Nedge
>>> Nnode
>>> Ntip
>>> reorder
>>> root
>>> unroot
>>>
>>> 2/ is.binary.tree() will be renamed is.binary() since the name is
>>> available
>>> (an alias with is.binary.tree will be provided for the next release).
>>>
>>> 3/ Functions already with methods for "phylo" and "multiPhylo" in ape
>>> (nothing to change):
>>>
>>> makeLabel (generic defined in ape)
>>> plot
>>> print
>>> summary
>>>
>>> 4/ The c() methods (currently for "phylo" and "multiPhylo") will be
>>> improved
>>> by implementing the 'recursive' option (currently ignored). This will
>>> permit
>>> to combine several objects of different classes into a single
>>> "multiPhylo"
>>> object (i.e., either a list of trees, or a list of lists depending on the
>>> value of 'recursive'; see ?c).
>>>
>>> 5/ Functions already with methods for "multiPhylo" (nothing to change):
>>>
>>> str

Re: [R-sig-phylo] ape functions to become generic

2016-10-03 Thread David Bapst
Hi Emmanuel (and list!),

These changes are appreciated, and will make dealing with multiPhylo
objects much easier. I know I certainly have blocks of code where I
need to 'carry' the multiPhylo class tag through every other line; it
always been a bit of a chore. However, two questions from the peanut
gallery.

1) Does this change result in any change in speed? Have you tested
this? (My guess is no practical computational time change, but I was
curious.)

2) Will those of us using these particular functions due to a
dependency or importing ape functions for our libraries need to alter
the way we call those particular functions? Have you tested this with
R CHECK?

Finally, thank you to you (and the rest of the ape authors) for
continuing to maintain and improve ape.

Cheers,
-Dave

On Mon, Oct 3, 2016 at 8:51 AM, Emmanuel Paradis
 wrote:
> Dear all,
>
> We are planning to introduce a substantial change in ape: several functions
> operating on "phylo" objects will be made generic with methods for "phylo"
> and "multiPhylo" objects. The motivation is to make things simpler when
> working with lists of trees. For instance, for a list of trees TR, testing
> if each tree is rooted can be donc with:
>
> sapply(TR, is.rooted)
>
> With the new version, this would be:
>
> is.rooted(TR)
>
> which is similar than for a "phylo" object. With functions requiring
> additional arguments, e.g., to root all the trees with the same outgroup,
> the current code is slightly more complicated:
>
> TRr <- lapply(TR, root, outgroup = "platypus")
> class(TRr) <- class(TR)
>
> This is because lapply does not propagate the class of its first argument.
> The new code will be as simple as with a "phylo" object:
>
> TRr <- root(TR, "platypus")
>
> To summarize the future changes:
>
> 1/ Functions to become generic with methods for "phylo" and "multiPhylo":
>
> di2multi
> drop.tip
> is.binary (see below)
> is.rooted
> is.ultrametric
> ladderize
> multi2di
> Nedge
> Nnode
> Ntip
> reorder
> root
> unroot
>
> 2/ is.binary.tree() will be renamed is.binary() since the name is available
> (an alias with is.binary.tree will be provided for the next release).
>
> 3/ Functions already with methods for "phylo" and "multiPhylo" in ape
> (nothing to change):
>
> makeLabel (generic defined in ape)
> plot
> print
> summary
>
> 4/ The c() methods (currently for "phylo" and "multiPhylo") will be improved
> by implementing the 'recursive' option (currently ignored). This will permit
> to combine several objects of different classes into a single "multiPhylo"
> object (i.e., either a list of trees, or a list of lists depending on the
> value of 'recursive'; see ?c).
>
> 5/ Functions already with methods for "multiPhylo" (nothing to change):
>
> str
> unique
>
> Comments and suggestions are welcome. These changes will be included in the
> next release of ape which will be version 4.0 and is planned this fall. As a
> reminder, the changes already implemented are listed in:
>
> http://ape-package.ird.fr/NEWS
>
> Best,
>
> Emmanuel
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] extracting from mrbayes

2016-07-20 Thread David Bapst
John,

I had to double-check this with someone who knew better first, but
they confirmed for me that the answer is that MrBayes doesn't infer a
Q matrix. By default, the Q matrix for Mk in MrBayes is always held
fixed so the rates of transition are always equal and fully
reversible, i.e. a simple Jukes-Cantor model. There's no setting that
allows MrBayes to freely vary and infer a Q matrix, but you can relax
the assumption of symmetrry via the symmetric Dirichlet hyperprior. If
you want to infer a Q model under a different model, there are lots of
R functions for fitting models to discrete character data, such as in
geiger or ape.

I suggest seeing April Wright et al.'s recent paper in Systematic
Biology for a clear explanation of this:.
http://sysbio.oxfordjournals.org/content/65/4/602

I hope this helps!

Cheers,
-Dave Bapst



On Tue, Jul 19, 2016 at 3:15 PM, John Denton  wrote:
> Hi folks,
>
> I need to do some simulation using the Mkv model, and am wondering if there 
> is a way to extract Mk Q-matrix values from mrbayes. A look at report lists 
> revmat as an output, but I do not see any parameters in the .p files when I 
> finish the run.
>
> Thanks,
>
> ~John
>
>
> John S. S. Denton, Ph.D.
> Department of Vertebrate Paleontology
> American Museum of Natural History
> www.johnssdenton.com
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] 'T151: New Approaches to Phylogenetic Paleobiology' at GSA Annual Meeting 2016. Sept 25-28 in Denver

2016-07-07 Thread David Bapst
Hi all,

Just a short reminder, that abstract submission for GSA (and thus for
our session) closes on July 12th, which is less than a week away.

Cheers!
-Dave

On Mon, Apr 4, 2016 at 10:25 AM, David Bapst <dwba...@gmail.com> wrote:
> Hello all,
>
> We are pleased to announce a topical session that we believe is of
> special interest to the R-Sig-Phylo list, scheduled for the 2016
> annual Geological Society of America meeting held from September
> 25th-28th in Denver, Colorado, USA. Our oral topical session, “New
> Approaches to Phylogenetic Paleobiology”, is organized by myself
> (David W. Bapst, South Dakota School of Mines and Technology), Melanie
> J. Hopkins (American Museum of Natural History), April M. Wright (Iowa
> State University), and David F. Wright (The Ohio State University),
> and sponsored by the Paleontological Society and the Paleontological
> Research Institution.
>
> We hope to highlight novel methods and analyses for inferring
> phylogenies of fossil taxa, dating divergences between clades and for
> using phylogenies to test macroevolutionary hypotheses.  A more
> detailed description is provided below. We would really love to see
> both work that combines molecular phylogenies with fossil data or work
> that uses phylogenies of fossil data. If you're doing anything that
> sounds like it might fit in, we encourage you to submit an abstract
> for our session (T151) and give an oral presentation on your work.
>
> Abstract submission is now open and closes on July 12th. The abstract
> fee is $50.00 for professionals and $25.00 for students. When you
> submit, please select Topical Session and then select our session
> (T151) from the list:
>
> https://gsa.confex.com/gsa/2016AM/cfp.epl
>
> Those of you who are classical biologists may be wondering 'why attend
> a geology meeting?'. GSA is one of the largest annual conferences
> attended by the paleontological community at large, as it also serves
> as the annual meeting for the Paleontological Society. The
> paleontological sessions at GSA include paleontologists working on
> vertebrates, invertebrates, plants and pretty much anything else that
> leaves a fossil, and many of the sessions are focused on evolutionary
> and ecological analyses of deep time.
>
> Please note there are several other topical sessions that dovetail
> with our interests in phylogenetic paleobiology: T152: Troubles and
> Triumphs with Fossil Phylogenies, chaired by Jennifer E. Bauer
> (University of Tennessee), Adriane R. Lam (University of Massachusetts
> Amherst), and Sarah L. Sheffield (University of Tennessee); T136:
> Across Space and through Time: Understanding Evolution and Ecology
> using Biogeography, chaired by Alexander M. Dunhill (University of
> Leeds) and Erin E. Saupe (Yale University); and T140: Evolution,
> Development, and Paleogenomics, chaired by David J. Bottjer
> (University of Southern California), and Jeffrey R. Thompson
> (University of Southern California). You can find the full list of
> topical sessions here:
>
> http://www.geosociety.org/meetings/2016/sessions/topical.asp
>
> In addition to topical sessions on specific topics, there will be a
> number of general technical sessions on morphometrics,
> diversification, macroevolutionary dynamics, functional morphology and
> mass extinctions, dependent on the abstracts submitted. You will
> likely find interesting paleobiological sessions running from the
> start of the conference to its end.
>
> For registration purposes, You can receive all the benefits of a GSA
> membership by being a Paleontological Society member instead, at a
> lower rate ($30-55), although if you are a student, it may be more
> prudent to consider GSA membership as some travel support may be
> dependent on that. Travel support for students and international
> researchers attending the GSA meeting can be found at
> http://community.geosociety.org/gsa2016/social-business/otf and
> http://community.geosociety.org/gsa2016/attendeeinfo/travel
>
> The Denver conference center is close to a number of hotels that offer
> special rates for attendees, and room reservation can be done through
> GSA. Downtown Denver is also home to a number of museums, a zoo and
> many restaurants. Registration for the conference and lodging
> reservation will open in May.
>
> If you have any questions regarding our session, feel free to contact
> me directly at dwba...@gmail.com
>
> Cheers,
> -Dave Bapst
>
>
> Session description:
> While paleontology has always been strongly linked to phylogenetics,
> the past decade has seen a major acceleration in the development and
> deployment of new methodologies for inferring phylogenies containing
> fossil taxa, using fossil infor

Re: [R-sig-phylo] BiSSE/MacroCAIC on Non-Ultrametric Tree with Polytomies?

2016-04-15 Thread David Bapst
Brian-

Is your tree non-ultrametric because it contains extinct taxa from the
fossil record, or is it simply an undated tree of extant taxa?

To my knowledge, there isn't yet a satisfactory solution to the first
(no BISSE for paleo-phylogenies) but if the second then, it seems the
best route would be to date it and use the methods developed for
ultrametric trees.

Cheers,
-Dave

On Wed, Apr 13, 2016 at 3:09 PM, Brian A. Gill  wrote:
> Hi Everyone.
>
> I'm trying to look at the association between a discrete binary predictor
> (Latitude: Colorado/Ecuador) and a continuous response (species richness).
>
> My phylogeny is a 50% majority rule consensus tree made in MrBayes. The
> tree has polytomies and is not ultrametric.
>
> I've found the methods below for looking at the influence of a discrete
> binary trait on richness, but I'm not sure if my tree is suitable or if
> there is a better approach.
>
> 1) Diversitree package BiSSE
> 2) Caper package using MacroCAIC
>
> Any suggestions would be greatly appreciated.
>
> Thank You.
>
>
> Brian
>
> --
> Brian A. Gill
>
> VISIT MY WEBSITE:
> http://gillbriana.wix.com/brian-gill
>
> FOLLOW ME ON TWITTER:
> @CSUBrianGill
>
> Colorado State University Biology
> 1878 Campus Delivery
> Fort Collins, CO 80523
> United States of America
>
> 970-215-7037
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] 'T151: New Approaches to Phylogenetic Paleobiology' at GSA Annual Meeting 2016. Sept 25-28 in Denver

2016-04-04 Thread David Bapst
Hello all,

We are pleased to announce a topical session that we believe is of
special interest to the R-Sig-Phylo list, scheduled for the 2016
annual Geological Society of America meeting held from September
25th-28th in Denver, Colorado, USA. Our oral topical session, “New
Approaches to Phylogenetic Paleobiology”, is organized by myself
(David W. Bapst, South Dakota School of Mines and Technology), Melanie
J. Hopkins (American Museum of Natural History), April M. Wright (Iowa
State University), and David F. Wright (The Ohio State University),
and sponsored by the Paleontological Society and the Paleontological
Research Institution.

We hope to highlight novel methods and analyses for inferring
phylogenies of fossil taxa, dating divergences between clades and for
using phylogenies to test macroevolutionary hypotheses.  A more
detailed description is provided below. We would really love to see
both work that combines molecular phylogenies with fossil data or work
that uses phylogenies of fossil data. If you're doing anything that
sounds like it might fit in, we encourage you to submit an abstract
for our session (T151) and give an oral presentation on your work.

Abstract submission is now open and closes on July 12th. The abstract
fee is $50.00 for professionals and $25.00 for students. When you
submit, please select Topical Session and then select our session
(T151) from the list:

https://gsa.confex.com/gsa/2016AM/cfp.epl

Those of you who are classical biologists may be wondering 'why attend
a geology meeting?'. GSA is one of the largest annual conferences
attended by the paleontological community at large, as it also serves
as the annual meeting for the Paleontological Society. The
paleontological sessions at GSA include paleontologists working on
vertebrates, invertebrates, plants and pretty much anything else that
leaves a fossil, and many of the sessions are focused on evolutionary
and ecological analyses of deep time.

Please note there are several other topical sessions that dovetail
with our interests in phylogenetic paleobiology: T152: Troubles and
Triumphs with Fossil Phylogenies, chaired by Jennifer E. Bauer
(University of Tennessee), Adriane R. Lam (University of Massachusetts
Amherst), and Sarah L. Sheffield (University of Tennessee); T136:
Across Space and through Time: Understanding Evolution and Ecology
using Biogeography, chaired by Alexander M. Dunhill (University of
Leeds) and Erin E. Saupe (Yale University); and T140: Evolution,
Development, and Paleogenomics, chaired by David J. Bottjer
(University of Southern California), and Jeffrey R. Thompson
(University of Southern California). You can find the full list of
topical sessions here:

http://www.geosociety.org/meetings/2016/sessions/topical.asp

In addition to topical sessions on specific topics, there will be a
number of general technical sessions on morphometrics,
diversification, macroevolutionary dynamics, functional morphology and
mass extinctions, dependent on the abstracts submitted. You will
likely find interesting paleobiological sessions running from the
start of the conference to its end.

For registration purposes, You can receive all the benefits of a GSA
membership by being a Paleontological Society member instead, at a
lower rate ($30-55), although if you are a student, it may be more
prudent to consider GSA membership as some travel support may be
dependent on that. Travel support for students and international
researchers attending the GSA meeting can be found at
http://community.geosociety.org/gsa2016/social-business/otf and
http://community.geosociety.org/gsa2016/attendeeinfo/travel

The Denver conference center is close to a number of hotels that offer
special rates for attendees, and room reservation can be done through
GSA. Downtown Denver is also home to a number of museums, a zoo and
many restaurants. Registration for the conference and lodging
reservation will open in May.

If you have any questions regarding our session, feel free to contact
me directly at dwba...@gmail.com

Cheers,
-Dave Bapst


Session description:
While paleontology has always been strongly linked to phylogenetics,
the past decade has seen a major acceleration in the development and
deployment of new methodologies for inferring phylogenies containing
fossil taxa, using fossil information for dating divergences, and
using phylogenies of fossil taxa to address major questions of ecology
and evolution in deep time. Notably, these cutting-edge methodological
advances have come from both the paleobiology and evolutionary biology
communities. This session will provide an opportunity to bridge the
gap between disciplines whose members often have little reason to
attend the same meeting (i.e. GSA versus Evolution) and promote the
unification of fossil and phylogenetic approaches to macroevolution.

-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, 

Re: [R-sig-phylo] summary stats for comparative methods p-values

2016-03-10 Thread David Bapst
Darrin, list-

I'm sure there's people on this list with better answers, so I'll
throw in first with what might be the wrong answer (but feels right to
me), and say you more or less need to report all of them: like, show a
full histogram of the p-values. At least, as a reviewer, that is what
would convince me whether there was evidence or not to reject a
hypothesis.

But I'm sure there's some statistical argument again that too, in
terms of taking a frequentist perspective across multiple versions of
the same dataset.

To the list: I look forward to hearing how I am wrong! ;)

-Dave

On Thu, Mar 10, 2016 at 4:54 AM, Darrin Hulsey
 wrote:
> I am running a series of statistics on a subset of 100 trees that returns 100 
> different p-values.  I was wondering what the best way to report summary 
> statistics for these 100 p-values would be (median?, measure of variance in 
> all 100 p-values?).  Thanks for any insight.
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] new testing version of ape

2016-02-22 Thread David Bapst
FYI, in case one wants to install the testing version of ape to
R-devel (in my case, also a Windows machine), I found I needed:

install.packages("ape",contriburl="http://ape-package.ird.fr/bin/windows/contrib/3.2;)

Emmanuel, I've tested the testing version with paleotree and a few
other projects I'm working on and I haven't found any issues.

Cheers,
-Dave

On Mon, Feb 22, 2016 at 2:16 AM, Emmanuel Paradis
 wrote:
> Dear all,
>
> A new testing version of ape (3.4-0.3) is available. It includes three main
> new features:
>
> - A new data class, "AAbin", to store amino acid sequences; there are eleven
> new functions to generate and manipulate them including translation from
> DNA.
>
> - The function checkAlignment does some diagnostics on a DNA alignment.
>
> - Some extra plotting functions built on ape's basic plotting functions
> (plot.phylo, nodelabels, phydataplot, ring) for a specific task. For the
> moment, there are two such functions: drawSupportOnEdges() and
> plotBreakLongEdges().
>
> Information on the new functions can be found at:
>
> http://ape-package.ird.fr/NEWS
>
> And instructions on how to get and install the testing version here:
>
> http://ape-package.ird.fr/ape_installation.html#versions
>
> A Windows version is available.
>
> Best,
>
> Emmanuel
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] getBtimes vs. branching.times

2016-01-14 Thread David Bapst
Lev,

This is easy, if the newick strings are structured the same so that
the resulting edge matrix and tip labels are identical. Here's a
worked example:

```
library(ape)

# with edge lengths
newick1<-"(Homo:30,(Echinus:18,(Cephalodiscus:12,(Rhabdopleura:8,(Dictyonema:1,(Rhabdinopora:1,Dicellograptus:3):1):1):4):4):10);"

# with node names
newick2<-"(Homo,(Echinus,(Cephalodiscus,(Rhabdopleura,(Dictyonema,(Rhabdinopora,Dicellograptus)Graptoloida)Eugraptolithina)Graptolithina)Pterobranchia)Ambulacraria)Deuterostomia;"

# convert newick strings to phylo objects

tree1<-read.tree(text=newick1)
plot(tree1)

tree2<-read.tree(text=newick2)
plot(tree2)
nodelabels(tree2$node.label)

# combine

if(identical(tree1$edge,tree2$edge) &
identical(tree1$tip.label,tree2$tip.label)){
tree3<-tree1
tree3$node.label<-tree2$node.label
}

plot(tree3)
nodelabels(tree3$node.label)
```

If $edge and $tip.label are not identical, then this is a somewhat
more complex issue.

Cheers,
-Dave

On Wed, Jan 13, 2016 at 4:39 PM, Yampolsky, Lev  wrote:
> Dear Colleagues,
>
> Thank you very much for your help, it’s all clear now. (I got way more
> than I asked for, for example, my trees include only extant taxa). And
> yes, branching.times() and getBtimes() return exact same numbers of
> course, I just didn’t understand ow indexing works.
>
> Next question, a very simple one again.
>
> I have two newick trees, identical topology. In one I have branch lengths,
> in the other I have node names. I would like a tree with both. How do I do
> this?
>
> Thanks in advance!
>
> --
> Lev Yampolsky
>
> Professor
> Department of Biological Sciences
> East Tennessee State University
> Box 70703
> Johnson City TN 37614-1710
> Cell 423-676-7489
> Office/lab 423-439-4359
> Fax423-439-5958
>
>
>
>
> On 1/13/16, 4:20 AM, "Emmanuel Paradis"  wrote:
>
>>To pile a little bit more after David's message, ape has the function
>>ltt.plot.coords which does the same thing than phytools::ltt but with
>>different options, including 'tol' which specifies the tolerance for
>>considering a tree as ultrametric or not.
>>
>>Best,
>>
>>Emmanuel
>>
>>Le 13/01/2016 03:29, Liam J. Revell a écrit :
>>> Hi Lev.
>>>
>>> You could also look at ltt in phytools. The object returned has the time
>>> of all the events on the tree - including the end of lineages that go
>>> extinct before the present. To access these, you can do:
>>>
>>> obj<-ltt(tree,plot=FALSE)
>>> obj$times
>>> obj$ltt
>>>
>>> & to see how these are associated with events, you can do:
>>>
>>> plot(obj,show.tree=TRUE)
>>>
>>> All the best, Liam
>>>
>>> Liam J. Revell, Associate Professor of Biology
>>> University of Massachusetts Boston
>>> web: http://faculty.umb.edu/liam.revell/
>>> email: liam.rev...@umb.edu
>>> blog: http://blog.phytools.org
>>>
>>> On 1/12/2016 10:22 PM, Dan Rabosky wrote:

 Dear Lev-

 I don't think branching.times can compute these for non-ultrametric
 trees.

 You can do this with package BAMMtools, but you need a "hidden"
 internal function. You can access it as

 "BAMMtools:::NU.branching.times"

 It returns branching times relative to the most recently-occurring tip
 in the tree. It's a R-based recursion that is a little slower that the
 ape function, so it's not recommended as a replacement for
 branching.times if you have an ultrametric tree.

 I'm not actively maintaining laser, but getBtimes returns the output
 of branching.times after sorting the times and stripping out the node
 names (this was useful for something many years ago!). If you plot
 sort(getBtimes(x)) and sort(branching.times(x)) they should be
identical.

 ~Dan Rabosky



 On Jan 12, 2016, at 7:37 PM, Yampolsky, Lev 
 wrote:

> Dear Colleagues,
>
> Does anyone know what is the difference between ape�s
> branching.times() and laser�s getBtimes()?
> And why they may be giving rather different results, particularly for
> internal branches? (From an ultrametric tree created by
> chronotree <- chronos(tree, lambda = 1, model = "correlated", quiet =
> FALSE, calibration = makeChronosCalib(tree), control =
> chronos.control())
>
> Thank you very much in advance for your help!
>
> PS. A related but less important question: I am curious how does
> branching.times() calculate branching times from a non-ultrametric
>tree?
>
> --
> Lev Yampolsky
>
> Professor
> Department of Biological Sciences
> East Tennessee State University
> Box 70703
> Johnson City TN 37614-1710
> Cell 423-676-7489
> Office/lab 423-439-4359
> Fax423-439-5958
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> 

Re: [R-sig-phylo] Plotting sampled-ancestor trees in R

2015-12-08 Thread David Bapst
Hi Roger,

I'm not aware of any existing solution. Could you send around a small
example of the data format of an output sampled ancestor tree from
BEAST or MrBayes? Are they just typical Newick/NEXUS format with
ancestors indicated tipis with zero-length branches or something more
complicated?

Remarkably I've not looked at the formatting of one, but obviously
plotting SA trees is something the community will need in the near
future.

Cheers,
-Dave

On Tue, Dec 8, 2015 at 5:46 AM, Roger Close  wrote:
> Hi all,
>
> Does anyone know of a way to plot sampled-ancestor trees in R such that
> ancestors lie on branches, rather than being zero-length terminals that
> follow a bifurcation?
>
> Many thanks,
> Roger
>
> ---
> Roger Close, Postdoctoral Research Associate
> Department of Earth Sciences, Oxford University
> South Parks Road
> Oxford OX1 3AN
> United Kingdom
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] branching time to branch length (eg. mcmctree)

2015-10-28 Thread David Bapst
Tristan,

It's alright. To be honest, I am (and should be) quite embarrassed
that I overlooked an ape function... I was a nice warm-up exercise,
nonetheless, and I can see how to extend it to handle dates for
non-ultrametric fossil trees, which is a case not covered by
compute.brtimes, and would make a nice addition for paleotree.

Glad we could help!

Cheers,
-Dave

On Wed, Oct 28, 2015 at 9:03 AM, Tristan Lefebure
 wrote:
> David, Emmanuel, many thanks!
>
> chrono3 <-  compute.brtime(tr, bt)
> all.equal.numeric(chrono$edge.length, chrono3$edge.length)
> #TRUE
> all.equal.numeric(chrono$edge.length, as.numeric(chrono2$edge.length))
> #also TRUE
>
> PS: sorry David, I feel kinda responsible for this lost 16 minutes...
>
>
>
> On Wed, Oct 28, 2015 at 3:53 PM, Emmanuel Paradis 
> wrote:
>
>> Hi Tristan,
>>
>> See compute.brtime in ape.
>>
>> Cheers,
>>
>> Emmanuel
>>
>>
>> Le 28/10/2015 15:31, Tristan Lefebure a écrit :
>>
>>> Greetings all,
>>>
>>> Does anyone know a way to transform branching times into branch length of
>>> a
>>> chronogram. Like the inverse function of ape::branching.time() ?
>>>
>>> say you have a chronogram named chrono:
>>>
>>> tr <- chrono
>>> tr$edge.length <- NULL
>>> bt <- branching.times(chrono)
>>> chrono2 <- magical.function.here(bt, tr)
>>>
>>> here I want :
>>>
>>> all(chrono2$edge.length == chrono$edge.length)
>>>
>>> This would be helpful in situations such as parsing the mcmctree output
>>> (mcmc.txt) that are made of sampled branching times by the MCMC (a big
>>> table with row=iteration and col=node age) and then, say, run the same
>>> diversification analysis on the MCMC trees to get some credibility
>>> intervals on the diversification parameters.
>>>
>>> Thanks !
>>>
>>> --
>>> Tristan
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ___
>>> R-sig-phylo mailing list - R-sig-phylo@r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>>> Searchable archive at
>>> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>>>
>>>
>>> Pour nous remonter une erreur de filtrage, veuillez vous rendre ici :
>>> http://f.security-mail.net/301eSIrvP0A
>>>
>>>
>>>
>>
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Re: [R-sig-phylo] branching time to branch length (eg. mcmctree)

2015-10-28 Thread David Bapst
Hello Tristan,

Does the code below work for your purpose? I don't know of a function
off the top of my head that does this in a current package on CRAN
(and although I might have missed such, I try to keep myself aware of
time-scaling functions in R, given my interests). However, its not too
difficult of an issue to come up with a solution for.

Cheers,
-Dave

PS: I appear to have done this with 16 minutes of getting your email...

###

library(ape)

nodeDates2branchLengths<-function(nodeDates, tree, allTipsModern){
if(!allTipsModern){
stop("nodeDates2branchLengths doesn't handle non-ultrametric
trees or trees where not all tips are at the modern day... yet")}
if(length(nodeDates)!=Nnode(tree)){
stop("nodeDates must be same length as number of nodes on input tree")}
if(!is.null(tree$edge.lengths)){
message("Warning: input tree has $edge.lengths present, these
will be replaced")}
#add zero ages for tips
allAges<-c(rep(0,Ntip(tree)),nodeDates)
# get mother node age for each edge
momAges<-allAges[tree$edge[,1]]
# get node ages for child nodes of each edge
childAges<-allAges[tree$edge[,2]]
#edge lengths = mom - child
edgeLengths<-momAges-childAges
tree$edge.length<-edgeLengths
return(tree)
}


chrono<-rcoal(10)

tr <- chrono
tr$edge.length <- NULL
bt <- branching.times(chrono)
chrono2 <- nodeDates2branchLengths(bt, tr, allTipsModern=TRUE)

layout(1:2)
plot(chrono);axisPhylo()
plot(chrono);axisPhylo()


On Wed, Oct 28, 2015 at 8:31 AM, Tristan Lefebure
 wrote:
> Greetings all,
>
> Does anyone know a way to transform branching times into branch length of a
> chronogram. Like the inverse function of ape::branching.time() ?
>
> say you have a chronogram named chrono:
>
> tr <- chrono
> tr$edge.length <- NULL
> bt <- branching.times(chrono)
> chrono2 <- magical.function.here(bt, tr)
>
> here I want :
>
> all(chrono2$edge.length == chrono$edge.length)
>
> This would be helpful in situations such as parsing the mcmctree output
> (mcmc.txt) that are made of sampled branching times by the MCMC (a big
> table with row=iteration and col=node age) and then, say, run the same
> diversification analysis on the MCMC trees to get some credibility
> intervals on the diversification parameters.
>
> Thanks !
>
> --
> Tristan
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] dist.nodes crashing with big trees

2015-10-16 Thread David Bapst
Hi Gustavo,

I'm paleotree's author and maintainer. Just to be clear that I
understand your problem, I believe you are saying that when you use
timeSliceTree, you are getting an error that the internal call to
dist.nodes is failing? Is that right?

The first thought I have is that maybe the solution here is to avoid
dist.nodes, as it is somewhat overkill. I use dist.nodes in that code,
which I wrote in 2011, to get the distance of tips and nodes from the
root. A better solution may now exist in another R package. I'd have
to investigate (although maybe someone on the list can suggest one).

The second thought I have is that there might be alternative functions
that do something lie timeSliceTree in another R package. Off the top
of my head, I recall that Nick Matzke had a similar, 'chainsaw'
function, which you can find here and appears not to call dist.nodes:

https://stat.ethz.ch/pipermail/r-sig-phylo/2011-July/001483.html

Again, maybe someone on the list knows of a good alternative function.

I'll try to give this more thought, but for now, maybe see if you can
use Nick's function succesfully. Overall though, I've discovered the
use of truly gigantic trees can often run into unexpected problems.

Cheers,
-Dave



On Fri, Oct 16, 2015 at 12:47 PM, Gustavo Burin Ferreira
 wrote:
> Dear list,
>
> I'm trying to perform a time travel in simulated phylogenies with both
> extant and extinct species using the timeSliceTree function form the
> paleotree package. My aim is to have the molecular phylogenies derived from
> the complete phylogeny (attached) in different points in time.
>
> However, when I try that with big trees (bigger than 2 tips total), I
> get an error of integer overflow coming from the dist.nodes function. After
> slightly tweaking the dist.nodes function (changing nm from integer to
> numeric/double), I get the following message:
>
> Error in dist.nodes(tree) (from #7) :
>   long vectors (argument 7) are not supported in .Fortran
>
> Since I don't know much about C or Fortran, I couldn't find a way of solving
> this by myself, so any help will be greatly appreciated.
>
> I'm sending one tree attached for example.
>
> Thank you very much in advance!
>
> Best,
>
> Gustavo Burin Ferreira, Msc.
> Instituto de Biociências
> Universidade de São Paulo
> Tel: (11) 98525-8948
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Re: [R-sig-phylo] Bug in ape: dropping tips from a ladderized tree (still) randomly shuffles the node labels

2015-08-17 Thread David Bapst
Hi Emannuel (and list),

Just wanted to let you know that after some testing with my own cases,
the new drop.tip appears to fix the error, so the issue is closed from
my perspective.

Cheers,
-Dave

On Tue, Jul 28, 2015 at 12:25 PM, Emmanuel Paradis
emmanuel.para...@ird.fr wrote:
 Hi David,

 I've conducted more tests and the bug was really in drop.tip and sometimes
 apparent without calling ladderize. The fix seems to work well. I have built
 ape 3.3-0.6 which is available on ape-package.ird.fr as source package.

 Best,

 Emmanuel


 Le 25/07/2015 19:33, Emmanuel Paradis a écrit :

 David,

 I was thinking about some simple tests to check that the function still
 works correctly in other situations. It can happen that when fixing a
 bug which occurs in a special situation in a piece of code, the code
 then fails in other (possibly simpler) situations. In the present case,
 the fix is the part of the code that renumbers the nodes which is thus
 used in all cases (even if there are no node labels). I'll conduct some
 tests later, but in the mean time if you see something strange, just
 tell me.

 I attach the new source file.

 Best,

 Emmanuel

 Le 25/07/2015 18:54, David Bapst a écrit :

 Hi Emmanuel,

 Thank you for the fix! And, yes, I realize, its probably one of ape's
 most widely used functions. Perhaps what we need is a function that
 tests whether there is a mismatch in the node.labels, across trees
 that might have different sets of taxa, which will help in the future
 to alert us if this bug appears again. Of course, such a function
 would need to avoid using drop.tip entirely. I've looked and I'm not
 aware of any function across the entire Phylogenetics taskview that
 fulfills this criteria.

 So, I admit that's a tough order. I've made a particularly ugly first
 stab at such a thing, mostly depending on prop.part. Its rather
 clumsy, as I originally wrote it as code to fix node.labels, rather
 than find the mismatches. Unfortunately, at present, it misidentifies
 root-ward losses of clades, due to dropping of stem/out-group tips, as
 a mismatch between node labels. Perhaps someone else will see a
 cleaner, more accurate solution.


 ###


 library(ape)

 testNodeLabels-function(tree1,tree2,printMisMatch=TRUE,plot=FALSE){
  nlab1-tree1$node.label
  if(!is.null(tree2$node.label)){
  nlab2-tree2$node.label
  }else{
  nlab2-rep(NA,Nnode(tree2))
  }
  #if tree2 has any taxa not in tree1, stop
  noMatch-sapply(tree2$tip.label,function(x)
 !any(x==tree1$tip.label))
  if(any(noMatch)){
  stop(tree2 has taxa not found in tree1 and thus is
 uncomparable)
  }
  #
  desc1-lapply(prop.part(tree1),function(x) tree1$tip.label[x])
  desc2-lapply(prop.part(tree2),function(x) tree2$tip.label[x])
  #need to remove taxa not shared by one without using drop.tip
  taxa-c(tree1$tip.label,tree2$tip.label)
  shared-taxa[sapply(taxa,function(x)
  any(x==tree1$tip.label)  any(x==tree2$tip.label))]
  #get ndesc for desc2
  ndesc2-sapply(desc2,length)
  #reorder desc2 and nlab2
  desc2-desc2[order(ndesc2)]
  nlab2-nlab2[order(ndesc2)]
  result-TRUE
  for(i in 1:length(desc1)){
  target-desc1[[i]]
  targetName-nlab1[i]
  sharedDesc-target[sapply(target,function(x)
  any(x==shared))]
  if(length(sharedDesc)1){
  #find matches in 2
  matches-sapply(desc2,function(x)
  all(sapply(sharedDesc,function(z) any(z==x
  }else{
  matches-FALSE
  }
  #get richest match - if there is no match, get NA
  matchClade-which(matches)[1]
  if(!is.na(matchClade)){
  matchName-identical(nlab1[i],nlab2[matchClade])
  if(!matchName){
  result-FALSE
  if(printMisMatch){
  warning(paste(\n A node with descendants:,
  paste0(sharedDesc,collapse=', '),
  \n is labeled:,nlab1[i],
  in tree1 but labeled:,
  nlab2[matchClade],in tree2 \n))
  }
  }
  }
  }
  #
  if(plot){
  #plot it
  layout(1:2)
  plot(tree1,show.tip.label=TRUE,use.edge.length=FALSE)
  nodelabels(tree1$node.label)
  plot(tree2,show.tip.label=TRUE,use.edge.length=FALSE)
  nodelabels(tree2$node.label)
  layout(1)
  }
  return(result)
  }

 set.seed(1)
 tree-rtree(10)
 tree$node.label-rep(NA,Nnode(tree))
 tree$node.label[1]-ROOT
 tree$node.label[5]-HELLO
 tree$node.label[8]-NOPE

 tree1-drop.tip(tree,t2)
 tree2-ladderize(tree)
 tree3-drop.tip(tree2,t2)

 testNodeLabels(tree,tree1)
 testNodeLabels(tree,tree2)
 testNodeLabels(tree,tree3)

 testNodeLabels

[R-sig-phylo] Bug in ape: dropping tips from a ladderized tree (still) randomly shuffles the node labels

2015-07-17 Thread David Bapst
Hello all,

Recently I noticed a complex function of mine that does some tree
transformations was randomly scrambling node.label elements.

In the course of doing so, I found this old email (below) from Rebecca
Best in 2012, which outlined an issue that occurred when a ladderized
tree had tips dropped. It appears that bug has reappeared  in more
recent version of ape.

Here's a slightly modified version of her example code, which appears
to still replicate a node label shuffling in ape v3.3.

#
require(ape)

#read tree
mytree-read.tree()
((D,(E,G)1)1,((H,J)0.8,(K,(((L,M)0.5,(N,O)0.6)1,(P,(Q,R)1)1)0.7)1)1);

#ladderize tree
mytree.lad-ladderize(mytree)

#node labels display on both trees correctly
layout(1:2)
plot(mytree,show.node.label=TRUE)
plot(mytree.lad,show.node.label=TRUE)

#drop tips from both trees
drop.mytree-drop.tip(mytree,c(L,D,G))
drop.mytree.lad-drop.tip(mytree.lad,c(L,D,G))

#plot both trees, node labels are incorrect for ladderized tree
dev.new()
layout(1:2)
plot(drop.mytree,show.node.label=TRUE)
plot(drop.mytree.lad,show.node.label=TRUE)
#

Although I'm still in the process of dismantling my own issue, so I am
not 100% certain, I strongly believe this is the culprit in my case,
as my script partly drops.tips from an input tree (that happens to
always be ladderized).

Cheers,
-Dave


-- Forwarded message --
From: Rebecca Best rjb...@ucdavis.edu
Date: Tue, Oct 2, 2012 at 12:26 AM
Subject: [R-sig-phylo] ladderize + drop.tip = shuffled node labels
To: r-sig-phylo@r-project.org


Hi all

I have been plotting some pruned trees recently, and have run into a
problem using drop.tip() after ladderize(). If you ladderize() and
then drop tips from the ladderized tree, then at least in my case the
node labels are no longer correct. This may be an unlikely sequence of
commands, but I thought I'd post this in case it is an easy fix, or it
helps anyone else avoid issues.
Thanks!

Rebecca

##

require(ape)

#read tree

mytree-read.tree()
((D,(E,G)1)1,((H,J)0.8,(K,(((L,M)0.5,(N,O)0.6)1,(P,(Q,R)1)1)0.7)1)1);

#ladderize tree

mytree.lad-ladderize(mytree)

#node labels display on both trees correctly

plot(mytree,show.node.label=TRUE)
plot(mytree.lad,show.node.label=TRUE)

#drop tips from both trees

drop.mytree-drop.tip(mytree,c(L,D,G))
drop.mytree.lad-drop.tip(mytree.lad,c(L,D,G))

#plot both trees, node labels are incorrect for ladderized tree

plot(drop.mytree,show.node.label=TRUE)
plot(drop.mytree.lad,show.node.label=TRUE)

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] PGLS with non-ultrametric tree

2015-07-16 Thread David Bapst
Hi Solomon,

Comparatives methods are routinely applied to non-ultrametric trees,
contrary to the text you quoted. See the last chapter of that book.
The phylogeny-based analyses that do generally require ultrametric
trees are those that fit some form of a lineage diversification model,
because these models are ultimately descended from the idea of
treating the age of modern lineages as a reverse survivorship curve.
Most trait-based analyses are fine.

What does typically need to be done for at least some PGLS functions,
is accounting for unequal tip variances with non-ultrametric trees. I
usually do something like this, just using gls() and ape functions...

tiph - diag( vcv.phylo(tree) )
gls(X1~X2 ,correlation=corBrownian(value=1, phy=tree),
weights=varFixed(~tiph), data=data)

Cheers,
-Dave

On Thu, Jul 16, 2015 at 3:19 PM, Solomon Chak tc...@vims.edu wrote:
 Hi Dr. Garland,

 I got the impression that an ultrametric tree is needed for comparative
 analysis from this book http://www.springer.com/us/book/9783662435496ch.
 2 pg. 38: most comparative analyses assume that the tree is ultrametric,
 as the majority of analyses deal with evolution of phenotypic traits of
 extant species with the underlying assumption is that the time available
 for phenotypic evolution is the same for all taxa.

 I understand that the methodology of PGLS can use any tree form, I suppose
 there're different assumptions if I used an additive tree or an ultrametric
 tree. Could you guide me to some references that explicitly discuss about
 this?

 Is it necessary to use an ultrametric tree If I want to estimate lambda in
 the residual error of the gls and do a branch length transformation as Revell
 2010
 http://onlinelibrary.wiley.com/doi/10./j.2041-210X.2010.00044.x/pdf
 suggested?

 Many thanks!

 Cheers,
 Solomon Chak

 ---
 *Solomon **Tin Chi **Chak*
 Ph.D. Candidate
 Tel: (804) 684-7484
 Marine Biodiversity Laboratory
 http://www.vims.edu/research/units/labgroups/marine_biodiversity/index.php
 Virginia Institute of Marine Science http://www.vims.edu/
 College of William and Mary http://www.wm.edu/
 PO Box 1346 / Rt. 1208 Greate Rd., Gloucester Pt, VA 23062, USA


 On Thu, Jul 16, 2015 at 2:55 PM, Theodore Garland Jr 
 theodore.garl...@ucr.edu wrote:

 Dear Solomon,

 I don;t know where you are trying to go with this, but any proper
 implementation of PGLS (I am not talking about methods that transform the
 branch lengths with things like Grafen's rho, Pagel's lambda or OU models)
 should be able to use any tree of any shape.  This is the same as for
 phylogenetically independent contrasts.

 Cheers,
 Ted

 Theodore Garland, Jr., Professor
 Department of Biology
 University of California, Riverside
 Riverside, CA 92521
 Office Phone:  (951) 827-3524
 Facsimile:  (951) 827-4286 (not confidential)
 Email:  tgarl...@ucr.edu
 http://www.biology.ucr.edu/people/faculty/Garland.html
 http://scholar.google.com/citations?hl=enuser=iSSbrhwJ

 Director, UCR Institute for the Development of Educational Applications

 Editor in Chief, Physiological and Biochemical Zoology

 Fail Lab: Episode One
 http://testtube.com/faillab/zoochosis-episode-one-evolution
 http://www.youtube.com/watch?v=c0msBWyTzU0

 
 From: R-sig-phylo [r-sig-phylo-boun...@r-project.org] on behalf of
 Solomon Chak [tc...@vims.edu]
 Sent: Thursday, July 16, 2015 3:31 AM
 To: r-sig-phylo@r-project.org
 Subject: [R-sig-phylo] PGLS with non-ultrametric tree

 Dear all,

 What are the pros and cons of the two methods to do pgls with a
 non-ultrametric tree? Many thanks!

 1) Convert the additive tree to ultrametric using penalized likelihood
 (Sanderson 2002) with ape:: chronopl after cross-validation to find the
 best lambda.

 2) Use weighted least-squares in which gls(y ~ x,
 correlation=corPagel(value=0.1, phy=phy, fixed=F),
 weights=varFixed(~tip.heights),
 data=dat)

 Cheers,
 Solomon Chak

 ---
 *Solomon **Tin Chi **Chak*
 Ph.D. Candidate
 Tel: (804) 684-7484
 Marine Biodiversity Laboratory
 
 http://www.vims.edu/research/units/labgroups/marine_biodiversity/index.php
 
 Virginia Institute of Marine Science http://www.vims.edu/
 College of William and Mary http://www.wm.edu/
 PO Box 1346 / Rt. 1208 Greate Rd., Gloucester Pt, VA 23062, USA

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at
 http://www.mail-archive.com/r-sig-phylo@r-project.org/


 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. 

Re: [R-sig-phylo] doubt

2015-07-05 Thread David Bapst
Just to clarify for future users who stumble on Liam's solution for
Lilian, the second block of code attaches the new tips to
non-ultrametric trees at the same distance as the current tips at
maximum distance from the root.

If this is a time-scaled phylogeny and the tree's root depth is equal
to its age, these new tips then are at time=0, i.e. they are now
extant tip taxa.  If no tips actually extend to the present (i.e. the
root depth isn't equal to the age of the root, as often occurs if the
phylogeny is entirely composed of extinct taxa), or the tips are
actually older then the present day, then further modification is
necessary of the new branch length.

(Also, if the tree isn't time-scaled but branches are instead scaled
to some other measure, this may be undesirable because there may be no
special meaning to being maximally far from the root, especially if
its actually an unrooted tree.)

If you're tree has a $root.time element indicating the root's age
because it was time-scaled with packages strap or paleotree (or
because you manually gave it a $root.time), then you can do, where
tipAge is the tip's age before-present in the same time-units as the
branches are scaled:

newLength-tree$root.time-tipAge-nodeheight(tree,node)
tree1-bind.tip(tree,tip.label,where=node,edge.length=newLength)

Cheers,
-Dave

On Sat, Jul 4, 2015 at 12:50 PM, Lilian Sayuri Ouchi de Melo
sayuriou...@gmail.com wrote:
 Hello Liam,

 Thank you very much for help me! My tree is not ultrametric and your second
 suggestion works perfectly!

 All the best and have a good time in Brazil!

 Em sáb, 4 de jul de 2015 às 12:31, Liam J. Revell liam.rev...@umb.edu
 escreveu:

 Hi Lilian.

 If your tree is ultrametric, which you can check using:

 is.ultrametric(tree)

 then when you attach a tip to a node or edge using bind.tip the length
 of the terminal edge leading to that tip will automatically be specified
 so that the tree remains ultrametric.

 If this is not the case you could try the following, in which node is
 the node number you want to attach the tip to:

 depth-max(nodeHeights(tree))-nodeheight(tree,node)
 tree-bind.tip(tree,tip.label,where=node,edge.length=depth)

 Let us know if this works.

 All the best, Lia

 Liam J. Revell, Assistant Professor of Biology
 University of Massachusetts Boston
 web: http://faculty.umb.edu/liam.revell/
 email: liam.rev...@umb.edu
 blog: http://blog.phytools.org

 On 7/3/2015 5:33 PM, Lilian Sayuri Ouchi de Melo wrote:
  Dear all,
 
  I have a time calibrated phylogeny and I need to insert some species on
 it.
  When I added those species with bind.tip function (phytools) the new
  phylogenetic tree doesn't have the calibration time. I tried to solve
 this
  problem in other packages such as APE and other programs like Mesquite
 and
  online platforms, but I did not get the solution.
 
  Is there any method that enable the insertion of additional species in a
  time calibrated phylogeny without losing branch length information?
 
  Thank you all in advance
 

 --
 Lilian Sayuri Ouchi de Melo
 (PhD student of São Paulo State University)

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

[R-sig-phylo] Margin Artifact in plot.phylo with Very Long Tip Labels, despite show.tip.label=FALSE

2015-06-18 Thread David Bapst
Hi all,

I was plotting some trees with obscenely long taxon names (long story)
and found an odd plotting artifact that leaves white-space when
show.tip.labels=FALSE, as if the plot was trying make room for the
extraordinarily long tip labels, even though they wouldn't be plotted.
I'm using R version 3.2.0 and ape 3.3.

Here's some reproducible code:

##

library(ape)
tree-rcoal(1000)

tree1-tree
tree1$tip.label-paste0(a_really_long_obnoxious_very_very_long,
_when_is_it_going_to_end_name_are_we_there_yet_maybe,
okay_lets_do_this,1:1000)

tree2-tree
tree2$tip.label-paste0(a_long_name,1:1000)

plot(tree1, show.tip.label=FALSE)

#

And we can see the plot of tree1 pushes the tips back, leaving a lot
of white space to the right. The curious thing is, plots for tree and
tree2 with its slightly longer name look identical, with the same
amount of whitespace.

##

plot(tree, show.tip.label=FALSE)

plot(tree2, show.tip.label=FALSE)

##

So there's some threshold to the length of the tip labels to produce
this white space.

For reasons not entirely clear to me, this issue inconsistently
appears when various layouts are used.

###

#has it:
layout(matrix(1:4,2,2))
plot(tree,show.tip.label=FALSE)
plot(tree1,show.tip.label=FALSE)
plot(tree2,show.tip.label=FALSE)
plot(tree,show.tip.label=FALSE)

#doesn't has it
layout(1:4)
plot(tree,show.tip.label=FALSE)
plot(tree1,show.tip.label=FALSE)
plot(tree2,show.tip.label=FALSE)
plot(tree,show.tip.label=FALSE)

###

Perhaps that suggests some clue to this odd behavior.

Apologies for all the emails lately!

Cheers,
-Dave

-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread David Bapst
Hello all,

(I'm a troublemaker today.)

Sometimes, in ordered discrete data, there are states we know might
exist as intermediary between observed states but aren't observed
themselves. I suppose this is probably common for meristic data. At
least to me, it seems like it should be possible to reconstruct node
states in a scenario with 'missing' states in a ML approach by
defining the corre

Anyway, in a recent conversation with a friend, he noted that he
couldn't get the function for ML ancestral reconstruction of discrete
characters, specifically ace (in ape) or rerootingMethod (in phytools)
to accept data with missing states. I was a little shocked by this,
and I didn't believe him in my foolhardiness and investigated myself.

#

library(ape)
data(bird.orders)

#make an ordered matrix for a 4 state trait
model-matrix(0,4,4)
for(i in 1:4){for(j in 1:4){
if(abs(i-j)2){
model[i,j]-0.1
}
}}
rownames(model)-colnames(model)-0:3

#simulate data where you have only observed endmembers
trait - factor(c(rep(0, 5), rep(3, 18)))
names(trait)-bird.orders$tip.label

ace(trait, bird.orders, type = discrete)
#works
ace(trait, bird.orders, type = discrete, model=model)
#fail

library(phytools)
rerootingMethod(tree=bird.orders, x=trait)
#works
rerootingMethod(tree=bird.orders, x=trait, model=model)
#fail

#

(And it doesn't look like ancestral.pml in phangorn accepts model matrices.)

So, are these functions rejecting a model with missing states due to a
real analytical issue that I'm blithely ignorant of, or is there some
other function that I've missed that will allow ML reconstruction with
missing states?

Cheers,
-Dave

-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread David Bapst
Liam,

Ah, I see, rerootingMethod(), unlike ace, will accept a matrix
representation of discrete trait values.

However, it doesn't appear that one can define a model matrix still?
Outside of molecular data, the missing state issue is often for
ordered data, hence the need to define a model matrix.


library(ape)
library(phytools)
data(bird.orders)

#make a matrix for a 4 step trait
model-matrix(0,4,4)
for(i in 1:4){for(j in 1:4){
if(abs(i-j)2){
model[i,j]-0.1
}
}}
rownames(model)-colnames(model)-0:3

#simulate data where you have only observed endmembers
trait - factor(c(rep(0, 5), rep(3, 18)))
names(trait)-bird.orders$tip.label
trait-to.matrix(trait,seq=0:3)

rerootingMethod(tree=bird.orders, x=trait)
#works
rerootingMethod(tree=bird.orders, x=trait, model=model)
#fails

#

Cheers,
-Dave

On Wed, Jun 17, 2015 at 12:06 PM, Liam J. Revell liam.rev...@umb.edu wrote:
 Hi David.

 Actually, if I understand correctly, this does work in phytools. I suspect
 it can be set up in phangorn as well - Klaus can probably explain how.

 So, if I understand correctly, you want to get marginal ancestral states for
 a character that can assume, say, states A, C, G,  T, but for which
 you have only observed states A, C,  G (for instance) in your tip
 taxa?

 The way to do this in rerootingMethod is as follows:

 library(phytools)
 ## simulate some data to work with:
 tree-pbtree(n=26,tip.label=letters,scale=1)
 Q-matrix(c(-2,1,1,1,-2,1,1,1,-2),3,3)
 rownames(Q)-colnames(Q)-c(A,C,G)
 x-sim.history(tree,Q)$states
 x ## our data
 ## now convert to a matrix representation:
 X-to.matrix(x,seq=c(A,C,G,T))
 ## reconstruct ancestral states
 fitER-rerootingMethod(tree,X,model=ER)
 fitER

 Note that as we have not observed any evidence that changes to T occur for
 this character, if we use a symmetric model instead, we will find that the
 marginal likelihoods at all internal nodes for state T are zero. This is
 because the maximum likelihood q[i,T]  q[T,i] for all i will be zero
 (sensibly). For instance:

 fitSYM-rerootingMethod(tree,X,model=SYM)
 fitSYM

 Let me know if this is what you had in mind.

 rerootingMethod just uses modified code from ace internally to do the
 calculations - so if ace does not permit this presently, it could easily be
 modified to allow it. phangorn too must allow this because for many
 nucleotide sites we want to reconstruct ancestral states - but we will have
 observed only a subset of the four nucleotides at that site.

 All the best, Liam

 Liam J. Revell, Assistant Professor of Biology
 University of Massachusetts Boston
 web: http://faculty.umb.edu/liam.revell/
 email: liam.rev...@umb.edu
 blog: http://blog.phytools.org


 On 6/17/2015 1:46 PM, David Bapst wrote:

 Hello all,

 (I'm a troublemaker today.)

 Sometimes, in ordered discrete data, there are states we know might
 exist as intermediary between observed states but aren't observed
 themselves. I suppose this is probably common for meristic data. At
 least to me, it seems like it should be possible to reconstruct node
 states in a scenario with 'missing' states in a ML approach by
 defining the corre

 Anyway, in a recent conversation with a friend, he noted that he
 couldn't get the function for ML ancestral reconstruction of discrete
 characters, specifically ace (in ape) or rerootingMethod (in phytools)
 to accept data with missing states. I was a little shocked by this,
 and I didn't believe him in my foolhardiness and investigated myself.

 #

 library(ape)
 data(bird.orders)

 #make an ordered matrix for a 4 state trait
 model-matrix(0,4,4)
 for(i in 1:4){for(j in 1:4){
  if(abs(i-j)2){
  model[i,j]-0.1
  }
  }}
 rownames(model)-colnames(model)-0:3

 #simulate data where you have only observed endmembers
 trait - factor(c(rep(0, 5), rep(3, 18)))
 names(trait)-bird.orders$tip.label

 ace(trait, bird.orders, type = discrete)
 #works
 ace(trait, bird.orders, type = discrete, model=model)
 #fail

 library(phytools)
 rerootingMethod(tree=bird.orders, x=trait)
 #works
 rerootingMethod(tree=bird.orders, x=trait, model=model)
 #fail

 #

 (And it doesn't look like ancestral.pml in phangorn accepts model
 matrices.)

 So, are these functions rejecting a model with missing states due to a
 real analytical issue that I'm blithely ignorant of, or is there some
 other function that I've missed that will allow ML reconstruction with
 missing states?

 Cheers,
 -Dave





-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive

Re: [R-sig-phylo] Missing States in ML Reconstruction of Discrete Ancestral States (phytools, ape)

2015-06-17 Thread David Bapst
Liam-

Yes, that works! I apparently confused the sort of model matrix needed
by rTraitDisc with the sort needed by ace.

Here's a full working example, for future posterity:

#

library(ape)
library(phytools)
data(bird.orders)

#make a matrix for a 4 step trait
model-matrix(c(0,1,0,0,
1,0,1,0,
0,1,0,1,
0,0,1,0),4,4)

#simulate data where you have only observed endmembers
trait - factor(c(rep(0, 5), rep(3, 18)))
names(trait)-bird.orders$tip.label
trait-to.matrix(trait,seq=0:3)

rerootingMethod(tree=bird.orders, x=trait)
#works
rerootingMethod(tree=bird.orders, x=trait, model=model)

#

An interesting thing to note about the above example is that even with
equal rates between sequential states, it infers a higher negative
rate of staying in the missing states, so a better model might be one
in we constrained the rate of staying in a state as the same across
all states. However, that doesn't seem to be possible with
ace/rerootingMethod as the diagonal of the model matrix is ignored,
right?

Brian, yes, corHMM seems like it should be able to do it; I overlooked
that package. diversitree's ML reconstruction functions don't seem to
accept a model matrix, at least based on current documentation.

-Dave


On Wed, Jun 17, 2015 at 1:30 PM, Liam J. Revell liam.rev...@umb.edu wrote:
 Hi David.

 I think the problem may be that you're specifying the model matrix
 incorrectly. The model matrix is an integer matrix in which each number is a
 different rate type and the diagonal is zeroes.

 So, for instance, for a single-rate ordered model with four states you would
 do:

 model-matrix(c(0,1,0,0,
 1,0,1,0,
 0,1,0,1,
 0,0,1,0),4,4)

 (with row  column names of your states).

 A symmetric ordered model would be:

 model-matrix(c(0,1,0,0,
 1,0,2,0,
 0,2,0,3,
 0,0,3,0),4,4) ## I think

 Does this help? In my tests it seems to run fine for phytools.

 All the best, Liam

 Liam J. Revell, Assistant Professor of Biology
 University of Massachusetts Boston
 web: http://faculty.umb.edu/liam.revell/
 email: liam.rev...@umb.edu
 blog: http://blog.phytools.org

 On 6/17/2015 3:06 PM, David Bapst wrote:

 Liam,

 Ah, I see, rerootingMethod(), unlike ace, will accept a matrix
 representation of discrete trait values.

 However, it doesn't appear that one can define a model matrix still?
 Outside of molecular data, the missing state issue is often for
 ordered data, hence the need to define a model matrix.

 
 library(ape)
 library(phytools)
 data(bird.orders)

 #make a matrix for a 4 step trait
 model-matrix(0,4,4)
 for(i in 1:4){for(j in 1:4){
  if(abs(i-j)2){
  model[i,j]-0.1
  }
  }}
 rownames(model)-colnames(model)-0:3

 #simulate data where you have only observed endmembers
 trait - factor(c(rep(0, 5), rep(3, 18)))
 names(trait)-bird.orders$tip.label
 trait-to.matrix(trait,seq=0:3)

 rerootingMethod(tree=bird.orders, x=trait)
 #works
 rerootingMethod(tree=bird.orders, x=trait, model=model)
 #fails

 #

 Cheers,
 -Dave

 On Wed, Jun 17, 2015 at 12:06 PM, Liam J. Revell liam.rev...@umb.edu
 wrote:

 Hi David.

 Actually, if I understand correctly, this does work in phytools. I
 suspect
 it can be set up in phangorn as well - Klaus can probably explain how.

 So, if I understand correctly, you want to get marginal ancestral states
 for
 a character that can assume, say, states A, C, G,  T, but for
 which
 you have only observed states A, C,  G (for instance) in your tip
 taxa?

 The way to do this in rerootingMethod is as follows:

 library(phytools)
 ## simulate some data to work with:
 tree-pbtree(n=26,tip.label=letters,scale=1)
 Q-matrix(c(-2,1,1,1,-2,1,1,1,-2),3,3)
 rownames(Q)-colnames(Q)-c(A,C,G)
 x-sim.history(tree,Q)$states
 x ## our data
 ## now convert to a matrix representation:
 X-to.matrix(x,seq=c(A,C,G,T))
 ## reconstruct ancestral states
 fitER-rerootingMethod(tree,X,model=ER)
 fitER

 Note that as we have not observed any evidence that changes to T occur
 for
 this character, if we use a symmetric model instead, we will find that
 the
 marginal likelihoods at all internal nodes for state T are zero. This
 is
 because the maximum likelihood q[i,T]  q[T,i] for all i will be zero
 (sensibly). For instance:

 fitSYM-rerootingMethod(tree,X,model=SYM)
 fitSYM

 Let me know if this is what you had in mind.

 rerootingMethod just uses modified code from ace internally to do the
 calculations - so if ace does not permit this presently, it could easily
 be
 modified to allow it. phangorn too must allow this because for many
 nucleotide sites we want to reconstruct ancestral states - but we will
 have
 observed only a subset of the four nucleotides at that site.

 All the best, Liam

 Liam J. Revell, Assistant Professor of Biology
 University of Massachusetts Boston
 web: http://faculty.umb.edu/liam.revell/
 email: liam.rev...@umb.edu
 blog: http

[R-sig-phylo] collapse.singles() can be confused by node numbering (Was: Bug in reorder.phylo() (related to cleaning phylo objects))

2015-06-17 Thread David Bapst
 - node.lab
tree$Nnode - nnode
## end
tree
}

##

I've marked my code addition with #*#. Let's see if it fixes our issue:

#

#test simulated example
#so let's test THAT with a simple example
phy-rtree(10)
phy$Nnode-phy$Nnode+1L
phy$edge[phy$edge10]-1+phy$edge[phy$edge10]
#let's jumble the node IDs a little
phy$edge[phy$edge==12]-0
phy$edge[phy$edge==13]-12
phy$edge[phy$edge==0]-13
phy$edge-rbind(phy$edge,c(11,13))
storage.mode(phy$edge)-integer
checkValidPhylo(phy)
#let's try collapsing nodes
phy1-collapse.singles(phy)
phy1$edge
tabulate(phy1$edge)
checkValidPhylo(phy1)
#it worked!

#let's try empirical example
tree1-collapse.singles(tree)
# with the collapse.singles() processed tree
checkValidPhylo(tree1)

##

Emmanuel, is there any chance you could implement this fix for
collapse.singles (or a similar fix; my code probably isn't very
efficient) in ape?

-Dave



On Mon, Jun 15, 2015 at 9:29 AM, Emmanuel Paradis
emmanuel.para...@ird.fr wrote:
 Hi David,

 collapse.singles() seems to work correctly if the phylo object is
 correctly conformed. Some features of this class may seem annoying (and
 Klaus and I alredy discussed about this), but these help for other things.
 As a reminder the class phylo is defined here:

 http://ape-package.ird.fr/misc/FormatTreeR_24Oct2012.pdf

 Recently, I put a function on github to help code writters:

 https://github.com/emmanuelparadis/checkValidPhylo

 This could help you to detect problems that would be tough to find
 otherwise.

 Cheers,

 Emmanuel


 Le 12/06/2015 22:41, David Bapst a écrit :

 Hi Klaus (and others),

 Ah, I see! The real bug then appears to be in collapse.singles, as it
 does not reorder the ID numbers in $edge. Here's a quick function to
 return the root ID:

 getRootID-function(tree){
  uniqueNode-unique(tree$edge[,1])
  whichRoot-sapply(uniqueNode,function(x)
  (sum(x==tree$edge[,2])==0))
  rootID-uniqueNode[whichRoot]
  return(rootID)
  }

 And if we run it...

 getRootID(tree) #original tree

 [1] 151

 getRootID(tree1)   #after collapse.singles

 [1] 151

 getRootID(tree2)   #after reorder.phylo

 [1] 131

 And we can see that although the number of nodes certainly changed
 when collapse.singles was run, it didn't change the root node's ID.

 So I guess this is really a collapse.singles bug report. Thanks for
 the insight, Klaus!

 -Dave

 On Fri, Jun 12, 2015 at 2:27 PM, Klaus Schliep klaus.schl...@gmail.com
 wrote:

 Hi David,

 I found the bug. Somehow ape assumes on the one hand that the root is
 number
 of tips + 1.
 On the other hand the root of an phylo object is the node which is in
 tree$edge[,1], but not in tree$edge[,2],
 this is the case even in an unrooted tree. This annoys me for a long
 time.

 The root of tree1 with the definition above is actually node 151 and not
 131. Changing these solves your problem:
 Here is a small function to do this for you:

 switch.nodes- function(tree, a, b){
  ntips = length(tree$tip.label)
  tree$edge[tree$edge==a] = 0L
  tree$edge[tree$edge==b] = as.integer(a)
  tree$edge[tree$edge==0L] = as.integer(b)
  if(!is.null(tree$node.label)){
  tmp-tree$node.label[a-ntips]
  tree$node.label[a-ntips] = tree$node.label[b-ntips]
  tree$node.label[b-ntips] = tmp
  }
  tree
 }

 library(phangorn)
 attr(tree1, order) = NULL
 getRoot(tree1)

 tree2 = switch.nodes(tree1, 131, 151)
 plot(tree2) # now works for me

 Cheers and have a nice weekend,
 Klaus







 On Fri, Jun 12, 2015 at 2:53 PM, David Bapst dwba...@gmail.com wrote:


 Hello all,

 As those of you who directly manipulate the guts of phylo objects in
 your code (or construct new phylo objects whole cloth from
 un-phylo-like data structures) have probably experienced, it is
 sometimes easy to create $edge matrices that aren't accepted by ape
 functions (I often use plot.phylo as my litmus for this).

 When this occurs, various things can be done; I usually do the
 following sequence:

 collapse.singles()
 reorder.phylo(,cladewise)
 read.tree(text=write.tree(,file=NULL))

 ...or something along those lines.

 However, I've run into an issue where reorder.phylo() returns what is
 essentially a scrap of the original $edge matrix, without warning.
 Very worrisome! I'm using R version 3.2.0 and ape 3.3. Here's, my
 script, including a call to a saved object on my website, so that the
 error can be reproduced:

 (Why do I have an .Rdata object listed with a .txt extension, you
 might wonder? Because my school apparently sanitizes file extensions
 on our hosted websites that it thinks are executables, archives or
 doesn't recognize, but doesn't bother to check file innards when it
 does recognize the extensions. Its easily hacked, at least.)

 #

 library(ape)

 load(url(http://webpages.sdsmt.edu/~dbapst/weirdTree_06-12-15.txt;))

 #can I plot it?
 plot(tree)
 #nope

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-15 Thread David Bapst
Hi Brian,

I was already aware of the read.tree(write.tree()) fix, however I've
run into (corner?) cases where a particular sorting of edges or
whatever can lead to a loss of tip taxa using the
read.tree(write.tree()) approach; plus, read.tree(write.tree()) gets
completely flabbergasted by singleton nodes...

Emmanuel, will checkValidPhylo be made a function in R? It something
I'd certainly like to call for my own internal
phylogeny-object-cleaning functions...

Cheers,
-Dave

On Mon, Jun 15, 2015 at 9:49 AM, Brian O'Meara omeara.br...@gmail.com wrote:
 A kludgy solution to achieve Dave's original use case of fixing
 not-quite-right phylo objects is to do:

 phy - read.tree(text=write.tree(phy))

 It converts the tree to Newick and reads it back in.

 It's not as good a solution as using a validator (great addition, Emanuel!)
 to find and fix the general problem, but it can help in a pinch.

 Best,
 Brian


 ___
 Brian O'Meara
 Assistant Professor
 Dept. of Ecology  Evolutionary Biology
 U. of Tennessee, Knoxville
 http://www.brianomeara.info

 Postdoc collaborators wanted: http://nimbios.org/postdocs/
 Calendar: http://www.brianomeara.info/calendars/omeara

 On Mon, Jun 15, 2015 at 11:29 AM, Emmanuel Paradis emmanuel.para...@ird.fr
 wrote:

 Hi David,

 collapse.singles() seems to work correctly if the phylo object is
 correctly conformed. Some features of this class may seem annoying (and
 Klaus and I alredy discussed about this), but these help for other things.
 As a reminder the class phylo is defined here:

 http://ape-package.ird.fr/misc/FormatTreeR_24Oct2012.pdf

 Recently, I put a function on github to help code writters:

 https://github.com/emmanuelparadis/checkValidPhylo

 This could help you to detect problems that would be tough to find
 otherwise.

 Cheers,

 Emmanuel


 Le 12/06/2015 22:41, David Bapst a écrit :

 Hi Klaus (and others),

 Ah, I see! The real bug then appears to be in collapse.singles, as it
 does not reorder the ID numbers in $edge. Here's a quick function to
 return the root ID:

 getRootID-function(tree){
  uniqueNode-unique(tree$edge[,1])
  whichRoot-sapply(uniqueNode,function(x)
  (sum(x==tree$edge[,2])==0))
  rootID-uniqueNode[whichRoot]
  return(rootID)
  }

 And if we run it...

 getRootID(tree) #original tree

 [1] 151

 getRootID(tree1)   #after collapse.singles

 [1] 151

 getRootID(tree2)   #after reorder.phylo

 [1] 131

 And we can see that although the number of nodes certainly changed
 when collapse.singles was run, it didn't change the root node's ID.

 So I guess this is really a collapse.singles bug report. Thanks for
 the insight, Klaus!

 -Dave

 On Fri, Jun 12, 2015 at 2:27 PM, Klaus Schliep klaus.schl...@gmail.com
 wrote:

 Hi David,

 I found the bug. Somehow ape assumes on the one hand that the root is
 number
 of tips + 1.
 On the other hand the root of an phylo object is the node which is in
 tree$edge[,1], but not in tree$edge[,2],
 this is the case even in an unrooted tree. This annoys me for a long
 time.

 The root of tree1 with the definition above is actually node 151 and not
 131. Changing these solves your problem:
 Here is a small function to do this for you:

 switch.nodes- function(tree, a, b){
  ntips = length(tree$tip.label)
  tree$edge[tree$edge==a] = 0L
  tree$edge[tree$edge==b] = as.integer(a)
  tree$edge[tree$edge==0L] = as.integer(b)
  if(!is.null(tree$node.label)){
  tmp-tree$node.label[a-ntips]
  tree$node.label[a-ntips] = tree$node.label[b-ntips]
  tree$node.label[b-ntips] = tmp
  }
  tree
 }

 library(phangorn)
 attr(tree1, order) = NULL
 getRoot(tree1)

 tree2 = switch.nodes(tree1, 131, 151)
 plot(tree2) # now works for me

 Cheers and have a nice weekend,
 Klaus







 On Fri, Jun 12, 2015 at 2:53 PM, David Bapst dwba...@gmail.com wrote:


 Hello all,

 As those of you who directly manipulate the guts of phylo objects in
 your code (or construct new phylo objects whole cloth from
 un-phylo-like data structures) have probably experienced, it is
 sometimes easy to create $edge matrices that aren't accepted by ape
 functions (I often use plot.phylo as my litmus for this).

 When this occurs, various things can be done; I usually do the
 following sequence:

 collapse.singles()
 reorder.phylo(,cladewise)
 read.tree(text=write.tree(,file=NULL))

 ...or something along those lines.

 However, I've run into an issue where reorder.phylo() returns what is
 essentially a scrap of the original $edge matrix, without warning.
 Very worrisome! I'm using R version 3.2.0 and ape 3.3. Here's, my
 script, including a call to a saved object on my website, so that the
 error can be reproduced:

 (Why do I have an .Rdata object listed with a .txt extension, you
 might wonder? Because my school apparently sanitizes file extensions
 on our hosted websites that it thinks are executables, archives or
 doesn't recognize

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-15 Thread David Bapst
Whoops, I meant a 'function in ape?'
-Dave

On Mon, Jun 15, 2015 at 10:26 AM, David Bapst dwba...@gmail.com wrote:
 Hi Brian,

 I was already aware of the read.tree(write.tree()) fix, however I've
 run into (corner?) cases where a particular sorting of edges or
 whatever can lead to a loss of tip taxa using the
 read.tree(write.tree()) approach; plus, read.tree(write.tree()) gets
 completely flabbergasted by singleton nodes...

 Emmanuel, will checkValidPhylo be made a function in R? It something
 I'd certainly like to call for my own internal
 phylogeny-object-cleaning functions...

 Cheers,
 -Dave

 On Mon, Jun 15, 2015 at 9:49 AM, Brian O'Meara omeara.br...@gmail.com wrote:
 A kludgy solution to achieve Dave's original use case of fixing
 not-quite-right phylo objects is to do:

 phy - read.tree(text=write.tree(phy))

 It converts the tree to Newick and reads it back in.

 It's not as good a solution as using a validator (great addition, Emanuel!)
 to find and fix the general problem, but it can help in a pinch.

 Best,
 Brian


 ___
 Brian O'Meara
 Assistant Professor
 Dept. of Ecology  Evolutionary Biology
 U. of Tennessee, Knoxville
 http://www.brianomeara.info

 Postdoc collaborators wanted: http://nimbios.org/postdocs/
 Calendar: http://www.brianomeara.info/calendars/omeara

 On Mon, Jun 15, 2015 at 11:29 AM, Emmanuel Paradis emmanuel.para...@ird.fr
 wrote:

 Hi David,

 collapse.singles() seems to work correctly if the phylo object is
 correctly conformed. Some features of this class may seem annoying (and
 Klaus and I alredy discussed about this), but these help for other things.
 As a reminder the class phylo is defined here:

 http://ape-package.ird.fr/misc/FormatTreeR_24Oct2012.pdf

 Recently, I put a function on github to help code writters:

 https://github.com/emmanuelparadis/checkValidPhylo

 This could help you to detect problems that would be tough to find
 otherwise.

 Cheers,

 Emmanuel


 Le 12/06/2015 22:41, David Bapst a écrit :

 Hi Klaus (and others),

 Ah, I see! The real bug then appears to be in collapse.singles, as it
 does not reorder the ID numbers in $edge. Here's a quick function to
 return the root ID:

 getRootID-function(tree){
  uniqueNode-unique(tree$edge[,1])
  whichRoot-sapply(uniqueNode,function(x)
  (sum(x==tree$edge[,2])==0))
  rootID-uniqueNode[whichRoot]
  return(rootID)
  }

 And if we run it...

 getRootID(tree) #original tree

 [1] 151

 getRootID(tree1)   #after collapse.singles

 [1] 151

 getRootID(tree2)   #after reorder.phylo

 [1] 131

 And we can see that although the number of nodes certainly changed
 when collapse.singles was run, it didn't change the root node's ID.

 So I guess this is really a collapse.singles bug report. Thanks for
 the insight, Klaus!

 -Dave

 On Fri, Jun 12, 2015 at 2:27 PM, Klaus Schliep klaus.schl...@gmail.com
 wrote:

 Hi David,

 I found the bug. Somehow ape assumes on the one hand that the root is
 number
 of tips + 1.
 On the other hand the root of an phylo object is the node which is in
 tree$edge[,1], but not in tree$edge[,2],
 this is the case even in an unrooted tree. This annoys me for a long
 time.

 The root of tree1 with the definition above is actually node 151 and not
 131. Changing these solves your problem:
 Here is a small function to do this for you:

 switch.nodes- function(tree, a, b){
  ntips = length(tree$tip.label)
  tree$edge[tree$edge==a] = 0L
  tree$edge[tree$edge==b] = as.integer(a)
  tree$edge[tree$edge==0L] = as.integer(b)
  if(!is.null(tree$node.label)){
  tmp-tree$node.label[a-ntips]
  tree$node.label[a-ntips] = tree$node.label[b-ntips]
  tree$node.label[b-ntips] = tmp
  }
  tree
 }

 library(phangorn)
 attr(tree1, order) = NULL
 getRoot(tree1)

 tree2 = switch.nodes(tree1, 131, 151)
 plot(tree2) # now works for me

 Cheers and have a nice weekend,
 Klaus







 On Fri, Jun 12, 2015 at 2:53 PM, David Bapst dwba...@gmail.com wrote:


 Hello all,

 As those of you who directly manipulate the guts of phylo objects in
 your code (or construct new phylo objects whole cloth from
 un-phylo-like data structures) have probably experienced, it is
 sometimes easy to create $edge matrices that aren't accepted by ape
 functions (I often use plot.phylo as my litmus for this).

 When this occurs, various things can be done; I usually do the
 following sequence:

 collapse.singles()
 reorder.phylo(,cladewise)
 read.tree(text=write.tree(,file=NULL))

 ...or something along those lines.

 However, I've run into an issue where reorder.phylo() returns what is
 essentially a scrap of the original $edge matrix, without warning.
 Very worrisome! I'm using R version 3.2.0 and ape 3.3. Here's, my
 script, including a call to a saved object on my website, so that the
 error can be reproduced:

 (Why do I have an .Rdata object listed with a .txt extension, you
 might wonder? Because my school

Re: [R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-12 Thread David Bapst
Hi Klaus (and others),

Ah, I see! The real bug then appears to be in collapse.singles, as it
does not reorder the ID numbers in $edge. Here's a quick function to
return the root ID:

getRootID-function(tree){
uniqueNode-unique(tree$edge[,1])
whichRoot-sapply(uniqueNode,function(x)
(sum(x==tree$edge[,2])==0))
rootID-uniqueNode[whichRoot]
return(rootID)
}

And if we run it...

 getRootID(tree) #original tree
[1] 151
 getRootID(tree1)   #after collapse.singles
[1] 151
 getRootID(tree2)   #after reorder.phylo
[1] 131

And we can see that although the number of nodes certainly changed
when collapse.singles was run, it didn't change the root node's ID.

So I guess this is really a collapse.singles bug report. Thanks for
the insight, Klaus!

-Dave

On Fri, Jun 12, 2015 at 2:27 PM, Klaus Schliep klaus.schl...@gmail.com wrote:
 Hi David,

 I found the bug. Somehow ape assumes on the one hand that the root is number
 of tips + 1.
 On the other hand the root of an phylo object is the node which is in
 tree$edge[,1], but not in tree$edge[,2],
 this is the case even in an unrooted tree. This annoys me for a long time.

 The root of tree1 with the definition above is actually node 151 and not
 131. Changing these solves your problem:
 Here is a small function to do this for you:

 switch.nodes- function(tree, a, b){
 ntips = length(tree$tip.label)
 tree$edge[tree$edge==a] = 0L
 tree$edge[tree$edge==b] = as.integer(a)
 tree$edge[tree$edge==0L] = as.integer(b)
 if(!is.null(tree$node.label)){
 tmp-tree$node.label[a-ntips]
 tree$node.label[a-ntips] = tree$node.label[b-ntips]
 tree$node.label[b-ntips] = tmp
 }
 tree
 }

 library(phangorn)
 attr(tree1, order) = NULL
 getRoot(tree1)

 tree2 = switch.nodes(tree1, 131, 151)
 plot(tree2) # now works for me

 Cheers and have a nice weekend,
 Klaus







 On Fri, Jun 12, 2015 at 2:53 PM, David Bapst dwba...@gmail.com wrote:

 Hello all,

 As those of you who directly manipulate the guts of phylo objects in
 your code (or construct new phylo objects whole cloth from
 un-phylo-like data structures) have probably experienced, it is
 sometimes easy to create $edge matrices that aren't accepted by ape
 functions (I often use plot.phylo as my litmus for this).

 When this occurs, various things can be done; I usually do the
 following sequence:

 collapse.singles()
 reorder.phylo(,cladewise)
 read.tree(text=write.tree(,file=NULL))

 ...or something along those lines.

 However, I've run into an issue where reorder.phylo() returns what is
 essentially a scrap of the original $edge matrix, without warning.
 Very worrisome! I'm using R version 3.2.0 and ape 3.3. Here's, my
 script, including a call to a saved object on my website, so that the
 error can be reproduced:

 (Why do I have an .Rdata object listed with a .txt extension, you
 might wonder? Because my school apparently sanitizes file extensions
 on our hosted websites that it thinks are executables, archives or
 doesn't recognize, but doesn't bother to check file innards when it
 does recognize the extensions. Its easily hacked, at least.)

 #

 library(ape)

 load(url(http://webpages.sdsmt.edu/~dbapst/weirdTree_06-12-15.txt;))

 #can I plot it?
 plot(tree)
 #nope

 tree1-collapse.singles(tree)

 #any single-child nodes left?
 sum(sapply(unique(tree1$edge[,1]),function(x) sum(x==tree1$edge[,1])==1))
 #nope

 #can I plot it?
 plot(tree1)
 #nope

 #now reorder
 tree2-reorder.phylo(tree1,cladewise)
 tree2$edge

 #now reorder with postorder
 tree2-reorder.phylo(tree1,postorder)
 tree2$edge

 #

 As we can see, reorder.phylo with various ordering methods returns an
 edge matrix with just six rows, from a tree that originally had
 hundreds of edges. Most worrisome, it does this without any error
 message. In this particular case, I retain the tree correctly if I
 skip reorder.phylo and use the read.tree(write.tree) trick, but this
 behavior of reorder.phylo is worrying.

 Anyone have a clue what's going on here? If I am perhaps misusing
 reorder.phylo(), is there an alternative approach for use in cleaning
 phylo objects?

 Cheers,
 -Dave

 --
 David W. Bapst, PhD
 Adjunct Asst. Professor, Geology and Geol. Eng.
 South Dakota School of Mines and Technology
 501 E. St. Joseph
 Rapid City, SD 57701

 http://webpages.sdsmt.edu/~dbapst/
 http://cran.r-project.org/web/packages/paleotree/index.html

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at
 http://www.mail-archive.com/r-sig-phylo@r-project.org/




 --
 Klaus Schliep
 Postdoctoral Fellow
 Revell Lab, University of Massachusetts Boston




-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r

[R-sig-phylo] Bug in reorder.phylo() (related to cleaning phylo objects)

2015-06-12 Thread David Bapst
Hello all,

As those of you who directly manipulate the guts of phylo objects in
your code (or construct new phylo objects whole cloth from
un-phylo-like data structures) have probably experienced, it is
sometimes easy to create $edge matrices that aren't accepted by ape
functions (I often use plot.phylo as my litmus for this).

When this occurs, various things can be done; I usually do the
following sequence:

collapse.singles()
reorder.phylo(,cladewise)
read.tree(text=write.tree(,file=NULL))

...or something along those lines.

However, I've run into an issue where reorder.phylo() returns what is
essentially a scrap of the original $edge matrix, without warning.
Very worrisome! I'm using R version 3.2.0 and ape 3.3. Here's, my
script, including a call to a saved object on my website, so that the
error can be reproduced:

(Why do I have an .Rdata object listed with a .txt extension, you
might wonder? Because my school apparently sanitizes file extensions
on our hosted websites that it thinks are executables, archives or
doesn't recognize, but doesn't bother to check file innards when it
does recognize the extensions. Its easily hacked, at least.)

#

library(ape)

load(url(http://webpages.sdsmt.edu/~dbapst/weirdTree_06-12-15.txt;))

#can I plot it?
plot(tree)
#nope

tree1-collapse.singles(tree)

#any single-child nodes left?
sum(sapply(unique(tree1$edge[,1]),function(x) sum(x==tree1$edge[,1])==1))
#nope

#can I plot it?
plot(tree1)
#nope

#now reorder
tree2-reorder.phylo(tree1,cladewise)
tree2$edge

#now reorder with postorder
tree2-reorder.phylo(tree1,postorder)
tree2$edge

#

As we can see, reorder.phylo with various ordering methods returns an
edge matrix with just six rows, from a tree that originally had
hundreds of edges. Most worrisome, it does this without any error
message. In this particular case, I retain the tree correctly if I
skip reorder.phylo and use the read.tree(write.tree) trick, but this
behavior of reorder.phylo is worrying.

Anyone have a clue what's going on here? If I am perhaps misusing
reorder.phylo(), is there an alternative approach for use in cleaning
phylo objects?

Cheers,
-Dave

-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Constraining node values in an OUCH analysis

2015-06-04 Thread David Bapst
Aaron,

While contemplating Nate's question, I wondered, doesn't hansen
currently support NA codings for missing variables for tip taxa?
Unfortunately the donotrun{} example for hansen() using geiger data
isn't currently functioning, so I couldn't test this.

-Dave Bapst

On Thu, Jun 4, 2015 at 10:46 AM, Aaron King kin...@umich.edu wrote:
 Interesting question, Nate.  Do I understand you to say that you have data
 on some variables (and not others) at internal nodes?  If so, what happens
 when you just add those to the data, with NA to indicate missing values?
 Have you tried this?

 A.

 On Thu, Jun 4, 2015 at 11:10 AM, Nathan Thompson 
 nathan.thomp...@stonybrook.edu wrote:

 Hi all,

 I am performing an multivariate analysis in ouch on a group of extant
 species. I would ideally like to include information for fossil taxa in the
 analysis, however, no single fossil taxon preserves all of the variables of
 interest. However, I have performed univariate ancestral state
 reconstructions (with fossils) and obtained estimates of the node values.

 Is there any way, in a multivariate ouch analysis, to 'constrain' nodes to
 certain values based on this a priori knowledge of ancestral states?

 I realize the alternative would be to just run separate univariate OU
 analyses for each variable (including fossils), but I would like to do this
 in a multivariate framework.

 Thank you,

 Nathan E Thompson
 Doctoral Candidate
 Dept. of Anatomical Sciences
 Stony Brook University
 nathan.thomp...@stonybrook.edu

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at
 http://www.mail-archive.com/r-sig-phylo@r-project.org/




 --
 Aaron A. King, Ph.D.
 Ecology  Evolutionary Biology
 Mathematics
 Center for the Study of Complex Systems
 University of Michigan
 GPG Public Key: 0x15780975

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] ancestor vs. change plots

2015-04-25 Thread David Bapst
Milton, Brian, etc,

Just wanted to add some background on Alroy's anc-desc change
analyses, and the recognition of these relationships in the fossil
record. This may be tangential; it isn't clear to me what sort of
dataset that Milton has. So, Brian said...

 In Paleo, you can (well, arguably) see the ancestor and descendent pair, so
 you can assess the amount of change and the ancestral state.

Yes, in some extremely well-sampled fossil records, it is argued you
can qualitatively recognize ancestor-descendant relationships.
Diagrams depicting ancestor-descendant relationships are usually
called stratophenetic diagrams, even though that term may have been
originally defined for something slightly different. This is mostly
done in microfossil groups, like plankton; see Aze et al. 2011 for a
good example of this in planktonic foraminifera.

The quantitative ideal would be that ancestor inference would be part
of how we infer phylogenies. Fisher's (1992) stratocladistic method
included the potential for ancestral taxa in analyses that included
stratigraphic debt; very recently, Gavryushkina et al. (2014)
presented a similar model-based method for BEAST2 that included
ancestor-inference for tip-dated phylogeny inference with fossil taxa.
I have not seen anyone use either stratocladistics or Bayesian
tip-dating methods to get ancestor-descendant contrasts yet.

More commonly though, ancestor-descendant relationships are recognized
in less direct ways, after the phylogeny is inferred. Norell (1992)
and Smith (1994) suggest that we can treat earlier-appearing,
plesiomorphic taxa as ancestors to their later-appearing, apomorphic
sisters on a cladogram, but this ignores the potential for character
reversal (Wagner, 1996). Wagner (1995a) applied a confidence interval
approach based on sampling in the fossil record to identify
ancestor-descendant relationships among sister taxa on a cladogram and
then used these ancestor-descendant pairs to test for changes in the
rate of trait evolution between the Cambrian and post-Cambrian
(Wagner, 1995b). My cal3 method does something similar, but
stochastically suggests a large number of possible ancestor-descendant
relaitonships, as there is considerable uncertainty in which taxa are
ancestral, given the uncertainties that arise from the incompleteness
of the fossil record.

Some workers have recently used a combination of ancestral trait
reconstruction and phylogenies of fossil taxa to infer ancestral
states and then calculate the change between them, bypassing the need
to infer which observed taxa might be ancestral taxa. (And, this is
indeed suggested by Alroy, 2000.) However, there is considerable
uncertainty in ancestral trait reconstruction even with
non-ultrametric trees, so I strongly recommend against this procedure
except for very specific questions, in very specific cases.

Alroy (1998) only had a dataset of Cenozoic mammals from North America
containing taxonomic hierarchy information, and no phylogenetic
information beyond whatever is conveyed by taxonomy. As I understand
it, Alroy infered ancestor-descendant relationships by randomly
samples pairs of congeneric species from the mammal fossil record,
with the earlier appearing taxon always as an ancestor and the later
appearing species as the descendant, drawing pairs until all genera
had less than two species left in them. Alroy then bootstraps,
repeating this procedure many times over and over. I think Alroy only
sampled taxa as ancestors once, and thus avoided the non-independence
issues. Finarelli and Flynn (2007; 2009) do something similar as Alroy
(1998), but also randomly sample possible ancestor-descendant
relationships between higher taxa.

For more on interpreting the ancestor-descendant change analyses that
Alroy presents in the 2000 paper, you should also see Wang (2005, also
in Paleobiology), who touches on the variance issue.

-Dave

PS: I clearly spend a lot of time thinking about ancestor-descendant
relationships...



On Fri, Apr 24, 2015 at 1:30 PM, Brian O'Meara omeara.br...@gmail.com wrote:
 In Paleo, you can (well, arguably) see the ancestor and descendent pair, so
 you can assess the amount of change and the ancestral state. Using just
 info at the tips, you are inferring from N taxa N-1 ancestral states and
 2N-2 rates of change. That seems a lot to ask from data, especially since
 the rates and states affect each other and so aren't independent. You're
 also using a model that assumes an even rate of change over the tree, so an
 ancestor will tend to be between its descendants (exactly between, if you
 have a two taxon tree with coeval taxa). You could try more exotic models
 that allow multiple Brownian rates or even multiple Ornstein-Uhlenbeck
 rates, but there's a limit there, as well. There are Bayesian approaches
 that can paint a smear (estimated from post-burnin samples) of rates over
 multiple branches, but I'd be careful interpreting them as robust estimates
 of rate that are 

Re: [R-sig-phylo] (P)GLS (nlme) vs. PGLS (caper)

2015-03-16 Thread David Bapst
William,

Yes, the different PCM models make very different statements about
what is happening biologically in your data. Additionally, the three
Pagel parameters are not always easy to interpret biologically. Carl
Boettiger has some particularly lucid thoughts on Pagel's lambda:
http://www.carlboettiger.info/2013/10/11/is-it-time-to-retire-pagels-lambda.html

In general, model choice is much more satisfying if you have strong
prior expectations for the models you are choosing between being
realistic descriptions of the actual process.

My advice would be to carefully choose a priori models of trait
evolution that seem like defensible biologically-reasonable hypotheses
of how these traits might be evolving in your group, and then either
(a) use some sort of model choice criteria to choose between those
different PGLS models and interpret the parameters of this best-fit
model or (b) examine the parameter values estimated by the different
models for insights into the biological implications for your dataset.
For example, OU often fits better than BM, but sometimes the 'pull'
parameter in OU is so small that the best-fit OU model is not
describing a process of trait change that is distinguishable from BM.

 I've come to accept my dataset isn't representing brownian evolution, so I've 
 discarded those results, leaving me with the OU results

Hmm... William, is your dataset a time-scaled tree of fossil taxa?
Just curious, as these trees sometimes show an unfortunate bias toward
OU. This is in addition to the general ever-present bias toward OU,
see this recent paper by Ho and Ane:
http://onlinelibrary.wiley.com/doi/10./2041-210X.12285/abstract

I hope this helps,
-Dave Bapst

On Sun, Mar 15, 2015 at 6:24 PM, William Gearty wgea...@stanford.edu wrote:
 Hi all,
 I'm looking for some advice on and thoughts regarding performing a
 phylogenetic generalized least squares analysis in R.
 I've tried GLS from the nlme package using corBrownian and corMartins from
 the ape package and get one set of results (I've come to accept my dataset
 isn't representing brownian evolution, so I've discarded those results,
 leaving me with the OU results).
 I've also tried PGLS from the cape package, having it estimate the 3
 different Pagel parameters. After optimizing these parameters, I get
 different results from those of the OU (corMartins) GLS analysis.
 I'm wondering what is to blame for these drastically different results?
 The different parameters that the two methods are estimating?
 Is it the difference between using REML in the GLS vs. ML in the PGLS?
 Do people have particular preferences for running these types of analyses?
 Should I feel okay about estimating all three Pagel parameters at the same
 time with PGLS?
 Any insight or thoughts would be greatly appreciated.
 Thanks,
 Will

 --
 William Gearty
 PhD Student, Paleobiology
 Department of Geological and Environmental Sciences
 Stanford School of Earth, Energy  Environmental Sciences
 people.stanford.edu/wgearty

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] hierarchical model with phylogenetic dependence term

2014-12-22 Thread David Bapst
Cecile, Peter, Joe and all-

As far as I understand, Peter's analysis involves paleontological data with
non-ultrametric trees, and based on my understanding of Slater (2014), the
Freckleton approach using PIC is invalid for that type of dataset, although
Fitzjohn's pruning algorithm might still apply.

http://onlinelibrary.wiley.com/doi/10./2041-210X.12201/abstract

Cheers,
-Dave

On Mon, Dec 22, 2014 at 10:15 AM, Cecile Ane a...@stat.wisc.edu wrote:

 Hi again Peter,

 If matrix inversion and determinants are a bottleneck, there are multiple
 ways to avoid them (without assigning random effects to ancestral species),
 including Felsenstein (1973), FitzJohn (2012) and Freckleton (2012). The
 speed-up is huge if you have thousands of tips. This algorithm extends to a
 variety of models:
 http://sysbio.oxfordjournals.org/cgi/reprint/syu005?ijkey=
 bIsHxa2dpqXCplckeytype=ref

 Cecile.

 On 12/22/2014 12:01 PM, Peter Smits wrote:

 Cecile and Joe,

 Thank you for the replies. That helped clear up a lot for me.

 And thank you for the link Cecile. Estimating sigma_phy is quite a pain
 because of all the matrix inversions. I've a tree of approx. 2000 tips,
 so even using of a Cholesky decomposed V_{phy} doesn't buy me much time
 at all.

 Because the vector of means for the MVN in my work is all 0s, I've
 written my own MVN sampler to try and minimize how many inversions or
 determinants need to be calculated. The stan mailing list had a great
 little discussion on how to speed up estimation of MVN random effects
 with partially known covariance matrices
 https://groups.google.com/forum/#!topic/stan-users/HcvYaDu71_Y and I
 just followed that code. Now my posterior sampling at least gets off the
 ground and finishes.

 The stan list discussion possibly provides a useful starting template
 for other people on this list trying to do similar things.

 Cheers,

 Peter

 On Mon, Dec 22, 2014 at 11:32 AM, Cecile Ane a...@stat.wisc.edu wrote:

 Hi Peter,

 We have taken a similar approach in this paper:
 http://onlinelibrary.wiley.__com/doi/10./evo.12582/__abstract

 http://onlinelibrary.wiley.com/doi/10./evo.12582/abstract
 We also use a Bayesian approach, with a prior that allows us to
 integrate the ancestral state and the total variance analytically
 (no need for MCMC for those parameters). Our notation for your
 sigma_phy is lambda, like Pagel's, and we do use multiple
 individuals per species. For what it's worth.

 Regarding the scaling of branch lengths, I agree with Joe that there
 is nothing particular about 1, other than providing an easier
 interpretation for the numerical value of the phylogenetic variance.
 Cheers,
 Cecile.


 On 12/14/2014 01:03 PM, Peter Smits wrote:

 Hi list,

 I have a similar question to Edwin. I too am working with a
 hierarchical
 Bayesian model, though I've implemented it in stan. I've included
 a
 phylogenetic random effect term, which is modeled as being
 distributed as
 multivariate normal with known covariance matrix up to a constant,
 sigma_{phy}. This follows Lynch '91 Am Nat and Housworth et al.
 '04 Am Nat
 by drawing on the similarity with the animal model from
 quantitative
 genetics.

 My question is about the scaling of the covariance matrix: is it
 necessary
 to have the the diagonal terms satisfy x = 1 and all the off
 diagonals to
 be 0 = x  1? I have a time scaled phylogeny from which I have my
 covariance matrix, so currently all elements of the matrix are
 not scaled
 so that the greatest distance from the root to a tip is 1.
 Currently, the
 elements of the matrix are just the sum of the shared branch
 lengths. Is
 this appropriate? Why or why not?

 Any input would be much appreciated.

 Cheers,

 Peter Smits
 --
 Peter D Smits
 Grad student
 Committee on Evolutionary Biology
 University of Chicago
 psm...@uchicago.edu mailto:psm...@uchicago.edu
 http://home.uchicago.edu/~psmits/home.html


 --
 Cecile Ane
 Departments of Statistics and of Botany
 University of Wisconsin - Madison
 www.stat.wisc.edu/~ane/

 CALS statistical consulting lab:
 www.cals.wisc.edu/calslab/stat_consulting.php

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-
 sig-ph...@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

[[alternative HTML version deleted]]

___
R-sig-phylo 

Re: [R-sig-phylo] Plotting Posterior Probabilities from MrBayes Trees (An Update)

2014-10-08 Thread David Bapst
 in the 'simple' consensus tree
nexus file, reroots it and then rearranges the posterior probabilities
to match the same splits across both trees. I've checked this against
the read out logged by MrBayes and the result of rerooted trees in
FigTree, and the resulting posterior probabilities match those shown
across all three programs.

Anyway, I hope this helps the next person trying to figure out how to
plot posterior probabilites from MrBayes in R!

Cheers,
-Dave



On Fri, Oct 3, 2014 at 10:29 AM, David Bapst dwba...@gmail.com wrote:
 Just to clarify, off-list discussion with Graham reveals (after some
 confusion on my part) that if the simple format option is used in sumt
 in MrBayes, then ape's read.nexus will natively read the posterior
 probability values as node-labels. Which is interesting and I had not
 come across that information previously.

 Graham's comment is not in reference to the functioning of 
 read.annotated.nexus.

 Cheers,
 -Dave


 On Fri, Oct 3, 2014 at 8:49 AM, Slater, Graham slat...@si.edu wrote:
 Dave,

 I’ve had the same trouble with shuffling. However, all of this can be
 avoided if you specify the simple format for your .con file in the mrBayes
 block.

 sumt conformat = simple;

 The resulting tree will correctly display posterior probabilities in a
 phyloformat tree.

 Graham



 
 Graham Slater
 Peter Buck Post-Doctoral Fellow
 Department of Paleobiology
 National Museum of Natural History
 The Smithsonian Institution [NHB, MRC 121]
 P.O. Box 37012


 (202) 633-1316
 slat...@si.edu
 www.fourdimensionalbiology.com





 On Oct 3, 2014, at 10:42 AM, David Bapst dwba...@gmail.com wrote:

 Hello all,

 Recently, I wanted to display posterior probabilities on a 50%
 compatibility tree from a MrBayes run, created with the 'sumt'
 command. I looked around for ways to do this and found this email
 thread from last year:

 https://stat.ethz.ch/pipermail/r-sig-phylo/2013-June/002825.html

 ...which suggests using read.annotated.nexus() in package epibase,
 which has been renamed OutbreakTools more recently.

 Unfortunately, it appears read.annotated.nexus in OutbreakTools
 (v0.1-11, in R 3.1.1) improperly creates the new edge matrix,
 resulting in an apparent shuffling of tip labels. As this function was
 discussed on R-Sig-Phylo, I am sending this bug report to both the
 list and to the package maintainer (Thibaut J.).

 I don't have any BEAST output files, so I cannot test if this occurs
 with files that are not created by MrBayes.

 To show this phenomen, I have created an example .con.tre file using
 an example matrix of standard characters for several elephants that I
 stole off of Joe F.'s website. You can find the .con.tre file here on
 gdrive:

 https://drive.google.com/file/d/0B_xvEcEvKno_LTFhSVJrdHMtNFU/view?usp=sharing

 And now in R, a comparison with a tree:

 library(OutbreakTools)
 library(ape)

 tree1-read.nexus(mat.nex.con.tre)
 tree2-read.annotated.nexus(mat.nex.con.tre)

 layout(1:2)
 plot(tree1,no.margin=TRUE)
 plot(tree2,no.margin=TRUE)

 identical(tree1$tip.label,tree2$tip.label)
 identical(tree1$edge.length,tree2$edge.length)
 identical(tree1$edge,tree2$edge)

 Inspection of the tree file with FigTree suggests that the ape
 function is producing the correct tree and the OutbreakTools function
 is not. We can see the why with last three lines in the console:

 identical(tree1$tip.label,tree2$tip.label)

 [1] TRUE

 identical(tree1$edge.length,tree2$edge.length)

 [1] TRUE

 identical(tree1$edge,tree2$edge)

 [1] FALSE

 Closer inspection suggests that the issue appears to be that some
 terminal edges are inappropriately shuffled, thus shuffling the
 terminal tip labels on those edges, while leaving the tip.label order
 and the edge lengths the same. Also, larger trees seem to produce
 larger inconsistencies in the tree produced.

 So... now for the list, are there any other methods on CRAN for
 obtaining the posterior probabilities from a .con.tre file? Otherwise,
 next I guess I'll be trying phyloch.

 Cheers,
 -Dave

 --
 David W. Bapst, PhD
 Adjunct Asst. Professor, Geology and Geol. Eng.
 South Dakota School of Mines and Technology
 501 E. St. Joseph
 Rapid City, SD 57701

 http://webpages.sdsmt.edu/~dbapst/
 http://cran.r-project.org/web/packages/paleotree/index.html

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/





 --
 David W. Bapst, PhD
 Adjunct Asst. Professor, Geology and Geol. Eng.
 South Dakota School of Mines and Technology
 501 E. St. Joseph
 Rapid City, SD 57701

 http://webpages.sdsmt.edu/~dbapst/
 http://cran.r-project.org/web/packages/paleotree/index.html



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD

[R-sig-phylo] MrBayes Trees are Misread by read.annotated.nexus() in OutbreakTools

2014-10-03 Thread David Bapst
Hello all,

Recently, I wanted to display posterior probabilities on a 50%
compatibility tree from a MrBayes run, created with the 'sumt'
command. I looked around for ways to do this and found this email
thread from last year:

https://stat.ethz.ch/pipermail/r-sig-phylo/2013-June/002825.html

...which suggests using read.annotated.nexus() in package epibase,
which has been renamed OutbreakTools more recently.

Unfortunately, it appears read.annotated.nexus in OutbreakTools
(v0.1-11, in R 3.1.1) improperly creates the new edge matrix,
resulting in an apparent shuffling of tip labels. As this function was
discussed on R-Sig-Phylo, I am sending this bug report to both the
list and to the package maintainer (Thibaut J.).

I don't have any BEAST output files, so I cannot test if this occurs
with files that are not created by MrBayes.

To show this phenomen, I have created an example .con.tre file using
an example matrix of standard characters for several elephants that I
stole off of Joe F.'s website. You can find the .con.tre file here on
gdrive:

https://drive.google.com/file/d/0B_xvEcEvKno_LTFhSVJrdHMtNFU/view?usp=sharing

And now in R, a comparison with a tree:

library(OutbreakTools)
library(ape)

tree1-read.nexus(mat.nex.con.tre)
tree2-read.annotated.nexus(mat.nex.con.tre)

layout(1:2)
plot(tree1,no.margin=TRUE)
plot(tree2,no.margin=TRUE)

identical(tree1$tip.label,tree2$tip.label)
identical(tree1$edge.length,tree2$edge.length)
identical(tree1$edge,tree2$edge)

Inspection of the tree file with FigTree suggests that the ape
function is producing the correct tree and the OutbreakTools function
is not. We can see the why with last three lines in the console:

 identical(tree1$tip.label,tree2$tip.label)
[1] TRUE
 identical(tree1$edge.length,tree2$edge.length)
[1] TRUE
 identical(tree1$edge,tree2$edge)
[1] FALSE

Closer inspection suggests that the issue appears to be that some
terminal edges are inappropriately shuffled, thus shuffling the
terminal tip labels on those edges, while leaving the tip.label order
and the edge lengths the same. Also, larger trees seem to produce
larger inconsistencies in the tree produced.

So... now for the list, are there any other methods on CRAN for
obtaining the posterior probabilities from a .con.tre file? Otherwise,
next I guess I'll be trying phyloch.

Cheers,
-Dave

-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] MrBayes Trees are Misread by read.annotated.nexus() in OutbreakTools

2014-10-03 Thread David Bapst
Just to clarify, off-list discussion with Graham reveals (after some
confusion on my part) that if the simple format option is used in sumt
in MrBayes, then ape's read.nexus will natively read the posterior
probability values as node-labels. Which is interesting and I had not
come across that information previously.

Graham's comment is not in reference to the functioning of read.annotated.nexus.

Cheers,
-Dave


On Fri, Oct 3, 2014 at 8:49 AM, Slater, Graham slat...@si.edu wrote:
 Dave,

 I’ve had the same trouble with shuffling. However, all of this can be
 avoided if you specify the simple format for your .con file in the mrBayes
 block.

 sumt conformat = simple;

 The resulting tree will correctly display posterior probabilities in a
 phyloformat tree.

 Graham



 
 Graham Slater
 Peter Buck Post-Doctoral Fellow
 Department of Paleobiology
 National Museum of Natural History
 The Smithsonian Institution [NHB, MRC 121]
 P.O. Box 37012


 (202) 633-1316
 slat...@si.edu
 www.fourdimensionalbiology.com





 On Oct 3, 2014, at 10:42 AM, David Bapst dwba...@gmail.com wrote:

 Hello all,

 Recently, I wanted to display posterior probabilities on a 50%
 compatibility tree from a MrBayes run, created with the 'sumt'
 command. I looked around for ways to do this and found this email
 thread from last year:

 https://stat.ethz.ch/pipermail/r-sig-phylo/2013-June/002825.html

 ...which suggests using read.annotated.nexus() in package epibase,
 which has been renamed OutbreakTools more recently.

 Unfortunately, it appears read.annotated.nexus in OutbreakTools
 (v0.1-11, in R 3.1.1) improperly creates the new edge matrix,
 resulting in an apparent shuffling of tip labels. As this function was
 discussed on R-Sig-Phylo, I am sending this bug report to both the
 list and to the package maintainer (Thibaut J.).

 I don't have any BEAST output files, so I cannot test if this occurs
 with files that are not created by MrBayes.

 To show this phenomen, I have created an example .con.tre file using
 an example matrix of standard characters for several elephants that I
 stole off of Joe F.'s website. You can find the .con.tre file here on
 gdrive:

 https://drive.google.com/file/d/0B_xvEcEvKno_LTFhSVJrdHMtNFU/view?usp=sharing

 And now in R, a comparison with a tree:

 library(OutbreakTools)
 library(ape)

 tree1-read.nexus(mat.nex.con.tre)
 tree2-read.annotated.nexus(mat.nex.con.tre)

 layout(1:2)
 plot(tree1,no.margin=TRUE)
 plot(tree2,no.margin=TRUE)

 identical(tree1$tip.label,tree2$tip.label)
 identical(tree1$edge.length,tree2$edge.length)
 identical(tree1$edge,tree2$edge)

 Inspection of the tree file with FigTree suggests that the ape
 function is producing the correct tree and the OutbreakTools function
 is not. We can see the why with last three lines in the console:

 identical(tree1$tip.label,tree2$tip.label)

 [1] TRUE

 identical(tree1$edge.length,tree2$edge.length)

 [1] TRUE

 identical(tree1$edge,tree2$edge)

 [1] FALSE

 Closer inspection suggests that the issue appears to be that some
 terminal edges are inappropriately shuffled, thus shuffling the
 terminal tip labels on those edges, while leaving the tip.label order
 and the edge lengths the same. Also, larger trees seem to produce
 larger inconsistencies in the tree produced.

 So... now for the list, are there any other methods on CRAN for
 obtaining the posterior probabilities from a .con.tre file? Otherwise,
 next I guess I'll be trying phyloch.

 Cheers,
 -Dave

 --
 David W. Bapst, PhD
 Adjunct Asst. Professor, Geology and Geol. Eng.
 South Dakota School of Mines and Technology
 501 E. St. Joseph
 Rapid City, SD 57701

 http://webpages.sdsmt.edu/~dbapst/
 http://cran.r-project.org/web/packages/paleotree/index.html

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/





-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Re: [R-sig-phylo] Early burst branch rescale

2014-06-02 Thread David Bapst
Julien-

Does mvSHIFT account for the OU rescaling issue on non-ultrametric
trees that Graham mentions? If so, how?

Cheers,
-Dave

On Mon, Jun 2, 2014 at 5:26 PM, Julien Clavel julien.cla...@hotmail.fr wrote:
 Hi Jon,

 Take a look at the mvSHIFT function in mvMORPH. This is typically what you 
 are looking for and you can use it with non-ultrametric trees (it's maybe 
 faster than classic functions).

 Best,

 Julien

 Date: Mon, 2 Jun 2014 14:55:06 -0500
 From: mitchel...@uchicago.edu
 To: r-sig-phylo@r-project.org
 Subject: [R-sig-phylo] Early burst branch rescale

 Hello all,

 I'm trying to figure out how to rescale certain branches of a tree
 according to an early burst model.

 First I've generated a tree using TreeSim

 N - 100

 Nn - N*2 -1

 test - sim.bd.taxa(N, 1, 1, 0.8, complete=FALSE)


 Then I 'paint' the branches depending on whether or not they occur in the
 first or second half of the clade's history:


 Root -max(nodeHeights(test2))

 Age - 0.5*Root

 test2 - make.era.map(test[[1]][[1]], c(0, Age))


 Using rescale() from geiger, I can reformat the whole tree, and using
 sim.rates() from phytools, it's easy to simulate different sigmas. But what
 I'd like to do is also simulate different evolutionary modes (OU and EB) in
 the different regimes (like Graham's MEE paper). Is there a way to rescale
 the branches in one portion of the tree according to the OU alpha or EB r
 parameters?

 Thanks!
 -- Jon

 _

 Jonathan S. Mitchell
 http://home.uchicago.edu/~mitchelljs/

 PhD Student
 Committee on Evolutionary Biology
 The University of Chicago
 1025 57th Str, Culver Hall 402
 Chicago, IL 60637

 Geology Department
 The Field Museum of Natural History
 1400 S. Lake Shore Dr.
 Chicago, IL 60605

   [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] drop trees from multiphylo list

2014-04-28 Thread David Bapst
Hi John,

A fully reproducible example of the error you have encountered would be this:

trees.pool-rmtree(N=10,n=100)
trees.pool[[1]]-NULL

Which returns the same error; the reason for this is that 'multiphylo'
is an S3 class so ape has a specific function that replaces the
generic  replacement command, specifically from the help file for
multiphylo:

## S3 replacement method for class 'multiPhylo'
x[...] - value

Which presumably tests whether a replacement is a valid phylo object
and returns this error if you've supplied an object of the wrong
class.

Furthermore, I notice the lines:

} else {
i = i+1

Uh, maybe I'm not correctly understanding your R code, but it looks
like to me you're trying to advance 'i' while within a for loop... for
loops in R automatically advance i so this is unnecessary.

Perhaps an easier way to do what your doing would be to use a sapply()
to test whether the trees satisfy the condition or not and then
subset, i.e...

keep-sapply(trees.pool,function(x) length(unique(x$tip.state))  3)
trees.pool-trees.pool[!keep]

Does that work better for you?

I hope this helps,
-Dave B

On Mon, Apr 28, 2014 at 7:44 AM, John Denton jden...@amnh.org wrote:
 Hi folks,

 I have a set of trees with tip states, generated by simulation, in a 
 multiphylo object. I'd like to drop trees from the list based on a criterion 
 (some trees do not exhibit all three tip states).

 I've tried the following (which is admittedly clumsy; I am not very familiar 
 with multiPhylo lists):

 trees.pool - apply(pars, 1, function(pars) trees(pars, type=musse, n=1, 
 max.taxa=250, max.t=40, include.extinct=FALSE, x0=1))
 class(trees.pool) - multiPhylo

 # Screen these trees for ntax size, all states present:

 for (i in 1:length(trees.pool)) {

 if (length(unique(trees.pool[[i]]$tip.state))  3) {
 trees.pool[[i]] - NULL
 } else {
 i = i+1
 }
 }

 but I get the error

 Error in `[[-.multiPhylo`(`*tmp*`, i, value = NULL) :
   trying to assign an object not of class phylo into an object of class 
 multiPhylo.

 Any ideas?

 Thanks!

 ~John


 John S. S. Denton, Ph.D.
 Department of Vertebrate Paleontology
 American Museum of Natural History
 www.johnssdenton.com
 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] utilise more data by making polytomies

2014-02-25 Thread David Bapst
At the risk of inundating you with options, Henry, there is also
expandTaxonTree in the package paleotree (on CRAN) which is similar to the
above, but also lets you collapse higher taxa you list as paraphyletic,
which can be useful if the taxonomic work of your group has never been
concerned with monophyly.

Cheers,
-Dave


On Tue, Feb 25, 2014 at 3:33 PM, Julien Clavel julien.cla...@hotmail.frwrote:

 Hi,

 There is also the stickTip function:
 http://rleca.pbworks.com/w/file/fetch/40813743/stickTips_1.2.html
 it is possible to tweak the code for more specific things...

 Best,

 Julien

  From: liam.rev...@umb.edu
  Date: Tue, 25 Feb 2014 10:32:36 -0500
  To: h.ferguson-...@ucl.ac.uk; r-sig-phylo@r-project.org
  Subject: Re: [R-sig-phylo] utilise more data by making polytomies
 
  Something similar to this is in phytools (
 http://blog.phytools.org/2013/11/new-function-to-add-species-to-genus-in.html),
 though not yet on CRAN. Let me know if this is what you're thinking of.
 
  All the best, Liam
 
  Liam J. Revell, Assistant Professor of Biology
  University of Massachusetts Boston
  web: http://faculty.umb.edu/liam.revell/
  email: liam.rev...@umb.edu
  blog: http://blog.phytools.org
 
  --
  Sent from Windows Phone
 
  -Original Message-
  From: Ferguson-Gow, Henry
  Sent: 2/25/2014 10:23 AM
  To: r-sig-phylo@r-project.org
  Subject: [R-sig-phylo] utilise more data by making polytomies
 
  Hi All
 
  I have a large dataset and a large tree, however the intersection
 between them both is quite low. As a supplement to analyses solely on the
 species that appear in both the dataset and the tree I thought I could take
 the species that are present in the dataset and not the tree, and add those
 tips in as a polytomy with their congenerics present on the tree. Is there
 a method in R that would help me to do this?
 
  Many thanks
 
  Henry
 
 
[[alternative HTML version deleted]]
 
  ___
  R-sig-phylo mailing list - R-sig-phylo@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
  Searchable archive at
 http://www.mail-archive.com/r-sig-phylo@r-project.org/
 
[[alternative HTML version deleted]]
 
  ___
  R-sig-phylo mailing list - R-sig-phylo@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
  Searchable archive at
 http://www.mail-archive.com/r-sig-phylo@r-project.org/

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at
 http://www.mail-archive.com/r-sig-phylo@r-project.org/




-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] The Curious Behavior of is.binary.tree

2014-01-22 Thread David Bapst
That all sounds great as gravy to me, Emmanuel. Thanks for clarifying
the help file.
-Cave

On Wed, Jan 22, 2014 at 4:08 AM, Emmanuel Paradis
emmanuel.para...@ird.fr wrote:
 Hi David,

 You are right about this help page which is not so accurrate. I have
 modified it with:

   The test differs slightly whether the tree is rooted or not. An
   urooted tree is considered binary if all its nodes are of degree three
   (i.e., three edges connect to each node). A rooted tree is considered
   binary if all nodes (including the root node) have exactly two
   descendant nodes, so that they are of degree three expect the root
   which is of degree 2.

 About the concept of rooted vs. unrooted, it is not so different from the
 one in Newick. Consider the tree:

   (A,B,C);

 is it an unrooted (binary) tree, or a rooted tree with a basal trifurcation?
 The presence of a root edge helps to solve this ambiguity, so:

   (A,B,C):0;

 is a (non-binary) rooted tree (note that both trees are graphically
 identical). Ape considers the first tree as unrooted because it is the kind
 of trees produced by many functions such as nj, bionj, etc.

 Best,

 Emmanuel

 Le 16/01/2014 17:32, David Bapst a écrit :

 Liam and to those who responded privately,

 Yes, I understand that's the general reasoning for why ape refers to
 trees with a polytomous root as 'unrooted'.

 But if a tree with a basal trichotomy is an acceptable binary tree,
 this doesn't jive with the help description for is.binary.tree in ape.
 The references to 'two descendant nodes' is the help file's
 terminology, after all. In particular, it doesn't match the text about
 binary trees having 2Ntip-2 edges; that is only true for 'rooted'
 binary trees.

 I also don't think every instance of a polytomy existing at the root
 reflects a user who necessarily realizes such topologies are treated
 as 'unrooted'; after all, a user might have use cases where a polytomy
 at the root actually represents a real multifurcating branching event.
 Although I realize this has never fully agreed with ape's concept of
 rooted and unrooted, I know I generally input trees in R with
 polytomous roots because there's some uncertainty in the proper
 outgroup, or the outgroup got dropped between inference and analysis.
 Either way, the tree is rooted and has directionality, it just doesn't
 have a fully resolved root. There's probably even better examples of
 use cases involving polytomous roots that just aren't occurring to me
 right now.

 Users may also not be immediately familiar with the 'rooted' and
 'unrooted' concepts in ape as related to the presence of polytomies at
 the root node; I know I wasn't familiar with this concept when I first
 started working with phylogenies in R (although I admit I did know by
 the time I used is.binary.tree in my code).

 So, I think some clarification might be needed about the application
 of this function.

 Cheers,
 -Dave

 On Wed, Jan 15, 2014 at 8:03 PM, Liam J. Revell liam.rev...@umb.edu
 wrote:

 Hi David.

 In an unrooted, fully dichotomous tree each internal node is attached to
 three  exactly three nodes (some of which are tips). (In a rooted binary
 tree one additional internal node exists, the root, which is attached to
 only two nodes.) Ancestor  descendant have no meaning until the tree is
 rooted. The fact that an unrooted tree stored as an object of class
 phylo
 has one node with three 'descendants' (these aren't actually all
 descendants, as the tree is unrooted) is just an artifact of the way the
 object is stored in memory  thus is.binary.tree is behaving correctly.

 All the best, Liam

 Liam J. Revell, Assistant Professor of Biology
 University of Massachusetts Boston
 web: http://faculty.umb.edu/liam.revell/
 email: liam.rev...@umb.edu
 blog: http://blog.phytools.org


 On 1/15/2014 3:34 PM, David Bapst wrote:


 Hi Emmanuel and the rest of the list,

 In some code, I use the ape function is.binary.tree to test if a
 phylogeny is fully dichotomous. However, some recent analyses have
 made me wonder if this wasn't the right choice. I'm not sure if the
 following is a bug report me or me not understand the reasoning of a
 function in ape.

 You see, I had an 'unrooted' (in ape terminology) tree with a basal
 trichotomy. I wouldn't consider such a tree to be fully dichotomous,
 but is.binary.tree says such a tree is in fact binary (i.e. returns
 TRUE). It appears to be limited to just trees with basal trichotomies.
 If the root is an even larger polytomy (more than three descendant
 nodes), is.binary.tree returns FALSE.

 I was a bit surprised, as the function description says This function
 tests whether a phylogenetic tree is binary, i.e. whether every node
 (including the root node) has exactly two descendant nodes. This
 would make me think it also tests if the root has two descendant
 nodes, but that doesn't seem to be the case, unless an unrooted tree
 with three lineages is (for some reason I'm unaware of) considered

Re: [R-sig-phylo] The Curious Behavior of is.binary.tree

2014-01-16 Thread David Bapst
Liam and to those who responded privately,

Yes, I understand that's the general reasoning for why ape refers to
trees with a polytomous root as 'unrooted'.

But if a tree with a basal trichotomy is an acceptable binary tree,
this doesn't jive with the help description for is.binary.tree in ape.
The references to 'two descendant nodes' is the help file's
terminology, after all. In particular, it doesn't match the text about
binary trees having 2Ntip-2 edges; that is only true for 'rooted'
binary trees.

I also don't think every instance of a polytomy existing at the root
reflects a user who necessarily realizes such topologies are treated
as 'unrooted'; after all, a user might have use cases where a polytomy
at the root actually represents a real multifurcating branching event.
Although I realize this has never fully agreed with ape's concept of
rooted and unrooted, I know I generally input trees in R with
polytomous roots because there's some uncertainty in the proper
outgroup, or the outgroup got dropped between inference and analysis.
Either way, the tree is rooted and has directionality, it just doesn't
have a fully resolved root. There's probably even better examples of
use cases involving polytomous roots that just aren't occurring to me
right now.

Users may also not be immediately familiar with the 'rooted' and
'unrooted' concepts in ape as related to the presence of polytomies at
the root node; I know I wasn't familiar with this concept when I first
started working with phylogenies in R (although I admit I did know by
the time I used is.binary.tree in my code).

So, I think some clarification might be needed about the application
of this function.

Cheers,
-Dave

On Wed, Jan 15, 2014 at 8:03 PM, Liam J. Revell liam.rev...@umb.edu wrote:
 Hi David.

 In an unrooted, fully dichotomous tree each internal node is attached to
 three  exactly three nodes (some of which are tips). (In a rooted binary
 tree one additional internal node exists, the root, which is attached to
 only two nodes.) Ancestor  descendant have no meaning until the tree is
 rooted. The fact that an unrooted tree stored as an object of class phylo
 has one node with three 'descendants' (these aren't actually all
 descendants, as the tree is unrooted) is just an artifact of the way the
 object is stored in memory  thus is.binary.tree is behaving correctly.

 All the best, Liam

 Liam J. Revell, Assistant Professor of Biology
 University of Massachusetts Boston
 web: http://faculty.umb.edu/liam.revell/
 email: liam.rev...@umb.edu
 blog: http://blog.phytools.org


 On 1/15/2014 3:34 PM, David Bapst wrote:

 Hi Emmanuel and the rest of the list,

 In some code, I use the ape function is.binary.tree to test if a
 phylogeny is fully dichotomous. However, some recent analyses have
 made me wonder if this wasn't the right choice. I'm not sure if the
 following is a bug report me or me not understand the reasoning of a
 function in ape.

 You see, I had an 'unrooted' (in ape terminology) tree with a basal
 trichotomy. I wouldn't consider such a tree to be fully dichotomous,
 but is.binary.tree says such a tree is in fact binary (i.e. returns
 TRUE). It appears to be limited to just trees with basal trichotomies.
 If the root is an even larger polytomy (more than three descendant
 nodes), is.binary.tree returns FALSE.

 I was a bit surprised, as the function description says This function
 tests whether a phylogenetic tree is binary, i.e. whether every node
 (including the root node) has exactly two descendant nodes. This
 would make me think it also tests if the root has two descendant
 nodes, but that doesn't seem to be the case, unless an unrooted tree
 with three lineages is (for some reason I'm unaware of) considered to
 have two descendant nodes.

 There's also some stuff in ?is.binary.tree about fully dichotomous
 trees having 2Ntip-2 edges, which is only true if the root is also
 dichotomous (and thus the tree is 'rooted'). It isn't true for taxa
 with a basal trichotomy.

 Here's some code. I got the same results with both ape v3.0-11 and the
 v3.1 that Emmanuel had sent out two weeks ago.

 library(ape)

 tree-rtree(10)
 #collapse root
 tree$edge.length[which(tree$edge[,1]==11)[1]]-0
 tree1-di2multi(tree)
 is.binary.tree(tree1)
 is.rooted(tree1)

 tree-stree(3)
 is.binary.tree(tree)
 is.rooted(tree)

 tree-stree(4)
 is.binary.tree(tree)
 is.rooted(tree)

 Is.rooted correctly returns FALSE, so does that mean best practice to
 get a tree where every node has two descendant nodes would be use
 is.binary.tree()  is.rooted()?

 Curious on your thoughts on this and the intent of is.binary.tree.

 -Dave





-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig

[R-sig-phylo] The Curious Behavior of is.binary.tree

2014-01-15 Thread David Bapst
Hi Emmanuel and the rest of the list,

In some code, I use the ape function is.binary.tree to test if a
phylogeny is fully dichotomous. However, some recent analyses have
made me wonder if this wasn't the right choice. I'm not sure if the
following is a bug report me or me not understand the reasoning of a
function in ape.

You see, I had an 'unrooted' (in ape terminology) tree with a basal
trichotomy. I wouldn't consider such a tree to be fully dichotomous,
but is.binary.tree says such a tree is in fact binary (i.e. returns
TRUE). It appears to be limited to just trees with basal trichotomies.
If the root is an even larger polytomy (more than three descendant
nodes), is.binary.tree returns FALSE.

I was a bit surprised, as the function description says This function
tests whether a phylogenetic tree is binary, i.e. whether every node
(including the root node) has exactly two descendant nodes. This
would make me think it also tests if the root has two descendant
nodes, but that doesn't seem to be the case, unless an unrooted tree
with three lineages is (for some reason I'm unaware of) considered to
have two descendant nodes.

There's also some stuff in ?is.binary.tree about fully dichotomous
trees having 2Ntip-2 edges, which is only true if the root is also
dichotomous (and thus the tree is 'rooted'). It isn't true for taxa
with a basal trichotomy.

Here's some code. I got the same results with both ape v3.0-11 and the
v3.1 that Emmanuel had sent out two weeks ago.

library(ape)

tree-rtree(10)
#collapse root
tree$edge.length[which(tree$edge[,1]==11)[1]]-0
tree1-di2multi(tree)
is.binary.tree(tree1)
is.rooted(tree1)

tree-stree(3)
is.binary.tree(tree)
is.rooted(tree)

tree-stree(4)
is.binary.tree(tree)
is.rooted(tree)

Is.rooted correctly returns FALSE, so does that mean best practice to
get a tree where every node has two descendant nodes would be use
is.binary.tree()  is.rooted()?

Curious on your thoughts on this and the intent of is.binary.tree.

-Dave

-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Simulation of extinct taxa onto a phylogeny of extant taxa?

2013-10-01 Thread David Bapst
Hi Jurriaan-

I've been thinking about this after your email and my sense is that
such a simulation would be very difficult. Just dropping onto the tree
branching events on the extant tree that only produced one living
daughter might not be too difficult under a homogenous birth-death
model.  However, some of those extinct lineages coming off those nodes
could actually be clades of considerable size, and you'd still have to
condition in the simulation on those clades going extinct before the
modern... which sounds difficult to me. In addition, the probability
of getting an unobserved node and the size of the unseen, extinct
clades would vary the closer you get to the modern (the branch length
probabilities in Mooers et al., 2012, Syst. Biol. might be useful
here). Someone else on the list might know better and know of an
elegant way around these issues.

My suggestion is that there might be easier ways to get whatever it is
you'd like from these simulations. For example, if you'd like to
estimate the expected number of total number of extinct and surviving
lineages for some surviving lineage, the appendix for Raup (1985)
provides some equations that might be useful for you.

-Dave

On Mon, Sep 30, 2013 at 2:05 PM, Jurriaan de Vos
jurriaan_de...@brown.edu wrote:
 Dear list members,

 I am grateful for any pointers related to the following problem:

 I am trying to simulate extinct taxa into a completely sampled phylogeny of 
 extant taxa.  I can estimate lambda and mu for a phylogeny under the 
 time-homogeneous birth-death model. I want to use these values to simulate 
 trees that contain also the extinct taxa, but, here's the crux, the topology 
 of the extant taxa needs to remain the same. (I only want to add branches 
 that eventually go extinct, keeping the branching times among extant taxa 
 unchanged. If I prune extinct taxa, the tree must be identical to the 
 original tree.) I have been unsuccessful in finding a solution. Is there any 
 function implemented that does this?

 Reason that I want to keep the original tree is that I want to do simulations 
 for trees with multiple MEDUSA-style rate-partitions. I can disassamble the 
 tree in into its rate partitions and simulate trees that satisfy lambda, mu, 
 extant taxa and age of the partitions, but to correctly reassamble the tree, 
 the topological relations among extant members of rate partitions should 
 remain unchanged.

 Thanks in advance for any help!

 Juri

 --
 Jurriaan M. de Vos, PhD
 Research Associate, Edwards Lab
 Dept. of Ecology and Evolutionary Biology
 Brown University
 Providence, RI, USA

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://webpages.sdsmt.edu/~dbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Getting started making R packages

2013-07-12 Thread David Bapst
Tristan-

I found this to be the most important how-to reference, but I am a windows user.

http://robjhyndman.com/hyndsight/building-r-packages-for-windows/

For distributing on CRAN, making help files and examples is the most
critical step. package.skeleton() is  helpful in setting up the
necessary directories and initial help documents for you, and then you
can go fill them out.

I found that looking at other people's package files on github or
elsewhere can be quite useful, such as when trying to figure out
formatting for stuff in the NAMESPACE file. For example:
https://github.com/richfitz/diversitree
http://www.phytools.org/
https://github.com/cboettig

Yes, R CMD check is where much of your time will be spent, but once
you are done with that, you will build the tarball for CRAN. You
should definitely run check with the --as-cran option, since it is
more stringent, and also preferably with R-devel.

A word of warning: CRAN administrators have fairly strict regulations
regarding how much time single help files or the entire package is
allowed to take, in terms of error checking with the help examples.
They may complain if your examples take too long, which may require
putting those in 'don't run' sections. When I submit, I am often
guilty of having examples that run too long.

There are other policies, and some suggestions, beyond the extensions
pdf which Elliot linked to. You should also look at these:
http://cran.r-project.org/web/packages/policies.html
http://developer.r-project.org/Rds.html

Good luck and let me know if you have any more specific questions,

-Dave

On Fri, Jul 12, 2013 at 1:19 PM, Tristan Stayton tstay...@bucknell.edu wrote:
 Hello,

 I'm relatively new to the world of R and need some general advice.  I have
 a number of R functions that I'd like to put together in a package and
 distribute via CRAN, and I've found a few more or less helpful tutorials on
 the subject.  However, I seem to be getting stuck with rtools (running R
 CMD check, etc...) and even if I get past that I'm sure other issues will
 come up.  So I'm wondering if there are any resources or tutorials
 available which you all would recommend.  What was helpful to you when you
 were first learning to build and distribute packages?

 Thanks in advance.  And feel free to let me know if this is not the proper
 venue for such questions.

 Tristan

 --
 C. Tristan Stayton
 Associate Professor of Biology
 Bucknell University
 Lewisburg, PA  17837

 Office:  570-577-3272

 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] collapse descendants of a node to a polytomy

2013-06-22 Thread David Bapst
Hi John,

I'm not familiar with any such function either. However, a handy trick
for doing this sort of thing is changing the branch lengths of
descendant nodes to zero and using the ape function di2multi to
collapse those edges, creating a polytomy.

Now, it isn't clear to me from your email whether you want to collapse
just all the edges immediately descended from your selected node or
all the branches descended from that node. Here's a worked example for
both cases:

library(ape)
set.seed(444)
tree-rtree(10)
plot(tree)
node-mrca(tree)[t4,t2]

#collapse immediate branches
tree1-tree
tree1$edge.length-rep(1,
Nedge(tree1))#replace all edge lengths with 1
tree1$edge.length[tree1$edge[,1]==node]-0#replace descendent edge
lengths with 0
tree1-di2multi(tree1)
tree1$edge.length-NULL#get rid of branch lengths

plot(tree1)

#collapse all descendant branches
tree2-tree
library(phangorn)
descNodes-Descendants(tree2,node,all)
tree2$edge.length-rep(1,Nedge(tree2))#replace all edge lengths with 1
descEdges-sapply(tree2$edge[,2],function(x) any(x==descNodes))
tree2$edge.length[descEdges]-0
tree2-di2multi(tree2)
tree2$edge.length-NULL#get rid of branch lengths

plot(tree2)

The only downside is that this distorts the edge lengths of the
original tree, such that I just remove the edge lengths in the end.
Partly, this is because I initially replace all the edges with length
1, so di2multi didn't collapse any particularly short branches
(shorter than di2multi's threshold) that might have existed
originally. However, even without doing that safety measure, I dropped
the edge lengths mostly because we have to take some edges and
dropping them to length zero. The tips descended from that node will
be pulled back toward the root, which is simply artificial and why I
think its best practice to just get rid of the edge lengths.

An alternative to getting rid of the edge lengths would be to adjust
the distance between the tips and the new polytomy so that the clade
is the same depth as the original node, essentially fixing the tips in
place. That's a little more complicated (and I don't know of any
function that does it, although Liam's bind.tip in phytools does
something similar, by default, for adding a new tip). You didn't say
anything about whether you wanted to retain edge.length information,
so I won't go into further into that.

Cheers from Snowbird,
-Dave Bapst

On Fri, Jun 21, 2013 at 8:11 PM, John Denton jden...@amnh.org wrote:
 Hi folks,

 I'd like to collapse the descendants of a node, identified using something 
 like node - mrca(tree)[A, B]. I did not see a function in ape, geiger, 
 phyloch, or picante to do something like collapse.descendants(node). Is there 
 a package with a function like this?

 Thanks!

 ~John


 John S. S. Denton
 Ph.D. Candidate
 Department of Ichthyology and Richard Gilder Graduate School
 American Museum of Natural History
 www.johnssdenton.com
 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David W. Bapst, PhD
Adjunct Asst. Professor, Geology and Geol. Eng.
South Dakota School of Mines and Technology
501 E. St. Joseph
Rapid City, SD 57701

http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Lineages Through Time Plot with Confidence / HPD Interval

2013-04-16 Thread David Bapst
The function multiDiv in my package 'paleotree' plots the 95% quantile
for a diversity curve / LTT as a gray shaded region, among other
options.
-Dave Bapst

On Tue, Apr 16, 2013 at 12:33 AM, Simon Greenhill si...@simon.net.nz wrote:
 Hi all,

 Does anyone know of a good implementation of an LTT plot that can draw a 
 Confidence Interval or HPD interval from a set of trees? I've seen things 
 like `ltt` in phytools that can draw one line for each tree in the sample. 
 However, this can look a bit messy, and I'd ideally love to just plot the 95% 
 CI or HPD of the ages/lineages in the trees. Has anyone seen anything like 
 this?

 Many thanks,

 Simon

 ___
 R-sig-phylo mailing list - R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Fwd: Deadline extended: Unifying paleobiological and comparative perspectives on character evolution, Lisbon 2013 (ESEB)

2013-02-28 Thread David Bapst
-- Forwarded message --
From: Lee Hsiang Liow l.h.l...@ibv.uio.no
Date: Thu, Feb 28, 2013 at 2:23 AM
Subject: Deadline extended: Unifying paleobiological and comparative
perspectives on character evolution, Lisbon 2013 (ESEB)

Dear Colleagues,

We would like to invite you to send abstracts to our symposium on
Unifying paleobiological and comparative perspectives on character
evolution for the 14th ESEB congress in Lisbon taking place 19-24th
of August 2013.

Link: https://www.eseb2013.com/symposia

Deadline for submission has been extended to 8 March 2013.

Organizers: Lee Hsiang Liow  Thomas F. Hansen. University of Oslo,
Department of Biology, CEES.

Invited speakers: Gene Hunt and Folmer Bokma.

Summary: It is no longer debated that the fossil record is necessary
to inform us about the history of life, yet the integration of data
and perspectives using fossils and comparative data in understanding
evolution is far from mature.  This symposium gathers researchers
straddling the realms of the extinct and the extant to explore how we
can better understand evolutionary processes especially on time scales
common to palaeobiological and phylogenetic comparative studies, using
character evolution as a focal point.

Sincerely,
Lee Hsiang Liow  Thomas F. Hansen

--
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Fwd: Symposium announcement: Unifying paleobiological and comparative perspectives on character evolution, Lisbon 2013 (ESEB)

2012-12-18 Thread David Bapst
Cross-posting the following, announcing a symposium next year at the
ESEB Congress which I think will be of interest to some R-Sig-Phylo
list users.
-Dave

-- Forwarded message --
From: Lee Hsiang Liow l.h.l...@bio.uio.no
Date: Tue, Dec 18, 2012 at 1:12 AM

Dear Colleagues,

We would like to invite you to send abstracts to our symposium on
Unifying paleobiological and comparative perspectives on character
evolution for the 14th ESEB congress in Lisbon taking place 19-24th
of August 2013.

Organizers: Lee Hsiang Liow  Thomas F. Hansen. University of Oslo,
Department of Biology, CEES.

Emails: l.h.l...@bio.uio.no  thomas.han...@bio.uio.no

Invited speakers: Gene Hunt and Folmer Bokma.

Summary: It is no longer debated that the fossil record is necessary
to inform us about the history of life, yet the integration of data
and perspectives using fossils and comparative data in understanding
evolution is far from mature.  This symposium gathers researchers
straddling the realms of the extinct and the extant to explore how we
can better understand evolutionary processes especially on time scales
common to palaeobiological and phylogenetic comparative studies, using
character evolution as a focal point.

Link: https://www.eseb2013.com/symposia

Deadline for submission 28 February 2013.

Abstracts will be selected by the organizers for either oral or poster
presentation. When submitting your abstract please state your
preference for talk or poster. Talks will be assigned time slots of 15
minutes and selected based on relevance for the symposium.

Sincerely,
Lee Hsiang Liow  Thomas F. Hansen

--
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] prop.clades() errors

2012-11-09 Thread David Bapst
Hi Jeremy,
Emmanuel and I had a off-list conversation after that email, so there was
follow-up, we just never told the list about it!

To my knowledge, the issue I was having where not all clades shared were
being detected with prop.clades was unique to 3.0-1. For example, under my
3.0-6 install of ape, the code from my old email actually does show
multiple shared clades with prop.clades.

Here it is again with ape 3.0-6:

library(ape)
library(paleotree)
set.seed(3)
tree1-rtree(30)
tree2-degradeTree(tree1,0.5)
layout(matrix(1:2,,2));plot(tree1);plot(tree2)

and

 prop.clades(tree1,tree2)
 [1] 1 2 0 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 0 1 1 0 1 0 0

Now, for the sake of posterity, it turns out the '2' which threw me in that
original email was a result of me not telling prop.clades that my trees
were rooted (and Emmanuel has updated the man page so this is crystal
clear):

 prop.clades(tree1,tree2,rooted=TRUE)
 [1] 1 1 0 0 0 1 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 0 1 1 0 1 0

Jeremy, could you make some example data where prop.clades underestimates
shared clades? Also, have you also tried applying reorder.phylo or
collapse.singles to your trees before trying prop.clades?

-Dave


On Thu, Nov 8, 2012 at 2:04 PM, Jeremy Yoder jbyo...@gmail.com wrote:

 All,

 I'm working on some analyses that require comparison of tree structures,
 and I've bumped into the problem David Bapst posted about back in March:
 http://www.mail-archive.com/r-sig-phylo@r-project.org/msg01840.html -
 briefly, prop.clades() is failing to count many clades that are in common.
 There doesn't seem to be any followup to that post; has anyone made
 progress figuring it out?

 I'm currently using ape 3.0-6 and R 2.15.1 on a MacBook running Mountain
 Lion.

 thanks,
 Jeremy

 
 Jeremy B. Yoder
 Postdoctoral Associate
 Department of Plant Biology
 University of Minnesota

 www.jeremybyoder.com (http://www.jeremybyoder.com)

 jbyo...@gmail.com

 Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

 http://home.uchicago.edu/%7Edwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] fitContinuous-Early Burst Model

2012-11-04 Thread David Bapst
Nicolas,
Not certain how you are time-scaling your tree, but I often get warnings of
singularity from various comparative analysis functions due to the presence
of very short terminal branches. I have found that such warnings of
singularity when dealing with paleo-trees can often be avoided by adding a
very small amount to all the terminal branch lengths, say 0.001. This is
very simple to do with a few lines of code; alternatively, the function
addTermBranchLength() in the library paleotree does this automatically if a
tree is passed to it.

Also, I would advice you to consider multiple methods for time-scaling your
tree of fossil taxa and compare results across those trees, if you are not
doing so already. In practice, I find one can sometimes give very different
results for some comparative analyses with different time-scaling methods
on the same paleontological dataset.
-Dave


On Sun, Nov 4, 2012 at 10:59 AM, Nicolas Campione 
nicolas.campi...@mail.utoronto.ca wrote:

 Dear R Phylo List,

 I'm trying to test an Early Burst model of evolution against a tree using
 the 'fitContinuous' function in 'geiger'. However, I get the following
 error message, and am unsure as to what I can do to fix this:

  fitContinuous(tree,trait,model=EB)

 Fitting  EB model:
 Error in solve.default(phyvcv) :
   Lapack routine dgesv: system is exactly singular: U[4,4] = 0

 My tree is based on fossil taxa and my branch lengths are calculated using
 time (in millions of years). I seem to be able to test every other model,
 only EB is giving me troubles. I'm pretty sure it has something to do with
 the branch lengths, cause if I used other measures, such as all=1 or
 grafen, I don't get an error.

 Has anybody had this issue before?

 Any assistance would be greatly appreciated.

 Cheers,

 -Nic-

 
 Nicolás E. Campione
 M.Sc., Ph.D. Candidate
 Dept. Ecology  Evolutionary Biology
 University of Toronto
 25 Wilcocks St.
 Toronto, ON
 Canada M5S 3B2

 Royal Ontario Museum
 100 Queen's Park
 Toronto, ON
 Canada M5S 2C6
 Office: 416-586-5591
 Email: nicolas.campi...@mail.utoronto.ca

 [[alternative HTML version deleted]]


 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

http://home.uchicago.edu/%7Edwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] fitContinuous-Early Burst Model

2012-11-04 Thread David Bapst
Yeah, I was concerned it might have been related to a zero-branch-length
problem, but some simulation shows that only Graham's fix will let
fitContinuous run with a simulated paleo-tree.
-Dave


library(paleotree)
library(geiger)
taxa-simFossilTaxa_SRCond(avgtaxa=30,p=0.1,q=0.1,r=0.1)
rangesCont-sampleRanges(taxa,r=0.1)
cladogram-taxa2cladogram(taxa)
#get the true tree at the first appearance times
trueTree-taxa2phylo(taxa,obs_time=rangesCont[,1])
trait-rTraitCont(trueTree)

#no solution
fitContinuous(trueTree,trait,model=EB) #nope
#my solution
fitContinuous(addTermBranchLength(trueTree),trait,model=EB) #nope
#Graham's solution
fitContinuous(trueTree,trait,model=EB,bounds=list(alpha=c(0,1))) #yep


On Sun, Nov 4, 2012 at 1:17 PM, Frank Burbrink
frank.burbr...@csi.cuny.eduwrote:

 Just to confirm that Graham's fix works.

 Using the following libraries (and their dependencies) I conducted the
 simulations:

 library(TreeSim)
 library(phytools)
  sim.bd.taxa(30,1,lambda=0.1,mu=0.05)[[1]][[1]]-tree
 fastBM(tree)-data

 fitContinuous(tree,data,model=EB)
 Fitting  EB model:
 Error in solve.default(phyvcv) :
   Lapack routine dgesv: system is exactly singular
 ###This now works with a parameterized alpha (below)...not sure how
 good the estimates are (they were simulated under ###BM after all)

 fitContinuous(tree,data,model=EB, bounds=list(alpha=c(0,1)))
 Fitting  EB model:
 $Trait1
 $Trait1$lnl
 [1] -264.4297

 $Trait1$beta
 [1] 0.8355526

 $Trait1$a
 [1] 0.001813503

 $Trait1$aic
 [1] 534.8593

 $Trait1$aicc
 [1] 535.1042

 $Trait1$k
 [1] 3

 On Sun, Nov 4, 2012 at 2:01 PM, David Bapst dwba...@uchicago.edu wrote:
  Nicolas,
  Not certain how you are time-scaling your tree, but I often get warnings
 of
  singularity from various comparative analysis functions due to the
 presence
  of very short terminal branches. I have found that such warnings of
  singularity when dealing with paleo-trees can often be avoided by adding
 a
  very small amount to all the terminal branch lengths, say 0.001. This is
  very simple to do with a few lines of code; alternatively, the function
  addTermBranchLength() in the library paleotree does this automatically
 if a
  tree is passed to it.
 
  Also, I would advice you to consider multiple methods for time-scaling
 your
  tree of fossil taxa and compare results across those trees, if you are
 not
  doing so already. In practice, I find one can sometimes give very
 different
  results for some comparative analyses with different time-scaling methods
  on the same paleontological dataset.
  -Dave
 
 
  On Sun, Nov 4, 2012 at 10:59 AM, Nicolas Campione 
  nicolas.campi...@mail.utoronto.ca wrote:
 
  Dear R Phylo List,
 
  I'm trying to test an Early Burst model of evolution against a tree
 using
  the 'fitContinuous' function in 'geiger'. However, I get the following
  error message, and am unsure as to what I can do to fix this:
 
   fitContinuous(tree,trait,model=EB)
 
  Fitting  EB model:
  Error in solve.default(phyvcv) :
Lapack routine dgesv: system is exactly singular: U[4,4] = 0
 
  My tree is based on fossil taxa and my branch lengths are calculated
 using
  time (in millions of years). I seem to be able to test every other
 model,
  only EB is giving me troubles. I'm pretty sure it has something to do
 with
  the branch lengths, cause if I used other measures, such as all=1 or
  grafen, I don't get an error.
 
  Has anybody had this issue before?
 
  Any assistance would be greatly appreciated.
 
  Cheers,
 
  -Nic-
 
  
  Nicolás E. Campione
  M.Sc., Ph.D. Candidate
  Dept. Ecology  Evolutionary Biology
  University of Toronto
  25 Wilcocks St.
  Toronto, ON
  Canada M5S 3B2
 
  Royal Ontario Museum
  100 Queen's Park
  Toronto, ON
  Canada M5S 2C6
  Office: 416-586-5591
  Email: nicolas.campi...@mail.utoronto.ca
 
  [[alternative HTML version deleted]]
 
 
  ___
  R-sig-phylo mailing list
  R-sig-phylo@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 
 
 
 
  --
  David Bapst
  Dept of Geophysical Sciences
  University of Chicago
  5734 S. Ellis
  Chicago, IL 60637
  http://home.uchicago.edu/~dwbapst/
  http://cran.r-project.org/web/packages/paleotree/index.html
 
  http://home.uchicago.edu/%7Edwbapst/
 
  [[alternative HTML version deleted]]
 
 
  ___
  R-sig-phylo mailing list
  R-sig-phylo@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 



 --
 NEW EMAIL ADDRESS:
 frank.burbr...@csi.cuny.edu
 ***
 Frank T. Burbrink, Ph.D.
 Professor
 Biology Department
 6S-143
 2800 Victory Blvd.
 College of Staten Island/CUNY
 Staten Island, New York 10314
 E-Mail:frank.burbr...@csi.cuny.edu
 Phone:718-982-3961
 Web Page: http://scholar.library.csi.cuny.edu/~fburbrink/
 ***

 

 Washington Monthly
 http

Re: [R-sig-phylo] fitContinuous-Early Burst Model

2012-11-04 Thread David Bapst
Yeah, my simulations with paleotree agrees with Frank's, except no values
below a=0 will work at all without using addTermBranchLength; apparently
the terminal ZLBs are having some effect on it. When I use
addTermBranchLength, then I can get down to -0.4, at which point I get a
slightly new warning message:

fitContinuous(addTermBranchLength(trueTree),trait,model=EB,bounds=list(alpha=c(-0.4,0)))
Fitting  EB model:
Error in solve.default(phyvcv) :
  system is computationally singular: reciprocal condition number =
2.04244e-16


On Sun, Nov 4, 2012 at 2:48 PM, Frank Burbrink
frank.burbr...@csi.cuny.eduwrote:

 Just as a followup to my example (which contains numerous extinct taxa).

 Using these values for alpha fails:
  fitContinuous(tree,data,model=EB,bounds=list(alpha=c(-1,0)))
 Fitting  EB model:
 Error in solve.default(phyvcv) :
   Lapack routine dgesv: system is exactly singular


 Above the lower bound of -0.4 (e.g., -0.3, -0.2 etc.)  Works here:

  fitContinuous(tree,data,model=EB,bounds=list(alpha=c(-.3,0)))
 Fitting  EB model:
 $Trait1
 $Trait1$lnl
 [1] -264.4632

 $Trait1$beta
 [1] 0.9233574

 $Trait1$a
 [1] 0

 $Trait1$aic
 [1] 534.9264

 $Trait1$aicc
 [1] 535.1713

 $Trait1$k
 [1] 3

 On Sun, Nov 4, 2012 at 1:07 PM, Graham Slater gsla...@ucla.edu wrote:
  Hi Nic,
 
  It's not a problem with the branch lengths, at least not the
 non-ultrametricity of the tree. It's probably that the lower bound on the
 exponential change parameter is too low, resulting in a singular
 phylogenetic variance covariance matrix. Try changing the lower bound as
 follows:
 
  eb.fit - fitContinuous(phy, data, model  =EB, bounds = list(a=c(X,
 0))) # where X is the lower bound you chose.
 
  You can compute an appropriate value for X if you're willing to choose a
 minimum rate for the end of the EB process. In this case, the lower bound
 would be log(min.rate) / T where T is the depth of your tree and min.rate
 is the ending rate. I've found a value of 10^-5 is reasonable in most cases.
 
  Graham
  
  Graham Slater
  Peter Buck Post-Doctoral Fellow
  Department of Paleobiology
  National Museum of Natural History
  The Smithsonian Institution [NHB, MRC 121]
  P.O. Box 37012
  Washington DC 20013-7012
 
  slat...@si.edu
  www.eeb.ucla.edu/gslater
 
 
 
 
 
 
 
  On Nov 4, 2012, at 11:59 AM, Nicolas Campione wrote:
 
  Dear R Phylo List,
 
  I'm trying to test an Early Burst model of evolution against a tree
 using the 'fitContinuous' function in 'geiger'. However, I get the
 following error message, and am unsure as to what I can do to fix this:
 
  fitContinuous(tree,trait,model=EB)
 
  Fitting  EB model:
  Error in solve.default(phyvcv) :
   Lapack routine dgesv: system is exactly singular: U[4,4] = 0
 
  My tree is based on fossil taxa and my branch lengths are calculated
 using time (in millions of years). I seem to be able to test every other
 model, only EB is giving me troubles. I'm pretty sure it has something to
 do with the branch lengths, cause if I used other measures, such as all=1
 or grafen, I don't get an error.
 
  Has anybody had this issue before?
 
  Any assistance would be greatly appreciated.
 
  Cheers,
 
  -Nic-
 
  
  Nicolás E. Campione
  M.Sc., Ph.D. Candidate
  Dept. Ecology  Evolutionary Biology
  University of Toronto
  25 Wilcocks St.
  Toronto, ON
  Canada M5S 3B2
 
  Royal Ontario Museum
  100 Queen's Park
  Toronto, ON
  Canada M5S 2C6
  Office: 416-586-5591
  Email: nicolas.campi...@mail.utoronto.ca
 
[[alternative HTML version deleted]]
 
  ___
  R-sig-phylo mailing list
  R-sig-phylo@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
 
  ___
  R-sig-phylo mailing list
  R-sig-phylo@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-sig-phylo



 --
 NEW EMAIL ADDRESS:
 frank.burbr...@csi.cuny.edu
 ***
 Frank T. Burbrink, Ph.D.
 Professor
 Biology Department
 6S-143
 2800 Victory Blvd.
 College of Staten Island/CUNY
 Staten Island, New York 10314
 E-Mail:frank.burbr...@csi.cuny.edu
 Phone:718-982-3961
 Web Page: http://scholar.library.csi.cuny.edu/~fburbrink/
 ***

 

 Washington Monthly
 http://www.washingtonmonthly.com/magazine/septemberoctober_2012/features/americas_bestbangforthebuck_co039461.php
 magazine ranks the College of Staten Island as one of “America’s
 Best-Bang-for-the-Buck Colleges”

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

http://home.uchicago.edu/%7Edwbapst/

[[alternative HTML

Re: [R-sig-phylo] Add species branches to genus level tree

2012-10-02 Thread David Bapst
Thomas-
I think your interests might be served by my function expandTaxonTree
in my library paleotree on CRAN. Given a genus-level tree with data on
the species within each genus, it will turn each genus into an
unresolved polytomy of the congeneric species.
-Dave

On Tue, Oct 2, 2012 at 3:08 AM, Davies, Thomas
thomas.dav...@exeter.ac.uk wrote:
 Dear All

 Sorry to mass email with what could be a very basic question.  I am trying to 
 generate a tree for 1000 plus species.  To reduce the search effort I first 
 generated a tree to genus level from NCBI Itol with the intention of adding 
 species branches to each genus after.  Doing this manually has invariably 
 proved challenging as it's difficult to locate and solve all the sources of 
 human error that creep in when manual editing.  Is there a function in R that 
 can do this?  Say something that matches the genus in the species name to the 
 genus tip on the tree, and adds branches accordingly? It is not my intention 
 that the tree be based on divergence times, this isn't feasible given the 
 number and order of species I am working with, hence the reason for using the 
 NCBI taxonomy.

 Any help is much appreciated

 cheers

 Tom
 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo



-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] mccr test for non ultrametric trees

2012-05-30 Thread David Bapst
Pasquale-
This isn't a feasible solution, because the branch lengths of a
paleo-tree are a function of birth, death and sampling rates. I'll be
discussing work that Matt Pennell, Emily King and I have been doing
relating to this issue next month at Evolution.
-Dave

On Wed, May 30, 2012 at 8:23 AM, pasquale.r...@libero.it
pasquale.r...@libero.it wrote:



 Hi all,

 I would enquire the list about a simple issue. Is there any method implemented
 to test for changes in diversification rate as applied to fossil (non-
 ultrametric) trees?. As far as I understand, the methods so far available work
 on ultrametric trees (I've inspected laser's mccrTest.Rd, and Cusimano's et 
 al.
 CorSiM). I'm tempted to say that an easy workaround would be to get the real
 age of nodes by substituting the function branching.times with an an hoc 
 script
 where needed, and then simulate trees of the same size as the orginal (e.g.
 with TreeSim functions) to get the null distribution of gamma values. Is that
 feasible?
 thanks,

 Pas

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo



-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] Continuous character simulation

2012-04-25 Thread David Bapst
Vanderlei-
Negative alpha would imply a detractor, rather than an attractor,
similar to what was found by Alroy (1996) in his Cope's Rule paper. Is
that the sort of dynamic you wanted to simulate?

I'm not familiar with any discussion of negative alpha values in the literature.
-Dave

On Wed, Apr 25, 2012 at 1:57 PM, Vanderlei Debastiani
vanderleidebasti...@yahoo.com.br wrote:
 Dear,

 Could I simulate continuous character evolution using a Ornstein-Uhlenbeck 
 model (Function rTraitCont in the package ape) with a negative alpha value?

 My intention is to simulate trait evolution with different phylogenetic 
 signal (less or more similar than expected under Brownian motion evolution) 
 using the K statistic.

 The function works with negative alpha, simulating traits with different K 
 values, but does it make any sense?

 Thanks,

 Vanderlei Debastiani
 Laboratório de Ecologia Filogenética e Funcional
 Programa de Pós-Graduação em Ecologia
 Universidade Federal do Rio Grande do Sul
 www.ufrgs.br/leff




        [[alternative HTML version deleted]]


 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


[R-sig-phylo] Problems with prop.clades and compar.ou

2012-03-24 Thread David Bapst
Hello all,
I recently ran into two issue with ape, using R 2.14.2 and ape 3.0-1.

1) I'm having some issues with the output from prop.clades, which was
recent noted in another discussion on this list. The output of the original
function is definitely incorrect and the output of the 'fixed' version
offered on the site occasionally (repeatably but not consistently) produces
an incorrect value in the output.

For an example, I'll compare a tree and then a second tree which is
generated by using degradeTree from the library paleotree to remove about
half the nodes. This is a

library(ape)
library(paleotree)
set.seed(3)
tree1-rtree(30)
tree2-degradeTree(tree1,0.5)
layout(matrix(1:2,,2));plot(tree1);plot(tree2)

In the plot we can see the two trees are the same; tip labels are
identical, just we've degraded how resolved the tree is. The nodes that are
present in the second are still present in the first, though. But if we run
prop.clades...

 prop.clades(tree1,tree2)
 [1] 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

There's definitely more than two clades shared, so that's not right.
Summary-1 of prop.part should also tell us how many bifurcations are shared:

 summary(prop.part(tree1,tree2))-1
 [1] 1 1 0 0 0 1 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 0 1 1 0 1 0

That looks more right.

Now, recently Klaus S. suggested a fix for prop.clades (
http://www.mail-archive.com/r-sig-phylo@r-project.org/msg01779.html) but
the fix doesn't also work right I've pasted Klaus's fix in below, but
I'll rename it prop.clades.mod:

prop.clades.mod - function (phy, ..., part = NULL, rooted = FALSE)
{
if (is.null(part)) {
obj - list(...)
if (length(obj) == 1  class(obj[[1]]) != phylo)
obj - unlist(obj, recursive = FALSE)
part - prop.part(obj, check.labels = TRUE)
}
bp - prop.part(phy)
if (!rooted){
bp - postprocess.prop.part(bp)
part - postprocess.prop.part(part)   # This line I added!!
}
n - numeric(phy$Nnode)
for (i in seq_along(bp)) {
for (j in seq_along(part)) {
if (identical(bp[[i]], part[[j]])) {
n[i] - attr(part, number)[j]
done - TRUE
break
}
}
}
n
}

And if we run it on this particular dataset...

 prop.clades.mod(tree1,tree2)
 [1] 1 2 0 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 0 1 1 0 1 0 0

What is a two doing in the output? How can a bipartition appear twice in
tree2?

Maybe I need to collapse. singles...

 prop.clades.mod(tree1,collapse.singles(tree2))
 [1] 1 2 0 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 0 1 1 0 1 0 0

No, that didn't fix anything.

The appearance of these 2s doesn't happen all the time, but it happens
often enough on large simulated trees to worry me, particularly since I
discovered this in a simulation where I was summing prop.clades to find the
number of shared bipartions. It seems like its always the second element of
the output that has the 2. Am I misunderstanding something here?


2) While on an grand experiment comparing the many alternatives for fitting
OU models in R, I ran into an error using compar.ou in ape. So what I was
doing:

library(ape)
set.seed(2)
tree-rtree(20)
trait-rTraitCont(tree)
fit-compar.ou(trait, tree)

But I got the following:

Error in chol.default(V) :
  the leading minor of order 10 is not positive definite

Any tree I generate with rtree or rcoal seems to generate this or a similar
error with compar.ou, so it doesn't seem to be an issue with me using a
non-ultrametric tree. Any ideas?

Thanks, all!

-Dave

-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

 http://home.uchicago.edu/%7Edwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] diversitree with multicore

2012-03-21 Thread David Bapst
Hey Rafael-
Hey, I'm using mclapply right now! What I'm doing with it is a trick I use
often in lapply and sapply statements. If I have, say a list 'A' and a
vector 'B' of the same length that I want to analyze in a lapply statement
which analyzes each corresponding pair, I do the following:

mclapply(1:length(A),function(x) myfunctionhere(A[[x]], B[x]))

So, in this way, you could put each likelihood function in a list with the
corresponding starting parameters in another list of the same length and
then use the code above.

Also, you can also do more complex things, say if you want to end up with a
nested list where you analyze each element of A with every element of B...
mclapply(1:length(A),function(x) lapply(1:length(B),function(y)
myfunctionhere(A[[x]], B[y]))

-Dave


On Wed, Mar 21, 2012 at 10:58 AM, Rafael Rubio de Casas r...@nescent.orgwrote:

 Dear all,
 I have been trying to come up with easy ways to split diversitree runs
 among processors when using multiple trees. It seems that the multicore
 package would be a good way of doing it, but I have failed to use
 multicore with diversitree functions. Essentially, I cannot figure out
 how to tell multicore that the function takes two set of objects, one
 containing the likelihood functions and another one containing the
 parameters. Does anybody have experience and/or advice doing this? Any
 guidance would be most welcome.
 Other alternatives for splitting diversitree jobs among processors would
 also be highly appreciated.
 Thanks in advance,
 Rafa
 --
 National Evolutionary Synthesis Center
 *NESCent http://www.nescent.org/*
 2024 W. Main Street, Suite A200
 Durham, NC27705
 r...@nescent.org mailto:r...@duke.edu
 919.668.9107

[[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/
http://cran.r-project.org/web/packages/paleotree/index.html

http://home.uchicago.edu/%7Edwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


[R-sig-phylo] Comparative Methods and Pseudo-Traits

2011-11-10 Thread David Bapst
Hello all,
A recent discussion set my mind thinking on a particular issue and, once
again, I decided to ask for the general opinion of R-Sig-Phylo denizens. It
may be easier to start with an example.

Let's say that there exists a worker who is measuring several different
traits across a number of species and then testing for correlations among
these traits. The first test is body size versus growth rate and they use
independent contrasts or PGLS to test for a the correlation, accounting for
phylogeny. Both of these traits are inherited, evolving variables. Now
let's say they'd like to test for the relationship between growth rate and
some metric of the anthropogenic degradation of that species' habitat. Now
what? It is even valid to apply PIC to the habitat degradation metric even
though it is not an inherited, evolving trait? It's unclear to me.

Let's consider a paleontological example, one which I have found myself
both strongly agreeing and disagreeing with at times. Essentially, how
should we test for extinction selectivity on some trait at a mass
extinction event? Let's say we think body size is a predictor of the risk
of extinction during that event and so we want to test for a correlation
between them (please ignore that extinction would be a discrete variable
for the moment). Do we treat these variable with PIC or PGLS? Is it really
proper to refer to the probability of going extinct during a mass
extinction as an evolving trait? Let's say we did and we got different
results than when we used an analysis which did not account for the
phylogenetic covariance. How should we interpret these results?

One explanation I know of is that when we apply phylogenetic comparative
methods to these quasi-traits to consider their relationship to another
trait, we are assuming that these variables are actually the result of some
underlying, unobserved set of traits which are evolving along the
phylogeny. This makes sense, maybe in the extinction event case, which
would mean that any PCM analysis would be testing for an evolutionary
relationship between body size and these unobserved traits which predict
extinction. Of course, if extinction risk is largely a function of
non-inherited traits, then the initial assumption may be incorrect (that
extinction risk itself is an evolving trait). Regardless, I don't see how
to apply that explanation to the habitat degradation example.

So, what do people think? How should we test for correlation when
non-evolving quasi-traits are involved? I'm very interested to hear
people's thoughts on this matter.
-Dave Bapst, UChicago

-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] Simulating binomial trait shifts on a phylogeny

2011-10-13 Thread David Bapst

 __**_
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/**listinfo/r-sig-phylohttps://stat.ethz.ch/mailman/listinfo/r-sig-phylo




 --
 Rob Lanfear
 Postdoc,
 Centre for Macroevolution and Macroecology,
 Research School of Biology,
 Australian National University

 Tel: +61 2 6125 7270
 www.robertlanfear.com

        [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] Getting ACE information out of R

2011-08-10 Thread David Bapst
Morgan-
The node labels from ace() are the ID numbers used in the edge matrix
(you can see that with tree$edge, where 'tree' is your phylogeny
object), and the are numbered from (Ntip(tree)+1) to
(Ntip(tree)+Ntip(tree)-1). Thus, to give your tree the IDs from the
edge matrix as node labels, just do:

tree$node.label-Ntip(tree)+(1:(Ntip(tree)-1))
plot.phylo (tree,show.node.label=T)   #and we can see
the node labels!

I hope that helps.
-Dave


On Wed, Aug 10, 2011 at 1:49 PM, Morgan Langille
morgan.g.i.langi...@gmail.com wrote:
 I have a tree with no node labels and I am running ACE many times. I
 would like to somehow get ACE data, specifically reconstruction$ace
 out of R. I can create node labels for my tree using function
 makenodelabel, but these don't correspond to the node labels within
 the phylo data structure that is used as the names within
 reconstruction$ace. I see two choices:

 Is there a way to easily set the node labels for my tree to correspond
 to the internal R phylo object node labels?

 OR

 Is there a way to map the internal phylo node labels to the node
 labels on the tree?


 Any help is greatly appreciated!


 Morgan Langille
 http://morganlangille.com

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] R: Re: R: ancestral state reconstruction for tips

2011-08-05 Thread David Bapst
As the diversity of explicit models of trait evolution grow, it will
be interesting to see if any consensus develops about which models
hold most often in general and whether any insight is gained into
which conditions predict appearance of different models.

I think Joe is right that realizing a model is an inaccurate or
imprecise description of reality should impel us to develop better
models of the world around us, because this partly how science moves
forward. However, I don't think pointing out that a model is deficient
requires that that person must themselves develop an alternative.
After all, an alternative model that capture a more realistic level of
complexity may not be possible in some situations (it is certainly
possible in trait evolution models, however.) Requiring such a thing
would put too much pressure on scientific whistle-blowers, who play a
very important role in reminding the rest of us that the world is more
than the models we use to understand it and make our predictions.

-Dave




On Fri, Aug 5, 2011 at 10:51 AM, Joe Felsenstein j...@gs.washington.edu wrote:

 Pasquale Raia said:

 Of course Ted is right, but my problem with this computation, or
 with the
 simple exercise I was proposing is well another: as a
 paleontologist I often
 come across pretty exceptional phenotypes (dwarf hippos and
 elephants, huge
 flightless birds, to make a few examples). When you use methods
 like this (I
 mean Garland and Ives') and compare the output with those
 phenotypes, as I did,
 you immediately realize what the the bottom line is: no matter if
 they are
 nodes or tips, by using the expected (under BM) covariance the
 estimated
 phenotypes are dull, perfectly reasonable but very different from
 anything
 exceptional you may find yourself to work with. This is why I feel
 it is
 difficult to rely on those (unobserved) values to begin with.

 I think that what is being said is that Brownian Motion is too sedate
 a process
 and does not predict some of the large changes actually seen in the
 fossil
 record.

 That's a legitimate point but does put the onus on the maker of the
 point to
 propose some other stochastic process that is tractable and has these
 large
 changes (and that fits with known Mendelian and Darwinian mechanisms).
 Just complaining that the Brownian stochastic process is no good is
 insufficient.

 If we want to add the fossils to the calculation, then they will of
 course
 pressure the Brownian Motion process to change more in their vicinity,
 which may help some.

 Joe
 
 Joe Felsenstein      j...@gs.washington.edu
  Dept of Genome Sciences and Dept of Biology, Univ. of Washington,
 Box 5065, Seattle Wa 98195-5065


        [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


[R-sig-phylo] Session on Phylogenetic Paleobiology at GSA 2011 (Abstracts Due TODAY!)

2011-07-26 Thread David Bapst
Hello all,
Just wanted to send a final reminder that abstracts for our session at GSA
2011 is due today, June 26th. See my previous email below for more details.
Thanks,
-Dave Bapst and Emily King, UChicago



On Mon, Jul 18, 2011 at 11:39 AM, David Bapst dwba...@uchicago.edu wrote:

 Hello all,
 I just wanted to send a last reminder to the readers of this list about a
 particular conference session at this year's Geological Society of America
 2011. This conference will be held in Minneapolis, from October 9th to the
 12th. This session, proposed by Emily King and I, will focus on analyses
 that use both the fossil record and phylogenetic data to investigate
 evolutionary dynamics, such as diversification, evolutionary rates and
 trends. Emily and I would really love to see work that combines molecular
 phylogenies with fossil data and also work that uses phylogenies of fossil
 data. If you're doing anything that sounds like it might fit in, we
 encourage you to submit an abstract for our session (T61) and give an oral
 presentation on your work.

 Those of you who are biologists might be thinking But Dave, what am I
 going to do at a geology conference? GSA 2011 is pretty much the big annual
 meeting for North American paleontologists and so one can find interesting
 paleobiology-related sessions running from the start of the conference to
 its end. There tends to be a large number of general sessions on
 morphometrics, diversification, macroevolutionary dynamics, functional
 morphology and mass extinctions. This year, the Paleontological Society is
 also sponsoring special sessions on *Species and Speciation in the Fossil
 Record and **Lessons from the Living: Paleontological Investigations
 Using Modern Analogs.*

 The abstract submission deadline is July 26th, which is about about ONE
 WEEK away. You can find out more about GSA 2011 and submit your abstract
 online here http://www.geosociety.org/meetings/2011/. The abstract fee
 is $35.00 for professionals and $20.00 for students. (
 http://www.geosociety.org/meetings/2011/)

 Please let me or Emily know if you have any questions.
 -Dave Bapst, UChicago

 --
 David Bapst
 Dept of Geophysical Sciences
 University of Chicago
 5734 S. Ellis
 Chicago, IL 60637
 http://home.uchicago.edu/~dwbapst/




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] Generating all possible phylogenies...

2011-07-21 Thread David Bapst
Liutauras-
allTrees() in the phangorn package can calculate all possible trees for up
to 10 tips.
Cheers,
-Dave, UChicago

On Thu, Jul 21, 2011 at 10:20 AM, Liutauras Rusaitis 
liutauras.rusai...@st-annes.ox.ac.uk wrote:

 Hello,

 Is it possible to use Ape Library to generate all possible evolutionary
 tree structures given a fixed number of nodes? We're studying plant leaf
 evolutions and we need to test each evolutionary tree on our models. We
 realize the number of trees would be huge, so we'd chooce only the most
 parsimonious trees once we can generate all of them.

 Thanks,

 Liutauras
 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


[R-sig-phylo] Session on Phylogenetic Paleobiology at GSA 2011 (Abstracts Due in a Week!)

2011-07-18 Thread David Bapst
Hello all,
I just wanted to send a last reminder to the readers of this list about a
particular conference session at this year's Geological Society of America
2011. This conference will be held in Minneapolis, from October 9th to the
12th. This session, proposed by Emily King and I, will focus on analyses
that use both the fossil record and phylogenetic data to investigate
evolutionary dynamics, such as diversification, evolutionary rates and
trends. Emily and I would really love to see work that combines molecular
phylogenies with fossil data and also work that uses phylogenies of fossil
data. If you're doing anything that sounds like it might fit in, we
encourage you to submit an abstract for our session (T61) and give an oral
presentation on your work.

Those of you who are biologists might be thinking But Dave, what am I going
to do at a geology conference? GSA 2011 is pretty much the big annual
meeting for North American paleontologists and so one can find interesting
paleobiology-related sessions running from the start of the conference to
its end. There tends to be a large number of general sessions on
morphometrics, diversification, macroevolutionary dynamics, functional
morphology and mass extinctions. This year, the Paleontological Society is
also sponsoring special sessions on *Species and Speciation in the Fossil
Record and **Lessons from the Living: Paleontological Investigations Using
Modern Analogs.*

The abstract submission deadline is July 26th, which is about about ONE WEEK
away. You can find out more about GSA 2011 and submit your abstract online
here http://www.geosociety.org/meetings/2011/. The abstract fee is $35.00
for professionals and $20.00 for students. (
http://www.geosociety.org/meetings/2011/)

Please let me or Emily know if you have any questions.
-Dave Bapst, UChicago

-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] cut a tree in a given time interval

2011-07-12 Thread David Bapst
Do you want a function that gives you a tree of taxa observed in a time bin
(like, in the fossil record, as in Ruta et al., 2007)? Or gives you the tree
of the lineages extant at point in time based on some global phylogeny? If
that is what you want, the following function I wrote for doing time-slices
on trees should do that. My most recent version (not posted) has some
additions so that the same time-slice can be taken across multiple trees
that may have the root in different place. (These modifications use the
earliest fossil species as an anchor time.)

This version of the code seems to work okay, for example try:
tree1-rtree(500)
timeslice.phy(tree1,slice.time=4,plot=T)

Let me know if this works alright,
-Dave, UChicago


timeslice.phy-function(ttree,slice.time,plot=T){
#take a phylogeny and produce a phylogenetic 'slice' at time X
#makes an ultrametric tree, as if made of lineages extant at time X
#where X is a point in time after root time = 0
require(ape)
tslice-slice.time #time from root to slice time
#first let's drop all edges that branch later than the slice
#make them all single lineages by dropping all but one taxon
dnode-dist.nodes(ttree)[,Ntip(ttree)+1]
#identify the ancestor nodes of edges which cross the tslice
cedge-which(sapply(1:Nedge(ttree),function(x)
any(ttree$edge[x,1]==which(dnodetslice))
 any(ttree$edge[x,2]==which(dnode=tslice
droppers-numeric()
for(i in 1:length(cedge)){
desc-ttree$edge[cedge[i],2]
if(descNtip(ttree)){#if an internal edge that goes past the
tslice
desctip-unlist(prop.part(ttree)[desc-Ntip(ttree)])#drop all
but one tip
droppers-c(droppers,desctip[-1])
}}
stree-drop.tip(ttree,droppers)
#which edges cross over tslice?
dnode-dist.nodes(stree)[,Ntip(stree)+1]
cedge-sapply(1:Nedge(stree),function(x)
any(stree$edge[x,2]==which(dnode=tslice)))
cnode_depth-dnode[stree$edge[cedge,1]]
stree$edge.length[cedge]-tslice-cnode_depth
#last, let's drop all terminal taxa that are less than the tslice
dnode-dist.nodes(stree)[,Ntip(stree)+1]
droppers-which((dnode[1:Ntip(stree)]+0.1)tslice)
stree-drop.tip(stree,droppers)

if(plot){layout(matrix(1:2,,2));plot(ladderize(ttree),show.tip.label=F);axisPhylo();plot(stree,show.tip.label=F)}
stree
}

On Tue, Jul 12, 2011 at 3:19 PM, ppi...@uniroma3.it wrote:

 Hi all,
 someone knows a smart coding to cut a tree in order to
 retain only taxa present in a given time interval bin?

 Thanks in advance for any suggestion
 best
 paolo

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] Branch and Bound Maximum Parsimony

2011-03-28 Thread David Bapst
Matthew-
In addition to Ross's suggestion of TNT, I would recommend that you consider
options less commonly used by paleontologists. One option is Mr. Bayes,
which can apply the Mk2 model from Lewis (2001) to morphological data.
Another is Strataphy (Marcot and Fox, 2008) which can apply stratocladistics
(if you are willing to work with the assumptions of that method; I realize
some people have strong opinions against it). Note that both these methods
require that autapomorphies are included.
-Dave Bapst, UChicago

On Mon, Mar 28, 2011 at 12:34 AM, Matthew Vavrek
matt...@matthewvavrek.comwrote:

 Hello,
 although I know a lot of people have moved away from it, I was wondering if
 there is an implementation of a tree search function using maximum parsimony
 with a branch and bound option for R. I work in a lab that has been using
 PAUP forever, but I'm trying to see if R would be a viable alternative
 (especially since PAUP seems to be in some sort of limbo, from what I can
 gather on the intertubes). However, maximum parsimony is typically what is
 used, and usually the datasets that were being used could be run in a
 relatively short (ie 15 minutes) time span in PAUP using a branch-and-bound
 search, thereby locating all the most parsimonious trees. I've tried the
 phangorn package which has a parsimony ratchet function that works really
 well, but within paleontology (my field) there are still a good number of
 people that want an exhaustive search. Alternatively, if there is no
 exhaustive search, what would be the best tree search function for
 morphological (character) data? Most of the discussions I can find revolve
 more around DNA/molecular data, which are hard to come by in fossils (unless
 you are Michael Crichton).

 Thanks
 Matthew Vavrek

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


[R-sig-phylo] Possible Error in prop.part() ?

2011-03-25 Thread David Bapst
Hello all,
I was using prop.part() to identify nodes shared between several topologies,
when I discovered a strange error, where prop.part() was underestimating the
number of partitions found in common. I was able to fix the error for some
comparisons by outputting the trees as Newick strings and reading them back
in with read.tree(text=write.tree()). However, this didn't work for all
topologies, which actually allowed me to reproduce the error for you all,
using the code below. tree1 and tree2 have five shared nodes, but
prop.part() only reports two partitions as being found in common.
prop.clades() seems to report the correct number.

require(ape)
tree1-read.tree(text=(((TAXt9,TAXt4),(((TAXt6,TAXt3),TAXt13),((TAXt1,(TAXt12,TAXt14)),TAXt11))),TAXt7);)
tree2-read.tree(text=(((TAXt6,((TAXt13,TAXt3),(TAXt1,(TAXt12,TAXt14,(TAXt11,(TAXt9,TAXt4))),TAXt7);)
prop.part(tree1,tree2)
prop.clades(tree1,tree2)

For this particular example, it turns out that prop.part() correctly
estimated the number of partitions prior to me applying the read.tree() fix.
But I'm doing this over a large number of pairs, so I need a solution that
works for all.

I'm using R v2.12.2 and ape v2.6-3. I haven't updated to 2.7 since I use
read.nexus() quite a bit; let me know if it is reproducible in that version.
-Dave

-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


[R-sig-phylo] Conditioning on Total Tips in Birth-Death Trees

2011-03-23 Thread David Bapst
Hello all,
Are there any birth-death tree functions which condition on the total
number of tips (extinct and extant) on a tree rather than the number
of surviving tips? All the ones I've been able to find condition on
time or on the number of extant tips. I put together the following
kludge using a while() loop and the rlineage() function in ape, which
returns bd trees within a given range of total number of tips, but it
would be ideal to me not to have to condition on time.

bdtree.paleo-function(birth,death,time,minTip=0,maxTip=Inf){
rt-rlineage(birth,death,Tmax=time)
while(Ntip(rt)minTip | 
Ntip(rt)maxTip){rt-rlineage(birth,death,Tmax=time)}
rt
}

Also, I'm not very familiar with the birth-death literature and I've
been looking for one particular bit of information, which I thought I
might ask if anyone here knew. I was wondering if it was known what
the expected probability distribution of branch lengths for a
fully-sampled phylogeny (includes all extinct lineages) is? I've been
trying to figure out, if for a fully extinct tree with homogenous
rates,  whether we would expect the branch lengths of internal
branches to follow an exponential distribution based on the birth
parameter (and extinct terminal edges following an exponential
distribution based on the death parameter) or if the branch lengths
are a function of both parameters. Perhaps I'm not using the right
keywords, but my literature searches haven't found the information I'm
looking for.

Thanks,
-Dave

-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] Q: Likelihood ratio test and rate shift test on complete dated phylogeny

2011-03-22 Thread David Bapst
Dan, Robert, others-

 (i) Can you use a Likelihood ratio test to test whether a birth death model 
 fits your data better than a pure birth model? (likelihood scores are 
 obtained from LASER).

 Yes, this would be valid, as the models are nested.

If I might ask, what biological inference would one draw if the pure
birth model fits better than the birth-death model? That the
extinction rate is negligible?

-Dave

-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] Q: Likelihood ratio test and rate shift test on complete dated phylogeny

2011-03-22 Thread David Bapst
Dan, All-

If I understand correctly, that's a separate issue than what Ted is
getting at; I think he's worried about the effect of data dredging by
running all possible models (as Burnham and Anderson warn against) and
not mis-parametrization of the simple model. Data-dredging will bias
us toward finding complex models that fit overly well. The common
solution in data mining is to subset your data and thus confirm a
preferred model for one subset by testing the preference in another
subset, but I don't think that can be applied to studies with a single
tree.

-Dave

On Tue, Mar 22, 2011 at 12:37 PM, Dan Rabosky drabo...@berkeley.edu wrote:

 Hi Ted-

 Others can weigh in here, but - at the very least - I would consider a model 
 with 2 rates as having at least 1 additional parameter (the location of the 
 rate shift). This seems to perform OK in practice. I admit that I have always 
 been a bit uncomfortable with this, though - the null hypothesis model does 
 not have a shift point. I think there are parallels here to finding 
 breakpoints in segmented regression models. Here's a paper I've been meaning 
 to read that might be relevant.

 Davies, R.B. (1987) Hypothesis testing when a nuisance parameter is present 
 only under the alternative. Biometrika 74, 33–43.

 ~Dan







 On Mar 22, 2011, at 10:19 AM, tgarl...@ucr.edu tgarl...@ucr.edu wrote:

 This can also be done using the package diversitree, with the
 function make.bd.split and variants thereof. You will probably
 have to write a function to iteratively partition the tree
 into all possible splits.

 Hi Dan,

 How would this approach deal with the problem of multiple comparisons, i.e., 
 in effect testing many different hypotheses (or exploratory data mining) on 
 the same data set and overall tree?

 Cheers,
 Ted


 Theodore Garland, Jr.
 Professor
 Department of Biology
 University of California, Riverside
 Riverside, CA 92521
 Office Phone:  (951) 827-3524
 Wet Lab Phone:  (951) 827-5724
 Dry Lab Phone:  (951) 827-4026
 Home Phone:  (951) 328-0820
 Facsimile:  (951) 827-4286 = Dept. office (not confidential)
 Email:  tgarl...@ucr.edu

 Main Departmental page:
 http://www.biology.ucr.edu/people/faculty/Garland.html

 List of all Publications:
 http://www.biology.ucr.edu/people/faculty/Garland/GarlandPublications.html

 Garland and Rose, 2009
 http://www.ucpress.edu/books/pages/10604.php


   Original message 

    Date: Tue, 22 Mar 2011 09:44:26 -0700
    From: Dan Rabosky drabo...@berkeley.edu
    Subject: Re: [R-sig-phylo] Q: Likelihood ratio test and rate shift
    test on complete dated phylogeny
    To: R.J. den Tex rjden...@yahoo.com
    Cc: r-sig-phylo@r-project.org


 Hi Robert-

 (i) Can you use a Likelihood ratio test to test whether a birth
    death model fits your data better than a pure birth model?
    (likelihood scores are obtained from LASER).

 Yes, this would be valid, as the models are nested.

 (ii) How can I test if a rate shift has occurred on a particular
    node/branch in a complete taxon phylogeny?

 There are lots of possible methods for this. Or perhaps it is
    better to say that there are lots of variants of a single general
    approach. There are the 1-rate versus 2-rate model in LASER
    (fitNDR_2rate, fitNDR_1rate) after Rabosky et al. (Proc. R. Soc. B,
    2007); there is the MEDUSA approach, which would allow more than 1
    rate shift across your tree (Alfaro et al., PNAS; this method is
    implemented in GEIGER).

 This can also be done using the package diversitree, with the
    function make.bd.split and variants thereof. You will probably have
    to write a function to iteratively partition the tree into all
    possible splits. Actually, I think the diversitree calculations
    *may* be the most accurate if you have different extinction rates
    across the tree.

 There is also the method from Moore and Donoghue (2009, PNAS) - i
    think tRate is the name of the package - although I don't think this
    is distributed on the archive for R packages.

 ~Dan Rabosky



 Thank you very much beforehand!

 Robert den Tex
 PhD student
 Dept. Evolutionary Biology
 EBC, Uppsala University
 Uppsala,
 Sweden

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo





 [[alternative HTML version deleted]]

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo






        [[alternative HTML version deleted]]


 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo





-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https

Re: [R-sig-phylo] multi2di: any way to return all possible combinations of polytomy to dichotomous trees?

2011-03-13 Thread David Bapst
Alistair-
Even if all the polytomies are small, if there are many of them, the
number of potential trees may be very large. I don't know the exact
numbers.

The following, for a phylo object named tree should give you a
vector which identifies those nodes that are polytomies (have more
than 2 descendant branches).

nodes-1:max(tree$edge)
polys-nodes[sapply(nodes,function(x) sum(x==tree$edge[,1]))2]

Enjoy!
-Dave

On Sun, Mar 13, 2011 at 7:16 AM, Alastair Potts pott...@gmail.com wrote:
 Hi David,
 Thanks for the response. I did not consider the computational difficulties
 primarily because my polytomies are small - usually only involving 3 tips. I
 think your extract.clade() -- allTrees() -- bind.tree() suggestion would
 work well. This is actually for a simulation study where simulated data are
 analysed using parsimony in PAUP, thus I have many trees that might have
 this small polytomy - is there any way to identify nodes that contain
 polytomies? After that, I think I should be able to implement the above
 suggestion fairly easily.

 General comments to all:
 Essentially my problem lies with the consensus function, and although
 David's suggestion would solve the problem, it seems like a very long-winded
 way of doing it.

 Is it not possible to get the consensus() function to accept a tree with a
 polytomy, along with the other trees, and add this to the overall consensus
 tree (which is expected to contain polytomies if there are topological
 differences)?

 Thanks for your time,
 Cheers,
 Alastair

 David Bapst wrote:

 Alistair-

 How many multifurcations are there, with how many branches each? If
 the number of potentially resulting trees is too high, it may not be
 possible to store all the possible trees in memory.

 If your tree is small, you might try allTrees(), which is the only
 ready to use function I know of which gives all possible trees, but
 only for tree with up to 10 tips.

 If you have a tree with more than 10 taxa but one or two small
 polytomies, you could remove the polytomies out with extract.clade(),
 find all their resolutions with allTrees(), stick their descendant
 tips back onto the polytomy with bind.tree() and then stick them back
 into the original tree with bind.tree(). It sounds crazy, but I've
 written code that sort of does this for my tree, so that I can weigh
 polytomy resolution by the fit of the solutions to a model of
 preservation potential in the fossil record. It would still require
 some programming, though, for you to get what you want.

 -Dave

 On Sat, Mar 12, 2011 at 7:32 AM, Alastair Potts pott...@gmail.com wrote:


 Good day all,
 I was wondering if there was any way to get multi2di to return trees with
 all possible combinations when breaking up a polytomy to a dichotomous
 branching tree?

 The reason why I ask is that PAUP is returning non-binary trees from some
 analyses (e.g. a set of most parsimonious trees). The consensus function
 requires binary trees, so I use the multi2di function to force these
 trees
 to binary trees. However, as not all possible trees are returned, just
 one
 possibility, I am getting more resolution in my topology that is actually
 present in the PAUP strict consensus tree when I use the consensus
 function.

 I've looked at the multi2di function thinking I may be able to get it to
 return all trees - but it is a problem beyond my meagre programming
 skills.

 Any help would be much appreciated!

 Cheers,
 Alastair
 --
 -
 Alastair Potts
 PhD candidate
 Botany Department
 University of Cape Town
 alastair.po...@uct.ac.za or pott...@gmail.com
 University Private Bag, Rondebosch 7700, South Africa
 or
 PO Box 115, Loxton 6985, South Africa
 Cell: 082 491-7275

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo







 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] multi2di: any way to return all possible combinations of polytomy to dichotomous trees?

2011-03-12 Thread David Bapst
Alistair-

How many multifurcations are there, with how many branches each? If
the number of potentially resulting trees is too high, it may not be
possible to store all the possible trees in memory.

If your tree is small, you might try allTrees(), which is the only
ready to use function I know of which gives all possible trees, but
only for tree with up to 10 tips.

If you have a tree with more than 10 taxa but one or two small
polytomies, you could remove the polytomies out with extract.clade(),
find all their resolutions with allTrees(), stick their descendant
tips back onto the polytomy with bind.tree() and then stick them back
into the original tree with bind.tree(). It sounds crazy, but I've
written code that sort of does this for my tree, so that I can weigh
polytomy resolution by the fit of the solutions to a model of
preservation potential in the fossil record. It would still require
some programming, though, for you to get what you want.

-Dave

On Sat, Mar 12, 2011 at 7:32 AM, Alastair Potts pott...@gmail.com wrote:
 Good day all,
 I was wondering if there was any way to get multi2di to return trees with
 all possible combinations when breaking up a polytomy to a dichotomous
 branching tree?

 The reason why I ask is that PAUP is returning non-binary trees from some
 analyses (e.g. a set of most parsimonious trees). The consensus function
 requires binary trees, so I use the multi2di function to force these trees
 to binary trees. However, as not all possible trees are returned, just one
 possibility, I am getting more resolution in my topology that is actually
 present in the PAUP strict consensus tree when I use the consensus function.

 I've looked at the multi2di function thinking I may be able to get it to
 return all trees - but it is a problem beyond my meagre programming skills.

 Any help would be much appreciated!

 Cheers,
 Alastair
 --
 -
 Alastair Potts
 PhD candidate
 Botany Department
 University of Cape Town
 alastair.po...@uct.ac.za or pott...@gmail.com
 University Private Bag, Rondebosch 7700, South Africa
 or
 PO Box 115, Loxton 6985, South Africa
 Cell: 082 491-7275

 ___
 R-sig-phylo mailing list
 R-sig-phylo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo




-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


  1   2   >