Re: [R-sig-phylo] chronos ape substitution rate strict clock

2024-03-04 Thread Liam J. Revell
Dear Vincenzo.

If I understand your problem problem, you do not have any explicit 
calibration points -- but you have a hypothesized average clock rate?

If so, then you can obtain an ultrametric tree from/ape::chronos/ for 
any value of the smoothing parameter (/lambda/) and then simply re-scale 
it to have the desired total depth (based on your hypothesized clock rate).

To choose a "correct" value of /lambda/ one can use cross-validation as 
described in Sanderson (2002; doi:10.1093/oxfordjournals.molbev.a003974).

Others should feel welcome to weigh in if this is not right.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 3/4/2024 11:09 AM, Vincenzo Ellis wrote:
> [You don't often get email fromvael...@udel.edu. Learn why this is important 
> athttps://aka.ms/LearnAboutSenderIdentification  ]
>
> CAUTION: EXTERNAL SENDER
>
> Dear Emmanuel,
>
> Thank you very much for your response. I cannot see how to provide the
> substitution rate to the phangorn::pml_bb() function, but I was looking at
> the ape::node.dating() function and it appears that I could provide the
> substitution rate to the "mu" argument and then set the "node.dates"
> argument to NA or zero for all tips (I'm not sure if NA or zero would be
> preferable to force the tips to all be from a single time point). Do you
> think that would work? I'm not sure how to make ape::node.dating() accept a
> substitution rate rather than try to estimate one. Maybe an option could be
> added to allow mu to equal a user-specified number rather than the output
> of ape::estimate.mu()?
>
> Another option might be to calculate an estimated age for every node
> connecting sister taxa in the tree by converting the genetic distances
> between sister pairs to divergence times using the substitution rate and
> then use those as priors in ape::chronos(). I suppose I could also apply
> that logic to date all of the nodes by using the mean pairwise distances
> between taxa on either side of a node and converting that to divergence
> times (although the R code for such a calculation would likely take me a
> while to figure out). Would that be another option?
>
> Thanks again,
>
> Vincenzo
>
> On Sat, Mar 2, 2024 at 5:44 AM Emmanuel Paradis
> wrote:
>
>> Hi Vincenzo,
>>
>> There's no direct way to do this with ape::chronos(). You may have a look
>> at the function phangorn::pml_bb() but I'm not sure it can estimate the
>> dates if the rate is provided in a model object given as main argument(?)
>>
>> That said, I expect that estimating so many dates to be very challenging
>> (unless you have a lot of known dates for calibration). This implies that
>> you are certainly right to look for an approach where you don't need to
>> estimate the rates.
>>
>> Best,
>>
>> Emmanuel
>>
>> - Le 27 Fév 24, à 22:40, Vincenzo ellisvael...@udel.edu  a écrit :
>>
>>> Dear R-sig-phylo members,
>>>
>>> I've made a maximum likelihood tree in Raxml for several thousand taxa
>>> using a single gene that has an estimated substitution rate of 0.006
>>> substitutions/nucleotide/My. Is there a way to use chronos in ape to
>> apply
>>> that substitution rate as a fixed clock rate and generate an ultrametric
>>> time-scaled version of the tree?
>>>
>>> Thank you,
>>>
>>> Vincenzo
>>>
>>>[[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 athttp://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/


[R-sig-phylo] Postdoc at OIST

2024-01-31 Thread Liam J. Revell
Dear colleagues.

Lauren Sallan is advertising a postdoctoral position for her lab at the 
Okinawa Institute of Science & Technology (OIST) that may be of interest 
to some people on this list. I had the opportunity to visit OIST last 
year & was super-impressed -- and Okinawa is beautiful! If this was 15 
years ago, I'd be applying myself. Details below & at the following 
link: 
https://www.oist.jp/careers/postdoctoral-scholar-or-staff-scientist-macroevolution-unit.
 
I'm sure you can also contact Lauren directly for additional information.

-

Postdoctoral Scholar or Staff Scientist / Macroevolution Unit

THE POSITION

The Okinawa Institute of Science and Technology Graduate University 
(OIST; see www.oist.jp) is a dynamic new graduate university of science 
and technology in Okinawa Prefecture, Japan. The university is located 
on 85 hectares of protected forestland overlooking beautiful shoreline 
and coral reefs. The campus is striking architecturally, and the 
facilities are outstanding (OIST campus video tour). There are no 
academic departments, which facilitates multidisciplinary research. 
Outstanding resources and equipment are provided and managed to 
encourage easy access and collaboration. English is the official 
language of the University, and the university research community is 
fully international, with more than 50 countries represented. OIST is 
rapidly gaining recognition in the worldwide academic community as a 
model for excellence in education and research.

Position summary:

A postdoctoral scholar (PhD <5 years) or staff scientist position (PhD 
 >5 years) is available in the Macroevolution Unit at OIST. We seek a 
highly motivated and creative researcher with a background in 
macroevolution (e.g. phylogenetics, evolutionary processes, organismal 
biology, and/or paleontology) and a deep interest in reconstructing the 
evolution of vertebrate life and biodiversity dynamics (extinction, 
diversification, innovation), and a desire to develop their own 
projects. The researcher will pursue novel work involving data and 
methods such as phylogenetic comparative methods, trait analysis, and/or 
fossil record occurrences.

This position is open to both paleontologists and researchers working on 
living groups, models, and molecular data, with a preference for those 
interested in fishes or other aquatic life. Exact projects will be 
developed through discussions with PI Sallan based on the skills, 
interests, and ideas of the selected researcher.

*The start date is negotiable. Promising senior graduate students and 
postdocs with time remaining in their current positions are encouraged 
to apply.

-- 
Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


[[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] Evolution 2024 Symposium on Replicability & Reproducibility

2024-01-24 Thread Liam J. Revell
Dear colleagues.

Shinichi Nakagawa & I have organized a symposium for the 3rd Joint 
Congress on Evolutionary Biology to be held next summer in Montreal, 
Canada & that might be of interest to some people people on this mailing 
list.

The theme of the symposium is "Replicability & Reproducibility in 
Ecological & Evolutionary Research" and the underlying idea is to 
feature talks focused both on analysis reproducibility, good research 
practices for replicability (such as pre-registration, blinding, etc.), 
and the "science of science" (e.g., meta-science research aimed at 
measuring research reliability & improving research practices).

Here are some more details:

What: A symposium on “Replicability & Reproducibility in Ecological & 
Evolutionary Research” at ​the 3rd Joint Congress on Evolutionary 
Biology (2024)

Where: Montreal, Quebec, Canada (https://www.evolutionmeetings.org/)

When: July 26-30, 2024 (the exact date for the symposium TBA)

About: A collection of diverse presentations on reproducibility and 
“research on research” (meta-research/meta-science) in ecology and 
evolution.

Goal: Via the symposium, we increase the awareness of research issues 
and inefficiencies in ecology and evolution to promote open, reliable 
and transparent sciences.

How to attend: Many conference support grants are available for students 
and early career researchers (e.g., conference fee waiver and travel 
support). See a collection of them here: 
https://www.evolutionmeetings.org/travel--support.html.

What you need to do now: Apply for a grant right now. If you need a visa 
to visit Canada, conference pre-registration is open 
(https://www.evolutionmeetings.org/). Regular conference registration & 
abstract submission will open in February. Please consider submitting 
your talk to our symposium! Even if your talk is not accepted by our 
symposium, all talks submitted by the deadline will be accepted for the 
conference and placed in an appropriate session.

Organizers and contacts: Please send any questions to symposium 
co-organizers Shinichi Nakagawa (s.nakag...@unsw.edu.au) and/or Liam 
Revell (liam.rev...@umb.edu)

Proposal: A growing number of fields across the medical & social 
sciences have identified what’s become known as a "crisis of 
reproducibility," typically manifesting as studies & meta-analyses that 
point to low reproducibility of key research findings. In one well-known 
example, an industry lab attempted to replicate 52 important preclinical 
results of cancer biology and was only able to duplicate key findings in 
6 of these. Though evolutionary biology has yet to encounter its own 
replication crisis, survey data and other information suggest that 
research practices known to be linked to low reproducibility are 
probably widespread. This symposium invites diverse perspectives on 
replicability & reproducibility, open science, the impact of research 
practices on the reliability of findings, & 'meta-science' (the science 
of science) to help ask if ecology & evolutionary biology are on the 
cusp of their own replication crisis & what can be done about it.

-- 
Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


[[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] HPD in threshBayes function (phytools)

2023-10-30 Thread Liam J. Revell
Dear Leonardo.

This is covered in Chapter 7, pp. 215-219 of my book with Luke Harmon 
(https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r), 
but don't worry -- I also just posted a solution on my blog: 
http://blog.phytools.org/2023/10/computing-hpd-interval-on-evolutionary.html.

I hope this helps you figure out what you need to do!

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 10/30/2023 8:11 PM, Leonardo Matheus Servino wrote:
> [You don't often get email fromleonardomserv...@gmail.com. Learn why this is 
> important athttps://aka.ms/LearnAboutSenderIdentification  ]
>
> CAUTION: EXTERNAL SENDER
>
> Dear group,
>
> I am performing analyses using threshBayes from the phytools package. I was
> wondering if someone has ever extracted the highest posterior density
> intervals (HPD) values using this function. How could I make this?
>
> Thanks in advance
>
> --
> Leonardo Matheus Servino
> Pós-graduação em Ecologia
>
> Departamento de Ecologia
> Universidade de São Paulo
> Rua do Matão, Trav. 14, n˚ 101
> Cid. Universitária - São Paulo, SP
> 05508-090
> Brasil
>
> *Lattes<http://lattes.cnpq.br/3993528079964952>  - **ResearchGate
> <https://www.researchgate.net/profile/Leonardo_Servino>  - ORCID
> <https://orcid.org/-0002-6772-376X>  - LinkedIn
> <https://www.linkedin.com/in/leonardo-matheus-servino-8379ba1b2>*
>
>  [[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 athttp://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/


Re: [R-sig-phylo] Highlighting Specific Clades in a Lineage-Through-Time Plot

2023-10-28 Thread Liam J. Revell
I like Will's suggestion. Unfortunately, /phytools::ltt.simmap/ method 
in /phytools/ on CRAN does not support ultrametric trees.

I have updated it on GitHub & also posted a workflow to my blog that may 
capture what Russell is going for (if I understand it correctly): 
http://blog.phytools.org/2023/10/visualizing-lineage-accumulation-on.html.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 10/28/2023 6:56 PM, William Gearty wrote:
> CAUTION: EXTERNAL SENDER
>
> The output from Liam's function should be pretty useable for ggplot, too. I
> think the function has a plot argument that you can just set to False.
>
> On Sat, Oct 28, 2023, 6:37 PM Russell Engelman
> wrote:
>
>> It looks like what Liam wrote (specifically, the final figure in the post)
>> is pretty close to what I am looking for.
>>
>> Emmanuel's suggestion of using ltt.plots.coords might also work, and it
>> might be easier to input that data into ggplot if I could find some way to
>> merge the various matrices.
>>
>> Russell
>>
>> On Fri, Oct 27, 2023 at 10:04 AM William Gearty
>> wrote:
>>
>>> You could also map your states (in this case, taxonomic groupings) onto
>>> your tree, then make an ltt plot with phytools::ltt(). Liam has a great
>>> blog post about it here:
>>> http://blog.phytools.org/2022/08/lineage-through-time-plots-for.html.
>>>
>>> Best,
>>> Will
>>>
>>> --
>>> *William Gearty*
>>> *Lerner-Gray Postdoctoral Research Fellow*
>>> Division of Paleontology
>>> American Museum of Natural History
>>> williamgearty.com
>>>
>>>
>>>
>>> On Thu, Oct 26, 2023 at 9:55 PM Emmanuel Paradis
>>> wrote:
>>>
>>>> Hi Russell,
>>>>
>>>> There are several implementations of LTT plots among several packages,
>>>> so the details certainly differ depending on which one(s) you use.
>>>>
>>>> Maybe you can use the ape function ltt.plot.coords() which returns a
>>>> matrix with 2 columns giving the number of lineages for each node time of
>>>> the tree. I guess you'll need to do a bit of programming to combine the
>>>> different outputs from different trees.
>>>>
>>>> Best,
>>>>
>>>> Emmanuel
>>>>
>>>> - Le 27 Oct 23, à 8:05, Russell Engelman
>>>> a écrit :
>>>>
>>>>> Dear R-Sig-Phylo,
>>>>> I was wondering if there was any way to color-code a
>>>> lineage-through-time plot,
>>>>> to highlight the proportion of taxa at specific intervals that belong
>>>> to a
>>>>> particular clade. I.e., an LTT plot of tetrapod diversity through
>>>> time, and I
>>>>> want to highlight the number of lineages at any one point in time that
>>>> are
>>>>> chondrichthyans, sarcopterygians, lissamphibians, etc. (see attached
>>>> fig. as an
>>>>> example). I figured I can do this by asking R to return all lineages
>>>> that are
>>>>> descendants of a specific node, but am not sure what functions I can
>>>> use to
>>>>> convert the dated tree into an object that can be read into ggplot.
>>>>> Sincerely,
>>>>> Russell
>>>>> ___
>>>>> 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 athttp://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/


[R-sig-phylo] Postdoc in phylogenetic comparative methods at UMiami

2023-10-21 Thread Liam J. Revell
B. Thapa-Magar, 
M.E. Afkhami & C.A. Searcy. (2019) Soil microbiomes underlie population 
persistence of an endangered plant species. American Naturalist. 194: 
488-94.

Past Afkhami and Searcy lab postdocs have gone on to become Tenure-Track 
Faculty, the Director of the Plant Lab at Archbold Biological Station, a 
Geospatial Analyst, an Ecologist for State Conservation Agency, and a 
Marie Curie Postdoctoral Fellow.

-- 
Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


[[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] command for access posterior probabilities values of pie charts obtained from make.simmap

2023-08-22 Thread Liam J. Revell
Dear Felipe.

Assuming your "multiSimmap" object is called /maps/, you can try 
something like /summary(maps)$ace/. That should be a matrix with the 
posterior probabilities from stochastic mapping at all the nodes and 
tips of the tree.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 8/22/2023 11:22 AM, Felipe Rossetto wrote:
> CAUTION: EXTERNAL SENDER
>
> Dear all,
>
> I am trying to find an email where Liam showed a command that allows us to
> get the posterior probability values of pie charts at nodes of trees
> resulting from make.simmap computation, but I failed to find it. Does
> someone know this command? If yes, I am very grateful, if it is possible to
> share it.
>
> Thanks in advance
>
> Felipe
>
>  [[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 athttp://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/


Re: [R-sig-phylo] print circles in the tree nodes coloring by PP

2023-08-11 Thread Liam J. Revell
Dear Pedro.

The common way to accomplish this is using /ape::nodelabels/; however, 
in Chapter 13 of my recent book 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
with Luke Harmon we show how to code it yourself pretty easily. I also 
just posted a solution that you might find useful on my blog: 
http://blog.phytools.org/2023/08/coloring-nodes-by-bootstrap-or-bayesian.html.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 8/10/2023 11:11 AM, Pedro Taucce wrote:
> [You don't often get email frompedrotau...@gmail.com. Learn why this is 
> important athttps://aka.ms/LearnAboutSenderIdentification  ]
>
> CAUTION: EXTERNAL SENDER
>
> Dear all,
>
> I want to plot an ultrametric BEAST2 tree with circles in the nodes colored
> by posterior probability: > 0.95 black, between 0.5 and 0.95 gray and 0.5
> and below no circle (or white). Is that possible? I have tried several
> packages and solutions and the more close solution I figured out is:
>
> # Load the required libraries
> library(treeio)
> library(phytools)
>
> # Set the working directory
> setwd("~/Documents/Anolis_Ana/BEAST2/")
>
> # Read the tree from the file
> my_tree <- read.beast("anolis_ND2.tre")
> posterior <- my_tree$posterior
>
> # Define colors based on posterior probabilities
> colors <- ifelse(posterior > 0.95, "black",
>   ifelse(posterior > 0.5, "darkgray", "white"))
> # Assign colors to tree nodes
> my_tree$node.color <- colors
>
> # Plot the tree with custom node colors
> plot(my_tree,direction="upwards",show.tip.label = F, node.color = colors)
>
> The problem is it colors the branches instead of the nodes. Any ideas?
>
> Thank you very much!
>
> Pedro
> -
> Dr. Pedro P. G. Taucce
> Postdoctoral Researcher (CNPq - PDJ)
> National Institute of Amazonian Research (INPA)
> Av. André Araújo 2936, Petrópolis
> CEP 69.067-375 Manaus, AM
>
> http://www.pedrotaucce.org/
> Lattes<http://lattes.cnpq.br/6010051338306653>  | LinkedIn
> <http://linkedin.com/in/pedrotaucce>  | ResearchGate
> <https://www.researchgate.net/profile/Pedro-Taucce>
>
> Associate Editor, *The Herpetological Journal
> <https://www.thebhs.org/publications/the-herpetological-journal>*
>
> Subject Editor, *Zoosystematics and Evolution<https://zse.pensoft.net/>*
>
> Subject Editor, *Neotropical Biology and Conservation
> <https://neotropical.pensoft.net/>*
>
>  [[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 athttp://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/


Re: [R-sig-phylo] Possible problem with Scaled likelihoods in ancestral state estimation

2023-07-28 Thread Liam J. Revell
Dear Laura.

The marginal ancestral states that you obtained under the "ER" model are 
consistent with a very high backward/forward rate of transitions between 
the two states. If the best-fitting model implies a very high 
transitions rate between the two states, then we can say almost nothing 
about the character condition for internal nodes (hence the "50:50" 
results you see).

Sometimes the /cause/ of very high estimated transition rates in an M/k/ 
model can easily be pinpointed -- for example, a pair of sister taxa 
separated by a short evolutionary distance but with different states. In 
your case, however, I don't see it. Something I've seen on rare 
occasions is a /likelihood surface/ for the M/k/ model that has a sharp 
peak close to zero, but then monotonically increases towards infinite 
(but with a much lower likelihood). Optimization can miss this first 
peak and spuriously convergence on large values for the transition rate 
/q/. One way to identify this problem would be by visualizing the 
likelihood surface. This is pretty easy with /fitMk/ (as shown on my 
blog here 
<http://blog.phytools.org/2021/12/graphing-likelihood-surface-of-fitted-m.html>)
 
-- but if you'd like help, please send me your tree & data (or, even 
better, a saved .RData workspace) and I will take a look at your problem.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 7/28/2023 9:57 AM, Laura Schaedler wrote:
>
>   
> You don't often get email from schaedler.la...@gmail.com. Learn why 
> this is important <https://aka.ms/LearnAboutSenderIdentification>
>   
>
> CAUTION: EXTERNAL SENDER
> Hello all,
>
> I am doing ancestral state estimation analyses with binary traits 
> (presence or absence of a behavior), and while doing so I ran into 
> something that is puzzling me.
>
> For one particular behavior, the results look wrong to me, although R 
> doesn't report any errors during the analyses. Assuming Equal rates is 
> the best model (which I previously assessed with /fitDiscrete/), no 
> matter if I use function /ace/, /make.simmap/, or /ancr/ after 
> /fitMk/, this behavior shows the same values of scaled likelihoods for 
> all ancestral states (0.5, figure attached). Setting marginal = T does 
> not change the results.
>
> When looking at this information plotted on my tree that just doesn't 
> feel right.
> I would expect likelihood values to be greater in some ancestral nodes 
> (those immediately before groups of species where all of them have the 
> behavior) and smaller in others (those before groups without the 
> behavior), not the same likelihood for all of them.
>
> Now, if I choose to run analyses with model = ARD, for /ace /and 
> /ancr/ I get results that look similar to what I would expect 
> (although /make.simmap/ yields the same result as model = ER; figure 
> attached). However, as I have previously run /fitDiscrete/ to 
> determine what is the best model for this behavior, and it was ER, I 
> don't think it makes sense to just choose ARD instead because 'it 
> looks better' (AIC weight ER = 0.74 /vs./ AIC weight ARD = 0.25).
>
> As I have congruent results no matter which functions I use, I wonder 
> if this could be influenced by the way that this behavior is 
> distributed across the tree (too dispersed? - but not a 'problem' that 
> I could fix, it's just how my data is).
> Does anyone have any thoughts on whether my results are correct or if 
> something might be off?
>
> I appreciate your time and effort.
> Best,
> Laura
>
> -- 
> Laura Maria Schaedler
> Doutoranda em Ecologia
> Laboratório de Biologia Evolutiva e Comportamento Animal
> Instituto Nacional de Pesquisas da Amazônia
> http://lattes.cnpq.br/5795430755021849 
> <http://lattes.cnpq.br/5795430755021849>
>
> /PhD student in Ecology
> Evolutionary Biology and Animal Behavior Lab
> National Institute for Amazon Research
> Manaus, AM, Brazil/
>
> ___
> R-sig-phylo mailing list -R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive athttp://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/


Re: [R-sig-phylo] time axis in fan style phylogeny: arcs did not appear in eps file

2023-06-24 Thread Liam J. Revell
Dear Felipe.

It's possible that .eps doesn't support transparency. Have you tried 
plotting to a different device, e.g., .pdf or .png? Alternatively, you 
could undo the transparency by changing /make.transparent("blue",0.1)/ 
for just /"blue"/.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 6/25/2023 12:09 AM, Felipe Rossetto wrote:
>
>   
> You don't often get email from rossetto.fel...@gmail.com. Learn why 
> this is important <https://aka.ms/LearnAboutSenderIdentification>
>   
>
> CAUTION: EXTERNAL SENDER
>
> Dear all,
>
> I am including time axis in a circular phylogeny following this nice post
>
> http://blog.phytools.org/2018/02/another-technique-for-including-time.html 
> <http://blog.phytools.org/2018/02/another-technique-for-including-time.html>
>
> where this loop is used to drawing arcs:
>
> for(iin1:length(obj)){a1<-0a2<-2*pidraw.arc(0,0,radius=obj[i],a1,a2,lwd=1, 
> col=make.transparent("blue",0.1))}
> But when I saved the circular phylogeny in eps for further editing i  
> illustrator, the arcs do not appear, and please, I would like to know 
> if there is a command where it is possible to save the arcs in a eps file.
>
> Thanks a lot
>
> Felipe
[[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] Error in phytools rateshift

2023-05-17 Thread Liam J. Revell
Dear Lior.

> I don't know what property of my data creates this phenomenon. Could 
> this be related to the very broad range of trait values (spanning two 
> orders of magnitude)?
Based on the trait distribution, you might consider transforming your 
data to a log-scale.

> 1. Is there a way to let the software determine the optimal number of 
> rate shifts? Something like what the SURFACE package does with OU models?
/rateshift/ is a likelihood method, so you can fit models with 0, 1, 2, 
3, shifts (and so on), and then compare models using AIC or likelihood 
ratio tests. As we show in Chapter 5 of our book 
(https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r), 
it's even possible to compare the /rateshift/ model to other models, 
such as the "EB" model of /geiger::fitContinuous/, in which the rate of 
evolution changes as a continuous (rather than step) function of time.

> 2. Is it possible to test specific hypotheses, i.e. choose the 
> positions of rate shifts a-priori and calculate the likelihood?
Yes, this corresponds to the method of O'Meara et al. (2006; 
/Evolution/) and is implemented in the /phytools/ function 
/brownie.lite/. In the case of a specific set of hypothesized rate 
shifts, one simply needs to first "paint" these on the tree using the 
/phytools/ function/make.era.map/, and then fit your model of interest 
with /brownie.lite/. This model can *also* be compared to /rateshift/ 
using standard methods. We assume that each /fitted/ (rather than set) 
rate shift would consume one degree of freedom.

> 3. Can I forbid the software from placing shifts on branches leading 
> to clades smaller than X species?
One *could* constrain /rateshift/ to not place a rate shift (say) any 
higher (above the root) than a certain total depth below the tips. 
(/rateshift/ doesn't give this control to the user, but it would be an 
easy feature to add.) On the other hand, I'm not sure I would advise 
doing this simply because a rate shift very close to the present is 
probably indicative of unexplained variance in the tip taxa, rather than 
a genuine temporal rate shift. This could be due, for example, to 
measurement error / uncertainty in the species means for the trait we're 
studying.

I hope this is helpful.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 5/17/2023 10:37 AM, Lior Glick wrote:
> CAUTION: EXTERNAL SENDER
> Hi Liam, and thanks a lot for the quick fix! I highly appreciate it.
> I was able to install from github and the commands now completes 
> successfully. Unfortunately, convergence was not reached with 100 
> iterations. This is probably not surprising if the likelihood surface 
> is flat. I don't know what property of my data creates this 
> phenomenon. Could this be related to the very broad range of trait 
> values (spanning two orders of magnitude)?
>
> Some other questions related to this type of analysis:
> 1. Is there a way to let the software determine the optimal number of 
> rate shifts? Something like what the SURFACE package does with OU models?
> 2. Is it possible to test specific hypotheses, i.e. choose the 
> positions of rate shifts a-priori and calculate the likelihood?
> 3. Can I forbid the software from placing shifts on branches leading 
> to clades smaller than X species?
>
> As far as I can tell, these features were not implemented in 
> rateshift(), so my questions are, whether such analyses have been 
> implemented somewhere else, and do you see any reason why this 
> shouldn't work (if I make the relevant adjustments to your code).
>
> Thanks again.
> Lior
>
> On Tue, May 16, 2023 at 9:48 PM Liam J. Revell  
> wrote:
>
> Hi Lior.
>
> I just updated /rateshift/ in /phytools/ on GitHub with these
> adjustments. It seems to work well and will run your dataset
> without failing.
>
> I did observe an odd thing with the two-rate model for your data
> which is that the likelihood surface for the position of the
> rate-shift seems to be totally flat. I don't know what would give
> your data this property. (In fact, I don't know if I could
> simulate data with this attribute if I tried.) I found this result
> to be so worrying that I took your original tree & simulated data
> containing a single rate shift -- but I found that I was able to
> recover the temporal position of this shift without an enormous
> amount of trouble (though optimization /is/ very slow). This
> suggests that I am not seeing the result of a software bug or an
> idiosyncratic prob

Re: [R-sig-phylo] Error in phytools rateshift

2023-05-16 Thread Liam J. Revell
Hi Lior.

I just updated /rateshift/ in /phytools/ on GitHub with these 
adjustments. It seems to work well and will run your dataset without 
failing.

I did observe an odd thing with the two-rate model for your data which 
is that the likelihood surface for the position of the rate-shift seems 
to be totally flat. I don't know what would give your data this 
property. (In fact, I don't know if I could simulate data with this 
attribute if I tried.) I found this result to be so worrying that I took 
your original tree & simulated data containing a single rate shift -- 
but I found that I was able to recover the temporal position of this 
shift without an enormous amount of trouble (though optimization /is/ 
very slow). This suggests that I am not seeing the result of a software 
bug or an idiosyncratic problem with the tree.

To update /phytools/ from GitHub you just need to have the /devtools/ 
CRAN package installed and then run 
/devtools:::install_github("liamrevell/phytools")/ from the command line 
of an interactive session in R.

If you want to try to visualize the likelihood surface for your rate 
shift, you make want to try this /phytools/ function 
/likeSurface.rateshift/. See more information here: 
http://blog.phytools.org/2016/08/function-to-plot-likelihood-surface-for.html. 
Unfortunately, it is also bound to be pretty slow for larger 
phylogenetic trees.

Let us know if this is of help.

Sincerely, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 5/16/2023 11:09 AM, Liam J. Revell wrote:
> CAUTION: EXTERNAL SENDER
>
> Hi Lior.
>
> I'm working on this for you now.
>
> Basically a lot of optimization iterations with /rateshift/ tend to
> fail, so I'm basically doing two things: (1) preventing a failed
> optimization from causing the whole run to fail using /try/; and (2)
> allowing the user to parallelize the multiple optimization iterations
> using /foreach/.
>
> When I get both of these fixes working I'll push the update to the
> /phytools/ GitHub and you can install the package from there.
>
> All the best, Liam
>
> Liam J. Revell
> Professor of Biology, University of Massachusetts Boston
> Web:http://faculty.umb.edu/liam.revell/
> Book: Phylogenetic Comparative Methods in R
> <https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r>
> (/Princeton University Press/, 2022)
>
>
> On 5/16/2023 9:57 AM, Lior Glick wrote:
>> CAUTION: EXTERNAL SENDER
>> Hello,
>> I am trying to run the rateshift function from phytools on a rather
>> large phylogeny (500 species).
>> With nrates=1 (null model) everything works fine. Using nrates=2 also
>> completed successfully, but did not reach convergence:
>>> bm_multi = rateshift(tree, data, nrates=2)
>>>   bm_multi$convergence
>> 0
>>
>> I therefore tried to increase to niter=100, but then I got the
>> following error:
>> Optimization progress:
>> |Error in solve.default(model2$hessian) :
>>Lapack routine dgesv: system is exactly singular: U[3,3] = 0
>> Calls: rateshift
>> Execution halted
>>
>> I also tried changing to method='REML' and got a slightly different error:
>> Optimization progress:
>> |Error
>> in optimHess(sig2, lik2, tree = tree, x = x) :
>>non-finite finite-difference value [2]
>> Calls: rateshift
>> Execution halted
>>
>> I saw in an old post
>> <http://blog.phytools.org/2017/10/fix-to-optimization-routine-for-non.html>  
>> that
>> a similar issue was fixed in fit.bd
>> <http://fit.bd/>.
>> Is there any fix for rateshit? Alternatively, has anything similar
>> been implemented in another function/package? Or any other suggestion
>> on how to go around this?
>>
>> Thanks!
>>
>> ___
>> R-sig-phylo mailing list -R-sig-phylo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>> Searchable archive athttp://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 athttp://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/


Re: [R-sig-phylo] Error in phytools rateshift

2023-05-16 Thread Liam J. Revell
Hi Lior.

I'm working on this for you now.

Basically a lot of optimization iterations with /rateshift/ tend to 
fail, so I'm basically doing two things: (1) preventing a failed 
optimization from causing the whole run to fail using /try/; and (2) 
allowing the user to parallelize the multiple optimization iterations 
using /foreach/.

When I get both of these fixes working I'll push the update to the 
/phytools/ GitHub and you can install the package from there.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 5/16/2023 9:57 AM, Lior Glick wrote:
> CAUTION: EXTERNAL SENDER
> Hello,
> I am trying to run the rateshift function from phytools on a rather 
> large phylogeny (500 species).
> With nrates=1 (null model) everything works fine. Using nrates=2 also 
> completed successfully, but did not reach convergence:
> > bm_multi = rateshift(tree, data, nrates=2)
> > bm_multi$convergence
> 0
>
> I therefore tried to increase to niter=100, but then I got the 
> following error:
> Optimization progress:
> |Error in solve.default(model2$hessian) :
>   Lapack routine dgesv: system is exactly singular: U[3,3] = 0
> Calls: rateshift
> Execution halted
>
> I also tried changing to method='REML' and got a slightly different error:
> Optimization progress:
> |Error
>  
> in optimHess(sig2, lik2, tree = tree, x = x) :
>   non-finite finite-difference value [2]
> Calls: rateshift
> Execution halted
>
> I saw in an old post 
> <http://blog.phytools.org/2017/10/fix-to-optimization-routine-for-non.html> 
> that 
> a similar issue was fixed in fit.bd 
> <http://fit.bd/>. 
> Is there any fix for rateshit? Alternatively, has anything similar 
> been implemented in another function/package? Or any other suggestion 
> on how to go around this?
>
> Thanks!
>
> ___
> R-sig-phylo mailing list -R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive athttp://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/


Re: [R-sig-phylo] Using results of make.simmap to color edges by most likely state

2023-04-18 Thread Liam J. Revell
Dear Rafa & list.

Here is a solution: 
http://blog.phytools.org/2023/04/coloring-edges-of-plotted-tree-by.html.

I applied it to marginal ancestral states obtained using the new 
/phytools/ method /ancr/, but the same principle could be used with a 
summary of stochastic maps. I will make a subsequent follow-up post 
covering that.

Let us know if this works!

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 4/18/2023 1:21 PM, Liam J. Revell wrote:
>
> Dear Rafa.
>
> Just a quick comment re the comment "I also noticed that results of 
> simmap have one extra edge than the tree
> itself"
>
> From ancestral state reconstruction (marginal reconstruction or a 
> summary of stochastic mapping) you'll end up with a matrix containing 
> a number of rows equal to the number of internal nodes of the tree, or 
> (in your case) the number of tips + the number of internal nodes. In 
> your case, you're interested in coloring all the edges of the tree, 
> which will be one fewer than the number of nodes + tips. This is 
> because every node (or tip) is preceded by one edge: except for the 
> root. Likewise, the order of your ancestral state matrix is by node 
> index; whereas the edges of the tree can have a variety of different 
> orders.
>
> Let me post a solution to my blog quickly & then I'll share it with 
> this group.
>
> All the best, Liam
>
> Liam J. Revell
> Professor of Biology, University of Massachusetts Boston
> Web: http://faculty.umb.edu/liam.revell/
> Book: Phylogenetic Comparative Methods in R 
> <https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
> (/Princeton University Press/, 2022)
>
>
> On 4/18/2023 10:59 AM, Rafael S Marcondes wrote:
>> CAUTION: EXTERNAL SENDER
>>
>> Hi all,
>>
>> I would like to use the results of make.simmap to plot the edges of a tree
>> by their most likely state. (Because my tree is really large and plotting
>> pie charts at the nodes gets really polluted.)
>>
>> So first I took $ace from the results to describe.simmap and added a column
>> for the most likely state, and another column for the color for plotting:
>>
>>> head(ace.max.lik)
>>   CLEL M P SL maxlikcol
>> 6621  0 0.000 0.002 0.998  0  P darkgoldenrod3
>> 6622  0 0.000 0.001 0.999  0  P darkgoldenrod3
>> 6623  0 0.000 0.007 0.993  0  P darkgoldenrod3
>> 6624  0 0.000 0.004 0.996  0  P darkgoldenrod3
>> 6625  0 0.000 0.001 0.999  0  P darkgoldenrod3
>> 6626  0 0.001 0.020 0.979  0  P darkgoldenrod3
>>
>> And I separately did that for the tips. (Which I also estimated, since they
>> had uncertainty in the original data):
>>
>>   CL EL M P SL maxlikcol
>> Rhea_americana  0.0000.000   0.000   1.000
>> 0.000  P darkgoldenrod3
>> Rhea_pennata0.0000.000   0.008   0.992
>> 0.000  P darkgoldenrod3
>> Casuarius_casuarius 0.0000.004   0.074   0.922
>> 0.000  P darkgoldenrod3
>> Casuarius_bennetti  0.0000.010   0.132   0.858
>> 0.000  P darkgoldenrod3
>> Dromaius_novaehollandiae0.0010.000   0.045   0.953
>> 0.001  P darkgoldenrod3
>> Apteryx_owenii  0.0000.000   0.995   0.005
>> 0.000  M   blue
>>
>> Then I tried to plot the edges by color using ape, putting the tips in
>> front of the internal nodes because that's the typical order of tree$edges:
>>
>> plot.phylo(x=m.ard[[1]],cex=0.2,edge.width=0.01,type='fan',
>> edge.lty=3,edge.color=c(tip.max.lik$col, ace.max.lik$col))
>>
>> It plots a beautiful plot, by the colors are mismatched to the edges. I
>> also noticed that results of simmap have one extra edge than the tree
>> itself:
>>
>>> nrow(md.ard$ace)
>> [1] 13239
>>
>>> nrow(m.ard[[1]]$edge)
>> [1] 13238
>>
>> I suspect that's that one extra edge that's causing the mismatch, but I
>> can't figure out where it's coming from, or how to fix it. Any tips or
>> workarounds to accomplish this task, which I might be overcomplicating?
>>
>> PS: I'm well aware that it's a bad idea to "flatten" the likelihoods of
>

Re: [R-sig-phylo] Estimating the posterior prob of the ancestral states of two nodes

2023-03-05 Thread Liam J. Revell
Dear Sishuo.

Yes, I think this would be a good way to do this.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 3/5/2023 9:49 PM, Sishuo Wang wrote:
> CAUTION: EXTERNAL SENDER
> Dear all,
>
> I would like to ask for a little help from you.
>
> I wish to estimate the posterior probability that *two* ancestral 
> nodes take particular states, given the observations of discrete trait 
> at the tips of a tree. I was wondering if using a *SCM* approach 
> described below would work.
>
>
> Inline image
>
>
> If so, I think this can be easily done using /make.simmap/ from 
> phytools where I would like to assign an equal prior on the root to 
> all states.
>
> Does the above make sense? Any insights are highly appreciated!
>
> Thanks,
> Sishuo
> 
> Postdoctoral Fellow, Haiwei Luo Lab
> Room 103A, F. S. Li Marine Science Laboratory, The Chinese University 
> of Hong Kong
> Shatin, New Territories, Hong Kong
>
>
> ___
> R-sig-phylo mailing list -R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive athttp://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/


Re: [R-sig-phylo] NAMESPACE issue

2023-02-28 Thread Liam J. Revell
Hi Kevin.

Sorry, this is pretty much all my fault. The definition of the S3 method 
/rescale/ now lives in /phytools/. /rescale/ is still exported by the 
namespace of /geiger/ on CRAN, so I suspect you're working with the 
GitHub version.

The easiest thing to do is add /phytools (>1.5-1)/ to *Depends:* in your 
DESCRIPTION file and /importFrom(phytools, rescale)/ to NAMESPACE. (This 
should work immediately because currently on CRAN /rescale/ is defined & 
exported by both /phytools/ and /geiger/.)

Please let me know if that works.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 2/28/2023 9:33 AM, Kevin Arbuckle wrote:
> CAUTION: EXTERNAL SENDER
>
> Hi Emmanuel,
>
> Strangely enough it was a Windows machine I used to check it and it runs 
> fine. The log files from the checks all come back fine except for the note in 
> my original email, but as the info in the log file only say what the problem 
> is but gives no indication how to address it in this case I'm struggling with 
> it. I assume it is something to do with the NAMESPACE file (or, plausibly, 
> the DESCRIPTION file) but as I can't figure out what's going on and nothing 
> has changed with imported functions from the geiger package I was hoping 
> someone might be able to spot issues in those files, or maybe has come across 
> a similar issue and knows how to resolve it.
>
> Cheers,
> Kev
>
> Dr Kevin Arbuckle
> Athro Cyswllt (Darllenydd) mewn Biowyddorau (Bioleg Esblygiadol) / Associate 
> Professor (Reader) in Biosciences (Evolutionary Biology)
> Adran Biowyddorau / Department of Biosciences
> Cyfadran Gwyddoniaeth a Pheirianneg / Faculty of Science and Engineering
> Prifysgol Abertawe  / Swansea University
> Abertawe / Swansea
> SA2 8PP
> UK
>
> Rhowch wybod i ni os hoffech dderbyn eich gohebiaeth yn Gymraeg. Rydym yn 
> croesawu gohebiaeth yn Gymraeg neu yn Saesneg. Ni fydd gohebu yn Gymraeg yn 
> arwain at oedi.
>
> -Original Message-
> From: Emmanuel Paradis
> Sent: 28 February 2023 11:03
> To: Kevin Arbuckle
> Cc: r-sig-phylo
> Subject: Re: [R-sig-phylo] NAMESPACE issue
>
> Hi Kevin,
>
> Do you run the checks of a new version of windex on this site:
>
> win-builder.r-project.org/
>
> ? It runs the checks both on Debian and Windowns with several choices of R 
> versions, and you can access the detailed log files.
>
> Best,
>
> Emmanuel
>
> - Le 28 Fév 23, à 17:38, arbucklekevin.arbuc...@swansea.ac.uk  a écrit :
>
>> Hi all,
>>
>> I realise this might not be strictly a phylogeny-related issue, but it
>> might be as it relates to geiger and in any case the CRAN Core Team
>> have left me at an impasse trying to get an update to windex through
>> to CRAN (just repeating the error message then ignoring messages
>> asking for clarification or advice on fixing it). Hopefully it's relevant 
>> enough to this list to be OK.
>>
>> When trying to submit an update to the package, all Debian checks are
>> coming back fine, but there is one note in the Windows checks that is
>> stopping the process. The note reads:-
>>
>> "windex: no visible global function definition for 'rescale'
>> Undefined global functions or variables:
>>   rescale"
>>
>> However, geiger (the package which contains rescale) is listed as a
>> dependency in the DESCRIPTION and is imported in the NAMESPACE, so
>> rescale should definitely be there. Combined with the lack of issue
>> flagged by Debian checks (which presumably would also check basic
>> things like 'do the functions exist') and the fact that this issue
>> hasn't occurred in previous version submitted to CRAN (nothing has
>> changed with respect to the use of the rescale function), I am at a loss.
>>
>> In case it helps, the contents of the DESCRIPTION and NAMESPACE files
>> are as
>> follows:-
>>
>> DESCRIPTION file:
>> Package: windex
>> Type: Package
>> Title: Analysing Convergent Evolution using the Wheatsheaf Index
>> Version: 2.0.4
>> Date: 2023-02-23
>> Author: Kevin Arbuckle and Amanda Minter
>> Maintainer: Kevin Arbuckle
>> kevin.arbuc...@swansea.ac.uk<mailto:kevin.arbuc...@swansea.ac.uk>
>> Description: Analysing convergent evolution using the Wheatsheaf
>> index, described in Arbuckle et al. (2014) > 10./2041-210X.12195>, and some other unrelated but perhaps useful 
>> functions.
>> License: GPL-2

Re: [R-sig-phylo] Extract and summarise internal branch lengths for different samples

2023-01-18 Thread Liam J. Revell
I'm not sure how it scales to a large tree, though! For an example 
phylogeny of 1,000 tips and a clade of 116 species it ran in the blink 
of an idea, so I suppose it's probably OK.


Obviously, I meant to write "blink of an eye." It's been a long day.

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)



On 1/18/2023 5:19 PM, Liam J. Revell wrote:

CAUTION: EXTERNAL SENDER

Dear Jhonny.

If I understand your problem correctly, this will work in /theory/ -- 
shown for clade/t5/ through /t9/ in your example.


This works when your tips in a sample form a /clade/ -- but will 
otherwise sum the internal edges leading to the internal nodes of all 
taxa in a set, while not counting any edge twice. I think that's what 
you want.


library(phytools)
library(phangorn)
## set tips
tips<-c("t9","t7","t5")
## get ancestors, leaving out the global root
anc<-setdiff(Reduce(union,
    lapply(sapply(tips,function(x,y) which(x==y),
    y=samptree$tip.label),FUN=Ancestors,x=samptree)),
    Ntip(samptree)+1)
## get sum of edge lengths
summed.edges<-sum(samptree$edge.length[sapply(anc,
    function(x,y) which(x==y),
    y=samptree$edge[,2])])
summed.edges ## this is your value

I'm not sure how it scales to a large tree, though! For an example 
phylogeny of 1,000 tips and a clade of 116 species it ran in the blink 
of an idea, so I suppose it's probably OK.


Let me know if it works for you.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpress.princeton.edu%2Fbooks%2Fphylogenetic-comparative-methods-in-r=05%7C01%7Cliam.revell%40umb.edu%7C6e8084093e574f7693cf08daf9a21fbe%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638096771974920509%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=0Fu38rJ14JGirC0URfQYnpyeJe1M9jpTfkisaMS6ymA%3D=0> 
(/Princeton University Press/, 2022)



On 1/18/2023 4:56 PM, Jhonny Capichoni Massante wrote:

CAUTION: EXTERNAL SENDER

Dear colleagues,

I would like to ask for a little help from you.

I have a phylogenetic tree with nine taxa and three samples (see 
figure below). Each sample has three taxa from the phylogeny. I am 
interested in extracting the internal branch lengths (corresponding 
to the ancestors of all tips) that are present in each sample 
(represented by the corresponding tips) and summarising them for each 
sample (e.g., summing all internal branch lengths on samples). Here 
is a rough reproducible example until getting all branch lengths:


#number of taxa

ntax <- 9

#get a phylogeny with 9 taxa

set.seed(999)

samptree <- rcoal(ntax)

#color fot the tips according to their occurrence on samples

colors <- c("blue", "blue", "blue", "green", "green", "green", 
"purple", "purple", "purple")


#plot the tree and branch lengths with rounded values

plot(samptree, label.offset = 0.2, tip.color = colors)

edgelabels(round(samptree$edge.length, 2),  cex=1, width = 1, height 
= 0.1,


frame = "none", bg = NULL, col = "red", offset = 1.5, adj = c(-0.1, 
-0.2))


#matrix with samples based on the phylogeny and three samples as in 
the figure


sample <- matrix(data  = 
c(1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1),


 nrow = 3,

 ncol = 9,

 dimnames = list(c("purple", "green", "blue"),

c("t4", "t3", "t6", "t8", "t2", "t1", "t9", "t7", "t5")),

 byrow = TRUE)

#get all branch lengths from the tree

all_branch_lenghts <- round(samptree$edge.length, 2)

From here, I could not separate internal branch lengths to tip 
lengths and trace these internal branches on samples based on their 
occurrence. Does anyone have an idea to do such a thing?


The real phylogeny has around 6,000 tips and the real number of 
samples is around 130. Thank you very much for any help!


Here is the figure that exemplifies what I want to do:

Best regards,

--

*Dr Jhonny Capichoni Massante*

Postdoctoral Research Fellow in Macroecology

Universidade de São Paulo

Instituto de Biociências

Departamento de Ecologia

Laboratório de Ecologia de Florestas Tropicais

Twitter 
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2FJCMassante=05%7C01%7Cliam.revell%40umb.edu%7C6e8084093e574f7693cf08daf9a21fbe%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7

Re: [R-sig-phylo] Extract and summarise internal branch lengths for different samples

2023-01-18 Thread Liam J. Revell

Dear Jhonny.

If I understand your problem correctly, this will work in /theory/ -- 
shown for clade/t5/ through /t9/ in your example.


This works when your tips in a sample form a /clade/ -- but will 
otherwise sum the internal edges leading to the internal nodes of all 
taxa in a set, while not counting any edge twice. I think that's what 
you want.


library(phytools)
library(phangorn)
## set tips
tips<-c("t9","t7","t5")
## get ancestors, leaving out the global root
anc<-setdiff(Reduce(union,
    lapply(sapply(tips,function(x,y) which(x==y),
    y=samptree$tip.label),FUN=Ancestors,x=samptree)),
    Ntip(samptree)+1)
## get sum of edge lengths
summed.edges<-sum(samptree$edge.length[sapply(anc,
    function(x,y) which(x==y),
    y=samptree$edge[,2])])
summed.edges ## this is your value

I'm not sure how it scales to a large tree, though! For an example 
phylogeny of 1,000 tips and a clade of 116 species it ran in the blink 
of an idea, so I suppose it's probably OK.


Let me know if it works for you.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)



On 1/18/2023 4:56 PM, Jhonny Capichoni Massante wrote:

CAUTION: EXTERNAL SENDER

Dear colleagues,

I would like to ask for a little help from you.

I have a phylogenetic tree with nine taxa and three samples (see 
figure below). Each sample has three taxa from the phylogeny. I am 
interested in extracting the internal branch lengths (corresponding to 
the ancestors of all tips) that are present in each sample 
(represented by the corresponding tips) and summarising them for each 
sample (e.g., summing all internal branch lengths on samples). Here is 
a rough reproducible example until getting all branch lengths:


#number of taxa

ntax <- 9

#get a phylogeny with 9 taxa

set.seed(999)

samptree <- rcoal(ntax)

#color fot the tips according to their occurrence on samples

colors <- c("blue", "blue", "blue", "green", "green", "green", 
"purple", "purple", "purple")


#plot the tree and branch lengths with rounded values

plot(samptree, label.offset = 0.2, tip.color = colors)

edgelabels(round(samptree$edge.length, 2),  cex=1, width = 1, height = 
0.1,


frame = "none", bg = NULL, col = "red", offset = 1.5, adj = c(-0.1, -0.2))

#matrix with samples based on the phylogeny and three samples as in 
the figure


sample <- matrix(data  = 
c(1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1),


 nrow = 3,

 ncol = 9,

 dimnames = list(c("purple", "green", "blue"),

c("t4", "t3", "t6", "t8", "t2", "t1", "t9", "t7", "t5")),

 byrow = TRUE)

#get all branch lengths from the tree

all_branch_lenghts <- round(samptree$edge.length, 2)

From here, I could not separate internal branch lengths to tip lengths 
and trace these internal branches on samples based on their 
occurrence. Does anyone have an idea to do such a thing?


The real phylogeny has around 6,000 tips and the real number of 
samples is around 130. Thank you very much for any help!


Here is the figure that exemplifies what I want to do:

Best regards,

--

*Dr Jhonny Capichoni Massante*

Postdoctoral Research Fellow in Macroecology

Universidade de São Paulo

Instituto de Biociências

Departamento de Ecologia

Laboratório de Ecologia de Florestas Tropicais

Twitter 
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2FJCMassante=05%7C01%7Cliam.revell%40umb.edu%7C0c16828ff4744a54578608daf99ef426%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C638096758395977858%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=27eVtIcGYjCmKshgu%2FYA1A6rcYUZRVlqT6MN4k7ojEc%3D=0> 
| RG 
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.researchgate.net%2Fprofile%2FJhonny-Massante=05%7C01%7Cliam.revell%40umb.edu%7C0c16828ff4744a54578608daf99ef426%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C638096758395977858%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=z2ElWX3LQXi9Aiadb0d%2B7bgCQeiB33qcXAtVTPa5rXw%3D=0> 
| LinkedIn 
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.linkedin.com%2Fin%2Fjhonny-capichoni-massante%2F=05%7C01%7Cliam.revell%40umb.edu%7C0c16828ff4744a54578608daf99ef426%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C638096758395977858%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV

[R-sig-phylo] phytools GitHub version

2023-01-17 Thread Liam J. Revell
Dear colleagues.

Anyone updating phytools from GitHub 
(https://github.com/liamrevell/phytools) -- for instance, using the 
remotes or devtools packages -- should be aware that this update will 
FAIL unless you first update ape from GitHub.

To update both ape and phytools to their GitHub development versions, 
users should first install the "remotes" CRAN package and then run:

|remotes::install_github("emmanuelparadis/ape") 
remotes::install_github("liamrevell/phytools")|

from the command prompt in R.

The CRAN ape & phytools packages also still work correctly together. 
Please let me know if you run into any problems with this while 
Emmanuel, Klaus, & I try to get both ape & phytools updated on CRAN.

That is all. Sincerely, Liam

-- 
Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


[[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] R phylogenetics workshop at UMass-Boston

2023-01-15 Thread Liam J. Revell
Dear colleagues.

Luke Harmon & I will be offering a graduate/postdoctoral level 
phylogenetic comparative methods in R workshop at the University of 
Massachusetts Boston from March 2nd through 5th, 2023 (four full 
workshop days).

Admission is limited to about 15 participants. Applications are welcome 
from all career stages, but we anticipate that most accepted applicants 
will be early career researchers (ECRs): graduate students & 
postdoctoral scholars.

We are very fortunate to be able to offer fairly generous participant 
support to accepted applicants. Air travel & hotel lodging in Boston 
will be fully covered for all (non-local) workshop participants. Our 
travel budget is finite; however, non-U.S. ECRs are nonetheless 
encouraged to apply & will be considered for travel support.

If this interests you or might benefit members of your lab, please by 
all means apply <http://www.phytools.org/umb2023/>! More information and 
an application form can be found at the following URL: 
http://www.phytools.org/umb2023/. Please don't hesitate to contact Luke 
or I with any questions.

The application deadline is *Friday, January 20th*.

Thanks everyone! All the best, Liam

-- 
Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


[[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] Error in phytools - locate.fossil?

2023-01-11 Thread Liam J. Revell
Dear Lindsey.

You should not adjust tol at all -- use the default. Sorry I wasn't 
clear on that. It is just an (arbitrarily) small value that helps us 
avoid evaluating solutions that are not "legal." (E.g., in your case, 
trying to attach a tip to an edge /below/ its parent node.)

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/


On 1/11/2023 7:58 AM, Lindsey Dehaan wrote:
> CAUTION: EXTERNAL SENDER
> Hey Liam,
>
> Thanks alot! I really appreciate it! I installed the new version and I 
> saw your edits to the locate.fossil function on github.
>
> I just have one more question, I am new to the tol argument and I am 
> not sure what the default should be set to. I've set it to a couple 
> numbers (ex, 0.5, 0.1 0.01) and my fossil now places correctly but 
> could you possibly tell me what this argument means and what I should 
> be setting it to?
>
> Best,
> Lindsey
>
> On Tue, Jan 10, 2023 at 6:07 PM Liam J. Revell  
> wrote:
>
> Dear Lindsey.
>
> Thanks for sharing the code & data. It made the problem pretty
> easy to resolve.
>
> Turns out it is a simple numerical precision issue.
>
> I have resolved it by adding an optional argument tolwith a
> sensible default value which most users can probably ignore (but
> can set to tol=0 if they want to guarantee the current behavior of
> locate.fossil). I pushed this update to /GitHub/:
> 
> https://github.com/liamrevell/phytools/commit/f1dcddbf56a7ae6bf9bece223cd6a949a57eac5f
> 
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fliamrevell%2Fphytools%2Fcommit%2Ff1dcddbf56a7ae6bf9bece223cd6a949a57eac5f=05%7C01%7Cliam.revell%40umb.edu%7C6422b30bf70147843d2708daf3d39a24%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638090387402381909%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=%2FJXMpg7Z1i%2BFfRVldtWd4dT7ITCbagH3wUZ01E%2BERhI%3D=0>.
>
> To obtain this updated version of /phytools/ I recommend
> installing the package /remotes/ and then running (from a fresh R
> session):
>
>     remotes::install_github("liamrevell/phytools")
>
> Let us know if this fixes everything!
>
> All the best, Liam
>
> Liam J. Revell
> Professor of Biology, University of Massachusetts Boston
> Web: http://faculty.umb.edu/liam.revell/
> 
> <https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Ffaculty.umb.edu%2Fliam.revell%2F=05%7C01%7Cliam.revell%40umb.edu%7C6422b30bf70147843d2708daf3d39a24%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638090387402381909%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=8bQ5oeB%2F%2B6HEvtu%2FdPrbzGpsorPxFPesbq%2FHm0WAOIM%3D=0>
>
>
> On 1/10/2023 4:42 PM, Lindsey Dehaan wrote:
>> CAUTION: EXTERNAL SENDER
>> Hey Liam,
>>
>> Thanks for the fast response.
>>
>> Attached is a simple script with the fossil I am having problems
>> with. All the files should be attached. Let me know if I missed a
>> file or you need anything else.
>>
>> I greatly appreciate your help on this. I have been stuck on this
>> for a while now.
>>
>> Best,
>> Lindsey
>>
>>
>> On Tue, Jan 10, 2023 at 4:23 PM Liam J. Revell
>>  wrote:
>>
>> Dear Lindsey.
>>
>> Thanks for posting your code, but would you mind sending me
>> (it can be off-list) an example in which I can also pull your
>> data & tree and re-run it with the real data that is
>> generating the error? This might be helpful in getting to the
>> bottom of your issue. Thanks!
>>
>> All the best, Liam
>>
>> Liam J. Revell
>> Professor of Biology, University of Massachusetts Boston
>> Web: http://faculty.umb.edu/liam.revell/
>> 
>> <https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Ffaculty.umb.edu%2Fliam.revell%2F=05%7C01%7Cliam.revell%40umb.edu%7C6422b30bf70147843d2708daf3d39a24%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638090387402381909%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=8bQ5oeB%2F%2B6HEvtu%2FdPrbzGpsorPxFPesbq%2FHm0WAOIM%3D=0>
>>
>>
>> On 1/10/2023 4:20 PM, Lindsey Dehaan wrote:
>>> CAUTION: EXTERNAL SENDER
>>>
>>> Hi all,
>>>
>>> I have a question regarding the phytools fun

Re: [R-sig-phylo] Error in phytools - locate.fossil?

2023-01-10 Thread Liam J. Revell
Dear Lindsey.

Thanks for sharing the code & data. It made the problem pretty easy to 
resolve.

Turns out it is a simple numerical precision issue.

I have resolved it by adding an optional argument tolwith a sensible 
default value which most users can probably ignore (but can set to tol=0 
if they want to guarantee the current behavior of locate.fossil). I 
pushed this update to /GitHub/: 
https://github.com/liamrevell/phytools/commit/f1dcddbf56a7ae6bf9bece223cd6a949a57eac5f.

To obtain this updated version of /phytools/ I recommend installing the 
package /remotes/ and then running (from a fresh R session):

remotes::install_github("liamrevell/phytools")

Let us know if this fixes everything!

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/


On 1/10/2023 4:42 PM, Lindsey Dehaan wrote:
> CAUTION: EXTERNAL SENDER
> Hey Liam,
>
> Thanks for the fast response.
>
> Attached is a simple script with the fossil I am having problems with. 
> All the files should be attached. Let me know if I missed a file or 
> you need anything else.
>
> I greatly appreciate your help on this. I have been stuck on this for 
> a while now.
>
> Best,
> Lindsey
>
>
> On Tue, Jan 10, 2023 at 4:23 PM Liam J. Revell  
> wrote:
>
> Dear Lindsey.
>
> Thanks for posting your code, but would you mind sending me (it
> can be off-list) an example in which I can also pull your data &
> tree and re-run it with the real data that is generating the
> error? This might be helpful in getting to the bottom of your
> issue. Thanks!
>
> All the best, Liam
>
> Liam J. Revell
> Professor of Biology, University of Massachusetts Boston
> Web: http://faculty.umb.edu/liam.revell/
> 
> <https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Ffaculty.umb.edu%2Fliam.revell%2F=05%7C01%7Cliam.revell%40umb.edu%7C9a241369fe2542ce1c0408daf3538a5b%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089837406791068%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=Wb5zlO%2B26s185WebtNT7rh0o1w1yy0KAJg%2BzTBsycNQ%3D=0>
>
>
> On 1/10/2023 4:20 PM, Lindsey Dehaan wrote:
>> CAUTION: EXTERNAL SENDER
>>
>> Hi all,
>>
>> I have a question regarding the phytools function locate.fossil().
>>
>> I have had a lot of success with this function but there are two fossils 
>> of
>> mine that the function does not like. I give the function my phylogeny, a
>> max and min age for the fossil, and the edge for the fossil to be placed
>> on. So I basically just want the function to estimate the branch length
>> subtending the fossil and the position of where the node subtending the
>> fossil attaches in the phylogeny.
>>
>> For two of my fossils I get the following error.
>>
>>
>>
>> *Error in bind.tree(tree, tip, where = where, position = pp) :   
>> 'position'
>> is larger than the branch length*
>>
>> The function does not seem to like my edge constraint with these two
>> fossils. When I remove my edge constraint it works and the fossil is 
>> placed
>> in the correct time interval but just on a different edge estimated using
>> ML. For one of my fossils, the edge I place my fossil on ranges from 42 
>> mya
>> to 4 mya and the age range for the fossil is between 33 and 28 mya. I am
>> confused why the function does not like the edge constraints I am giving
>> it. The error that I receive makes me believe that the position the
>> function is estimating for my fossil may be older than the edge 
>> constraint
>> I am giving it or I could just be missing something, most likely the
>> latter...
>>
>> Below is my code. This code works for almost all my fossils except for 
>> two
>> of them.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *fossil_to_add<-fossil_trait_data[13,] 
>> locate_fossil_data<-rbind(extant_data,
>> fossil_to_add) # used this data in
>> 
>> locate.fossil()extant_sister_clade<-rownames(extant_data)[c(grep(fossil_info[13,7],
>> rownames(extant_data)), grep(fossil_info[13,8],
>> rownames(extant_data)))]mrca<-getMRCA(tree,
>> extant_sister_clade)edge<-mrcamin_time<- depth - fossil_info[13,4] # 
>> depth
>> is the root age of the phylogeny max_time<-depth - fossil_info[13,3] # 
>> the
>> max and min ages are positive numbers time_constrain

Re: [R-sig-phylo] Error in phytools - locate.fossil?

2023-01-10 Thread Liam J. Revell
Dear Lindsey.

Thanks for posting your code, but would you mind sending me (it can be 
off-list) an example in which I can also pull your data & tree and 
re-run it with the real data that is generating the error? This might be 
helpful in getting to the bottom of your issue. Thanks!

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/


On 1/10/2023 4:20 PM, Lindsey Dehaan wrote:
> CAUTION: EXTERNAL SENDER
>
> Hi all,
>
> I have a question regarding the phytools function locate.fossil().
>
> I have had a lot of success with this function but there are two fossils of
> mine that the function does not like. I give the function my phylogeny, a
> max and min age for the fossil, and the edge for the fossil to be placed
> on. So I basically just want the function to estimate the branch length
> subtending the fossil and the position of where the node subtending the
> fossil attaches in the phylogeny.
>
> For two of my fossils I get the following error.
>
>
>
> *Error in bind.tree(tree, tip, where = where, position = pp) :   'position'
> is larger than the branch length*
>
> The function does not seem to like my edge constraint with these two
> fossils. When I remove my edge constraint it works and the fossil is placed
> in the correct time interval but just on a different edge estimated using
> ML. For one of my fossils, the edge I place my fossil on ranges from 42 mya
> to 4 mya and the age range for the fossil is between 33 and 28 mya. I am
> confused why the function does not like the edge constraints I am giving
> it. The error that I receive makes me believe that the position the
> function is estimating for my fossil may be older than the edge constraint
> I am giving it or I could just be missing something, most likely the
> latter...
>
> Below is my code. This code works for almost all my fossils except for two
> of them.
>
>
>
>
>
>
>
>
>
>
>
> *fossil_to_add<-fossil_trait_data[13,] locate_fossil_data<-rbind(extant_data,
> fossil_to_add) # used this data in
> locate.fossil()extant_sister_clade<-rownames(extant_data)[c(grep(fossil_info[13,7],
> rownames(extant_data)), grep(fossil_info[13,8],
> rownames(extant_data)))]mrca<-getMRCA(tree,
> extant_sister_clade)edge<-mrcamin_time<- depth - fossil_info[13,4] # depth
> is the root age of the phylogeny max_time<-depth - fossil_info[13,3] # the
> max and min ages are positive numbers time_constraints<-c(max_time,
> min_time)locate_fossil_tree<-locate.fossil(tree, locate_fossil_data,
> time.constraint=time_constraints,edge.constraint=edge, plot=TRUE)*
>
> Any help or advice, would be greatly appreciated!
>
> Best,
> Lindsey
> --
> Lindsey DeHaan
> Ph.D. Candidate
> Department of Earth and Environmental Sciences
> University of Michigan
>
>  [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list -R-sig-phylo@r-project.org
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylo=05%7C01%7Cliam.revell%40umb.edu%7C27cb8a8eb3dc4651433008daf35090b6%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089824617167715%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=tYwyCJW%2BdLBEpy4Tn290%2BXqmQNkV6%2FdGGsJmgnBXUcU%3D=0
> Searchable archive 
> athttps://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2F=05%7C01%7Cliam.revell%40umb.edu%7C27cb8a8eb3dc4651433008daf35090b6%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089824617167715%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=AGbpdEbfZDhgeTNHnQsgzRkj2%2FngM5Ud%2FCDVEFDCvnw%3D=0
[[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] Counting and getting the age of cherries in a tree

2023-01-09 Thread Liam J. Revell
Hi Ivan.

Try this simple code:

## load packages
library(phytools)
library(phangorn)
## get tips descended from each node
dd<-Descendants(tree,node=1:tree$Nnode+Ntip(tree),
     type="tips")
names(dd)<-1:tree$Nnode+Ntip(tree)
## get the NUMBER of tips from each node
nn<-sapply(dd,length)
## get corresponding node indices
nodes<-as.numeric(names(nn[which(nn==2)]))
## compute their heights above root
heights<-setNames(sapply(nodes,nodeheight,
     tree=tree),nodes)

This scales well up to trees with 1,000 or more tips IME. It gives you 
the /heights/ above the root of each node with two descendants (cherry). 
If your tree is ultrametric, to get the /depth/ you would just subtract 
this value from the total height of the tree.

Let me know if it works!!

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/


On 1/9/2023 5:37 PM, Ivan Magalhaes wrote:
> CAUTION: EXTERNAL SENDER
>
> Hi all,
> Perhaps a dumb question, but is there an easy way to count the number of 
> cherries in a given tree, and fetch their ages? (i.e. all the nodes with 
> exactly two descendants)
> Thanks! Best,Ivan
> --
> Dr. Ivan L. F. Magalhaes
>
> Postdoctoral fellow — División AracnologíaMuseo Argentino de Ciencias 
> Naturales "Bernardino Rivadavia"
> Av. Ángel Gallardo 470, C1405DJR, Buenos Aires, Argentina+54 11 4982-8370 
> ext. 169Website | ResearchGate | Twitter |iNaturalist | Lattes | CV-Ar | 
> ORCID | GitHub
>  [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list -R-sig-phylo@r-project.org
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylo=05%7C01%7Cliam.revell%40umb.edu%7C58b9f271e0124a5ff56a08daf292212b%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089006703316956%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=xpf1hbFEEJFsi%2BGI3in6yfxNbiThSss5ivqEeiuQS%2BY%3D=0
> Searchable archive 
> athttps://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2F=05%7C01%7Cliam.revell%40umb.edu%7C58b9f271e0124a5ff56a08daf292212b%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089006703316956%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=wcDMnSGFSQotMzfg05l83bCltDgOkk7SL%2F94LSNhiXQ%3D=0
[[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] fitContinuous in Geiger

2022-12-14 Thread Liam J. Revell

Dear William.

The sigma^2 parameter in a fitted Brownian model is a rate in the sense 
that it is the rate at which variation (variance) would be expected to 
accumulate per unit of time among a set of lineages that were evolving 
according to a random diffusion (Brownian) process. If you think it 
would be helpful, I can send you the corresponding section from a recent 
book I co-authored with Luke Harmon in which Brownian motion (and, 
specifically, Brownian motion on a phylogenetic tree) is treated: 
https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r. 
Please let me know & I'll send you a separate message off-list.


On the other hand, it seems possible that a discrete character evolution 
model like the extended Mk model might be more appropriate. When you say 
"karyotype" do you mean that the thing you're modeling is the number of 
chromosomes in the haploid genome? If so, then I think it makes more 
sense to think of chromosomes being added (by fission or genome 
duplication) and lost (by fusion) as occurring under a different 
stochastic process like a continuous time Markov chain. A little while 
ago I wrote a blog post describing a simple model for chromosome number 
evolution 
(http://blog.phytools.org/2022/07/a-model-for-chromosome-number-evolution.html); 
however, I believe there is a more sophisticated literature about this 
out there (due, perhaps, to the fact that karyotypic changes are often 
associated with speciation events -- something that a simple Mk model 
ignores).


All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/

On 12/14/2022 9:18 AM, William Brown wrote:

CAUTION: EXTERNAL SENDER

I am using fitContinuous to model karyotype evolution and trying to understand 
the meaning of the sigma-squared parameter in the output by drawing very simple 
trees and phenotype vectors.  However, the output sigma-squared values do not 
obviously correspond to any obvious variance calculation. Is there an obvious 
formula to make some intuitive sense of the output? Perhaps fitContinuous is 
the wrong function for getting a rate estimate from a phylogeny and a haploid 
karyotype vector.

Thanks for any help,

William



This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please contact the sender and delete the email and
attachment.

Any views or opinions expressed by the author of this email do not
necessarily reflect the views of the University of Nottingham. Email
communications with the University of Nottingham may be monitored
where permitted by law.





 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=05%7C01%7Cliam.revell%40umb.edu%7Cf0e82b7a90e348dbf0ea08dade00fb4c%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C638066393061933436%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=oqDpTATJL7i5woUPO2HFDjwhwgBF%2B0JLsNpCbXOdyCY%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=05%7C01%7Cliam.revell%40umb.edu%7Cf0e82b7a90e348dbf0ea08dade00fb4c%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C638066393062089678%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=jTT32udLxMBSCxEq8LgpKQFbLDH7RPudoctyRCrWkPM%3Dreserved=0


___
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] Phylogenetic bubble plot

2022-12-09 Thread Liam J. Revell

Dear Saleh.

Maybe this would be of help to you -- a couple of months ago I posted on 
my blog how to show pie charts at the tips of the tree that were scaled 
to the sample size of each species: 
http://blog.phytools.org/2022/07/graphing-pie-charts-at-tips-of-plotted.html.


This could quite easily be modified to just show abundances.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/

On 12/9/2022 4:51 PM, Saleh Rahimlou wrote:

CAUTION: EXTERNAL SENDER

Hello,

I require to make a phylogenetic bubble plot. I want to show the abundance of 
each tip with the size of the bubble in front of it. I would be grateful if 
someone could help.

Best,
Saleh Rahimlou
Research Fellow
Department of Ecology and Evolutionary Biology
University of Michigan
1105 North University
Ann Arbor, MI 48109
United States of America
Email: rahim...@umich.edu<mailto:rahim...@umich.edu>



 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=05%7C01%7Cliam.revell%40umb.edu%7Cde62d75b74de4093f94308dada2f9195%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638062195126981064%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=vLgyVk1JDZra%2BamucdzQUFbTUQlAKt%2BeRnFsvpdYlSM%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=05%7C01%7Cliam.revell%40umb.edu%7Cde62d75b74de4093f94308dada2f9195%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638062195126981064%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=B5qV9qYt9Y4%2FiE4J%2B%2F1G%2BZMwvSy2xVvEKisjACHJN2s%3Dreserved=0


___
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] ancestral state reconstruction with a complex discrete trait

2022-11-08 Thread Liam J. Revell

Dear Chris.

Does it make sense to treat {02} as an intermediate condition between 
{0} and {2}? If so, perhaps you'd like to try fitpolyMk in phytools, 
which can also easily combine with ancestral state estimation (e.g., 
with phytools::make.simmap). Here is an example: 
http://blog.phytools.org/2019/07/stochastic-character-mapping-with.html.


All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/

On 11/8/2022 2:35 PM, Krzysztof Kozak wrote:

CAUTION: EXTERNAL SENDER

Hello,

Is there a method for ancestral state reconstruction when the character can
take on multiple values, and those values vary in complexity?
For example, some species are white (0), some gray (1), some black (2), but
then some are black and white (02).
Two solutions I can think of are (1) code each combination as a simple
state (so black and white could be coded as '3'); (2) treat each state as
binary character.
Any better solutions, please?

- Chris Kozak

 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=05%7C01%7Cliam.revell%40umb.edu%7Ce7ab8068cea844ac67a408dac1c07f18%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638035329773830976%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=tgBZSH6ny135%2BjW7Y14kQcHXtmxu%2FgxDF6wEDKBgyLw%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=05%7C01%7Cliam.revell%40umb.edu%7Ce7ab8068cea844ac67a408dac1c07f18%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638035329773830976%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=beFK6iTET4OYiI%2FGnZylAnaGjBytYBMejwlKa1lA2WY%3Dreserved=0


___
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] issue with reading matrix in R package DispRity

2021-12-06 Thread Liam J. Revell

Hi Oliver & Marguerite.

It looks like the file is in "csv2" format -- with the comma as the 
decimal separator, and the semi-colon as column separator.


This file format can be read using read.csv2 instead of read.csv. (Or, 
alternatively, you can use read.csv but then update the arguments 
dec="," and sep=";".)


Hopefully this solves your problem.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 12/6/2021 9:52 PM, Marguerite Butler wrote:

EXTERNAL SENDER

Hi Oliver,
You have semicolons ; in your cells.  csv is "comma separated format". It
is using "," as the delimiter. Probably what is happening is the ";" is
interpreted as another delimiter in R, so you have a 2 column vector in
each cell. I would guess that htis will be read in as a list.

Why do you have two values in each cell? If they are important I would
suggest splitting them into two columns so that you only have one value per
cell.

Otherwise you can read in the list, and flatten it with code. But it would
probably be easier to just produce the .csv in the correct way.

An easy way to do this is to read in your .csv file with a word processor
and just do a search on ";" and replace with ",".   Then you should get 6
columns instead of three columns with two values each.

Marguerite

Marguerite



On Mon, Dec 6, 2021 at 2:08 PM Oliver Betz 
wrote:



Dear all:

I have an issue in correctly transferring the attached data frame to a
matrix to be processed in the R package DispRity.

I am running the following script that (1) reads in the attached
dataframe from Excel, (2) tansfers it to a matrix X and (3) uses the
column "subgroup" to define the two groups I want to work on.

Her is the script I am using:

#___

library (dispRity)

#(1) Reading dataframe
Data<-read.csv2("test.csv", row.names=1, header = T,
fileEncoding="UTF-8-BOM")

#(2) converts dataframe into a matrix
X<-data.matrix(Data)

#(3)define subsets
custom.subsets(X[, c(1,2)], group = as.factor(X[, 3]))

#___

However, once I have run the third line, I am getting an error message
such as:

Error: group argument must be either a "list", a "matrix", a
"data.frame" or a "phylo" object.



If I change the third line into: custom.subsets(dat[, c(2,3)], group =
as.factor(dat[, 4])), the error message is as follows:

Error in X[, 4] : subscript out of bounds
___


I will be very happy if anybody can give a hint how to resolve this
problem.


My best wishes,

Oliver Betz











___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7C4caba0752954434f0b0608d9b92cba92%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637744424051280848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=m8Yq%2FUOXRBTsfZa9BJ%2Bv81rieHq00FbwfRMNkiQvaHM%3Dreserved=0
Searchable archive at
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C4caba0752954434f0b0608d9b92cba92%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637744424051280848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=zEZn%2BQssRQcHPUZfU5lPWGO192XX0VLJGp2rJd4xAX0%3Dreserved=0




--

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
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbutlerlab.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C4caba0752954434f0b0608d9b92cba92%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637744424051280848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=7%2FUMuSYsSCBP9WTDIeP71I1KW%2FY6gkNsLuE%2BA8hEzTk%3Dreserved=0
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmanoa.hawaii.edu%2Fbiology%2Fpeople%2Fmarguerite-butlerdata=04%7C01%7Cliam.revell%40umb.edu%7C4caba0752954434f0b0608d9b92cba92%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637744424051280848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=qE73xEzLK7zy0T0lOXIo7EzZILQWbpMIqQjM2Ic6WsM%3Dreserved=

Re: [R-sig-phylo] Simulate trait evolution with different phylogenetic signal along a tree

2021-11-04 Thread Liam J. Revell

Dear Miguel.

One way to do something like would be by using the phytools function 
treeSlice.


treeSlice cuts the tree at a particular point. Depending on the argument 
orientation, it returns either the rootward tree or the descendant 
subtrees. So, say you want to simulate under Brownian motion from time 0 
to time t, and then just draw random values from a distribution centered 
on the ancestral value of each subtree descended from time t, you would 
just need to do two sets of simulations. First on the rootward tree, and 
then on each descendant subtree.


This could look something like the following:

## get hidden lambdaTree function (this is just to simulate random
## values for the subtrees from time t
lt<-phytools:::lambdaTree
## set t (here I'm imagining the tree has a total length of 100 and
## I want to slice it at time = 70 units above the root
t<-70
## slice the tree rootward of time = t -- this generates an object
## of class "multiPhylo"
rootward<-treeSlice(tree,orientation="rootwards",slice=t)
## now slice the tree tipward of time t -- this generates an object
## of class "multiPhylo" with a length equal to the number of tips
## in rootward
tipward<-treeSlice(tree,orientation="tipwards",trivial=TRUE,
slice=t)
## convert each subtree in tipward to a "phylo" object with an
## unbranching (singleton) root node. This is for simulation.
tipward<-lapply(tipward,rootedge.to.singleton)
## simulate the ancestral states for each subtree in tipward under
## pure Brownian motion
aa<-fastBM(rootward)
## create a vector of values
xx<-vector()
## simulate on each subtree to populate it. a is the ancestral state
## for each simulation
for(i in 1:length(tipward))
    xx<-c(xx,fastBM(lt(tipward[[i]],0),a=aa[i]))

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 11/4/2021 1:29 PM, Miguel Verdú del Campo wrote:

EXTERNAL SENDER

Dear list

Is there any way to simulate the evolution of a trait with a given significant 
signal (say K=1) from the tree root to time x and no signal (K=0) from time X 
to the present?

Thanks

Miguel Verdú

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7C1a5101f33c0a4deb496008d99fb8c766%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637716438239880743%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=mPBjrHJPPEd1iW0%2Bm3nfSEZiCAALVxhJ8EOsXJYXH7Q%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C1a5101f33c0a4deb496008d99fb8c766%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637716438239880743%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=d9koDURvcfb9cKVmMCB%2BenCUYsUViejZwALJbr9lNxU%3Dreserved=0



___
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] Codifying missing data and polymorphic state of characters in the same matrix

2021-09-04 Thread Liam J. Revell

Dear Felipe.

My suggestion would be to code the polymorphic condition as a third 
state -- so (if your trait is binary) you have three different character 
states: 0, 0+1, and 1.


Then you would enter your data as follows:

states: [0, 0+1, 1]
definitely in state zero: [1.0, 0.0, 0.0]
definitely in state one: [0.0, 0.0, 1.0]
definitely polymorphic: [0.0, 1.0, 0.0]
totally unknown: [0.33, 0.33, 0.33]

You can likewise encode other types of uncertainty about the condition 
of the trait. For instance, if you have observed state 0 in a taxon but 
have relatively little information, then you might want to say that the 
taxon is *either* in state 0 or 0+1. (The converse would obviously true 
for state 1.) This could be encoded as follows.


either state 0 or 0+1: [0.5, 0.5, 0.0]
either state 0+1 or 1: [0.0, 0.5, 0.5]

There's some grey area here too. For instance, how many observations are 
required to conclude that a taxon is "definitely in state zero" or 
"definitely in state one"? Perhaps you've observed only a few 
individuals for a species and all are in state 1. Is that taxon 
definitely monomorphic for the condition, or might it be polymorphic? 
make.simmap can handle this kind of nuance. For instance, you might 
decide the following for a particular taxon.


probably state 1, could be polymorphic: [0.0, 0.25, 0.75]

After you have coded your trait this way, you need to set up the model 
to fit to your data.


To do this you will have to create a design matrix -- the same as is 
used in ape::ace or geiger::fitDiscrete. This design matrix is passed to 
make.simmap as the argument model.


The key attribute of your model design matrix is that transitions from 0 
to 1 occur through the polymorphic condition 0+1.


For instance, for the trait with levels 0, 0+1, 1, your design matrix 
might have the form:


0   0+1 1
0   0   1   0
0+1 2   0   3
1   0   4   0

This is a model in which transitions are allowed to occur 0 <-> 0+1 and 
0+1 <-> 1, and all transitions can have different rates.


Finally, after running your stochastic mapping analysis, you can also 
merge states back together to compute statistics of interest -- such as 
the total posterior probabilities of a state at any node. For instance, 
you could merge the state 0 and 0+1 to get the probability of 0 at a 
node. This can be done using phytools::mergeMappedStates and then 
running the "simmap" summary methods as normal.


I hope this is of some help in getting you started Felipe.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 9/4/2021 7:36 PM, Felipe Rossetto wrote:

EXTERNAL SENDER
Hi everyone!
I am setting up a presence/absence matrix for running  stochastic 
mapping through the make.simmap function of phytools, but containing 
both taxa with polymorphic character state and with unknown data there. 
I know it is possible to represent missing data as probabilities 
instead of presence and absence, but I do not know how to distinguish 
missing data from polymorphic character codes for the analyses.


  So, would this following codification of missing data and polymorphic 
state be correct ?


*Taxon_A,*1,0,0 (character absent)
*Taxon_B*,0,1,0 (character present)
*Taxon_C*,0.5,0.5,0.0 (polymorphic character)
*Taxon_D*,0.33,0.33,0.33 (missing data)

Thank you very much in advance!

Felipe Rossetto



___
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] Working with BTRTools or BTProcessR

2021-06-08 Thread Liam J. Revell

Dear Greg.

I've never tried this package; however, it's not difficult to either 
substitute the set of values that are the branch lengths of a "phylo" 
object with a different set of values, or to multiple them by a 
different set.


For example, if you have the set of rates for your trait in a vector 
ordered by the edge lengths of the tree, you could just take your 
original tree (phy), substitute the edge-specific rates (sig2), then 
plot your tree as follows:


phy.sig2<-phy
phy.sig2$edge.length<-sig2
phytools::plotTree(phy.sig2)

Alternatively, if you want to show the amount of evolution that's 
expected to occur on each edge, that would be equivalent to the product 
of the edge length and it's edge-specific rate.


phy.sig2<-phy
phy.sig2$edge.length<-phy$edge.length*sig2
phytools::plotTree(phy.sig2)

I hope I'm understanding the problem correctly.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


On 6/8/2021 4:09 PM, Gregory Mutumi wrote:

EXTERNAL SENDER

  battree.nexus
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1n_sSFcP23nyLiIC49wcEZXUCVWIpOYk1%2Fview%3Fusp%3Ddrive_webdata=04%7C01%7Cliam.revell%40umb.edu%7Cfcee1f8fa0eb404382e108d92ab96851%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587798086523020%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=Hpdeo4rAo8rlRxETrg93gb7aBt47VwXdET6qoDerxPg%3Dreserved=0>
  BayesPCM9.Log.txt
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F168ii9utfUlUEqq2LXDy3C9FKe7bCm9w9%2Fview%3Fusp%3Ddrive_webdata=04%7C01%7Cliam.revell%40umb.edu%7Cfcee1f8fa0eb404382e108d92ab96851%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587798086533011%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=VOXQDIuyPzvzX2p605Z5OG0pxecy%2Bdpj7oaL%2BGFZdQ4%3Dreserved=0>
  BayesPCM9.Output.trees
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1th9D4-PMo9f8U9vlHARxFgnxUx8nUPUD%2Fview%3Fusp%3Ddrive_webdata=04%7C01%7Cliam.revell%40umb.edu%7Cfcee1f8fa0eb404382e108d92ab96851%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587798086533011%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=9PJZV%2FHz26CwsWjoWDVN8THuGe7doTglTix7C5s1fmI%3Dreserved=0>
  BayesPCM9.Schedule.txt
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1nhUUcSU6xJrgIeup_sDLABe4WXh6Y3Rf%2Fview%3Fusp%3Ddrive_webdata=04%7C01%7Cliam.revell%40umb.edu%7Cfcee1f8fa0eb404382e108d92ab96851%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587798086533011%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=LA1nmxEjiWePbyIG1ANTwDNT%2FeGL4qrqtvlOTLh6Vk0%3Dreserved=0>
  BayesPCM9.Stones.txt
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1tOcDqbMw840CkErCgiOiuj2Sf0-r_vCl%2Fview%3Fusp%3Ddrive_webdata=04%7C01%7Cliam.revell%40umb.edu%7Cfcee1f8fa0eb404382e108d92ab96851%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587798086533011%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=DxAe1O2%2FiHoXsxIaF%2BCUT9quQJkTaWutwm9gtA3kZ1M%3Dreserved=0>
  BayesPCM9.VarRates.txt
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1wNhBg9QvKj_5RPPE1wK2C1AeiWODEaPL%2Fview%3Fusp%3Ddrive_webdata=04%7C01%7Cliam.revell%40umb.edu%7Cfcee1f8fa0eb404382e108d92ab96851%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587798086533011%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=7ecLdWeGU1mH0xHdIzzZc57MBCTdsvXOgVOOShX1eMg%3Dreserved=0>
Dear All

Is there a way in BTprocessR or BTRTools (or any other package) to plot a
tree in such a way that the branch lengths are scaled by rate. Colour
gradients are a bit difficult to compare across many structures. I am
looking for a plot where faster rates make branches longer and slower rates
produce shorter branches.

The plotshifts function in BTRTools plots the tree with color gradient
depicting the rates. I am thinking maybe there is an option I am missing
out that simply does the trick to plot branches scaled by rate?

Please also help me with how to make the legend not plot over the scale. I
am not getting how to command the legend positions, I get errors if I try
the available option, maybe I am missing out something.

My code goes like this:

btresults9 <- rjpp(rjlog = "BayesPCM9.VarRates.txt",  rjtrees =
"BayesPCM9.Output.trees",tree = my.tree, 

Re: [R-sig-phylo] Recovering rate estimates from ape::ace

2021-06-08 Thread Liam J. Revell

Dear Rafa.

OK, I have now pushed an update to phytools such that it includes an 
as.Qmatrix method for the "ace" object class.


This allows you to extract, print, & plot the fitted transition matrix 
from a discrete character evolution model fit using ape::ace.


You might do this, for example, as follows:

fit<-ace(x,tree,type="discrete",model="SYM")
print(fit)
Q<-as.Qmatrix(fit)
print(Q)
plot(Q)

If your "ace" object comes from a continuous character analysis, it 
should just print a sensible error message.


To get this functionality, you need to update phytools from GitHub using 
devtools -- e.g.,


devtools::install_github("liamrevell/phytools")

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


On 6/8/2021 1:15 PM, Liam J. Revell wrote:

EXTERNAL SENDER

 > I'm still confused by how the rows/columns of Q match to my character
 > states, which in my case are denoted 0, 1 and 2. Can I assume they are
 > in the same order as the columns in $lik.anc?

Yes -- and the estimated rates are from the row state to the column state.

You can also compare to:

as.Qmatrix(fitMk(tree,x,model="ARD"))

where the labeling is better.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C88c96fc3219442e561d208d92aa12977%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587693963145265%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=Q0g1P4200sjnVMI60mHeWACMil4UMXswRKFHDqpXRvg%3Dreserved=0, 

https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.phytools.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C88c96fc3219442e561d208d92aa12977%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587693963145265%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=H8dUUuMjJ9ceBzruPJDAqowW2%2FVIPHwEqoEzDMk%2Fv4w%3Dreserved=0 > 


On 6/8/2021 1:05 PM, Rafael S Marcondes wrote:

EXTERNAL SENDER
Thanks, Liam. But I'm still confused by how the rows/columns of Q match
to my character states, which in my case are denoted 0, 1 and 2. Can I
assume they are in the same order as the columns in $lik.anc?

 > ace$lik.anc
    0   1    2
   [1,] 0.000 0.987116446 1.288355e-02
   [2,] 0.000 0.997965356 2.034644e-03
   [3,] 0.000 0.999896344 1.036562e-04
   [4,] 0.000 0.998461684 1.538316e-03
   [5,] 0.000 0.997119242 2.880758e-03
   [6,] 0.000 0.999662906 3.370942e-04
   [7,] 0.000 0.999887864 1.121365e-04

Rafa

*--*
*Rafael Sobral Marcondes, Ph.D.*

Pronouns: he/him

/"Eu quase que nada não sei. Mas desconfio de muita coisa"
/
/"I almost don't know nothing. But I suspect many things"/
   -João Guimarães Rosa, Brazilian novelist
(Portuguese original and free English translation by me)


On Mon, Jun 7, 2021 at 6:06 PM Liam J. Revell mailto:liam.rev...@umb.edu>> wrote:

    Dear Rafa.

    Try this to get the transition matrix, Q:

    k<-nrow(ace$index.matrix)
    Q<-matrix(ace$rates[ace$index.matrix],k,k)
    diag(Q)<--rowSums(Q,na.rm=TRUE)

    This should match what you get running:

    as.Qmatrix(fitMk(tree,x,model="ARD"))

    with phytools.

    All the best, Liam

    Liam J. Revell
    University of Massachusetts Boston [Assoc. Prof.]
    Universidad Católica de la Ssma Concepción [Adj. Res.]

    On 6/7/2021 6:52 PM, Rafael S Marcondes wrote:
 > EXTERNAL SENDER
 >
 > Hi all,
 >
 > I'm very confused trying to understand the output of ace::ape,
    specifically
 > the transition rates. I'm having a hard time understanding how
    the rates
 > are stored in the results.
 >
 > For example, I used an ARD model on a trait with three states,
    denoted just
 > 0, 1 and 2.
 >
 > I know that the rates are stored in $rates and the indices of
    $rates are
 > given in $index.matrix:
 >
 >> ace$index.matrix
 >   [,1] [,2] [,3]
 > [1,]   NA    3    5
 > [2,]    1   NA    6
 > [3,]    2    4   NA
 >
 >> ace$rates
 > [1] 0.107923960 0.012997878 0.0 0.008488054 0.0
    0.073339853
 >
 > But how do the ace$index.matrix columns and rows correspond to my
    character
 > states?
 >
 > Thanks for any help!
 >
 > Rafa
 >
 > *--*
 > *Rafael Sobral Marcon

Re: [R-sig-phylo] Recovering rate estimates from ape::ace

2021-06-08 Thread Liam J. Revell

> I'm still confused by how the rows/columns of Q match to my character
> states, which in my case are denoted 0, 1 and 2. Can I assume they are
> in the same order as the columns in $lik.anc?

Yes -- and the estimated rates are from the row state to the column state.

You can also compare to:

as.Qmatrix(fitMk(tree,x,model="ARD"))

where the labeling is better.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 6/8/2021 1:05 PM, Rafael S Marcondes wrote:

EXTERNAL SENDER
Thanks, Liam. But I'm still confused by how the rows/columns of Q match 
to my character states, which in my case are denoted 0, 1 and 2. Can I 
assume they are in the same order as the columns in $lik.anc?


 > ace$lik.anc
                0           1            2
   [1,] 0.000 0.987116446 1.288355e-02
   [2,] 0.000 0.997965356 2.034644e-03
   [3,] 0.000 0.999896344 1.036562e-04
   [4,] 0.000 0.998461684 1.538316e-03
   [5,] 0.000 0.997119242 2.880758e-03
   [6,] 0.000 0.999662906 3.370942e-04
   [7,] 0.000 0.999887864 1.121365e-04

Rafa

*--*
*Rafael Sobral Marcondes, Ph.D.*

Pronouns: he/him

/"Eu quase que nada não sei. Mas desconfio de muita coisa"
/
/"I almost don't know nothing. But I suspect many things"/
   -João Guimarães Rosa, Brazilian novelist
(Portuguese original and free English translation by me)


On Mon, Jun 7, 2021 at 6:06 PM Liam J. Revell <mailto:liam.rev...@umb.edu>> wrote:


Dear Rafa.

Try this to get the transition matrix, Q:

k<-nrow(ace$index.matrix)
Q<-matrix(ace$rates[ace$index.matrix],k,k)
diag(Q)<--rowSums(Q,na.rm=TRUE)

This should match what you get running:

as.Qmatrix(fitMk(tree,x,model="ARD"))

with phytools.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

On 6/7/2021 6:52 PM, Rafael S Marcondes wrote:
 > EXTERNAL SENDER
 >
 > Hi all,
 >
 > I'm very confused trying to understand the output of ace::ape,
specifically
 > the transition rates. I'm having a hard time understanding how
the rates
 > are stored in the results.
 >
 > For example, I used an ARD model on a trait with three states,
denoted just
 > 0, 1 and 2.
 >
 > I know that the rates are stored in $rates and the indices of
$rates are
 > given in $index.matrix:
 >
 >> ace$index.matrix
 >       [,1] [,2] [,3]
 > [1,]   NA    3    5
 > [2,]    1   NA    6
 > [3,]    2    4   NA
 >
 >> ace$rates
 > [1] 0.107923960 0.012997878 0.0 0.008488054 0.0
0.073339853
 >
 > But how do the ace$index.matrix columns and rows correspond to my
character
 > states?
 >
 > Thanks for any help!
 >
 > Rafa
 >
 > *--*
 > *Rafael Sobral Marcondes, Ph.D.*
 >
 > Pronouns: he/him
 >
 >
 > *"Eu quase que nada não sei. Mas desconfio de muita coisa"*
 > *"I almost don't know nothing. But I suspect many things"*
 >    -João Guimarães Rosa, Brazilian novelist
 > (Portuguese original and free English translation by me)
 >
 >          [[alternative HTML version deleted]]
 >
 > ___
 > R-sig-phylo mailing list - R-sig-phylo@r-project.org
<mailto:R-sig-phylo@r-project.org>
 >

https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7C95354f087a314328586808d92a070658%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587031952745482%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=MpJuKhub05VZQOWBn0HY8OIOIm4cSeez00A%2FWvPFWyM%3Dreserved=0

<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylo=04%7C01%7Cliam.revell%40umb.edu%7Ce1ae391a561847bef3e608d92a9fadbf%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587687571208367%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000=t%2BMtPNQnfATokwj73UOnNbJoaVienkb4SkjlW56mDBY%3D=0>
 > Searchable archive at

https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r

Re: [R-sig-phylo] Recovering rate estimates from ape::ace

2021-06-07 Thread Liam J. Revell

Dear Rafa.

Try this to get the transition matrix, Q:

k<-nrow(ace$index.matrix)
Q<-matrix(ace$rates[ace$index.matrix],k,k)
diag(Q)<--rowSums(Q,na.rm=TRUE)

This should match what you get running:

as.Qmatrix(fitMk(tree,x,model="ARD"))

with phytools.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

On 6/7/2021 6:52 PM, Rafael S Marcondes wrote:

EXTERNAL SENDER

Hi all,

I'm very confused trying to understand the output of ace::ape, specifically
the transition rates. I'm having a hard time understanding how the rates
are stored in the results.

For example, I used an ARD model on a trait with three states, denoted just
0, 1 and 2.

I know that the rates are stored in $rates and the indices of $rates are
given in $index.matrix:


ace$index.matrix

  [,1] [,2] [,3]
[1,]   NA35
[2,]1   NA6
[3,]24   NA


ace$rates

[1] 0.107923960 0.012997878 0.0 0.008488054 0.0 0.073339853

But how do the ace$index.matrix columns and rows correspond to my character
states?

Thanks for any help!

Rafa

*--*
*Rafael Sobral Marcondes, Ph.D.*

Pronouns: he/him


*"Eu quase que nada não sei. Mas desconfio de muita coisa"*
*"I almost don't know nothing. But I suspect many things"*
   -João Guimarães Rosa, Brazilian novelist
(Portuguese original and free English translation by me)

 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7C95354f087a314328586808d92a070658%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587031952745482%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=MpJuKhub05VZQOWBn0HY8OIOIm4cSeez00A%2FWvPFWyM%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C95354f087a314328586808d92a070658%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637587031952745482%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=6crcPjrShW98xiu%2FYtB06ygMmY2Uurg3niR951K4Src%3Dreserved=0



___
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] Using bind.tip and lapply on a multiPhylo object

2021-06-04 Thread Liam J. Revell



Dear Russell.

For some reason, my emails don't seem to be getting through to the whole 
list -- so my apologies if this ends up being redundant with another reply.


In short, if you supply a vector of tip labels that are identical (e.g., 
c("Cricetomys_emini","Cricetomys_emini")), ape::getMRCA returns the 
parent node of the corresponding taxon -- rather than the tip index. I 
didn't know that, but now I do.


You can switch to using phytools::fastMRCA. fastMRCA takes two tip label 
arguments instead of one -- so in your case the function call would be 
fastMRCA(tree,"Cricetomys_emini","Cricetomys_emini").


You can also just use the base R function which. In this case, you would 
do which(tree$tip.label=="Cricetomys_emini"). This should have the same 
effect.


You do seem to be using the arguments 'where' and 'position' correctly 
in phytools::bind.tip. 'where' should point to the node immediately 
*above* (i.e., tipward) of the place you want to attach the new tip; 
while 'position' should be the depth *below* that node.


Here's an update to your mapply call using fastMRCA instead of getMRCA.

newtree<-mapply(bind.tip,tree=tree,where=lapply(tree,fastMRCA,
sp1="Cercopithecus_mitis",sp2="Cercopithecus_mitis"),
MoreArgs=list(tip.label="Cercopithecus_albogularis",
position=0.59,edge.length=0.59),SIMPLIFY=FALSE)
class(newtree)<-"multiPhylo"

Please let me (& the list) know if this solution works as expected.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 6/4/2021 1:17 AM, Russell Engelman wrote:

EXTERNAL SENDER
Dear Everyone,

I think these are all really good suggestions. I tried this with my data 
(specifically the mapply with getMRCA) and it sort of worked. Sort of in 
that the mapply did apply the transformation to all 100 trees, but I 
noticed that after I applied it I got some funky results. Here is 
another example with /Cricetomys ansorgei /and some associated code...


hbltree <-read.nexus(file=" hbltree .nex")
class(hbltree)<-"multiPhylo"
newtrees<-mapply(bind.tip,tree=hbltree,where=lapply(hbltree,getMRCA,
   
  tip=c("Cricetomys_emini","Cricetomys_emini")),

                  MoreArgs=list(tip.label="Cricetomys_ansorgei",
                      position=3.282,edge.length=3.282),SIMPLIFY=FALSE)

However I noticed that when I printed the phylogeny the function for 
some reason does not place /C. ansorgei /as the sister taxon to /C. 
emini/, instead it places it as sister to /C. emini/ + /C. gambianus. 
/That part I am not sure why this is because getMRCA should find the 
terminal tip of /C. emini/, given that it is finding the MRCA of the 
same taxon.


It also does not place /C. ansorgei /at the tip of the tree. This might 
be a side effect of the function selecting the wrong node to insert the 
taxon on, but I think part of it as well is that I'm not familiar with 
how to handle the position and edge.length arguments in this case. I 
know from consulting the primary literature that /C. ansorgei /is 
recoded to have diverged from its nearest sister taxon, /C. emini/, 
about 3.282 Ma. So I know the 'edge.length' argument should be set to 
3.282. I've often struggled a lot with how to efficiently set the 
'position' argument afterwards.


Is it possible I am calling the wrong node or something to insert the 
taxon at?


Sincerely,
Russell

On Thu, Jun 3, 2021 at 10:47 AM Liam J. Revell <mailto:liamjrev...@gmail.com>> wrote:


Dear Russell et al. (sorry if this is a re-send: my message yesterday
seems to have been blocked by the listserv)

Using a for loop is a great idea! Highly underrated in R, IMO.

However, for future reference, the reason that your code didn't work
with lapply is because the list you're 'applying' over (tree) also
appears among the arguments!

If you want to use apply-family functions instead of a for loop (just,
say, for fun) then you have two basic options: you can write a custom
function; or you can use mapply.

Here's some (untested) code to do it.

## first, using a custom function & lapply:
foo<-function(tree) bind.tip(tree,
      tip.label="Cercopithecus_albogularis",
      position=0.59,edge.length=0.59,
      where=getMRCA(tree,tip=c("Cercopithecus_mitis",
      "Cercopithecus_mitis")))
newtree<-lapply(tree,foo)
class(newtree)<-"multiPhy

Re: [R-sig-phylo] Using bind.tip and lapply on a multiPhylo object

2021-06-04 Thread Liam J. Revell



Dear Russell et al. (sorry if this is a re-send: my message yesterday 
seems to have been blocked by the listserv)


Using a for loop is a great idea! Highly underrated in R, IMO.

However, for future reference, the reason that your code didn't work 
with lapply is because the list you're 'applying' over (tree) also 
appears among the arguments!


If you want to use apply-family functions instead of a for loop (just, 
say, for fun) then you have two basic options: you can write a custom 
function; or you can use mapply.


Here's some (untested) code to do it.

## first, using a custom function & lapply:
foo<-function(tree) bind.tip(tree,
tip.label="Cercopithecus_albogularis",
position=0.59,edge.length=0.59,
where=getMRCA(tree,tip=c("Cercopithecus_mitis",
"Cercopithecus_mitis")))
newtree<-lapply(tree,foo)
class(newtree)<-"multiPhylo"

## now, using mapply:
newtree<-mapply(bind.tip,tree=tree,where=lapply(tree,getMRCA,
tip=c("Cercopithecus_mitis","Cercopithecus_mitis")),
MoreArgs=list(tip.label="Cercopithecus_albogularis",
position=0.59,edge.length=0.59),SIMPLIFY=FALSE)
class(newtree)<-"multiPhylo"

(Code is not guaranteed! I don't have the data file, so I didn't 
actually test it -- but something like this ought to work.)


Regardless, I recommend using ape::getMRCA (or phytools::fastMRCA) 
because otherwise you're computing an N x N matrix in each iteration of 
your function call just to get one node index.


Good luck! All the best, Liam

--
Liam J. Revell
University of Massachusetts Boston
Universidad Católica de la Ssma Concepción

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 6/2/2021 8:18 PM, Nathan Upham wrote:

Hi Russell:

Glad to hear you’re using the VertLife mammal trees — they are built on a 
taxonomy of 5,911 species of which only 4,098 are sampled for DNA, so there is 
already a ~30% chunk that is placed using taxonomic constraints and birth-death 
branch lengths as sampled during the estimation of 28 Bayesian patch clades.

Adding additional species described since the 2015 cutoff of that VertLife 
taxonomy makes sense (e.g., up to ~6,500 species on mammaldiversity.org).  
However, keep in mind that they will not have birth-death estimated branch 
lengths, but rather more likely be added as a polygamy to given clade and then 
randomly resolved.

Given the sample code you provided, the key thing you’ll want to do is run a 
*loop* rather than using lapply, so that you can specify a given tree each 
time, e.g.:

newtrees<-vector(“list”,length(trees))
for(j in 1:length(trees)){
newtrees[[j]] <- bind.tip(tree=trees[[j]], tip.label="Cercopithecus_albogularis”, 
position=0.59,edge.length = 0.59, 
where=mrca(tree[[j]])["Cercopithecus_mitis","Cercopithecus_mitis"])
}

I also wrote some code to prune mammal trees and add extinct Caribbean species, 
which uses a similar approach of making polytomies and randomly resolving them 
— here is the repo:
https://github.com/n8upham/CaribbeanExtinctions-WTWTW/tree/master/mamPhy_pruningCode
And here is the code file:
https://github.com/n8upham/CaribbeanExtinctions-WTWTW/blob/master/mamPhy_pruningCode/pruningCode_MamPhy-to-CaribbeanTaxa.R

Hope that helps,
—nate




Nathan S. Upham, Ph.D. (he/him)
Assistant Research Professor & Associate Curator of Mammals
Arizona State University, School of Life Sciences
  ~> Check out the new Mammal Tree of Life <http://vertlife.org/data/mammals/> 
and the Mammal Diversity Database <https://mammaldiversity.org/>

Research Associate, Yale University (Ecology and Evolutionary Biology)
Research Associate, Field Museum of Natural History (Negaunee Integrative 
Research Center)
Chair, Biodiversity Committee, American Society of Mammalogists
Taxonomy Advisor, IUCN/SSC Small Mammal Specialist Group

personal web: n8u.org | Google Scholar 
<https://scholar.google.com/citations?hl=en=zIn4NoUJ_op=list_works=AJsN-F6ybkfthmTdjTpow6sgMhWKn1EKcfNtmIF_wzZcev7yeHuEu5_aolFS85rWiVRHpiQgbwg43i6eS6kArrabLdFL4bntzUSRmlRP2CW4lbZqeEcColw>
 | ASU profile <https://isearch.asu.edu/profile/3682356>
e: nathan.up...@asu.edu | Skype: nate_upham | Twitter: @n8_upham 
<https://twitter.com/n8_upham>





On Jun 2, 2021, at 4:19 PM, Eliot Miller  wrote:

Hi Russell,

A package I wrote a while back should be able to do that fairly easily.
https://urldefense.com/v3/__https://github.com/eliotmiller/addTaxa__;!!IKRxdwAv5BmarQ!OZj7-dFRbxvUothKjSj6hr9B0eXscAO6LVWi1-a

Re: [R-sig-phylo] Using bind.tip and lapply on a multiPhylo object

2021-06-04 Thread Liam J. Revell

Dear Russell et al.

Using a for loop is a great idea! Highly underrated in R, IMO. ;)

However, for future reference, the reason that your code didn't work 
with lapply is because the list you're 'applying' over (tree) also 
appears among the arguments!


If you want to use apply-family functions instead of a for loop (just, 
say, for fun) then you have two basic options: you can write a custom 
function; or you can use mapply.


Here's some (untested) code to do it.

## first, using a custom function & lapply:
foo<-function(tree) bind.tip(tree,
tip.label="Cercopithecus_albogularis",
position=0.59,edge.length=0.59,
where=getMRCA(tree,tip=c("Cercopithecus_mitis",
"Cercopithecus_mitis")))
newtree<-lapply(tree,foo)
class(newtree)<-"multiPhylo"

## now, using mapply:
newtree<-mapply(bind.tip,tree=tree,where=lapply(tree,getMRCA,
tip=c("Cercopithecus_mitis","Cercopithecus_mitis")),
MoreArgs=list(tip.label="Cercopithecus_albogularis",
position=0.59,edge.length=0.59),SIMPLIFY=FALSE)
class(newtree)<-"multiPhylo"

(Code is not guaranteed! I don't have the data file, so I didn't 
actually test it -- but something like this ought to work.)


Regardless, I recommend using ape::getMRCA (or phytools::fastMRCA) 
because otherwise you're computing an N x N matrix in each iteration of 
your function call just to get one node index.


Good luck! All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 6/2/2021 8:18 PM, Nathan Upham wrote:

EXTERNAL SENDER

Hi Russell:

Glad to hear you’re using the VertLife mammal trees — they are built on a 
taxonomy of 5,911 species of which only 4,098 are sampled for DNA, so there is 
already a ~30% chunk that is placed using taxonomic constraints and birth-death 
branch lengths as sampled during the estimation of 28 Bayesian patch clades.

Adding additional species described since the 2015 cutoff of that VertLife 
taxonomy makes sense (e.g., up to ~6,500 species on mammaldiversity.org).  
However, keep in mind that they will not have birth-death estimated branch 
lengths, but rather more likely be added as a polygamy to given clade and then 
randomly resolved.

Given the sample code you provided, the key thing you’ll want to do is run a 
*loop* rather than using lapply, so that you can specify a given tree each 
time, e.g.:

newtrees<-vector(“list”,length(trees))
for(j in 1:length(trees)){
newtrees[[j]] <- bind.tip(tree=trees[[j]], tip.label="Cercopithecus_albogularis”, 
position=0.59,edge.length = 0.59, 
where=mrca(tree[[j]])["Cercopithecus_mitis","Cercopithecus_mitis"])
}

I also wrote some code to prune mammal trees and add extinct Caribbean species, 
which uses a similar approach of making polytomies and randomly resolving them 
— here is the repo:
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fn8upham%2FCaribbeanExtinctions-WTWTW%2Ftree%2Fmaster%2FmamPhy_pruningCodedata=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674838188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=KeZWNETOkPBekL3j5AIr2hygW49PbdSKImMV39QTXtE%3Dreserved=0
And here is the code file:
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fn8upham%2FCaribbeanExtinctions-WTWTW%2Fblob%2Fmaster%2FmamPhy_pruningCode%2FpruningCode_MamPhy-to-CaribbeanTaxa.Rdata=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674838188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=10u8o7U8dqC1pyK6GteNycoSACTOXAO2VaHNJmTeddk%3Dreserved=0

Hope that helps,
—nate




Nathan S. Upham, Ph.D. (he/him)
Assistant Research Professor & Associate Curator of Mammals
Arizona State University, School of Life Sciences
  ~> Check out the new Mammal Tree of Life 
<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvertlife.org%2Fdata%2Fmammals%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674838188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=DbfdSFyjoCtDqUWuVoRs%2BC8Toe3v2BuFHgIpBTim9M0%3Dreserved=0>
 and the Mammal Diversity Database 
<https://n

Re: [R-sig-phylo] Using bind.tip and lapply on a multiPhylo object

2021-06-04 Thread Liam J. Revell
Dear Russell et al. (sorry if this is a re-send: my message yesterday 
seems to have been blocked by the listserv)


Using a for loop is a great idea! Highly underrated in R, IMO.

However, for future reference, the reason that your code didn't work 
with lapply is because the list you're 'applying' over (tree) also 
appears among the arguments!


If you want to use apply-family functions instead of a for loop (just, 
say, for fun) then you have two basic options: you can write a custom 
function; or you can use mapply.


Here's some (untested) code to do it.

## first, using a custom function & lapply:
foo<-function(tree) bind.tip(tree,
tip.label="Cercopithecus_albogularis",
position=0.59,edge.length=0.59,
where=getMRCA(tree,tip=c("Cercopithecus_mitis",
"Cercopithecus_mitis")))
newtree<-lapply(tree,foo)
class(newtree)<-"multiPhylo"

## now, using mapply:
newtree<-mapply(bind.tip,tree=tree,where=lapply(tree,getMRCA,
tip=c("Cercopithecus_mitis","Cercopithecus_mitis")),
MoreArgs=list(tip.label="Cercopithecus_albogularis",
position=0.59,edge.length=0.59),SIMPLIFY=FALSE)
class(newtree)<-"multiPhylo"

(Code is not guaranteed! I don't have the data file, so I didn't 
actually test it -- but something like this ought to work.)


Regardless, I recommend using ape::getMRCA (or phytools::fastMRCA) 
because otherwise you're computing an N x N matrix in each iteration of 
your function call just to get one node index.


Good luck! All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 6/2/2021 8:18 PM, Nathan Upham wrote:

EXTERNAL SENDER

Hi Russell:

Glad to hear you’re using the VertLife mammal trees — they are built on a 
taxonomy of 5,911 species of which only 4,098 are sampled for DNA, so there is 
already a ~30% chunk that is placed using taxonomic constraints and birth-death 
branch lengths as sampled during the estimation of 28 Bayesian patch clades.

Adding additional species described since the 2015 cutoff of that VertLife 
taxonomy makes sense (e.g., up to ~6,500 species on mammaldiversity.org).  
However, keep in mind that they will not have birth-death estimated branch 
lengths, but rather more likely be added as a polygamy to given clade and then 
randomly resolved.

Given the sample code you provided, the key thing you’ll want to do is run a 
*loop* rather than using lapply, so that you can specify a given tree each 
time, e.g.:

newtrees<-vector(“list”,length(trees))
for(j in 1:length(trees)){
newtrees[[j]] <- bind.tip(tree=trees[[j]], tip.label="Cercopithecus_albogularis”, 
position=0.59,edge.length = 0.59, 
where=mrca(tree[[j]])["Cercopithecus_mitis","Cercopithecus_mitis"])
}

I also wrote some code to prune mammal trees and add extinct Caribbean species, 
which uses a similar approach of making polytomies and randomly resolving them 
— here is the repo:
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fn8upham%2FCaribbeanExtinctions-WTWTW%2Ftree%2Fmaster%2FmamPhy_pruningCodedata=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674838188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=KeZWNETOkPBekL3j5AIr2hygW49PbdSKImMV39QTXtE%3Dreserved=0
And here is the code file:
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fn8upham%2FCaribbeanExtinctions-WTWTW%2Fblob%2Fmaster%2FmamPhy_pruningCode%2FpruningCode_MamPhy-to-CaribbeanTaxa.Rdata=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674838188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=10u8o7U8dqC1pyK6GteNycoSACTOXAO2VaHNJmTeddk%3Dreserved=0

Hope that helps,
—nate




Nathan S. Upham, Ph.D. (he/him)
Assistant Research Professor & Associate Curator of Mammals
Arizona State University, School of Life Sciences
  ~> Check out the new Mammal Tree of Life 
<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvertlife.org%2Fdata%2Fmammals%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674838188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=DbfdSFyjoCtDqUWuVoRs%2BC8Toe3v2BuFHgIpBTim9M0%3D

Re: [R-sig-phylo] question regarding PGLS

2021-05-30 Thread Liam J. Revell

Dear Oliver & Julien.

> Also, “gls” estimates a correlation rather than a covariance
> structure. On non-ultrametric trees (such as yours) this will lead to
> different results.

This is a great point. If your tree is non-ultrametric you can do 
something like:


w<-diag(vcv.phylo(tree))
spp<-names(w)
corLambda<-corPagel(1,phy=tree,form=~spp)
fit<-gls(...,correlation=corLambda,weights=varFixed(~w))

(I'm not sure the exact code, but it should be something like that.)

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 5/30/2021 8:42 PM, Julien Clavel wrote:

EXTERNAL SENDER

Hi Oliver,

The "gls" from nlme uses REML by default. I think that caper or phylolm use ML instead. 
On small sample size ML estimates (e.g., "lambda") are known to be biased and you may 
sometimes not have enough power to estimate them. With increasing sample size (bigger trees) this 
is less an issue as the bias should vanishes and ML will likely converge to similar values to REML.

Also, “gls” estimates a correlation rather than a covariance structure. On 
non-ultrametric trees (such as yours) this will lead to different results.

Regards,

Julien




De : R-sig-phylo  de la part de Oliver Betz 

Envoyé : dimanche 30 mai 2021 22:49
À : r-sig-phylo@r-project.org 
Objet : [R-sig-phylo] question regarding PGLS


Dear list members:


I tried various R packages to calcuate a PGLS with the data set (csv
and nwk) I have attached to this email. I would like to use the Pagels
lambda model to attain an index that measures whether data exhibit
phylogenetic dependence or not.

While doing so, I came up with the following problem. Using ape - for
example, according to the script of the Latin American Macroevolution
Workshop and others - I attained results (regarding intercept, slope
and lambda) that differ from the results I received from caper or
phylolm. For example, with ape, lambda amounts to 0.57, whereas
according to caper or phylolm lambda amounts to 0.

Please find the R script that I have used attached (first block is
just the data reading and organisational part; 2nd block: PGLS Pagels
Lambda according to ape, 3rd block: PGLS Pagels Lambda according to
caper).

Do you have any idea why these packages produce these different
results and which software I should follow?

Thanks for any suggestions.

Oliver Betz
University of Tübingen
Tübingen
Germany
___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7Ca0076f879f9041059c2008d923ccf9bf%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637580185553969207%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=3pSEeLqSLv2l7K0fgnUCu0hgUiCQYPpOuu0t%2FpQSvJc%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7Ca0076f879f9041059c2008d923ccf9bf%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637580185553969207%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=lqErdhi2GLfaN5%2F01McrOWg2ePmWeuKnmFDB%2B%2BStolI%3Dreserved=0



___
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] Changing the color of text and nodes in arc.cladelabels in phytools

2021-04-05 Thread Liam J. Revell



Dear Russell.

I'm sorry that arc.cladelabels does not have the functionality that you 
want.


Have you tried setting par(fg)? E.g.:

par(fg="the color you want")
arc.cladelabels(...)
par(fg="black")

You could also try par(col) or par(col.lab).

Let me know if that works, if not I can see about adding the option you 
need to the function.


All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 4/4/2021 10:36 PM, Russell Engelman wrote:

EXTERNAL SENDER

Dear R-sig-phylo,

I am a researcher who has been trying to plot a continuous trait map onto a
phylogeny using the phytools and ape packages in R. I have been trying to
denote specific clades using the arc.cladelabels function in phytools, but
I have also been trying to color-code the text, curve, and node for each of
the groups to make it easier to see which branches pertain to which clade.
However, I have been having a lot of trouble adjusting the properties of
the text and nodes created by arc.cladetools.

Here is an example using the *Anolis *svl data that shows what I mean:

```
library(ape)
library(phytools)
anole.tree<-read.tree("https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2Feqg2015%2Fdata%2Fanole.tredata=04%7C01%7Cliam.revell%40umb.edu%7C017b93bf1ab74239149608d8f84157ed%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637532306822786314%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=NN6WMsldnLYZtuXWpndNA6ORhejdZbJdqDuNeI6PsY8%3Dreserved=0;)
svl <- 
read.csv("https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2Feqg2015%2Fdata%2Fsvl.csvdata=04%7C01%7Cliam.revell%40umb.edu%7C017b93bf1ab74239149608d8f84157ed%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637532306822796308%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=EA2P63ohsozCGtfU9hpg9k319zu168X%2BfmCZlOJ4cX4%3Dreserved=0;,
 row.names=1)
svl <- as.matrix(svl)[,1]
fit <- fastAnc(anole.tree,svl,vars=TRUE,CI=TRUE)
obj<-contMap(anole.tree,svl,plot=FALSE)
nodes<-c(mrca(anole.tree)["equestris","noblei"],
  mrca(anole.tree)["barahonae","barbatus"])
labels<-c("clade1","clade2")
plot(obj,type="fan",cex=5,fsize=0.5,lwd=5)
for(i in 1:length(nodes))
   arc.cladelabels(text = labels[i],node = nodes[i],mark.node = TRUE,
ln.offset =
 1.39, col = c("green","red")[i], lab.offset =
 1.46, fsize = .5, orientation = "curved")
```

None of the calls I have tried for the arc.cladelabels function seem to be
able to adjust the color of the text labels the function creates (e.g.,
text.col, col.text, col.lab, etc), nor the color or size of the nodes when
mark.node = TRUE. The "col" call only affects the line drawn. Examining the
base code for arc.cladelabels finds that the color of the nodes is always
set to be red, and I have been unable to figure out how to alter it. I
could always write a custom function that copies arc.cladelabels but alters
the color function, but my concern is that this is part of an RMarkdown
document and as a result any alteration I make to the arc.cladelabels
function will not show up when another person knits the data (as it will
call on their copy of phytools).

Alternatively I am wondering if it is possible to export the tree to ggtree
and add the nodes there, but I have noticed that ggtree does not allow for
arced clade labels and for some reason it also greatly extends the margins
of the plot beyond the margins of the graph when its equivalent of
arc.cladelabels (geom_cladelabel) is called.

I was wondering if anyone else here knew any potential ways I could adjust
the color and size of the text and nodes for this function.

Sincerely,
Russell

 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7C017b93bf1ab74239149608d8f84157ed%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637532306822796308%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=Zwv%2BMozIB7k%2BouxvRxE7VDq9KetciJh2E3ZO5Iung0g%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phyl

Re: [R-sig-phylo] host ape source code on GitHub?

2020-12-03 Thread Liam J. Revell

Dear Nick.

When you encounter a bug or issue in ape have you tried emailing 
Emmanuel (emmanuel.para...@ird.fr) or this list? Usually he is pretty 
responsive.


All the best, Liam

Liam J. Revell
University of Massachusetts Boston
Universidad Católica de la Ssma Concepción

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

Excess mortality & COVID-19 explorer web application:
https://liamrevell.github.io/excess-mortality-explorer.html

On 12/3/2020 9:44 AM, Nick Youngblut wrote:

EXTERNAL SENDER

Hello!

I keep running into bugs with the ape R package, and I usually just work around the issues (eg., using 
another phylogeny R package) because I don’t know of a good way of submitting bug reports to the package 
developer(s). While 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fape-package.ird.fr%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7Ccd7c756b843a4c61842f08d8979a0f0c%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637426035237836148%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=q98folhy9dOyyQEvdAFwO8ZWsrcq56cgfF1DPAzSpJM%3Dreserved=0
 
<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fape-package.ird.fr%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7Ccd7c756b843a4c61842f08d8979a0f0c%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637426035237836148%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=q98folhy9dOyyQEvdAFwO8ZWsrcq56cgfF1DPAzSpJM%3Dreserved=0>
 is useful, it doesn’t allow users to provide feedback about ape (or the other R packages listed). It would 
be great to have the ape package source code on GitHub, and that will probably make future development of the 
source code easier (eg., allowing PRs from other developers).

Best,
Nick
 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7Ccd7c756b843a4c61842f08d8979a0f0c%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637426035237836148%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=qZpAddX%2FfXVH0ffHxZeKs8a60GTq0tusF4FGCM7diiY%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7Ccd7c756b843a4c61842f08d8979a0f0c%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637426035237846137%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=c8LZxBy2m%2BYerywWQOmLPnNwEH%2Fobflkd%2F97v%2FqE3js%3Dreserved=0


___
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] singularity with pgls and ordinal factor

2020-11-18 Thread Liam J. Revell

Hi Ted.

My best guess is that some trees have zero-length terminal edges 
resulting in implied correlations between related species of 1. Could 
that be the case with your trees? Note that a good solution to this 
problem *is not* to add a small amount of edge length to the tips 
causing the problem as this will tend to give the observations for those 
tips very high weight in your analysis. Instead, you might consider 
pruning one or the other species from your analysis.


All the best, Liam

Liam J. Revell
University of Massachusetts Boston
Universidad Católica de la Ssma Concepción

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

Excess mortality & COVID-19 explorer web application:
https://liamrevell.github.io/excess-mortality-explorer.html

On 11/18/2020 1:35 PM, Ted Stankowich wrote:

EXTERNAL SENDER

Hello all,

I’m running pgls analyses using caper and have run into an issue with 
getting computationally singular errors. I’m trying to run a continuous 
dependent variable (HeadShades) against an ordinal factor (GsizeF). I 
get the following error when I run this:


Error in solve.default(xVix, tol = .Machine$double.eps) :

   system is computationally singular: reciprocal condition number = 
4.8348e-18


The error appears on some versions of the analyses (some trees) but not 
others. My understanding is this error is usually due to collinearity 
issues between independent variables, but it’s not clear why it would 
appear in a univariate test. When Gsize is treated as continuous (which 
technically it isn’t because the levels aren’t equal), the test runs 
smoothly. I have attached the data and tree and the code is below. Any 
insights would be appreciated.


Thanks!

Ted Stankowich

Data 
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2F1drv.ms%2Fu%2Fs!AjCGFCdv8AGXhP0ZbuoSY0eNSUL-aA%3Fe%3Dzhx91p=04%7C01%7Cliam.revell%40umb.edu%7C413ab7bc64884f213c6008d88bf0cd16%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637413213661723135%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=lFd59EeHp7GkmGMyYJNud5XHF3obrO6GgWaijhoZip0%3D=0>


Tree 
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2F1drv.ms%2Fu%2Fs!AjCGFCdv8AGXhP0a_lincn5SRTqsJA%3Fe%3DbDfBHl=04%7C01%7Cliam.revell%40umb.edu%7C413ab7bc64884f213c6008d88bf0cd16%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637413213661723135%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=0DVi5jdpOfOoqLBNl6sNoEaeHVD8vR%2BX3OdmLfHxRQk%3D=0>


library(phytools)

library(caper)

library(geiger)

library(evobiR)

row.names(NewMod56)=NewMod56$UphamDNABinomial

name.check(NewMod56dnaTree, NewMod56, data.names=NewMod56$UphamDNABinomial)

NewMod56=ReorderData(NewMod56dnaTree, NewMod56, taxa.names="row names")

NewMod56cd=comparative.data(phy=NewMod56dnaTree, data=NewMod56, 
names.col = UphamDNABinomial, vcv=TRUE)


NewMod56mod=pgls(HeadShades~GsizeF, data=NewMod56cd, lambda = 'ML')


___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7C413ab7bc64884f213c6008d88bf0cd16%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637413213661753119%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=T3pLaYakDvsrlNvYc9UMY%2FTKtqVf4r6gd3%2BMBe1mogI%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C413ab7bc64884f213c6008d88bf0cd16%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637413213661753119%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=TyHckzx4HpIVXcJX6wbIXtsXqotpMfoN4z283BlJKk4%3Dreserved=0



___
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] evolutionary rate for species with low phylogenetic signal

2020-09-24 Thread Liam J. Revell
I agree with Julien about this. If you have very few observations per 
species in your original data, it might even be useful to just compute a 
single pooled estimate of the within-species variance, and then use that 
to obtain estimates of the standard error for each species mean. To do 
this, first calculate a pooled variance in the normal way 
(https://en.wikipedia.org/wiki/Pooled_variance), and then divide the 
square-root of this variance by the square root of the sample size for 
each species to get an estimate of the standard error for that species. 
This works better if your data have been log-transformed in which case 
an assumption of homogeneity of the variance is more likely to hold.


I also agree with Dave, though, that if the Brownian model doesn't fit 
your data reasonably well, then sigma^2 is pretty difficult to 
interpret. (I hate to point to one of my own papers, but a couple of 
years ago some colleagues & I published a study in which we made a set 
of 'phylogenetic Anscombe' datasets - each of which showed a really 
different among-species pattern, and yet that all had the same value of 
sigma^2: https://dx.doi.org/10./2041-210X.13067. The point of this 
article, like Anscombe 1973, was about graphing - but it may also apply 
to your problem.)


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/24/2020 1:46 PM, Julien Clavel wrote:

[EXTERNAL SENDER]

Hi Karla,

As pointed out by Liam you can account for the sampling error with 
fitContnuous. Pagel's lambda corresponds to BM + noise at the tips (e.g. 
sampling error). If after accounting for this nuisance (for a set of 
competitive models) you find that BM is better than the other models, then it 
will makes sense to consider the sigsq as a reasonable measure of rate even if 
your Pagel's lambda estimate was low.

Best wishes,

Julien

De : R-sig-phylo  de la part de Karla Shikev 

Envoyé : jeudi 24 septembre 2020 03:41
À : Liam J. Revell 
Cc : R Sig Phylo Listserv ; Theodore Garland 

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

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/, 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2Fdata=02%7C01%7Cliam.revell%40umb.edu%7Cc32f6ae954334ee27bbf08d860a9554a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637365627682724545sdata=mPJpNrUUHdUZ7nGRvCSc0yJSGpec32VK8%2F5ijH3ATTw%3Dreserved=0

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, J

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

2020-09-23 Thread Liam J. Revell

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 mailto:liam.rev...@umb.edu>> wrote:

Dear Karla.

What do you want to use fitContinuous to do?

fitContinuous fits multiple models, some of which will result in
low
values of lambda in a test of phylogenetic signal. In fact, this is
really the main point of fitContinuous: to compare alternative
models
for trait evolution. If you just want to estimate the
most-likely rate
of evolution assuming a Brownian evolutionary process, you could
just
compute the mean squared PIC value (this is the REML estimate of
sigma^2).

fitContinuous can also take into account sampling error in the
estimation of species means, which can be a cause for low measured
values of phylogenetic signal.

Hope this is of some help Karla.

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

<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2F=02%7C01%7Cliam.revell%40umb.edu%7C4b3649722f5c4a9bb0f508d86021d687%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637365045732071994=L7HXU2Ljrj89dZ5ql%2FRWMB7ddrReMWnZxdufzJQ2Nvs%3D=0>

Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

On 9/23/2020 8:21 PM, Karla Shikev wrote:
 > [EXTERNAL SENDER]
 >
 > Dear friends,
 >
 > I guess this is as much a philosophical question as it is
methodological. I
 > want to estimate the rate of evolution of a trait (e.g. using the
 > fitContinuous function), but the trait has low phylogenetic
signal (e.g.
 > lambda close to 0). Does it make sense to use fitContinuous
on a trait
 > evolving like that?
 >
 > Thanks for your input.
 >
 > Karla
 >
 >          [[alternative HTML version deleted]]
 >
 > ___
 > R-sig-phylo mailing list - R-sig-phylo@r-pro

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

2020-09-23 Thread Liam J. Revell

Dear Karla.

What do you want to use fitContinuous to do?

fitContinuous fits multiple models, some of which will result in low 
values of lambda in a test of phylogenetic signal. In fact, this is 
really the main point of fitContinuous: to compare alternative models 
for trait evolution. If you just want to estimate the most-likely rate 
of evolution assuming a Brownian evolutionary process, you could just 
compute the mean squared PIC value (this is the REML estimate of sigma^2).


fitContinuous can also take into account sampling error in the 
estimation of species means, which can be a cause for low measured 
values of phylogenetic signal.


Hope this is of some help Karla.

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 8:21 PM, Karla Shikev wrote:

[EXTERNAL SENDER]

Dear friends,

I guess this is as much a philosophical question as it is methodological. I
want to estimate the rate of evolution of a trait (e.g. using the
fitContinuous function), but the trait has low phylogenetic signal (e.g.
lambda close to 0). Does it make sense to use fitContinuous on a trait
evolving like that?

Thanks for your input.

Karla

 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=02%7C01%7Cliam.revell%40umb.edu%7C238f2a4ce92f4b62411f08d86017813f%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637365001363567653sdata=4u7Q9SP0M9b0l07P13q6zruhfqyMW0AEVIqa%2FT9p1Ko%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=02%7C01%7Cliam.revell%40umb.edu%7C238f2a4ce92f4b62411f08d86017813f%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637365001363567653sdata=sKb4MeniYVOo5pQSEUtWRIpz%2BAGHt6wccZ%2B5mPQl7qU%3Dreserved=0



___
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 in Ape package

2020-09-18 Thread Liam J. Revell

Dear Sabrina.

What a great question.

The reason that you're seeing this behavior is because 
prop.clades(rooted=TRUE) treats your trees as rooted; while 
prop.clades(rooted=FALSE) treats them as unrooted.


The short answer to which you should use is that if your inference 
method in the bootstrapping analysis estimates an unrooted tree, you 
should set prop.clades(rooted=FALSE). *Most* phylogeny inference methods 
(ML, MP, NJ, ME, LS) estimate *unrooted* trees; only UPGMA and molecular 
clock methods estimate rooted trees.


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/18/2020 7:52 AM, Sabrina Rossi wrote:

[EXTERNAL SENDER]

Dear Ape team,


I am a researcher at the University of Cambridge (UK) and I had a quick 
question regarding ape and creating boostrap trees.


I am struggling to understand the difference between prop.clades(root=FALSE) 
and prop.clades(root=TRUE).


I am building ape trees based on methylation data for kidney cancer tissue. 
When I use boot.phylo (1000 bootstraps) and prop.clades with unrooted trees, 
the output of prop.clades is 100% for all the clades. In other words, the 
clades return the same result for all 1000 bootstrap trees.

However, when the same thing is repeated with a rooted tree of the same data, 
the output of prop.clades is very different: 100%  18%  30%  35%  73%  81%  62% 
 70%  77%  84%. In other words, the clades are very different for the bootstrap 
trees.


Would you please be able to help me understand the difference between 
prop.clades with root=TRUE versus root=FALSE?

Or do you have any useful reading material that may explain this? I cannot find 
anything on the internet.

What is the best practice, rooted or unrooted, considering I get completely 
different results?


Thank you very much for taking the time to answer my question

Best wishes

Dr Sabrina Rossi

BSc MPhil MBChB MRCS

University of Cambridge



 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=02%7C01%7Cliam.revell%40umb.edu%7C642a8093de024d4c45f908d85c1a1304%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637360614343423569sdata=1lPGmceyxBAlmgaT8UECbAgzu2DxYI%2F2RZePh9uSFfA%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=02%7C01%7Cliam.revell%40umb.edu%7C642a8093de024d4c45f908d85c1a1304%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637360614343423569sdata=7uL82jhBPH9alEUYdg0xGXTDQRXcluopc3Luf77zwSE%3Dreserved=0



___
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 - removing the extinct taxa from trees

2020-08-25 Thread Liam J. Revell

Hi Elvira.

In your Newick string those NaN are branch lengths, not taxon labels.

What do you mean by 'delete' the NaNs? You can set them to zero, as follows:

tree$edge.length[is.na(tree$edge.length)]<-0

but then you get a tree that looks like this:

http://www.phytools.org/blog/Elvira-tree.png

so it's kind of hard to tell which taxa are extinct

Sorry I can't be of more help! 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 8/25/2020 9:00 PM, Elvira D`bastiani wrote:

**[EXTERNAL SENDER]

Hi Liam

Also thank you for your informative answer. However, I don't want to 
simulate trees. For example one of my trees looks like this:


(2:17, (3: 258, (4: 1, (5: 1, ((7:47, (8:13, ((11: 1, (13: 46,9: 60): 
35): 35): 26, (10: 3, (12: 7, ((15: 4,14: 17): NaN, 6: NaN): - 904): 
53): 0): 34): 31): NaN, 1: NaN): - 621): 1): 138): 53);


Here, I need to delete these NaN from the phylo file.

I believe that with these functions I am unable to delete these NaN or 
extract only the surviving species.


Thank you for the help.

Elvira.

Em ter., 25 de ago. de 2020 às 17:33, Liam J. Revell 
mailto:liam.rev...@umb.edu>> escreveu:


Dear Elvira.

I'm not sure what's going on with the NaN values, but one issue that I
see with your example is that ape::drop.fossil identifies fossil
lineages by finding those that end before the present. Since rtree just
splits the tree randomly & samples the edge lengths from a uniform
distribution, this will leave you with only one lineage!

To see how the function should work you could try something like:

set.seed(99)
tree<-pbtree(n=15,b=1,d=0.2)
plotTree(tree)
plotTree(pruned<-drop.fossil(tree))

Hopefully this leaves things a bit clearer.

For fun, also try:

par(mfrow=c(1,1),mar=c(5.1,4.1,2.1,2.1),bty="n")
ltt(tree,lty="dashed",log.lineages=FALSE,log="y")
ltt(pruned,lty="solid",add=TRUE,log.lineages=FALSE,
         log="y")
legend("topleft",c("observed","reconstructed"),
         lty=c("dashed","solid"),bty="n")

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

<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2F=02%7C01%7Cliam.revell%40umb.edu%7Ce8848bf509ed41e5115408d8495b7db0%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637340004615417539=5%2F1PtYD6DMW7gK7ef3QiRvXSeI0bozADU5lgrW9qPq0%3D=0>

Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

On 8/25/2020 4:21 PM, Elvira D`bastiani wrote:
 > [EXTERNAL SENDER]
 >
 > Hi,
 >
 > I'm a beginner with phylogeny analysis. I'm having trouble
extracting only
 > the surviving species from the phylogenies of my model.
 >
 > I used the drop.fossil (fPar) functions from ape and the drop.extinct
 > (fPar) from geiger. But it is not deleting the way I need it.
 >
 > Running example correctly:
 > my.tree = rtree (15, rooted = TRUE, tip.label = NULL, br = runif)
#random
 > tree in phylo format
 > class (my.tree)
 > my.tree $ edge.length #I need this information without NaN.
 >
 >> my.tree$edge.length [1] 0.53879430 0.71471795 0.40579050
0.15278814 0.34023276 0.62665485
 >   [7] 0.05737268 0.85166764 0.21264535 0.53946203 0.13648759
0.32486514
 > [13] 0.62107629 0.25598225 0.63487580 0.48567211 0.93817692
0.85750154
 > [19] 0.37088354 0.31420183 0.82853436 0.45184151 0.31587841
0.09780854
 > [25] 0.06490054 0.68945737 0.66805060 0.90454665
 >
 >
 > However in the same tree format (phylo format) in my analysis the
 > edge.length comes out with NaN. Even after using the drop.fossil
(fPar) or
 > drop.extinct (fPar) functions. It looks like this:
 >
 >> fPar$edge.length [1]   17   53  258  138    1    1    1 -621 
NaN   47   31   13   34   26
 > [15]    1   35   46   60    0    3   53    7 -904  NaN    4   17 
NaN  NaN

 >
 >
 > Is there any way to delete these NaN?
 >
 >
 > Thanks in advance for the answer
 >
 > Best wishes
 >
 > e.
 >
 > --
 >
 > *Elvira D'Bastiani*Doutoranda em Ecologia e Conservação
 > Laboratório de Interações Biológicas
 > Universidade Federal do Paraná (UFPR), Curi

Re: [R-sig-phylo] Problem - removing the extinct taxa from trees

2020-08-25 Thread Liam J. Revell

Dear Elvira.

I'm not sure what's going on with the NaN values, but one issue that I 
see with your example is that ape::drop.fossil identifies fossil 
lineages by finding those that end before the present. Since rtree just 
splits the tree randomly & samples the edge lengths from a uniform 
distribution, this will leave you with only one lineage!


To see how the function should work you could try something like:

set.seed(99)
tree<-pbtree(n=15,b=1,d=0.2)
plotTree(tree)
plotTree(pruned<-drop.fossil(tree))

Hopefully this leaves things a bit clearer.

For fun, also try:

par(mfrow=c(1,1),mar=c(5.1,4.1,2.1,2.1),bty="n")
ltt(tree,lty="dashed",log.lineages=FALSE,log="y")
ltt(pruned,lty="solid",add=TRUE,log.lineages=FALSE,
log="y")
legend("topleft",c("observed","reconstructed"),
lty=c("dashed","solid"),bty="n")

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 8/25/2020 4:21 PM, Elvira D`bastiani wrote:

[EXTERNAL SENDER]

Hi,

I'm a beginner with phylogeny analysis. I'm having trouble extracting only
the surviving species from the phylogenies of my model.

I used the drop.fossil (fPar) functions from ape and the drop.extinct
(fPar) from geiger. But it is not deleting the way I need it.

Running example correctly:
my.tree = rtree (15, rooted = TRUE, tip.label = NULL, br = runif) #random
tree in phylo format
class (my.tree)
my.tree $ edge.length #I need this information without NaN.


my.tree$edge.length [1] 0.53879430 0.71471795 0.40579050 0.15278814 0.34023276 
0.62665485

  [7] 0.05737268 0.85166764 0.21264535 0.53946203 0.13648759 0.32486514
[13] 0.62107629 0.25598225 0.63487580 0.48567211 0.93817692 0.85750154
[19] 0.37088354 0.31420183 0.82853436 0.45184151 0.31587841 0.09780854
[25] 0.06490054 0.68945737 0.66805060 0.90454665


However in the same tree format (phylo format) in my analysis the
edge.length comes out with NaN. Even after using the drop.fossil (fPar) or
drop.extinct (fPar) functions. It looks like this:


fPar$edge.length [1]   17   53  258  138111 -621  NaN   47   31   
13   34   26

[15]1   35   46   6003   537 -904  NaN4   17  NaN  NaN


Is there any way to delete these NaN?


Thanks in advance for the answer

Best wishes

e.

--

*Elvira D'Bastiani*Doutoranda em Ecologia e Conservação
Laboratório de Interações Biológicas
Universidade Federal do Paraná (UFPR), Curitiba, Paraná, Brasil
*https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Felviradbastiani.wixsite.com%2Fecoevodata=02%7C01%7Cliam.revell%40umb.edu%7C40eeed8a082f4da7db1008d8493475c7%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637339836973837977sdata=u5GV45faTYzUsRhhQpCQc9C5%2BSLDcrzE6mcyNlRNVUU%3Dreserved=0
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Felviradbastiani.wixsite.com%2Fecoevodata=02%7C01%7Cliam.revell%40umb.edu%7C40eeed8a082f4da7db1008d8493475c7%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637339836973837977sdata=u5GV45faTYzUsRhhQpCQc9C5%2BSLDcrzE6mcyNlRNVUU%3Dreserved=0>*

 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=02%7C01%7Cliam.revell%40umb.edu%7C40eeed8a082f4da7db1008d8493475c7%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637339836973837977sdata=IdKD9kLK5Xh3yt1BDkA8n1srFFr5paq%2BSJAfivocP%2B4%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=02%7C01%7Cliam.revell%40umb.edu%7C40eeed8a082f4da7db1008d8493475c7%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637339836973837977sdata=5poPu09PsiPLuPYLC4itm9ouYfTXHC7ZNapkveNlkBU%3Dreserved=0



___
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] Rphylopars changing observed data values

2020-07-20 Thread Liam J. Revell

Dear Nick.

I don't know what's going on with Rphylopars, but phytools also has a 
multivariate phylogenetic imputation function, phylo.impute. It's 
described here on my blog: 
http://blog.phytools.org/2019/03/phylogenetic-imputation-with.html 
(although, of course you should use the phytools version not the posted 
code).


All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, 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 7/16/2020 10:47 AM, Nick Crouch wrote:

[EXTERNAL SENDER]

Hi all,

I'm trying to use Rphylopars to impute some missing data, but am having some 
strange results with my empirical data.

The phylopars should return a `data.frame` of the original data with the 
missing (NA) values calculated given the phylogenetic data and evolutionary 
model. However, my known values are being changed in the output. For example:


head(empirical.data)

speciesTrait
1   Species_1   14.0
2   Species_2   12.0


head(p_BM$anc_recon)

speciesTrait
1   Species_1   12.0
2   Species_2   8.9

The function works fine when I use different combinations of simulated data:
* simulated traits + simulated phylogeny works fine
* simulated traits + empirical phylogeny works fine
* empirical data + simulated phylogeny works fine

The phylogeny has no 0 branch lengths, is binary, and ultrametric. I have tried 
log-transforming the data. I have also tried sequentially dropping one tip at a 
time from the tree and re-running to see if any single tip is causing the 
problem. Different models also have the same effect.

If anyone has any thoughts i'd appreciate it.

Nick

--

Nick Crouch
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnickcrouch.github.io%2Fdata=02%7C01%7Cliam.revell%40umb.edu%7Cfb9cae70c8884b194ba308d82cc914ca%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637308589448752383sdata=hXkX5aboOGy3cJaK6QZBYAnm3kNrs%2Fqj2hAocX9MTKU%3Dreserved=0
Postdoctoral scholar, Jablonski lab
The University of Chicago

 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=02%7C01%7Cliam.revell%40umb.edu%7Cfb9cae70c8884b194ba308d82cc914ca%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637308589448752383sdata=VO6CC1WW3FuZg3geh0vZAL7NADKfHuxXxftuMW%2FTic4%3Dreserved=0
Searchable archive at 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=02%7C01%7Cliam.revell%40umb.edu%7Cfb9cae70c8884b194ba308d82cc914ca%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637308589448762381sdata=skztD9PMN5AVLUr03a1TXg2iNjWL9Aw5NvA3aYCvoyg%3Dreserved=0



___
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] phyl.RMA error

2020-06-09 Thread Liam J. Revell

Hi Ted.

It's a good bet that your input vectors, log(Skull) and log(Tusk), don't 
have names.


In your case, if your data frame is called Data, you might first compute:

ln.Skull<-setNames(log(Data$Skull),Data$Binomial)
ln.Tusk<-setNames(log(Data$Tusk),Data$Binomial)

and then run:

Model<-phyl.RMA(ln.Skull,ln.Tusk,tree,h0=1.0)
Model
plot(Model) ## this is kind of cool.

Note, that as pointed out in the documentation of the function: "some 
statistician think there is never a condition in which a 
reduced-major-axis regression should be used" (I believe this has even 
been discussed on this list); and "The statistical hypothesis testing is 
based on Clarke (1980; reviewed in McArdle 1988), which differs from 
some other implementations of non-phylogenetic major axis regression in R."


All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, 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 6/8/2020 4:18 PM, Ted Stankowich wrote:

[EXTERNAL SENDER]

Hello,

We're trying to run phylogenetically corrected reduced major axes regression 
analyses and have encountered an error we can't debug. We're using the function 
phyl.RMA in the package 'phytools'. Here is the code we are using and the error 
it returns.




Model <- phyl.RMA(log(Skull), log(Tusk), tree, h0=1.0)


Error in if (sign(beta1) != sign(h0)) { :

   missing value where TRUE/FALSE needed

We can't seem to figure out which argument is missing, and we've tried 
including all of the T/F based arguments we think are possible. Our species 
dataset and nexus file are printed below.  Any advice would be greatly 
appreciated.

We have the following dataset:
Binomial Skull  Tusk
 
1 Tragulus_javanicus93.7  14.6
2 Tragulus_kanchil  99.7  13.9
3 Tragulus_napu 98.1  11.1
4 Tragulus_nigricans99.8  13.2
5 Moschiola_meminna101.   14.6
6 Moschus_berezovskii  134.   55.0
7 Moschus_moschiferus  152.   52.9
8 Muntiacus_muntjak193.   26.4
9 Muntiacus_reevesi159.   23.4
10 Muntiacus_truongsonensis 184.   27.7
11 Muntiacus_vaginalis  203.   28.6
12 Hydropotes_inermis   162.   48.5
13 Hyemoschus_aquaticus 122.   20.1
14 Elaphodus_cephalophus186.   17.3

And the following nexus tree:

#NEXUS
[R-package APE, Mon Jun 08 12:20:01 2020]

BEGIN TAXA;
   DIMENSIONS NTAX = 12;
   TAXLABELS
  Tragulus_napu
  Tragulus_kanchil
  Tragulus_javanicus
  Hyemoschus_aquaticus
  Moschiola_meminna
  Muntiacus_reevesi
  Muntiacus_muntjak
  Muntiacus_truongsonensis
  Elaphodus_cephalophus
  Hydropotes_inermis
  Moschus_moschiferus
  Moschus_berezovskii
   ;
END;
BEGIN TREES;
   TRANSLATE
  1Tragulus_napu,
  2Tragulus_kanchil,
  3Tragulus_javanicus,
  4Hyemoschus_aquaticus,
  5Moschiola_meminna,
  6Muntiacus_reevesi,
  7Muntiacus_muntjak,
  8Muntiacus_truongsonensis,
  9Elaphodus_cephalophus,
  10  Hydropotes_inermis,
  11  Moschus_moschiferus,
  12  Moschus_berezovskii
   ;
   TREE * UNTITLED = [] 
1:5.540957781,(2:2.978817423,3:2.978817423):2.562139698):10.78911152,4:16.33006601):6.360692368,5:22.69076035):5.725388419,(6:1.611149584,7:1.611149848):1.556474893,8:3.167624477):4.130280196,9:7.297904013):1.497063399,10:8.794967413):7.19682079,(11:2.539095678,12:2.539096008):13.45269085):12.42436025);



Dr. Ted Stankowich
Associate Professor
Department of Biological Sciences
California State University Long Beach
Long Beach, CA 90840
theodore.stankow...@csulb.edu<mailto:theodore.stankow...@csulb.edu>
562-985-4826
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.csulb.edu%2Fmammal-lab%2Fdata=02%7C01%7Cliam.revell%40umb.edu%7C5a74928c910446b96b1508d80caf5765%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637273294515730787sdata=7FUGnuFJCdRHmPiVrWPPAu%2BLEyK6O%2B4VyAKHz1n63qw%3Dreserved=0
@CSULBMammalLab



Dr. Ted Sta

Re: [R-sig-phylo] Alllowing and considering "missing data" as values for reconstruction of ancestral character states

2020-04-14 Thread Liam J. Revell



Hi Carolina.

I agree with Brian that a Q matrix in which the elements of a row are 
all zeros is not likely to be you problem. It just means that the ML 
estimated transition rate from 1->0, in your case, is zero.


I agree with Brian that the message "1000 trees with a mapped discrete 
character with states: 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55" is 
surprising. Does your discrete character really have 27 states?


All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, 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 4/13/2020 3:23 PM, Brian O'Meara wrote:

**[EXTERNAL SENDER]

With raydisc, you need one column with the species name and a column 
with the data; so something like data[,c(1,2)] might be needed. If you 
want, you could email the files (tree, data, script to run) to Jeremy 
(jmbea...@uark.edu <mailto:jmbea...@uark.edu>) and me to check out.


For the simmap results, a rate of zero can be the estimate if it seems 
that there are no transitions from state 0 to 1. But the number of 
discrete states at the end ("1000 trees with a mapped discrete character 
with states: 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 
44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55") seems unexpected to me.


Best,
Brian


___
Brian O'Meara

Professor, Dept. of Ecology & Evolutionary Biology, UT Knoxville
Associate Head, Dept. of Ecology & Evolutionary Biology, UT Knoxville
He/Him/His



On Mon, Apr 13, 2020 at 2:32 PM Carolina Santos Vieira 
mailto:carolsantosvie...@gmail.com>> wrote:


Hi Liam and all users

My morphological data varies from binary and multisate characters,
including polymorphism and non-applicable coding for many of those
characters. I've made a lot of progress after Liam's advices, but
lately I
have been getting an error from make.simmap.

By trying to run a simulation with make.simmap under ARD model on
characters with states that the probability is zero on occuring in a
given
terminal,  after calling summary(), this error is displayed:

Error in colMeans(x$count) : 'x' must be an array of at least two
dimensions

When changing the input of the same data in a two column array, the
error
still persists. The same data was analyzed with make.simmap under
"ER" and
"SYM" models, and they run just fine. I am also comparing the
results using
fitDiscrete (geiger) and ace (ape) functions and they display
results for
"ARD" model without a glitch. According to output from fitDiscrete
function, ARD model is indicated as the "best" model comparing AIC
likelihoods.
I've noticed that in this particular character, the "Q" matrix extracted
from make.simmap simmulation under "ARD" is the following:

Q =
           0        1
0 -1.916782 1.916782
1  0.00 0.00

Are those "zero" probabilities the cause of the error? And by that I
mean,
should I take from this evidence that "ARD" is not an appropriate
model to
this character?

Also, results from characters with "non-applicable" coding (NA in
matrix)
for some terminal are coming out very different from what I would
expect.
Is this coding allowed for ancestral reconstruction?
I am sorry for the many questions, and I would be very glad if any
suggestions come to mind.

Best wishes,
Carolina Vieira.

-
This is the error rundown:

 > anc.tree_ard<-make.simmap(tree,ch434,model="ARD")
make.simmap is sampling character histories conditioned on the
transition
matrix

Q =
           0        1
0 -1.916782 1.916782
1  0.00 0.00
(estimated using likelihood);
and (mean) root node prior probabilities
pi =
   0   1
0.5 0.5
Done.
 > plot(anc.tree_ard,node.numbers=T,cores,fsize=0.5,ftype="i")
 > add.simmap.legend(colors=cores,prompt=FALSE,x=0.5*par()$usr[1],
+                   y=-30*par()$usr[3],fsize=0.8)
 > title(main="ACSR \"ARD\" model (make.simmap)")
 > anc.tree_ard<-make.simmap(tree,ch434,model="ARD",nsim=1000)
make.simmap is sampling character histories conditioned on the
transition
matrix

Q =
           0        1
0 -1.916782 1.916782
1  0.00 0.00
(estimated using likelihood);
and (mean) root node prior probabilities
pi =
   

Re: [R-sig-phylo] Alllowing and considering "missing data" as values for reconstruction of ancestral character states

2020-02-26 Thread Liam J. Revell

Dear Carolina.

After running make.simmap with nsim=100 or more, just run summary( ) on 
your "multiSimmap" object and then plot the result. For instance:


map.trees<-make.simmap(tree,x,model="SYM",nsim=200)
map.summary<-summary(map.trees)
print(map.summary)
plot(map.summary,ftype="off",lwd=1,cex=c(0.7,0.4))
map.summary$ace ## probabilities at nodes

All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, 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 2/24/2020 2:33 PM, Carolina Santos Vieira wrote:

**[EXTERNAL SENDER]

Hi Liam,

Thank you very much for clearing that up!
I was able to run the make.simmap script, but in the first plot instead 
of getting one symbol of the corresponding state at the tips, they are 
displayed in proportional sizes (I've attached the plot).


I have also looked into how to get the likelihoods from each ancestral 
state from this analysis (like we get from "lik.anc" in ace function), 
but didn't find it. Is it possible to get it?


Thank you again for the help!
Best regards,
Carolina Vieira
Bióloga - Mestre em Ecologia e Conservação
Doutoranda em Biologia Animal (PPGBAN - UFRGS)


Em sex., 21 de fev. de 2020 às 22:53, Liam J. Revell 
mailto:liam.rev...@umb.edu>> escreveu:


Dear Carolina.

I don't know how rayDISC works (but the authors of corHMM are on this
list, so they will probably respond); however, for
phytools::make.simmap
& phytools::rerootingMethod, which can also handle missing data,
missingness is coded by supplying the input data in the form of an N
x k
matrix for N species & k character states. In this case, we would
put 0s
and 1s in any row in which the character state was known; and a series
of values of 1/k for any completely unknown state.

For instance:
         0       1       2
sp A    0       0       1
sp B    1       0       0
sp C    1/3     1/3     1/3
sp D    0       1/2     1/2

corresponds to species A in state '2', species B in state '0', and
species C unknown or missing. Species D is in either state '1' or '2',
but not in state '0'. (Instead of 1/k you can also set them all to
be 1.
The likelihood changes, but ancestral states are the same.)

I hope this is helpful. All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2F=02%7C01%7Cliam.revell%40umb.edu%7Cbeaccbb894534e0785d708d7b9607ccd%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637181696380978269=%2Fialzss4jrVm8Rpt6jDUXwkdGqQZMMFA4N84HgVhWps%3D=0>

Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

On 2/21/2020 8:22 PM, Carolina Santos Vieira wrote:
 > [EXTERNAL SENDER]
 >
 > Dear all,
 >
 > I am working with a morphological matrix which contains multistate
 > characters (including polymorphism) and some missing data entries
(coded as
 > NA in data file for input). There are no unvariable characters in
coding.
 > For the reconstruction of ancestral characters, I came across
with rayDISC
 > function from corHMM package (since fitDiscrete doesn't seem to
account for
 > it).
 >
 > However, when running the script two kinds of errors are displayed:
 >
 > - Calling the full data file with the rayDISC function, no matter
which
 > character is selected for the analysis, it returns with this error:
 >
 > rayDISC(phy,data, ntraits=1, charnum=1, rate.mat=NULL, model=c("ER"),
 > node.states=c("marginal"), state.recon=c("subsequently"),
 > lewis.asc.bias=FALSE, p=NULL, root.p=NULL, ip=NULL, lb=0, ub=100,
verbose=TRUE,
 > diagn=FALSE)
 >
 > $diagnostic
 > [1] "Character 1 is invariant. Analysis stopped."
 >
 >
 > - I have tried clipping the data creating a new object with just one
 > of the characters, but a new error appears:
 >
 > Error in data[, 1] : incorrect number of dimensions
 >
 > I also looked into running make.simmap in parallel
 >

(https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.phytools.org%2F2017%2F11%2Frunning-makesimmap-in-parallel.htmldata=02%7C01%7Cliam.revell%40umb.edu%7Ce210401fdd8c483d2bde08d7b735d3f4%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637179

Re: [R-sig-phylo] Alllowing and considering "missing data" as values for reconstruction of ancestral character states

2020-02-21 Thread Liam J. Revell

Dear Carolina.

I don't know how rayDISC works (but the authors of corHMM are on this 
list, so they will probably respond); however, for phytools::make.simmap 
& phytools::rerootingMethod, which can also handle missing data, 
missingness is coded by supplying the input data in the form of an N x k 
matrix for N species & k character states. In this case, we would put 0s 
and 1s in any row in which the character state was known; and a series 
of values of 1/k for any completely unknown state.


For instance:
0   1   2
sp A0   0   1
sp B1   0   0
sp C1/3 1/3 1/3
sp D0   1/2 1/2

corresponds to species A in state '2', species B in state '0', and 
species C unknown or missing. Species D is in either state '1' or '2', 
but not in state '0'. (Instead of 1/k you can also set them all to be 1. 
The likelihood changes, but ancestral states are the same.)


I hope this is helpful. All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, 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 2/21/2020 8:22 PM, Carolina Santos Vieira wrote:

[EXTERNAL SENDER]

Dear all,

I am working with a morphological matrix which contains multistate
characters (including polymorphism) and some missing data entries (coded as
NA in data file for input). There are no unvariable characters in coding.
For the reconstruction of ancestral characters, I came across with rayDISC
function from corHMM package (since fitDiscrete doesn't seem to account for
it).

However, when running the script two kinds of errors are displayed:

- Calling the full data file with the rayDISC function, no matter which
character is selected for the analysis, it returns with this error:

rayDISC(phy,data, ntraits=1, charnum=1, rate.mat=NULL, model=c("ER"),
node.states=c("marginal"), state.recon=c("subsequently"),
lewis.asc.bias=FALSE, p=NULL, root.p=NULL, ip=NULL, lb=0, ub=100, verbose=TRUE,
diagn=FALSE)

$diagnostic
[1] "Character 1 is invariant. Analysis stopped."


- I have tried clipping the data creating a new object with just one
of the characters, but a new error appears:

Error in data[, 1] : incorrect number of dimensions

I also looked into running make.simmap in parallel
(https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.phytools.org%2F2017%2F11%2Frunning-makesimmap-in-parallel.htmldata=02%7C01%7Cliam.revell%40umb.edu%7Ce210401fdd8c483d2bde08d7b735d3f4%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637179314141242835sdata=%2FHwtbpjRxREIS7T2PPIQZ%2B5iyRpVbGaHMKWX6e8%2Fb5U%3Dreserved=0),
and this happens: " Error in if (any(x < 0)) x <- x - min(x) :
missing Value when TRUE/FALSE needed ". Trying to replace NA as
'unknown' to be considered in the analysis by changing its "status" to
FALSE, it returns in the matrix coded as "0", which is not properly
valid since this implies coding it as a known state (and not missing
data, as it truly is).


I appreciate if anyone could shine a light on this matter.
With regards,
Carolina Vieira
Bióloga - Mestre em Ecologia e Conservação
Doutoranda em Biologia Animal (PPGBAN - UFRGS)

 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=02%7C01%7Cliam.revell%40umb.edu%7Ce210401fdd8c483d2bde08d7b735d3f4%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637179314141252833sdata=feVEKUpekTBV5FVzfZDdDU7sJGi6x%2FGtumn3TpmhRuk%3Dreserved=0
Searchable archive at 
https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=02%7C01%7Cliam.revell%40umb.edu%7Ce210401fdd8c483d2bde08d7b735d3f4%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637179314141252833sdata=8otz0Vyk02Uo2uGw4fWbOqfuA4EKp8GQ71cZufu3XFg%3Dreserved=0



___
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] aov.phylo vs phylANOVA

2018-11-15 Thread Liam J. Revell

Hi Jacob.

As far as I know, aov.phylo and phylANOVA should be doing more or less 
the same thing. With random data if I run enough simulations for the 
null distribution of F the P-values of the two different implementations 
come out almost exactly the same. One difference that I noted is that if 
you give either method data vectors without taxon names both work, but 
only phylANOVA gives a warning.


Please send along the data that has generated this incongruency if you 
are unable to figure it out.


All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

On 11/15/2018 2:30 PM, Jacob Berv wrote:

Dear R-sig-phylo,
I was wondering if anyone on here might be able to help me understand the 
difference between phytool’s implementation of phylogenetic ANOVA and geiger’s 
implementation. From the respective documentation, it seems that both 
approaches rely on and cite the same reference:

Garland T Jr, AW Dickerman, CM Janis, and JA Jones. 1993. Phylogenetic analysis 
of covariance by computer simulation. Systematic Biology 42(3):265-292.

Both seem to have a similar approach, at least as it is described in their 
respective documentations, and both seem to rely on character simulations to 
derive their p values. It seems aov.phylo uses sim.char() and phylANOVA uses 
fastBM() for their simulations internally.

On Liam’s blog, he indicates that these tests are the same, except that 
phylANOVA additionally performs post-hoc tests.
http://blog.phytools.org/2013/02/updated-phylanova.html

However, running some of my data through both of these tests is generating 
totally different results (aov.phylo detecting significant differences where 
phylANOVA does not, with p values differing by 5 orders of magnitude.

Running my same test data~group through a pgls also generates a result 
comparable to what I get from phylANOVA — so it seems like perhaps aov.phylo is 
the outlier?

Best,
Jake Berv
___
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/


Re: [R-sig-phylo] Problem with make.simmap in Phytools

2018-10-31 Thread Liam J. Revell

Dear Kimberly.

I see one error in your script which is that when you populate the list 
of sets of stochastic map trees you call the object 'simtrees' - but 
when you try to summarize the results, you attempt to pass an object 
called 'simtree' (no 's') to the summary method.


A couple of other comments.

(1) The function call list(500) creates a list with one object, the 
numeric value 500, rather than a list with 500 elements.


(2) In general, it is not necessary to iterate tree by tree over you 
"multiPhylo" object in the way you have. Instead, the simple call:


simtrees<-make.simmap(trees,trait,model,nsim)

will produce a "multiSimmap" object containing nsim x length(trees) 
stochastic map trees.


(3) Finally, you can call the S3 summary method for the object class 
"multiSimmap" directly on this single, "multiSimmap" object containing 
all the stochastic map trees - rather than on each set of nsim trees in 
turn. If you decide to do that, however, you should keep in mind that 
trees from a Bayesian posterior sample may differ one from the other in 
topology. For this I recommend using the argument check.equal OR 
supplying a reference tree via the argument ref.tree. In the former 
case, the method first checks if all trees are equal, and if they are 
not, computes a consensus tree and the posterior probabilities at each 
node of the consensus topology conditional on that node being present in 
each sampled tree. If ref.tree is supplied, the method will do the same 
but using the reference tree instead of a consensus tree. In the case of 
Bayesian MCMC, the reference tree could be (for instance) the MCC tree. 
Useful examples may be found be searching for "ref.tree" on my blog.


I hope that this helps you find your error. If it does not, please free 
to send me your saved workspace & I will try to figure it out.


All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

On 10/31/2018 4:49 PM, Kimberly Lynn Foster wrote:

Hello, I am currently trying to run make.simmap in Phytools ver 0.6-60 and 
Geiger ver 2.0.6, I am running the function on a subsample of 500 trees from 
the posterior distribution. I have included the full code, but there error I 
get is found in the last line of code

simtrees<-list(500)
YY<-list(500)
for (i in 1:500){
   simtrees[[i]]<-make.simmap(CrenuchidTreesLadderized[[i]], habitattrait, 
model="ER", nsim=1000)
   YY[[i]]<- describe.simmap(simtree[[i]], plot=F)
}


ERROR = Error in UseMethod("isSymmetric") :
   no applicable method for 'isSymmetric' applied to an object of class "c('double', 
'numeric')"


Any help would be greatly appreciated, full code below:


require(phytools)
require(geiger)


habitat<-read.csv("C:/Users/XXX/Dropbox/Crenuchid R Files/Crenuchid R 
Files/Crenuchid_2state_BvsP.csv", row.names=1)
habitat[habitat==0] <- "Pelagic"
habitat[habitat==1] <- "Benthic"
habitat_color <- habitat


habitat_color[habitat=="Benthic"] <- "#6EA0FF"   ### blue
habitat_color[habitat=="Pelagic"] <- "#FFB322" ### Orange

# simmap  multiple trees 
.
  alltrees<-read.nexus("posteriorsamples.tre.trprobs") #reading trees from 
posteior distribution

  wib <- name.check(phy=alltrees[[1]], data=habitat)
  wib ## will show what is in tree not data, data not tree

  # ??name.check
# Now to drop tips
length(alltrees)
prunedpostsamp<-list(500)
for (i in 1:500){
prunedpostsamp[[i]]<-drop.tip(alltrees[[i]], wib$tree_not_data)
}
  wib <- name.check(phy=prunedpostsamp[[1]], data=habitat)
  prunedpostsamp[[1]]$tip.label
  #Let's ladderize all trees in the distribution with lapply() and plot the 
first tree again
  CrenuchidTreesLadderized <- lapply(prunedpostsamp, ladderize)
plot(CrenuchidTreesLadderized[[1]], cex=0.4) #Plot the first ladderized tree
  #However, does the order of tips in the plot match the order of tiplabels in 
the tree object?   NO help? is this the issue ???

#Please 
compare##
CrenuchidTreesLadderized[[1]]$tip.label

habitattrait<-habitat[CrenuchidTreesLadderized[[1]]$tip.label,]
names(habitattrait)<- CrenuchidTreesLadderized[[1]]$tip.label

length(habitattrait) ## 54
class(habitattrait) ## character

#Compare tree with data
compare <- treedata(CrenuchidTreesLadderized[[1]], habitattrait, sort=TRUE) #R 
will inform you of any inconsistencies and how they were solved!
?treedata

### SIMMAP for multiple trees this can take a while while while 



simtrees<-list(500)
YY

Re: [R-sig-phylo] Adding species to genera tree as polytomies

2018-10-16 Thread Liam J. Revell

Hi Liam.

First of all, great choice of names!

Secondly, add.species.to.genus is a very old function & I wouldn't be 
surprised to find that it had some bugs. Be forewarned!


Thirdly, I used Will's suggestion & got the function to work in the 
script you sent to me off-list, but with one additional modification 
that in your 'for' loop you were not replacing the tree with the added 
tip in each iteration of the loop. I.e.:


new.tree<-tree
for (i in 1:length(tips)){
new.tree<-add.species.to.genus(tree,tips[i])
}

will only result in a tree with one more tip than the original tree. 
Your script should instead have the form:


new.tree<-tree
for (i in 1:length(tips)){
new.tree<-add.species.to.genus(new.tree,tips[i])
}

Note that where="root" does not work if a genus is monotypic (as yours 
will be the first time a new tip is added to a given genus) & instead 
the species will be added halfway along the edge leading to that genus. 
Henceforward, additional species will be added to this point. This (or 
some variant thereof) must be the case, because if new tips were instead 
added at the start of this edge then sister genera would invariably form 
single, polytomous combs. (Draw it on a piece of paper. You'll see what 
I mean.)


Finally, I noticed that some of your edge lengths in the original tree 
have negative lengths. This is not a problem for the method, as it turns 
out, but it will create an interesting visualization when graphed.


Here is your fully modified script:

library(phytools)
bee_tree=read.tree("bee_tree.nex")
species=read.csv("species.csv",stringsAsFactors = FALSE)
beetree<-bee_tree
## Will's suggestion
beetree$tip.label<-paste(beetree$tip.label,"_sp.",sep="")
for(i in 1:length(species$Genus_species)){
beetree<-add.species.to.genus(beetree,species$Genus_species[i],
where="root")
}
## prune out these same taxa
ii<-grep("sp.",beetree$tip.label)
beetree<-drop.tip(beetree,beetree$tip.label[ii])

I hope this is helpful.

All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

On 10/15/2018 11:01 PM, Liam Kendall wrote:

Hi members,

I am struggling with what I think is a relatively simple problem. I have a 
genera tree (i.e. genera are the branch tips) that I need to add 390 species to 
as polytomies with equal branch lengths below the genera tips/nodes.

Can anyone help me do this in R? I have tried a for loop using 
add.species.to.genus from phytools but it doesn’t work, I am guessing this is 
because the genera are tips rather than nodes (and I cant debug the code to 
find a solution).

Is there another function in the R universe that might work?

Any help would be much appreciated.

Best,
Liam
___
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/


Re: [R-sig-phylo] change colors in make.simmap

2018-09-26 Thread Liam J. Revell

Hi Martin.

The solution of Gopal will work to change the color scheme of the
'densityMap' object, but this is also automated in the function setMap.

For example (in which trees is our 'multiSimmap' object):

obj<-densityMap(trees,res=200,plot=FALSE)
plot(obj) ## original color gradient
obj<-setMap(obj,invert=TRUE)
plot(obj) ## flipped color gradient
obj<-setMap(obj,c("blue","green","yellow"))
plot(obj,outline=TRUE,lwd=4) ## arbitrary gradient

However, you have probably noted that the function plots the posterior 
probability of being in a given state, by default the alphanumerically 
second of the two mapped states. This can also be changed as follows (in 
which x is our trait vector):


ss<-sort(unique(x))[2:1]
obj<-densityMap(trees,res=200,plot=FALSE,states=ss)
plot(obj)

In this case what should be plotted is the posterior probability of 
being in the alphanumerically first state, rather than the second.


All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

On 9/26/2018 9:23 AM, Gopal Murali wrote:

Hi Martin, The below code might help you.

require(phytools) tree<-pbtree(n=100) # simulate tree 
s<-sample(c(0,1),100,replace = T) # create character state 
names(s)<-tree$tip.label # assign tip labels to character state 
mtreel<-make.simmap(tree,s,nsim=10) XX <- densityMap(mtreel, lwd =

2,ftype="off") s<-colorRampPalette(c("green","red")) # change the
colors here XX$cols[]<-s(length(XX$cols)) plot(XX, lwd =
2,ftype="off",outline=FALSE)

Regards, Gopal Murali

-

 *“**How strange is the lot of us mortals! Each of us is here for a
brief sojourn; for what purpose he knows not, though he sometimes
thinks he senses it. But without deeper reflection one knows from
daily life that one exists for other people…a hundred times every day
I remind myself that my inner and outer life are based on the labors
of other men, living and dead, and that I must exert myself in order
to give in the same measure as I have received and am still
receiving,”* ― Albert Einstein 
<http://www.goodreads.com/author/show/9810.Albert_Einstein> 
-




On Wed, Sep 26, 2018 at 5:36 PM  wrote:


Hello,

I want to change the colors of a Bayesian stochastic mapping,
using make.simmap (e.g., switching blue and red). Is it possible?

(I tried switching the order of the columns of the states -- no
effect.)

Thanks for any help!

Martin Ramirez

___ 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/



___
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] Issue with SIMMAP on 500 sampled Trees

2018-09-15 Thread Liam J. Revell

Hi Kimberly.

What version of phytools are you using? Neither make.simmap nor 
describe.simmap call MatrixExp.


All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

On 9/15/2018 10:38 AM, Kimberly Lynn Foster wrote:

Hello, I am looking at a family of fish and habitat transitions using SIMMAP in 
phytools.

I keep running into the error below when using a subsample of 500 trees. I used 
compare.tree and check.names to make sure all my tips match my data and visa 
versa. Any help would be greatly appreciated.



simtrees<-list(500)
YY<-list(500)
for (i in 1:500){

+ simtrees[[i]]<-make.simmap(CrenuchidTreesLadderized[[i]], habitattrait, 
model="ER", nsim=1000)
+ YY[[i]]<- describe.simmap(simtree[[i]], plot=F)
+ }
Error in MatrixExp(Y) : "mat" must be a square matrix



Kim

[[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 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] Aligning tree tip labels together in ape

2018-08-24 Thread Liam J. Revell

Hi Nick.

The following is a 'solution' that works with phytools; however, you 
should keep in mind that you will not generally be able to use a 
constant offset value if your tip labels vary in length. In that case, 
you would either have to use a variable offset or figure out the minimum 
offset required such that the circles fall outside of the taxon labels.


library(phytools)
par(lty="dotted",fg="black")
plotTree(force.ultrametric(sim_tree,"extend"),type="fan",lwd=1)
tiplabels(pch = 19, col = rainbow(3), offset = 6)
par(lty="solid",fg="transparent")
plotTree(sim_tree,type="fan",lwd=1,add=TRUE)
par(fg="black")

For a more general solution you might offset your taxon labels by a 
constant amount, or you can use the function strwidth and some basic 
trigonometry to find the position outside the taxon labels to draw your 
circles.


All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

On 8/24/2018 10:04 AM, Carleson, Nick wrote:

Hello all,

I'm using the R package 'ape' to make non-ultrametric phylogenetic trees 
. I want to align tip labels together when drawing a tree with 
plot.phylo(), and also add on more labels using the tiplabels() 
function. But, I can't get additional tip labels from tiplabels aligned 
properly with those from plot.phylo. When I call tiplabels, the labels 
are being drawn at the true edge length instead of neatly around the 
plot with the tip labels drawn by plot.phylo. So, in the plot below, I 
want the tip labels (circles) to be aligned adjacent to the tip labels 
(names) drawn byplot.phylo.


Good: tips like t30, t31, and t2
Bad: tips like t1, t20, and t21




Can anyone help me out?

Below is the code to produce the tree above. I'm using ape version 5.1 
and R version 3.4.3.


library(ape)
set.seed(31)
sim_tree <- rlineage(0.1, 0.05)
plot.phylo(sim_tree, type = "fan", align.tip.label = TRUE)
tiplabels(pch = 19, col = rainbow(3), offset = 6)

Thanks all!

**Nick Carleson*
*

**

PhD Student*| Oregon State University
*Graduate Research Assistant | *Botany and Plant Pathology**
*



___
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/


Re: [R-sig-phylo] Question regarding log likelihood in OUCH package

2018-08-12 Thread Liam J. Revell

Hi Danielle.

With regard to the first problem, that is not an error. Likelihoods 
obtained from continuous probability densities are not probabilities 
(these can only be obtained by integrating the density function on a 
finite interval) and thus can take values >1 (and thus log-likelihoods >0).


In my experience, the most common reason for the second problem is a 
tree with zero-length terminal edges (and thus covariances between 
species that are equal to their respective variances). The solution to 
this *should not* be to add a very small value to the offending terminal 
edges, as this can give very high weight to the associated tips. It 
might be by pruning one tip or the other from the analysis, or by using 
some reasonable criterion to modify the terminal edge lengths.


All the best,

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

On 8/12/2018 11:32 AM, Danielle Miller wrote:

Hi,

I’m interested in using the OUCH package to estimate BM and OU parameters for a 
specific trait among many different trees.
My goal is to determined which model is the most suitable for each tree, 
applying likelihood ratio test.

As I’m a new user in R when it comes to phylogenetic analysis, I started by 
running the documentation example (Hansen, documentation page 11) and was 
surprised to see that the loglikelihood was a positive number

BM:
$call
brown(data = otd[c("tarsusL", "beakD")], tree = ot)

$sigma.squared
[,1]   [,2]
[1,] 0.02878091 0.08897504
[2,] 0.08897504 0.43711838

$theta
$theta$tarsusL
[1] 3.020419

$theta$beakD
[1] 1.826695


$loglik
[1] 9.90115

As this number is crucial for further analysis - Is this a transformation of 
the resulting log likelihood? (e.g. -2 * log(L) as described in the paper) or 
am I missing something here..?

In addition I have another issue, I have a tree constructed of ~400 viral 
genomes and their corresponding trait values. When I’m running the 
documentation script with my own data (in the same format)
I get the following error:
Error in solve.default(v, e) :
   system is computationally singular: reciprocal condition number = 1.59061e-17

I guess it says that my variance covariance matrix is not inversable, hence I 
manually tried to adjust the retol parameter in the Hansen function in order to 
make it work (however I’ll need to second guess my results?), but I still get 
the same error.
Code example:
h1 <- hansen(
+ tree=ot,
+ data=otd[c("k5")],
+ regimes=otd["regimes"],
+ fit=TRUE,
+ sqrt.alpha=1,
+ sigma=1,
+ maxit=50,
+ reltol=1e-20,
+ method="Nelder-Mead"
+ )

I’ll be thankful for any advice or answer,
Danielle

  

  


___
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/


Re: [R-sig-phylo] p-value in pgls.Ives

2018-07-30 Thread Liam J. Revell

Dear Iara.

In fact, it is now possible to conduct a null hypothesis test with this 
method in phytools. I posted about it in my blog in 2017: 
http://blog.phytools.org/2017/11/bivariate-phylogenetic-regression-with.html.


All the best, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/

On 7/30/2018 8:12 AM, Iara Reinaldo Coriolano wrote:

Hello all,

I'm using the function pgls.Ives() from the package phytools to incorporate
within-species variance in both variables. I would like to know whether a
statistic to evaluate the significance of the values were incorporated
after the 2015 post asking about it.

Thanks in advance,

Iara Reinaldo Coriolano
Bacharela em Ciências Biológicas pela Universidade Federal do Ceará
Mestranda pelo Programa de Pós-graduação em Ecologia - UFRGS
Laboratório de Ecologia de Populações - UFRGS - http://ferrazlab.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/



___
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] Simulating tree from a given tree

2018-07-30 Thread Liam J. Revell

Dear Miguel & Eduardo.

This is correct, except that you should keep in mind that pbtree (like 
most, but not all, such simulators) generates trees from the first 
speciation event. Thus, the correct procedure must first involve drawing 
a wait time from an exponential distribution, deciding if the next event 
was a speciation or an extinction, attaching a stem to the base tree, 
and then (if the event was a speciation) simulating a birth-death tree 
to attach to this stem.


The algorithm would thus be something like:

1. Decide on a desired total height for the tree, h. (If, say, the tree 
has a current total height/depth of 100, this could be any value >100.)

2. Go to a tip in the base tree. Compute it's height, t1.
3. Draw a random value from an exponential distribution, t2, with rate 
b+d for birth rate b & death rate d.
4. If t1+t2Otherwise, add h-t1 to the current tip and go to 2 for the next tip.
5. Decide if the current event is a speciation or extinction event. Draw 
a random value from a uniform distribution on (0,1). If that value is 
greater than b/(b+d) you are done with this tip: go back to step 2 for 
the next tip. Otherwise, advance to step 6.
6. Compute t3=h-(t1+t2). Simulate a birth-death tree for t3 with birth & 
death rates b & d. Attach the b/d tree to the current tip. Advance to 
the next tip & go back to step 2.


All the best, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/

On 7/30/2018 8:58 AM, Eduardo Ascarrunz wrote:

Maybe you could use a birth-death model. You can estimate the speciation
rate and extinction rate from your original tree, and use those parameters
to run simulations of trees for 5 My with the pbtree function from
phytools. Run as many simulations as you have living tips in your original
tree, and bind each simulated tree to one of the living tips. It shouldn't
be too difficult to write a wrapper function to perform all those steps.

Cheers,

Eduardo

2018-07-29 11:06 GMT+02:00 :


Hi list:

Is there any function to simulate a tree from a given tree?. For example,
I have a tree encompassing 10 Million years and I would like to simulate
the "growth" of such tree for the following 5 MY.

Thanks in advance

Miguel Verdú

--

Centro de Investigaciones sobre Desertificacion
(CSIC-UV-GV)
Carretera Moncada - Náquera, Km. 4,5
Apartado Oficial
46113 Moncada (Valencia)
Spain
Tel +34 96 3424204
Fax +34 96 3424160
www.uv.es/verducam

___
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/



___
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 Liam J. Revell

Dear Alyson.

There is no general rule about this; however, my suggestion would be to 
use log-scaled values. This is because on a log-scale proportional 
changes in the trait are equal, independent of the magnitude of the 
trait. That is, a change of 1% in mass of whale is the same as a change 
in 1% in mass of a mouse. If your analysis includes both mice and 
whales, then on the original scale mice may appear to be changing very 
little in mass, while whales change a great deal - even if (relative to 
their sizes) both groups are changing just as much. On the other hand, 
if your analysis is of only whales or only mice it will make relatively 
little difference whether you use log-scaled data or the original values.


I hope this is of some help. All the best, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/

On 7/13/2018 2: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 <http://www.linkedin.com/pub/alyson-brokaw/3a/704/820>
Follow my research journey here! <http://afbrokaw.wordpress.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/



___
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] midpoint.root Error in phy$edge[, 2] : incorrect number of dimensions

2018-05-15 Thread Liam J. Revell
No idea. Are they running different R or package versions? 
phytools::midpoint.root has not been updated recently, but other 
internally used functions may have been.


All the best, Liam

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/15/2018 10:49 AM, Juan Antonio Balbuena wrote:

Thank you very much for your quick response.

I have the tree file in a cloud. When I run the code in one computer I 
get the error, whereas in the other one it runs fine. I use Windows 7 in 
both. So it is kind of weird.


Any idea of the reason?

All the best,

Juan


El 15/05/2018 a las 17:38, Liam J. Revell escribió:

Hello Juan.

I was able to read your tree & midpoint root it using 
phytools::midpoint.root no problem. I will paste the tree I created 
below, but note also that phangorn::midpoint is functionally 
equivalent & when I run:


tree<-read.tree(text=text) ## from your Newick string
t1<-midpoint.root(tree)
t2<-midpoint(tree)
all.equal.phylo(t1,t2)

I get TRUE.

All the best, Liam

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/15/2018 10:29 AM, Juan Antonio Balbuena wrote:

Hi all

This is really odd. I am using a piece of ode that used to work just 
fine with the very same file shown below. I changed computer and now 
get this error:


library(ape)

TreeH <- read.tree("Pf_tree_short.nwk")

TreeH <- midpoint.root(TreeH)
Error in phy$edge[, 2] : incorrect number of dimensions


The file Pf_tree_short.nwk si pretty short, so I can copy its 
contents here:


(PfH1:0.001054642,PfH9:0.004127868,((PfH3:0.08953517,(((PfH6:0.02378674,((PfH34:0.00255086,PfH40:0.00253142):0.001075694,(PfH39:0.002549484,PfH57:0.002551486):0.001030445):8.177499E-4,((PfH36:0.002555701,PfH43:0.002524015):0.001047094,(PfH41:0.002543331,PfH45:0.004011249):0.001035931):7.855741E-4):9.836483E-4,(PfH35:0.001056611,PfH38:0.002496405):0.001112379):0.00252234,(PfH37:0.002543709,PfH42:0.001073064):0.002640093):0.002623932,PfH56:0.00276149):0.02310424):0.01273145,PfH48:0.003223183):0.004103919,PfH44:0.006145397):0.06303876):0.04205169,(((PfH12:0.001042118,PfH25:0.002470368):9.797E-4,(PfH13:0.002446243,PfH16:0.002441275):9.147032E-4):8.726904E-4,(PfH14:0.002486386,PfH21:0.0025004):0.001079044):0.001147637,(PfH19:0.002508287,PfH22:0.002461656):0.001011963):0.00115,PfH24:0.00242401):0.002458328,(PfH15:0.003791243,PfH17:0.001056495):0.001058053):0.003886796,PfH23:0.004767665):0.1242874):0.1359654,PfH60:0.001068025,PfH84:0.0025608):0.001109104,(PfH81:0.00250909,PfH82:0.002508367):0.001089697):0.001053748,PfH83:0.002545513):0.002170283,(PfH79:0.001092604,PfH80:0.002562978):0.002563944):1.774651):0.09853968,(PfH26:0.001054175,PfH33:0.002518196):0.001162092,(PfH29:0.002488133,PfH70:0.003882958):0.001150588):7.06569E-4,(((PfH28:0.002519167,PfH32:0.002553086):9.516619E-4,(PfH31:0.002530325,PfH66:0.002590319):0.00105028):9.560662E-4,((PfH30:0.002507623,PfH74:0.002610591):0.001005149,(PfH68:0.002510002,PfH69:0.002556393):0.001053178):0.002324076):4.840203E-4):6.291873E-4,((PfH67:0.002528606,PfH72:0.00404201):0.001078995,(PfH75:0.005680973,PfH76:0.002538044):0.001066169):3.313337E-4):0.002079495,((PfH27:0.001071028,PfH71:0.005683054):0.001274396,PfH73:0.002455681):0.002553291):0.01016512):0.01257902,(PfH62:0.001050343,PfH63:0.004185532):0.005860629):0.00256691,PfH10:0.002582213):0.001063792); 



Any help will be most welcome.


Juan




___
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] midpoint.root Error in phy$edge[, 2] : incorrect number of dimensions

2018-05-15 Thread Liam J. Revell

I forgot to post the re-rooted Newick string as promised. It follows:

(PfH60:0.001068025,PfH84:0.0025608):0.001109104,(PfH81:0.00250909,PfH82:0.002508367):0.001089697):0.001053748,PfH83:0.002545513):0.002170283,(PfH79:0.001092604,PfH80:0.002562978):0.002563944):1.030357599,(PfH1:0.001054642,PfH9:0.004127868):0.001063792,PfH10:0.002582213):0.00256691,(PfH62:0.001050343,PfH63:0.004185532):0.005860629):0.01257902,(PfH26:0.001054175,PfH33:0.002518196):0.001162092,(PfH29:0.002488133,PfH70:0.003882958):0.001150588):0.000706569,(((PfH28:0.002519167,PfH32:0.002553086):0.0009516619,(PfH31:0.002530325,PfH66:0.002590319):0.00105028):0.0009560662,((PfH30:0.002507623,PfH74:0.002610591):0.001005149,(PfH68:0.002510002,PfH69:0.002556393):0.001053178):0.002324076):0.0004840203):0.0006291873,((PfH67:0.002528606,PfH72:0.00404201):0.001078995,(PfH75:0.005680973,PfH76:0.002538044):0.001066169):0.0003313337):0.002079495,((PfH27:0.001071028,PfH71:0.005683054):0.001274396,PfH73:0.002455681):0.002553291):0.01016512):0.09853968,((PfH3:0.08953517,(((PfH6:0.02378674,((PfH34:0.00255086,PfH40:0.00253142):0.001075694,(PfH39:0.002549484,PfH57:0.002551486):0.001030445):0.0008177499,((PfH36:0.002555701,PfH43:0.002524015):0.001047094,(PfH41:0.002543331,PfH45:0.004011249):0.001035931):0.0007855741):0.0009836483,(PfH35:0.001056611,PfH38:0.002496405):0.001112379):0.00252234,(PfH37:0.002543709,PfH42:0.001073064):0.002640093):0.002623932,PfH56:0.00276149):0.02310424):0.01273145,PfH48:0.003223183):0.004103919,PfH44:0.006145397):0.06303876):0.04205169,(((PfH12:0.001042118,PfH25:0.002470368):0.0009797,(PfH13:0.002446243,PfH16:0.002441275):0.0009147032):0.0008726904,(PfH14:0.002486386,PfH21:0.0025004):0.001079044):0.001147637,(PfH19:0.002508287,PfH22:0.002461656):0.001011963):0.00115,PfH24:0.00242401):0.002458328,(PfH15:0.003791243,PfH17:0.001056495):0.001058053):0.003886796,PfH23:0.004767665):0.1242874):0.1359654):0.7442934008);


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/15/2018 10:38 AM, Liam J. Revell wrote:

Hello Juan.

I was able to read your tree & midpoint root it using 
phytools::midpoint.root no problem. I will paste the tree I created 
below, but note also that phangorn::midpoint is functionally equivalent 
& when I run:


tree<-read.tree(text=text) ## from your Newick string
t1<-midpoint.root(tree)
t2<-midpoint(tree)
all.equal.phylo(t1,t2)

I get TRUE.

All the best, Liam

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/15/2018 10:29 AM, Juan Antonio Balbuena wrote:

Hi all

This is really odd. I am using a piece of ode that used to work just 
fine with the very same file shown below. I changed computer and now 
get this error:


library(ape)

TreeH <- read.tree("Pf_tree_short.nwk")

TreeH <- midpoint.root(TreeH)
Error in phy$edge[, 2] : incorrect number of dimensions


The file Pf_tree_short.nwk si pretty short, so I can copy its contents 
here:


(PfH1:0.001054642,PfH9:0.004127868,((PfH3:0.08953517,(((PfH6:0.02378674,((PfH34:0.00255086,PfH40:0.00253142):0.001075694,(PfH39:0.002549484,PfH57:0.002551486):0.001030445):8.177499E-4,((PfH36:0.002555701,PfH43:0.002524015):0.001047094,(PfH41:0.002543331,PfH45:0.004011249):0.001035931):7.855741E-4):9.836483E-4,(PfH35:0.001056611,PfH38:0.002496405):0.001112379):0.00252234,(PfH37:0.002543709,PfH42:0.001073064):0.002640093):0.002623932,PfH56:0.00276149):0.02310424):0.01273145,PfH48:0.003223183):0.004103919,PfH44:0.006145397):0.06303876):0.04205169,(((PfH12:0.001042118,PfH25:0.002470368):9.797E-4,(PfH13:0.002446243,PfH16:0.002441275):9.147032E-4):8.726904E-4,(PfH14:0.002486386,PfH21:0.0025004):0.001079044):0.001147637,(PfH19:0.002508287,PfH22:0.002461656):0.001011963):0.00115,PfH24:0.00242401):0.002458328,(PfH15:0.003791243,PfH17:0.001056495):0.001058053):0.003886796,PfH23:0.004767665):0.1242874):0.1359654,PfH60:0.001068025,PfH84:0.0025608):0.001109104,(PfH81:0.00250909,PfH82:0.002508367):0.001089697):0.001053748,PfH83:0.002545513):0.002170283,(PfH79:0.001092604,PfH80:0.002562978):0.002563944):1.774651):0.09853968,(PfH26:0.001054175,PfH33:0.002518196):0.001162092,(PfH29:0.002488133,PfH70:0.003882958):0.001150588):7.06569E-4,(((PfH28:0.002519167,PfH32:0.002553086):9.516619E-4,(PfH31:0.002530325,PfH66:0.002590319):0.00105028):9.560662E-4,((PfH30:0.002507623,PfH74:0.002610591):0.001005149,(PfH68:0.002510002,PfH69:0.002556393):0.001053178):0.002324076):4.840203E-4):6.291873E-4,((PfH67:0.002528606,PfH72:0.00404201):0.001078995,(PfH75:0.005680973,PfH76:0.002538044):0.001066169):3.313337E-4):0.002079495,((PfH27:0.001071028,PfH71:0.005683054):0.001274396,PfH73:0.002455681):0.002553291):0.01016512):0.01257902,(PfH62:0

Re: [R-sig-phylo] midpoint.root Error in phy$edge[, 2] : incorrect number of dimensions

2018-05-15 Thread Liam J. Revell

Hello Juan.

I was able to read your tree & midpoint root it using 
phytools::midpoint.root no problem. I will paste the tree I created 
below, but note also that phangorn::midpoint is functionally equivalent 
& when I run:


tree<-read.tree(text=text) ## from your Newick string
t1<-midpoint.root(tree)
t2<-midpoint(tree)
all.equal.phylo(t1,t2)

I get TRUE.

All the best, Liam

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/15/2018 10:29 AM, Juan Antonio Balbuena wrote:

Hi all

This is really odd. I am using a piece of ode that used to work just 
fine with the very same file shown below. I changed computer and now get 
this error:


library(ape)

TreeH <- read.tree("Pf_tree_short.nwk")

TreeH <- midpoint.root(TreeH)
Error in phy$edge[, 2] : incorrect number of dimensions


The file Pf_tree_short.nwk si pretty short, so I can copy its contents 
here:


(PfH1:0.001054642,PfH9:0.004127868,((PfH3:0.08953517,(((PfH6:0.02378674,((PfH34:0.00255086,PfH40:0.00253142):0.001075694,(PfH39:0.002549484,PfH57:0.002551486):0.001030445):8.177499E-4,((PfH36:0.002555701,PfH43:0.002524015):0.001047094,(PfH41:0.002543331,PfH45:0.004011249):0.001035931):7.855741E-4):9.836483E-4,(PfH35:0.001056611,PfH38:0.002496405):0.001112379):0.00252234,(PfH37:0.002543709,PfH42:0.001073064):0.002640093):0.002623932,PfH56:0.00276149):0.02310424):0.01273145,PfH48:0.003223183):0.004103919,PfH44:0.006145397):0.06303876):0.04205169,(((PfH12:0.001042118,PfH25:0.002470368):9.797E-4,(PfH13:0.002446243,PfH16:0.002441275):9.147032E-4):8.726904E-4,(PfH14:0.002486386,PfH21:0.0025004):0.001079044):0.001147637,(PfH19:0.002508287,PfH22:0.002461656):0.001011963):0.00115,PfH24:0.00242401):0.002458328,(PfH15:0.003791243,PfH17:0.001056495):0.001058053):0.003886796,PfH23:0.004767665):0.1242874):0.1359654,PfH60:0.001068025,PfH84:0.0025608):0.001109104,(PfH81:0.00250909,PfH82:0.002508367):0.001089697):0.001053748,PfH83:0.002545513):0.002170283,(PfH79:0.001092604,PfH80:0.002562978):0.002563944):1.774651):0.09853968,(PfH26:0.001054175,PfH33:0.002518196):0.001162092,(PfH29:0.002488133,PfH70:0.003882958):0.001150588):7.06569E-4,(((PfH28:0.002519167,PfH32:0.002553086):9.516619E-4,(PfH31:0.002530325,PfH66:0.002590319):0.00105028):9.560662E-4,((PfH30:0.002507623,PfH74:0.002610591):0.001005149,(PfH68:0.002510002,PfH69:0.002556393):0.001053178):0.002324076):4.840203E-4):6.291873E-4,((PfH67:0.002528606,PfH72:0.00404201):0.001078995,(PfH75:0.005680973,PfH76:0.002538044):0.001066169):3.313337E-4):0.002079495,((PfH27:0.001071028,PfH71:0.005683054):0.001274396,PfH73:0.002455681):0.002553291):0.01016512):0.01257902,(PfH62:0.001050343,PfH63:0.004185532):0.005860629):0.00256691,PfH10:0.002582213):0.001063792); 



Any help will be most welcome.


Juan


___
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] is.binary() says "FALSE" after using multi2di()

2018-05-14 Thread Liam J. Revell

Dear Pedro.

It looks like Graham has identified the problem - that the tree has some 
'singleton' nodes. These are nodes with only one (rather than 2 or more) 
descendant edges. This can be fixed using:


tree<-collapse.singles(tree)

from the 'ape' package. Hopefully this helps.

All the best, Liam

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/14/2018 10:41 AM, Graham Slater wrote:

Hi Pedro,

multi2di on this newick string returns a tree of 102 tips with 103 nodes, so 
you seem to have a badly formatted tree. Plotting the resulting tree with all 
edge lengths = 1 does not immediately reveal, at least to me, where the 
issue(s) lie but perhaps it will to you?

Graham
--
Graham J. Slater
Assistant Professor
Department of the Geophysical Sciences
University of Chicago
5734 S. Ellis Avenue
Chicago, IL 60637 USA

Tel: (773) 702-0249
email: gsla...@uchicago.edu<mailto:gsla...@uchicago.edu>
www.fourdimensionalbiology.com<http://www.fourdimensionalbiology.com>






On May 14, 2018, at 10:16 AM, Pedro Pequeno 
<pacol...@gmail.com<mailto:pacol...@gmail.com>> wrote:

Sp_102:16,Sp_101:16,Sp_100:16,Sp_99:16,Sp_98:16):5,(((Sp_97:13,Sp_96:13,Sp_95:13,Sp_94:13):4,Sp_93:17):2):2,Sp_92:21):2,Sp_91:23):3,(Sp_90:24,Sp_89:24,Sp_88:24,Sp_87:24,Sp_86:24):2):10,Sp_85:2,Sp_84:2,Sp_83:2):10,Sp_82:12):10,Sp_81:23):2,(Sp_80:15,Sp_79:15):10):2,Sp_78:27):3,(((Sp_77:9,Sp_76:9):5,Sp_75:14,Sp_74:14):6,Sp_73:20):10):3,((Sp_72:22,Sp_71:22,Sp_70:22):5.5,Sp_69:28):5.5):3,Sp_68:14,Sp_67:14):11,Sp_66:25,(Sp_65:12,Sp_64:12):12,Sp_63:25):7,(((Sp_62:4,Sp_61:4):4,Sp_60:8):4,Sp_59:12):2,((Sp_58:3.5,Sp_57:3.5):3.5,Sp_56:7):7):3,Sp_55:17):2,(Sp_54:15,Sp_53:15):4):6,(Sp_52:20,Sp_51:20):5):7):2,Sp_50:17,Sp_49:17):9,(Sp_48:20,Sp_47:20):6):2,(Sp_46:26,Sp_45:26):2):5,((Sp_44:20,Sp_43:20):10,((Sp_42:17,Sp_41:17,Sp_40:17,Sp_39:17,Sp_38:17,Sp_37:17,Sp_36:17):12,(Sp_35:14,Sp_34:14):14):1):3):1):2):0.5):0.5,(Sp_33:29,Sp_32:29):8):8,((Sp_31:11,Sp_30:11):2,Sp_29:13):3,(Sp_28:8,Sp_27:8):8,((Sp_26:5.3,Sp_25:5.3):5.3,(Sp_24:5.3,Sp_23:5.3):5.3):5.3,Sp_!
22:16,Sp_
21:16):8):8,Sp_20:32):2,Sp_19:34):11):9,((Sp_18:14,Sp_17:14):4,Sp_16:18):1,Sp_15:19):2,Sp_14:21):11,(Sp_13:21,Sp_12:21,Sp_11:21):11):5,Sp_10:37):17):12,(((Sp_9:14,Sp_8:14,Sp_7:14):15,Sp_6:29):27,Sp_5:56):10):25,Sp_4:91):59,(Sp_3:62,Sp_2:62):88):20,Sp_1:1.7e+02);


[[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 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] Postdoctoral position in R phylogenetics

2018-05-10 Thread Liam J. Revell

Dear colleagues.

This is just a reminder that I'm advertising for a postdoctoral research 
position in my lab at the University of Massachusetts Boston. The 
postdoc is specifically to work on phylogenetic comparative methods, but 
anyone with experience in R programming (or programming in other 
languages) and/or mathematical modeling who is interested in phylogeny 
methods should contact me or just apply.


Unfortunately, the application deadline is tomorrow! More information & 
a link to apply can be seen on my blog: 
http://blog.phytools.org/2018/04/postdoc-to-work-on-pcm-development-in.html.


All the best, Liam

--
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/

___
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-03 Thread Liam J. Revell
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://www.press.uchicago.edu/ucp/journals/journal/pbz.html>/



Fail Lab: Episode One

_https://www.youtube.com/watch?v=c0msBWyTzU0_


On Thu, May 3, 2018 at 1:09 PM, Liam J. Revell <liam.rev...@umb.edu 
<mailto:liam.rev...@umb.edu>> wrote:


I haven't been closing following this thread, so I'm not sure that
this is relevant - but phytools has a function called
'force.ultrametric' (I believe) that does precisely what its name
suggests it might.

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/
<http://faculty.umb.edu/liam.revell/>

On 5/3/2018 3:34 PM, David Bapst wrote:

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
<mailto:bome...@utk.edu>> wrote:

On Wed, May 2, 2018 at 2:53 PM, David Bapst
<dwba...@tamu.edu <mailto: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





___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
<mailto:R-sig-phylo@r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
<https://stat.ethz.ch/mailman/listinfo/r-sig-phylo>
Searchable archive at
http://www.mail-archive.com/r-sig-phylo@r-project.org/
<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/


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

2018-05-03 Thread Liam J. Revell
I haven't been closing following this thread, so I'm not sure that this 
is relevant - but phytools has a function called 'force.ultrametric' (I 
believe) that does precisely what its name suggests it might.


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 3:34 PM, David Bapst wrote:

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







___
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] Postdoc in PCM development in the Revell lab

2018-04-27 Thread Liam J. Revell

Dear list.

I am advertising for a postdoctoral research position in my lab. The 
position is available more or less immediately.


This is a re-advertisement of a postdoc that I posted last year (but 
didn't fill) with two important updates, as follows:
1. The postdoc is for PCM development in particular, rather than 
phylogeny methods more broadly.
2. The postdoc is for a minimum 2 years (given satisfactory progress, 
etc.) rather than for one year as advertised previously.


I consider PCMs to include anything related to the use of phylogenies to 
make evolutionary inferences, rather than the estimation of phylogeny - 
but please contact me if you'd like clarification.


The deadline to apply is May 11. More information along with a link to 
apply is available on my blog: 
http://blog.phytools.org/2018/04/postdoc-to-work-on-pcm-development-in.html.


All the best, Liam

--
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/

___
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] grafting chronograms onto backbone phylogeny

2018-04-26 Thread Liam J. Revell

If your case is simple - like you have a tree with tips labeled by
genus, and each species label from each subtree to be bound has tip
labels in the format Genus_species, this could be done using bind.tree
in ape.

For instance:

library(phytools)
## here's your backbone
backbone<-read.tree(text="((A:2.0,B:2.0):1,C:3.0);")
plotTree(backbone)

## here are your subtrees
A<-read.tree(text="(A_sp1:1.0,A_sp2:1.0);")
B<-read.tree(text="(B_sp1:1.5,B_sp2:1.5);")
C<-read.tree(text="((C_sp1:0.5,C_sp2:0.5):0.5,C_sp3:1.0);")
subtrees<-c(A,B,C)

for(i in 1:length(subtrees)){
genus<-strsplit(subtrees[[i]]$tip.label[[1]],"_")[[1]][1]
h<-max(nodeHeights(subtrees[[i]]))
tip<-which(backbone$tip.label==genus)
backbone$edge.length[which(backbone$edge[,2]==tip)]<-
backbone$edge.length[which(backbone$edge[,2]==tip)]-h
backbone<-bind.tree(backbone,subtrees[[i]],where=tip)
}

plotTree(backbone)

Something like that.

(Of course you could also modify this so that you just manually identify 
the tips to bind to. Given the small size of your problem this is 
probably what you want.)


All the best, Liam

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 4/26/2018 4:19 PM, Brian O'Meara wrote:

Look at congruify.phylo in geiger (and the associated paper: Eastman
JM, LJ Harmon, and DC Tank. 2013. Congruification: support for time
scaling large phylogenetic trees. Methods in Ecology and Evolution).

You could also look into SDM in ape (converting trees [not data] to 
distance matrices, first): relevant paper Criscuolo, A., Berry, V., 
Douzery, E. J. P. , and Gascuel, O. (2006) SDM: A fast

distance-based approach for (super)tree building in phylogenomics.
Systematic Biology, 55, 740–755.

Best, Brian

___



Brian O'Meara, http://www.brianomeara.info, especially Calendar
<http://brianomeara.info/calendars/omeara/>, CV 
<http://brianomeara.info/cv/>, and Feedback 
<http://brianomeara.info/teaching/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
<http://www.nimbios.org> (NIMBioS)


On Thu, Apr 26, 2018 at 5:07 PM, Chris Law <cj...@ucsc.edu> wrote:


Hi all,

I am trying to graft 3 chronograms onto a family level backbone.
Does anybody have any suggestions on what is the best way to do
this? Or is going through the tree files in textwrangler the only
way to do this.

Thanks!


*Chris Law​ **|* * ​*PhD Student *|* * ​*University of California,
Santa Cruz ​


Coastal Biology Building ​ 130 McAllister Way Santa Cruz, CA 95060 
cj...@ucsc.edu *|* research.pbsci.ucsc.edu/eeb/cjlaw/ Small Mammal
Research in the Forest Internship 
<http://research.pbsci.ucsc.edu/envs/smurf>


[[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/



___
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] "Not of class phylo" error when lapply is used

2018-04-09 Thread Liam J. Revell

Dear John.

You could try running .uncompressTipLabel on the "multiPhylo" object. 
Let us know if that works.


All the best, Liam

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 4/9/2018 9:46 AM, jschenk wrote:

Hi Folks,

I have been banging my head against what appears to be an easy coding problem 
for a while now and haven’t been able to hack my way out of it.  I am running a 
function to identify a posterior set of node ages for a particular node.  The 
function I wrote works just fine, but when I use lapply to sample across a 
posterior distribution, I get the “not of class ‘phylo’” error, even when I 
input a single tree of class phylo.  I have tried every typical solution (e.g., 
reassigning class), but haven’t identified a solution.  Does anyone know a 
workaround?

Please see the example code below.

Thanks,

John




library(ape)
#simulate a single tree with 20 tips
simtree <- rtree(20)
#Make sure the tree exists
plot(simtree)

#Function I wrote to find a node and then tell me the age of the node.  I 
realize that the simulated tree is not ultrametric in this example, in real 
life it will be - ultrametric trees also result in the same error
AgeDensity <- function(phy, species1, species2){
NodeNumber <- mrca(phy)[species1, species2]
ages <- branching.times(phy)[as.character(NodeNumber)]
return(as.numeric(ages))
}

#check the class of the tree object, it will say that it is of class phylo
class(simtree)

#Run my function AgeDensity and it works just fine
AgeDensity(simtree, "t3", "t15")

#When I use the lapply function, I get an error that the object is not a of 
class phylo, although I already verified that it is of class phylo.
lapply(simtree, AgeDensity, species1="t3", species2="t15")


#here is the same analysis conducted with multiple trees
multiTrees <- rmtree(20, 10)
class(multiTrees)
#I get the same error when I run my function across multiple trees
lapply(multiTrees, AgeDensity, species1="t3", species2="t15")

__
John J. Schenk, Ph.D.
Assistant Professor of Plant Biology
Georgia Southern University Herbarium (GAS), Curator
Department of Biology
4324 Old Register Road
Georgia Southern University
Statesboro, GA 30460-8042
Office:  2260 Biology Building
Office phone:  (912) 478-0848
Lab website: sites.google.com/a/georgiasouthern.edu/schenk
Herbarium website: sites.google.com/a/georgiasouthern.edu/gasherbarium








[[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 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] Interpretation of standard errors of parameter estimates in OUwie models

2018-04-04 Thread Liam J. Revell

Dear Rafael.

I believe the standard errors are computed from (negative inverse of) 
the Hessian matrix - which is a matrix containing the second-order 
partial derivatives (or some numerical approximation of them) from the 
likelihood surface.


These values are measurements of the curvature of the likelihood 
surface. If the likelihood surface is highly curved (downwards, that is 
negatively) then this means that the ML solution is much more likely 
than other nearby possibilities, and the negative inverse of this value 
is a small quantity - indicating little variance (i.e., uncertainty) in 
the estimated parameter. Conversely, a large standard error (the square 
of which is the variance) indicates that the likelihood surface is very 
flat (that is, it has a very small negative curvature) around the ML 
solution.


In your particular case broadly overlapping CIs for the parameter 
estimates (which can be computed as theta+-1.96*SE) of theta probably 
mean that the 'adaptive peaks' of different regimes can't be 
distinguished one from the other; whereas a CI for alpha that included 
zero (for instance) might suggest that a BM model probably better fits 
the data.


All the best, Liam

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 4/4/2018 2:30 PM, Rafael S Marcondes wrote:

Dear all,

I'm writing (again!) to ask for help interpreting standard errors of 
parameter estimates in OUwie models.


I'm using OUwie to examine how the evolution of bird plumage color 
varies across habitat types (my selective regimes) in a tree of 229 
tips. I was hoping to be able to make inferences based on OUMV and OUMVA 
models, but I was getting nonsensical theta estimates from those. So 
I've basically given up on them for now.


But even looking at theta estimates from OUM models, I'm getting really 
large standard errors, often overlapping the estimates from other 
selective regimes. So I was wondering what that means exactly. How are 
these erros calculated? How much do high errors it limit the biological 
inferences I can make? I'm more interested in the relative thetas across 
regimes than on the exact values (testing the prediction that birds in 
darker habitats tend to adapt to darker plumages than birds in more 
illuminated habitats).


I have attached a table averaging parameter estimates and errors from 
models fitted across a posterior distribution of 100 simmaps for four 
traits; and one exemplar fitted model from one trait in one of those 
simmaps.


Thanks a lot 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>



___
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/


Re: [R-sig-phylo] plot.cophylo: some edges missing

2018-03-13 Thread Liam J. Revell

Try ftype="off".

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 3/13/2018 11:27 AM, Juan Antonio Balbuena wrote:

Hi,

Yes!! It worked! Thank you so much!

BTW, is there a way to supress the tip labels? show.tip.label=FALSE does 
not work.


All the best

Juan


El 13/03/2018 a las 17:12, Liam J. Revell escribió:

Hola Juan.

I'm guessing you are using an old version of phytools as this bug has 
been identified & should be fixed 
(http://blog.phytools.org/2017/08/bug-fix-in-plotcophylo-for-co.html). 
If you update to the latest CRAN version that should take care of it, 
but I recommend updating to the latest version on GitHub using 
devtools as follows:


library(devtools)
install_github("liamrevell/phytools")

Let us know if the problem persists.

Saludos, Liam

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 3/13/2018 11:09 AM, Juan Antonio Balbuena wrote:

Hi all

I am using cophylo in phytools to draw a large tanglegram 
(phylogenies with 29 and 129 terminals, and 129 associations between 
them). The problem is that only a fraction of the edges of the larger 
tree (to the right) are plotted.


This is the syntax used


obj <- cophylo(euglossini29, orchids, links, rotate.multi=TRUE)

#which apparently works well:

Rotating nodes to optimize matching...
Done.

plot.cophylo(obj, links.lwd=1, link.lty=2, fsize=0.4, pts=FALSE, 
link.type="curved")


# the resulting plot can be visualized here: 
https://www.uv.es/balbuena/PDF/Rplot.pdf



I usually work in RStudio but I got the same result in an ordinary R 
console. In addition, when I use cophyloplot (ape) with the same 
input, I am able to get the tanglegram.


I wonder what the problem might be and any help will by much 
appreciated.


Juan A. Balbuena







___
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] Phylogenetic PCA and measurement error

2018-03-12 Thread Liam J. Revell

Graham's right of course. Sorry about that.

You might do something like:

Si<-(Xi-matrix(1,nrow(Xi),1)%*%phyl.vcv(Xm,vcv(tree),
1)$alpha[,1])%*%pca$Evec

I also agree with Joe that you can take the phylogeny into account 
whilst accounting for sampling error using his approach or that of Ives 
et al. In either case you will obtain a covariance matrix among traits 
the decomposition of which could be employed to compute scores for 
individuals in the original space as Joe suggests. I'm not sure whether 
or not it will make a difference. That probably depends on how much 
uncertainty in the values of species means has been ignored.


All the best, Liam

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 3/12/2018 11:29 AM, Graham Slater wrote:

Hi Rafael,

You need to mean-center your traits before multiplying by the matrix of 
eigenvectors. Compute the vector of phylogenetic means (under BM or 
Pagel’s lambda), subtract each value from the relevant column of Xm and 
then compute Si. The result should be identical to the scores from your 
phylogenetic PCA.


Graham

--
Graham J. Slater
Assistant Professor
Department of the Geophysical Sciences
University of Chicago
5734 S. Ellis Avenue
Chicago, IL 60637 USA

Tel: (773) 702-0249
email: gsla...@uchicago.edu <mailto:gsla...@uchicago.edu>
www.fourdimensionalbiology.com <http://www.fourdimensionalbiology.com>






On Mar 12, 2018, at 11:11 AM, Rafael S Marcondes 
<raf.marcon...@gmail.com <mailto:raf.marcon...@gmail.com>> wrote:


Hi Liam,

Thank you very much for the very fast response (as usual). To try out 
if I was using your approach correctly, I ran it with the 
species-level data, expecting that I would get the same PC scores as 
from phyl.PCA. That didn't happen though. Am I understanding/doing 
something wrong?


pca<-phyl.pca(tree,Xm)
Si<-Xm%*%pca$Evec
Expected that Si would be identical to pca$S. But they aren't.

I have attached my species-level data, individual-level data, and 
output of phyl.pca


Thank you,


*--
*
*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 Sun, Mar 11, 2018 at 5:16 PM Liam J. Revell <liam.rev...@umb.edu 
<mailto:liam.rev...@umb.edu>> wrote:


Hi Rafael.

So far as I know, there is currently no way to explicitly take into
account sampling error in computing principal components while also
accounting for the phylogeny. However, it is relatively
straightforward
to compute scores for individuals from a PCA conducted on species
means.

This would look as follows (in which Xm is a matrix containing values
for species for each trait, and Xi is a matrix with the same number of
columns but containing values for individuals):

pca<-phyl.pca(tree,Xm)
Si<-Xi%*%pca$Evec

Then, if you have a separate vector containing species ID as a factor,
you could compute means and variances for each component by species.

    I hope this is some help. All the best, Liam

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 3/11/2018 5:06 PM, Rafael S Marcondes wrote:
> Dear all,
>
> Does anyone have any advice on how to calculate measurement
error in an
> analysis using phylogenetic principal components? Or, in other
words, after
> I run a phylogenetic PCA on species-level data, how can I
"project" my
> individual-level data into the phylogenetic PCs so I can calculate a
> standard error? I'm running my pPCA using the lambda method and the
> covariance matrix.
>
> I would think this would be an usual, simple procedure, and that
there
> would be an R function for it, but I can't for the life of me find
> anything. The recent paper by Jonathan Drury et al linked below does
> mention doing it, but without going into any detail.
>
>
http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.2003563
>
> Thank you very much 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: @brow

Re: [R-sig-phylo] Phylogenetic PCA and measurement error

2018-03-11 Thread Liam J. Revell

Hi Rafael.

So far as I know, there is currently no way to explicitly take into 
account sampling error in computing principal components while also 
accounting for the phylogeny. However, it is relatively straightforward 
to compute scores for individuals from a PCA conducted on species means.


This would look as follows (in which Xm is a matrix containing values 
for species for each trait, and Xi is a matrix with the same number of 
columns but containing values for individuals):


pca<-phyl.pca(tree,Xm)
Si<-Xi%*%pca$Evec

Then, if you have a separate vector containing species ID as a factor, 
you could compute means and variances for each component by species.


I hope this is some help. All the best, Liam

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 3/11/2018 5:06 PM, Rafael S Marcondes wrote:

Dear all,

Does anyone have any advice on how to calculate measurement error in an
analysis using phylogenetic principal components? Or, in other words, after
I run a phylogenetic PCA on species-level data, how can I "project" my
individual-level data into the phylogenetic PCs so I can calculate a
standard error? I'm running my pPCA using the lambda method and the
covariance matrix.

I would think this would be an usual, simple procedure, and that there
would be an R function for it, but I can't for the life of me find
anything. The recent paper by Jonathan Drury et al linked below does
mention doing it, but without going into any detail.

http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.2003563

Thank you very much 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-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/


Re: [R-sig-phylo] problem with phylo.toBackbone

2018-02-20 Thread Liam J. Revell

Hi Felipe.

Yes, your phytools version is from late 2015 and I added the interactive 
feature in summer 2016 
(http://blog.phytools.org/2016/06/interactive-version-of-phylotobackbone.html). 
To update all packages you can run (in a fresh R session without any 
other sessions open):


update.packages()

however, if you have an older R version installed you may not get the 
most recent package versions from this command.


Alternatively, you can install the development version of phytools from 
GitHub using the package devtools. First install & load devtools from 
within R and then run:


install_github("liamrevell/phytools")

I hope this is of some help. All the best, Liam

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 2/20/2018 5:42 PM, Felipe Rossetto wrote:

Hi Laim,
the version is 0.5.10. maybe this verison does not support the functiom, 
right?''


Is there a command for updating the version?

Felipe Rossetto
Herbário FUEL
Departamento de Biologia Animal e Vegetal
Universidade Estadual de Londrina
Rodovia Celso Garcia Cid, PR 445 Km 380, Campus Universitário
Caixa postal 10.011
CEP: 86057-970
Londrina, Paraná, Brasil
CV: http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4211230P7


2018-02-20 19:38 GMT-03:00 Liam J. Revell <liam.rev...@umb.edu 
<mailto:liam.rev...@umb.edu>>:


Hi Felipe.

What version of phytools are you using? A very old phytools version
did not default to interactive mode if no translation table (trans)
was supplied.

Otherwise, I do not know - but it should not be because the tree is
not ultrametric.

    All the best, Liam

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/
<http://faculty.umb.edu/liam.revell/>


On 2/20/2018 5:34 PM, Felipe Rossetto wrote:

Hi everyone,

I am using the phylo.toBackbone function of phytools using an
ultrametric
tree.
When I ran the command obj<-phylo.toBackbone(tree), a message
''Error in
match(x, table, nomatch = 0L) : argument "trans" is missing, with no
default'' appeared. Is the problem related to the fact I used an
ultrametric tree?

Many thanks in advance

felipe

Felipe Rossetto
Herbário FUEL
Departamento de Biologia Animal e Vegetal
Universidade Estadual de Londrina
Rodovia Celso Garcia Cid, PR 445 Km 380, Campus Universitário
Caixa postal 10.011
CEP: 86057-970
Londrina, Paraná, Brasil
CV:
http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4211230P7
<http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4211230P7>

         [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
<mailto:R-sig-phylo@r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
<https://stat.ethz.ch/mailman/listinfo/r-sig-phylo>
Searchable archive at
http://www.mail-archive.com/r-sig-phylo@r-project.org/
<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/


Re: [R-sig-phylo] problem with phylo.toBackbone

2018-02-20 Thread Liam J. Revell

Hi Felipe.

What version of phytools are you using? A very old phytools version did 
not default to interactive mode if no translation table (trans) was 
supplied.


Otherwise, I do not know - but it should not be because the tree is not 
ultrametric.


All the best, Liam

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 2/20/2018 5:34 PM, Felipe Rossetto wrote:

Hi everyone,

I am using the phylo.toBackbone function of phytools using an ultrametric
tree.
When I ran the command obj<-phylo.toBackbone(tree), a message ''Error in
match(x, table, nomatch = 0L) : argument "trans" is missing, with no
default'' appeared. Is the problem related to the fact I used an
ultrametric tree?

Many thanks in advance

felipe

Felipe Rossetto
Herbário FUEL
Departamento de Biologia Animal e Vegetal
Universidade Estadual de Londrina
Rodovia Celso Garcia Cid, PR 445 Km 380, Campus Universitário
Caixa postal 10.011
CEP: 86057-970
Londrina, Paraná, Brasil
CV: http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4211230P7

[[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 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 geologic time scale on circular tree

2018-01-03 Thread Liam J. Revell
Oops. I just realized that will plot the colors in reverse - with the 
most recent eras in the center. This should be fixed:


plotTree(tree)
obj<-geo.legend()
r<-max(obj$leg[,1])-obj$leg[,2]
plotTree(tree,type="fan",fsize=0.6,lwd=1)
for(i in 1:nrow(obj$leg)){
color<-paste(strsplit(obj$colors[i],"")[[1]][1:7],collapse="")
draw.circle(0,0,radius=r[i],col=color,border="transparent")
}
par(fg="transparent")
plotTree(tree,type="fan",add=TRUE,fsize=0.6,lwd=1)
par(fg="black")

I will also post to my blog.

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/3/2018 10:55 AM, Liam J. Revell wrote:
[This sender failed our fraud detection checks and may not be who they 
appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]


If you're comfortable with solid colors, rather than semi-transparent as
in geo.legend, you could do something like this:

plotTree(tree)
obj<-geo.legend() ## this is just to get the colors

plotTree(tree,type="fan",lwd=1)
for(i in nrow(obj$leg):1){
    color<-paste(strsplit(obj$colors[i],"")[[1]][1:7],collapse="")
    draw.circle(0,0,radius=obj$leg[i,1],col=color,border="transparent")
}
par(fg="transparent")
plotTree(tree,type="fan",add=TRUE,lwd=1)
par(fg="black")

Otherwise you need to plot 'donuts' rather than circles. Let me figure
that one out & get back to you.

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/3/2018 10:17 AM, Jacob Berv wrote:

Hi all,
Does anyone know of a function to plot a geologic time scale as a 
series of concentric circles on a circularly plotted tree?


As far as I can tell there are three available functions that can do 
this on a regular cladogram:


axisGeo (phyloch)
geoscale.Phylo  (strap)
geo.legend (phytools)

But none of these works with a circular tree, as far as I can tell. It 
shouldn’t be too hard to code this manually as a series of concentric 
circles (going try that now), but I figured I’d ask here in case 
someone has already done this.


Cheers,
Jake Berv
___
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/


___
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 geologic time scale on circular tree

2018-01-03 Thread Liam J. Revell
If you're comfortable with solid colors, rather than semi-transparent as 
in geo.legend, you could do something like this:


plotTree(tree)
obj<-geo.legend() ## this is just to get the colors

plotTree(tree,type="fan",lwd=1)
for(i in nrow(obj$leg):1){
color<-paste(strsplit(obj$colors[i],"")[[1]][1:7],collapse="")
draw.circle(0,0,radius=obj$leg[i,1],col=color,border="transparent")
}
par(fg="transparent")
plotTree(tree,type="fan",add=TRUE,lwd=1)
par(fg="black")

Otherwise you need to plot 'donuts' rather than circles. Let me figure 
that one out & get back to you.


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/3/2018 10:17 AM, Jacob Berv wrote:

Hi all,
Does anyone know of a function to plot a geologic time scale as a series of 
concentric circles on a circularly plotted tree?

As far as I can tell there are three available functions that can do this on a 
regular cladogram:

axisGeo (phyloch)
geoscale.Phylo  (strap)
geo.legend (phytools)

But none of these works with a circular tree, as far as I can tell. It 
shouldn’t be too hard to code this manually as a series of concentric circles 
(going try that now), but I figured I’d ask here in case someone has already 
done this.

Cheers,
Jake Berv
___
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/

Re: [R-sig-phylo] Error in plotTree.wBars() in phytools

2017-11-11 Thread Liam J. Revell
Hi Rafael. When I load your workspace & run the following code I can 
produce the attached plot. Does this not work for you?


library(phytools)
dat<-dat[!is.na(dat)]
tips<-setdiff(tr$tip.label,names(dat))
tr<-drop.tip(tr,tips)
pdf(file="tree.pdf")
plotTree.wBars(tree=tr, x=dat, lwd=1, type='fan', scale=0.05,
width=0.35, col='red')
dev.off()

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 11/11/2017 10:49 AM, Rafael S Marcondes wrote:

Hi Liam,

That did solve that problem and now a tree is plotted. But it is just a 
plain tree without bars at the tips. Here's what I'm doing and the error 
I get:


 > plotTree.wBars(tree=tr, x=dat, type='fan', scale=0.05, width=1, 
col='red')

Error in if (min(x) < 0) h <- max(nodeHeights(tree)) :
   missing value where TRUE/FALSE needed

I thought the problem might be that some of my trait values are 
negative. But apparently that's not it, because dat=dat-min(dat) doesn't 
solve the problem.


Thanks,

*--
*
*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: @rafmarcondes <https://twitter.com/rafmarcondes>


On Fri, Nov 10, 2017 at 7:06 PM, Liam J. Revell <liam.rev...@umb.edu 
<mailto:liam.rev...@umb.edu>> wrote:


Hi Rafael.

It seems to just be that some of the values in your data vector are NAs.

Try:

dat<-dat[!is.na <http://is.na>(dat)]
tr<-drop.tip(tr,setdiff(tr$tip.label,names(dat)))
plotTree.wBars(tr,dat,type="fan",scale=0.1)

and you should obtain something that makes sense.

All the best, Liam

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

On 11/10/2017 6:04 PM, Rafael S Marcondes wrote:

Hi Liam,

Thanks for the quick reply. Playing with the scale argument
didn't help. I have attached my script and environment.

Thanks,

*--
*
*Rafael Sobral Marcondes*
PhD Candidate (Systematics, Ecology and Evolution/Ornithology)

Museum of Natural Science <http://sites01.lsu.edu/wp/mns/
<http://sites01.lsu.edu/wp/mns/>>
Louisiana State University
119 Foster Hall
Baton Rouge, LA 70803, USA

Twitter: @rafmarcondes <https://twitter.com/rafmarcondes
<https://twitter.com/rafmarcondes>>


On Fri, Nov 10, 2017 at 5:25 PM, Liam J. Revell
<liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>
<mailto:liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>>> wrote:

     Hello Rafael.

     Have you tried adjusting the argument 'scale' which sets
the factor
     by which x will be rescaled so that the tree & data can be
plotted
     in the same space?

     Also, if you are just plotting a right-facing phylogram I
recommend
     plotTree.barplot (also within phytools) which is in some
ways more
     flexible & robust.

     Failing any of these options you are welcome to send me
your saved
     workspace so I can investigate (& if there is a bug in
phytools -
     fix it).

     All the best, Liam

     Liam J. Revell, Associate Professor of Biology
     University of Massachusetts Boston
     web: http://faculty.umb.edu/liam.revell/
<http://faculty.umb.edu/liam.revell/>
     <http://faculty.umb.edu/liam.revell/
<http://faculty.umb.edu/liam.revell/>>
     email: liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>
<mailto:liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>>

     blog: http://blog.phytools.org

     On 11/10/2017 4:55 PM, Rafael S Marcondes wrote:

         Hi all,

         I'm encountering a little bump trying to use this
really cool
         plot function
         in phytools and I can't figure out what's wrong:

             plotTree.wBars(tree=tr, x=dat)

         Error in plot.window(xlim = xlim, ylim = ylim, asp = asp) :
         need finite 'xlim' values

         Including an xlim argument doesn't work:

             plotTree.wBars(tree=tr, x=dat, xlim=c(0,100),
ylim=c(0,100))

         Error in plot.window(xlim = xlim, ylim = ylim, asp = asp) :
       

Re: [R-sig-phylo] Error in plotTree.wBars() in phytools

2017-11-10 Thread Liam J. Revell

Hi Rafael.

It seems to just be that some of the values in your data vector are NAs.

Try:

dat<-dat[!is.na(dat)]
tr<-drop.tip(tr,setdiff(tr$tip.label,names(dat)))
plotTree.wBars(tr,dat,type="fan",scale=0.1)

and you should obtain something that makes sense.

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 11/10/2017 6:04 PM, Rafael S Marcondes wrote:

Hi Liam,

Thanks for the quick reply. Playing with the scale argument didn't help. 
I have attached my script and environment.


Thanks,

*--
*
*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: @rafmarcondes <https://twitter.com/rafmarcondes>


On Fri, Nov 10, 2017 at 5:25 PM, Liam J. Revell <liam.rev...@umb.edu 
<mailto:liam.rev...@umb.edu>> wrote:


Hello Rafael.

Have you tried adjusting the argument 'scale' which sets the factor
by which x will be rescaled so that the tree & data can be plotted
in the same space?

Also, if you are just plotting a right-facing phylogram I recommend
plotTree.barplot (also within phytools) which is in some ways more
flexible & robust.

Failing any of these options you are welcome to send me your saved
workspace so I can investigate (& if there is a bug in phytools -
fix it).

All the best, Liam

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

On 11/10/2017 4:55 PM, Rafael S Marcondes wrote:

Hi all,

I'm encountering a little bump trying to use this really cool
plot function
in phytools and I can't figure out what's wrong:

plotTree.wBars(tree=tr, x=dat)

Error in plot.window(xlim = xlim, ylim = ylim, asp = asp) :
need finite 'xlim' values

Including an xlim argument doesn't work:

plotTree.wBars(tree=tr, x=dat, xlim=c(0,100), ylim=c(0,100))

Error in plot.window(xlim = xlim, ylim = ylim, asp = asp) :
need finite 'xlim' values

Thanks for any help!


*--*
*Rafael Sobral Marcondes*
PhD Candidate (Systematics, Ecology and Evolution/Ornithology)

Museum of Natural Science <http://sites01.lsu.edu/wp/mns/
<http://sites01.lsu.edu/wp/mns/>>
Louisiana State University
119 Foster Hall
Baton Rouge, LA 70803, USA

Twitter: @rafmarcondes <https://twitter.com/rafmarcondes
<https://twitter.com/rafmarcondes>>

         [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
<mailto:R-sig-phylo@r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
<https://stat.ethz.ch/mailman/listinfo/r-sig-phylo>
Searchable archive at
http://www.mail-archive.com/r-sig-phylo@r-project.org/
<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/

Re: [R-sig-phylo] Error in plotTree.wBars() in phytools

2017-11-10 Thread Liam J. Revell

Hello Rafael.

Have you tried adjusting the argument 'scale' which sets the factor by 
which x will be rescaled so that the tree & data can be plotted in the 
same space?


Also, if you are just plotting a right-facing phylogram I recommend 
plotTree.barplot (also within phytools) which is in some ways more 
flexible & robust.


Failing any of these options you are welcome to send me your saved 
workspace so I can investigate (& if there is a bug in phytools - fix it).


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 11/10/2017 4:55 PM, Rafael S Marcondes wrote:

Hi all,

I'm encountering a little bump trying to use this really cool plot function
in phytools and I can't figure out what's wrong:


plotTree.wBars(tree=tr, x=dat)

Error in plot.window(xlim = xlim, ylim = ylim, asp = asp) :
need finite 'xlim' values

Including an xlim argument doesn't work:


plotTree.wBars(tree=tr, x=dat, xlim=c(0,100), ylim=c(0,100))

Error in plot.window(xlim = xlim, ylim = ylim, asp = asp) :
need finite 'xlim' values

Thanks 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: @rafmarcondes <https://twitter.com/rafmarcondes>

[[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 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] Brownian Evolution

2017-10-20 Thread Liam J. Revell

Hi William.

Why would you suspect phytools? ;)

I didn't figure this out for you, but I did eliminate some possibilities.

It does not seem to be due to phytools::fastBM. You can replace fastBM 
with phytools:sim.corrs or geiger:sim.char as follows:


var<-sim.char(Bigtrees[[i]],par=1,root=0)[,,1]
## or
var<-sim.corrs(Bigtrees[[i]],matrix(1,1,1))
## and
var1<-sim.char(subtrees[[i]],par=1,root=0)[,,1]
## or
var1<-sim.corrs(subtrees[[i]],matrix(1,1,1))

and the result is the same. (Note that all three use different methods 
for simulation.)


Neither does it seem to be due to phytools::phylosig. You can replace 
phylosig with geiger::fitContinuous as follows:


maxlambda<-phytools:::maxLambda(subtrees[[i]])
sig_sub[i]<-fitContinuous(subtrees[[i]],var[subtrees[[i]]$tip.label],
model="lambda",bounds=list(lambda=c(0,maxlambda)))$opt$lambda
sig[i]<-fitContinuous(subtrees[[i]],var1,model="lambda",
bounds=list(lambda=c(0,maxlambda)))$opt$lambda

and the result is unchanged. (Note that we need to compute the maximum 
value of lambda for which the likelihood function is defined otherwise 
fitContinuous by default bounds optimization on [0,1].)


What I also observed is that the variances are unequal, as you report, 
but not in a particular direction. That is, sometimes sig_sub has a 
higher variance, and sometimes sig does.


If I had to guess, I would hazard that perhaps the distribution of 
lambda (even after you make it symmetric) is leptokurtic which is why 
var.test is significant due to idiosyncratic differences in the variance 
of lambda, even though the values were obtained by the same process. 
(Invariably lamb_sub and lamb fail a normality test, so this seems like 
a distinct possibility.)


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 10/20/2017 1:32 AM, William Gelnaw wrote:

Hi all,
  I've been investigating the use of Pagel's lambda and run into a problem
comparing trees that have a low speciation rate and no extinction with
trees that have a high speciation rate and lots of extinction.   I'm
comparing phylogenetic signal in two characters.  In the first, I simulate
a character under Brownian evolution over a 200 taxon tree and then prune
it down to 100 taxa.  The second character was evolved over the pruned-down
tree.  I then estimated Pagel's lambda for both characters on the
pruned-down tree.  Doing this 500 times, I found that the error rate in the
estimate of lambda was not the same for the two methods of generating the
data.  The difference was small but statistically significant.  To my
understanding though, there shouldn't be a difference.  The rate of
evolution is the same in both cases and the tree topology and branch
lengths are identical.  If the characters are evolving in a Brownian way,
shouldn't there be, on average, no difference between the characters with
respect to phylogenetic signal?  Could this be an artifact of using fastBM
to simulate the characters?  Is there another function that I should be
using to simulate a character evolving under Brownian motion?

Here's the script I'm using:
library(phytools)
library(TreeSim)
library(adephylo)
age<-2
lambda <- 2.0
mu <- 0.5
frac <-0.6
sample_size<-100
smalltrees<-list()
Bigtrees<-sim.bd.taxa.age(200,500,lambda,mu,frac,age)
## using sim.bd.taxa.age to get an ultrametric tree with known age
subtrees<-list()
sig<-vector()
sig_sub<-vector()
for (i in 1:500){
var<-fastBM(Bigtrees[[i]],nsim=1)
tips_to_drop<-sample(1:200, 200-sample_size, replace=FALSE)
subtrees[[i]]<-drop.tip(Bigtrees[[i]], tips_to_drop)
var1<-fastBM(subtrees[[i]],nsim=1)
sig_sub[i]<-phylosig(subtrees[[i]],var,method="lambda")$lambda
sig[i]<-phylosig(subtrees[[i]],var1,method="lambda")$lambda}
lamb<-(2-sig)
## reflected the data around lambda=1 so that standard deviation has a
symmetric distribution
lamb<-c(lamb,sig)
lamb_sub<-(2-sig_sub)
lamb_sub<-c(lamb_sub,sig_sub)
var.test(lamb,lamb_sub)

Best regards,
  - Will Gelnaw

[[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 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] Postdoc in R phylogenetics

2017-10-04 Thread Liam J. Revell

Dear colleagues.

I'm advertising a postdoc in my lab at UMass-Boston to work on 
computational methods for phylogenetics in R. More information, 
including instructions to apply, are linked on my blog: 
http://blog.phytools.org/2017/10/postdoc-to-work-on-computational.html. 
Note that the postdoc is for *one year* with only a modest possibility 
of extension to multiple years contingent on external funding.


Please circulate to interested parties. Any questions about the position 
should be directed to this email address (liam.rev...@umb.edu).


Thanks!

--
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

___
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] Can I get coordinates from plot.phylo and not get blank page

2017-09-26 Thread Liam J. Revell

Hi Emmanuel, Rafael, & Elizabeth.

Some phytools functions suffer from the precisely the same issue 
identified by Elizabeth as phytools::plotTree and phytools::plotSimmap 
also have a plot=FALSE option, & Rafael's solution seems to work. For 
instance, I posted an example to my blog here:


http://blog.phytools.org/2017/09/possible-solution-for-functions-that.html

I'm not sure if this means I won't run into difficulty with this 
solution, but I'm eager to hear why.


- 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 9/26/2017 11:52 AM, Emmanuel Paradis wrote:

Hi Rafael,

This is used in example(phydataplot), but once you called plot(tree,
plot = FALSE), you cannot change x.lim, y.lim, etc. You can notice in
these examples that these parameters are (most of the time) not nicely
set: this is because the data are simulated. If you work interactively,
it's quite easy to find the appropriate value of x.lim with a few tries
for a given data set. Then, once this is saved in a script, it's
possible to repeat the plot and adjust the other parameters (colours,
legend, ...)

Best,

Emmanuel

Le 26/09/2017 à 18:10, Rafael Maia a écrit :

Hi Elizabeth,

I ran into a similar problem recently (with another package) and a
simple solution that worked for me is to call par(new=TRUE) before
your plot=TRUE plot. So something like:

  pdf('test.pdf')
  plot(tree, plot=FALSE)
  par(new=TRUE)
  plot(tree, plot=TRUE)
  dev.off()

HTH

Best,
Rafael Maia
—
Junior Fellow, Simons Society of Fellows
Rubenstein Lab, Columbia University
Department of Ecology, Evolution and Environmental Biology
New York, NY
http://www.rafaelmaia.net


On Sep 26, 2017, at 9:03 AM, Emmanuel Paradis
<emmanuel.para...@ird.fr <mailto:emmanuel.para...@ird.fr>> wrote:

Hi Elizabeth,

You can use directly the functions behind the calculations of the
coordinates; they are documented together: ?node.depth. But this will
not give the final coordinates since more calculations are needed
depending on the widths of the labels, etc.

Another possibility could be to plot the tree in a temporary file and
get the settings afterwards, eg:

R> tmpf <- tempfile()
R> pdf(tmpf)
R> plot(rtree(100))
R> dev.off()
X11cairo
  2
R> lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
R> lastPP
$type
[1] "phylogram"


R> unlink(tmpf) # optional since it's deleted when R is closed

Just for the record, if some users wonder about the usefulness of the
option plot=FALSE, see some examples in:

example(phydataplot)

HTH

Best,

Emmanuel

Le 26/09/2017 à 14:58, Elizabeth Purdom a écrit :

Hello,
I am writing a function that calls plot.phylo in the ape package
with the option plot=FALSE. I then do some calculations with the
output (the calculated coordinates), and then make another call to
plot.phylo with plot=TRUE. If I do this, then the plot=FALSE option
creates a blank plot, which is the result that is clearly documented
in the help pages.
However, I do not want this blank plot, because I am saving the
result (the second call to plot.phylo) to a pdf, and so the pdf has
a blank page before the plot I want. And since I’m calling this in a
function, I can’t “wait” for the second plot (a similar problem
occurs if you run it in a knitr document)
Is there a way to get the output from plot.phylo with all of the
coordinates, etc. without having to have the blank plot? (I do not
want an option to “add” the plot to the blank plot, if it exists,
because I am doing these calculations so that in my next call I can
change the x.lim options so the tree only takes up a fraction of the
plot, so I need to reset the par, etc., and not just draw on the
original coordinates set up by the blank plot)
Thank you,
Elizabeth Purdom
Pour nous remonter une erreur de filtrage, veuillez vous rendre ici
: http://f.security-mail.net/302lu3ZCAL7



___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
<mailto: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/


___
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] Possible Bug in ape::read.tree

2017-09-05 Thread Liam J. Revell
Hi George. Mario is correct that phytools can read a tree with singleton 
nodes (if that is indeed your problem), but the name of the function is 
read.newick. Good luck! - 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 9/5/2017 4:17 PM, George Vega Yon wrote:

Hi Mario,

That sounds great!

Thanks,

George G. Vega Yon
+1 (626) 381 8171
http://cana.usc.edu/vegayon

On Tue, Sep 5, 2017 at 2:08 PM, Mario José Marques-Azevedo <
mariojm...@gmail.com> wrote:


Hi, George,

Ape package do not read tree with singletons, yet. New version will read.
You can use readTree from phytools package for while.

Best regards,

Mario


On 5 Sep 2017 5:53 p.m., "George Vega Yon" <g.vega...@gmail.com> wrote:

Hi,

When trying to read this tree with the ape::read.tree function :

((AN14:0.000,AN15:0.000):0.000[&:Ev=0>1:S=
Homo-Pan:ID=AN13],(AN17:0.000,AN18:0.000):0.000[&:Ev=0>
1:S=Murinae:ID=AN16]):0.000[&:Ev=0>1:S=Euarchontoglires:
ID=AN12],(AN20:0.000,AN21:0.000):0.000[&:Ev=0>1:S=
Laurasiatheria:ID=AN19]):0.000[&:Ev=0>1:S=Eutheria:
ID=AN11],AN22:0.004):0.003[&:Ev=0>1:S=Mammalia:ID=AN10]
,AN23:0.000):0.014[&:Ev=0>1:S=Amniota:ID=AN9],AN24:0.
017):0.021[&:Ev=0>1:S=Tetrapoda:ID=AN8],((AN27:0.
066,AN28:0.052):0.010[&:Ev=1>0:ID=AN26],(AN30:0.031,
AN31:0.014):0.003[&:Ev=1>0:ID=AN29]):0.021[&:Ev=0>
1:S=Teleostei:ID=AN25]):0.147[&:Ev=0>1:S=Osteichthyes:
ID=AN7],AN32:0.194):0.104[&:Ev=0>1:S=Deuterostomia:ID=
AN6],((AN35:0.020,AN36:0.038):0.416[&:Ev=0>1:S=
Caenorhabditis:ID=AN34],((AN39:0.119,AN40:0.131):0.154[&
:Ev=0>1:S=Insecta:ID=AN38],AN41:0.317):0.104[&:Ev=0>
1:S=Arthropoda:ID=AN37]):0.118[&:Ev=0>1:S=Ecdysozoa:
ID=AN33],AN42:0.381):0.594[&:Ev=0>1:S=Bilateria:ID=AN5]
,AN43:2.000):0.414[&:Ev=0>1
 :S=Eumetazoa:ID=AN4],AN52:0.484,AN53:0.427):0.418[&:Ev=0>1:S=
Saccharomycetaceae:ID=AN51],AN54:0.733):0.320[&:Ev=0>
1:S=Saccharomycetaceae-Candida:ID=AN50],AN55:0.808):0.290[&:Ev=0>1:S=
Saccharomycetales:ID=AN49],(AN57:0.793,((AN60:0.206,AN61:
0.186):0.143[&:Ev=0>1:S=Sordariomyceta:ID=AN59],AN62:
0.331):0.332[&:Ev=0>1:S=Sordariomycetes-Leotiomycetes:
ID=AN58]):0.467[&:Ev=0>1:S=Pezizomycotina:ID=AN56]):0.
432[&:Ev=0>1:S=Pezizomycotina-Saccharomycotina:ID=AN48],
AN63:0.864):0.223[&:Ev=0>1:S=Ascomycota:ID=AN47],(AN65:
0.613,AN66:0.930,AN67:0.755):0.332[&:Ev=0>1:S=
Basidiomycota:ID=AN64]):0.618[&:Ev=0>1:S=Dikarya:ID=
AN46],((AN74:0.337,AN75:0.406):0.298[&:Ev=0>1:S=
Saccharomycetaceae:ID=AN73],AN76:0.578):0.338[&:Ev=0>
1:S=Saccharomycetaceae-Candida:ID=AN72],AN77:0.567):0.304[&:Ev=0>1:S=
Saccharomycetales:ID=AN71],(AN79:0.379,((AN82:0.398,AN83:
0.403):0.191[&:Ev=0>1:S=Sordariomyceta:ID=AN81],AN84:
0.366):0.140[&:Ev=0>1:S=Sordariomyc
 etes-Leotiomycetes:ID=AN80]):0.457[&:Ev=0>1:S=
Pezizomycotina:ID=AN78]):0.331[&:Ev=0>1:S=Pezizomycotina-
Saccharomycotina:ID=AN70],AN85:0.737):0.128[&:Ev=0>
1:S=Ascomycota:ID=AN69],(AN87:0.599,AN88:0.698):0.161[&:
Ev=0>1:S=Basidiomycota:ID=AN86]):0.398[&:Ev=0>1:S=
Dikarya:ID=AN68]):0.117[&:Ev=1>0:ID=AN45],(AN90:0.984,
AN91:0.893):0.158[&:Ev=1>0:ID=AN89]):0.262[&:Ev=0>
1:S=Fungi:ID=AN44]):0.394[&:Ev=0>1:S=Opisthokonts:ID=
AN3],(AN93:0.457,AN94:0.462):0.860[&:Ev=0>1:S=
Dictyostelium:ID=AN92]):0.301[&:Ev=0>1:S=Unikonts:ID=
AN2],AN95:1.440,AN96:2.000):2.000[&:Ev=0>1:S=Eukaryota:
ID=AN1])[&:Ev=1>0:ID=AN0];

I get the following error: "The tree has apparently singleton node(s):
cannot read tree file.  Reading Newick file aborted at tree no. 1",
which seems to be wrong since I can actually read this tree without problem
using rncl::read_newick_phylo and this online tool
http://etetoolkit.org/treeview/?treeid=6e192f20a3226cfdde219531cc533e
9f=ce443ed1e53858bf4e11d1e069c7a927

I understand that this particular tree is a modified version of Newick's
format, but this is the first time that I have problems reading this type
of tree.

Here my session info:


devtools::session_info()

Session info

-
 setting  value
 version  R version 3.4.1 (2017-06-30)
 system   x86_64, linux-gnu
 ui   RStudio (1.0.143)
 language (EN)
 collate  en_US.UTF-8
 tz   America/New_York
 date 2017-09-05

Packages

-
 package * version date   source
 ape   4.1 2017-02-14 CRAN (R 3.4.0)
 assertthat0.2.0   2017-04-11 CRAN (R 3.4.0)
 base* 3.4

Re: [R-sig-phylo] Simulating traits with different rates of evolution

2017-08-30 Thread Liam J. Revell

Hi Alejandro.

If the discrete character is mapped on the tree in a "simmap" style, 
then the student could use the phytools function sim.rates. Let me know 
if you need more information.


Sincerely, 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 8/30/2017 12:51 PM, Alejandro Gonzalez Voyer wrote:

Hello,

A student of mine is analyzing whether the rates of evolution of a continuous 
trait depend on the state of a discrete trait. He finds no support for a model 
with different rates of evolution. However, we would like to test how different 
the rates would have to be in order for the method to support a two-rate model. 
Thus I would like to know how we could simulate trait evolution for the 
continuous trait with rates differing depending on the state of the discreet 
trait.

Any suggestions are greatly appreciated.

Best wishes,

Alejandro

___
Dr Alejandro Gonzalez Voyer
Newton Advanced Fellow
Investigador Titular B

Laboratorio de Conducta Animal
Instituto de Ecología
Circuito Exterior S/N
Ciudad Universitaria
Universidad Nacional Autónoma de México
México, D.F.
04510
México

Tel: +52 55 5622 9044
E-mail: alejandro.gonza...@iecologia.unam.mx

Lab website: www.alejandrogonzalezvoyer.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/



___
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] OUwie and simmap trees constructed from prior probabilities of tip states

2017-08-11 Thread Liam J. Revell

Hi Marko.

The following link contains worked examples of several different model 
fitting methods that using the "simmap" object class from phytools, 
including OUwie:


https://goo.gl/rJRQCn

Here is a very simple example, also with OUwie, using a "multiSimmap" 
object:


https://goo.gl/Mbx4hn

I hope this is of some help. Sincerely, 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 8/11/2017 12:50 PM, Marko Djurakic wrote:

Hello,
I performed stochastic character mapping using make.simmap function from
phytools package (v.0.6-20) with provided prior probabilities of tip
states (3 states). I generated 1000 maps and I want to fit several
evolutionary models to each map in mvMORPH (v.1.0.9) and OUwie (v.1.50)
packages. I aim to estimate the uncertainty due to stochastic mapping.

I was able to do fitting of models using each map in mvMORPH, but I
stuck when I want to do this in OUwie.

OUwie function can use mapped states if the simmap.tree argument is set
to TRUE, but it also requires data frame (argument "data") where I need
to specify three columns: species names, the current selective regime,
and continuous trait.
If I used prior probabilities of states in order to obtain maps, in
turn, how can/should I specify current selective regime required for
"data" argument of OUwie function?

I appreciate any comment or suggestion.

Kind regards,
Marko

___
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/


Re: [R-sig-phylo] tip labels-stochastic mapping

2017-08-07 Thread Liam J. Revell

Hi Felipe.

I can't figure out your code or why tip labels might be being stripped. 
Can you post a fully reproducible example of this problem?


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 8/6/2017 11:23 PM, Felipe Rossetto wrote:

Hi Liam,
I was using the function simmap for stochastic mapping, but when I run
these following code, the character history is mapped along the phylogeny
branches, but the tip labels disappears:

# function to compute the states
foo<-function(char1){
  y<-sapply(char1$maps,function(char1) names(char1)[1])
  names(y)<-char1$edge[,1]
  y<-y[as.character(length(char1$tip)+1:char1$Nnode)]
  return(y)
}
XX<-sapply(mtrees,foo)
pies<-t(apply(XX,1,function(char1,levels,Nsim)
summary(factor(char1,levels))/Nsim,levels=c("0","1","2"),Nsim=100))

# done computing the states

*# code to plot the tree*
*mtrees<-rescaleSimmap(mtrees,1)*
*cols<-c("black","red", "yellow"); names(cols)<-c(0,1,2)*
*par(mar=rep(0.1,4))*
*plot.phylo(mtrees[[1]],plot=FALSE,no.margin=T)*
*plotSimmap(mtrees[[1]],cols,pts=FALSE,lwd=3,ftype="off", add=TRUE)*
*text(1,1:length(mtrees[[1]]$tip),mtrees[[1]]$tip.label, pos=4,font=3)*
*nodelabels(pie=pies,cex=0.6,piecol=cols)*

Is there a code for maintaining the tip labels in the phylogeny with
characters mapped?

Mnay thanks in advance

Felipe Rossetto
Herbário FUEL
Departamento de Biologia Animal e Vegetal
Universidade Estadual de Londrina
Rodovia Celso Garcia Cid, PR 445 Km 380, Campus Universitário
Caixa postal 10.011
CEP: 86057-970
Londrina, Paraná, Brasil
CV: http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4211230P7

[[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 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] comparing rates of evolution of a phenotypic trait among clades

2017-07-22 Thread Liam J. Revell

Hi Karla.

This is not yet possible, but it would be straightforward to add. For 
instance, we could let the user specify different models such as A==B!=C 
vs. A!=B==C and so on, and then compare this models in a standard way. I 
will try to do this soon and then get back to you & the list.


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 7/22/2017 8:51 PM, Karla Shikev wrote:

Thanks, Liam!

Just a quick follow-up question: in the example I saw on your webpage (with
three clades, one of which with a higher rate), how would you go about a
sort of "post-hoc" test to determine which clades differ significantly from
one another in their rates?

Karla

On Sat, Jul 22, 2017 at 4:13 PM, Liam J. Revell <liam.rev...@umb.edu> wrote:


Hi Karla.

phytools has a function called ratebytree for this. This essentially
corresponds to the 'censored' model of O'Meara et al. 2006, but we also
have a submitted manuscript describing it. I can send you that in a second
email.

For more information about using the function you can search for
'ratebytree' on my blog, blog.phytools.org.

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 7/22/2017 3:10 PM, Karla Shikev wrote:


Dear all,

I'd like to test whether the rate of evolution of a phenotypic trait (e.g.
body size) is significantly different among distantly-related clades (e.g.
mammals vs birds). I got tip data and completely resolved and callibrated
trees. One possibility would be to estimate rates and their confidence
intervals for each clade and to compare them directly, but I'm sure
there's
a more elegant way to do this.

Karla

[[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/



___
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] comparing rates of evolution of a phenotypic trait among clades

2017-07-22 Thread Liam J. Revell

Hi Karla.

phytools has a function called ratebytree for this. This essentially 
corresponds to the 'censored' model of O'Meara et al. 2006, but we also 
have a submitted manuscript describing it. I can send you that in a 
second email.


For more information about using the function you can search for 
'ratebytree' on my blog, blog.phytools.org.


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 7/22/2017 3:10 PM, Karla Shikev wrote:

Dear all,

I'd like to test whether the rate of evolution of a phenotypic trait (e.g.
body size) is significantly different among distantly-related clades (e.g.
mammals vs birds). I got tip data and completely resolved and callibrated
trees. One possibility would be to estimate rates and their confidence
intervals for each clade and to compare them directly, but I'm sure there's
a more elegant way to do this.

Karla

[[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 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] Nnode not equal to length of node.labels

2017-06-23 Thread Liam J. Revell

Hi Maria.

I believe I just fixed this on GitHub. There was a bug in phytools for 
the circumstance in which some but not all nodes are labeled. You can 
install phytools directly from GitHub using devtools as follows:


library(devtools)
install_github("liamrevell/phytools")

& then you can test as follows:

library(phytools)
tree<-read.newick(text='((a))A),(((b),(b1)))B)))C;')
tree$edge.length<-rep(1,nrow(tree$edge))
plotTree.singletons(tree)
nodelabels(tree$node.label)

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 6/22/2017 9:22 AM, Mario José Marques-Azevedo wrote:

Dears,

I'm studying the structure of phylo object to work it in my functions.
I'm using read.newick to read tree with singletons. I do not know why
the number of node is not equal to length of node.labels. For instance:

I have this tree (the same annexed):

tree<-read.newick(text='((a))A),(((b),(b1)))B)))C;')

tree$Nnode
[1] 10

tree$tip.label
[1] "a"  "b"  "b1"

tree$node.label
[1] "C" ""  ""  ""  "A" ""  "B"

length(tree$node.label)
[1] 7

Why nodes 11, 12 and 13 not have labels, even if it is "", in
tree$node.lable, but node 9 has?

Best regards,

Mario







___
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/


Re: [R-sig-phylo] Randomly Resolved Polytomies

2017-06-21 Thread Liam J. Revell

Hi Laura.

I think multi2di also performs random resolutions, so if you wanted to 
generate, say, 100 random resolutions could you not do:


trees<-replicate(100,multi2di(tree),simplify=FALSE)
class(trees)<-"multiPhylo"

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 6/21/2017 12:18 PM, Laura Jackson wrote:

Hi Liam,

I was trying to get this to work on my tree, but it seems that it
doesn't work for larger phylogenies (~1000 tips)? I get the following
error message,..."Error in allTrees(n, TRUE, dd) :
That would generate 7905853580625 trees, and take up more than
7905853581 MB of memory! "

I have attached my phylogeny here. I am trying to get even 10 different
randomly resolved trees. Is this possible with my phylogeny?

Thanks.
-Laura


On Wed, Jun 21, 2017 at 11:08 AM, Laura Jackson
<jacksonlaura...@gmail.com <mailto:jacksonlaura...@gmail.com>> wrote:

Liam,

Thanks so much for your reply and for the blog post, I was able to
get it working.

-Laura

On Wed, Jun 21, 2017 at 10:35 AM, Liam J. Revell
<liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>> wrote:

Dear Laura.

I also just posted a possible solution to my blog here:

http://blog.phytools.org/2017/06/generating-set-of-random-resolutions-of.html

<http://blog.phytools.org/2017/06/generating-set-of-random-resolutions-of.html>.

All the best, Liam

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

On 6/21/2017 11:02 AM, Liam J. Revell wrote:

[This sender failed our fraud detection checks and may not
be who they
appear to be. Learn about spoofing at
http://aka.ms/LearnAboutSpoofing
<http://aka.ms/LearnAboutSpoofing>]


Hi Laura.

The phytools functions resolveNode and resolveAllNodes could
be used.
They resolve either a single node in all possible ways; or
all nodes in
all possible ways, returning a "multiPhylo" object. Note
that in the
latter case the number of trees can be quite large. From the
phytools
doc: "For resolveNode applied to a multifurcation with n
descendants,
the number of resolved trees will be equal to the number of
possible
rooted trees of n taxa. (For instance, three for a
trifurcation, 15 for
a quadrifurcation, and so on.) For resolveAllNodes the
number of fully
resolved trees will be equal to the product of numbers for
resolveNode
applied to each multifurcation separately. (For instance, 45
for a tree
containing one trifurcation and one quadrifurcation.)" To
get a random
set of resolved trees, rather than all possible trees
(because this
number can be high), you could start with one multifurcating
node in the
tree, resolve it in all ways using resolveNode, pick one of
those
resolutions, then move to the next node & so on. I will try
to post a
    formal solution & then share it to the list.

All the best, Liam

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

On 6/21/2017 10:38 AM, Laura Jackson wrote:

Hi all,

I am using the ape package to randomly resolve
polytomies using
'multi2di'
and wondering if there is a way to use this function to
get a single
output
tree file that contains multiple different randomly
resolved trees using
some number of resamplings?

Thanks,
-Laura


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

Re: [R-sig-phylo] Randomly Resolved Polytomies

2017-06-21 Thread Liam J. Revell

Dear Laura.

I also just posted a possible solution to my blog here: 
http://blog.phytools.org/2017/06/generating-set-of-random-resolutions-of.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 6/21/2017 11:02 AM, Liam J. Revell wrote:

[This sender failed our fraud detection checks and may not be who they
appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]

Hi Laura.

The phytools functions resolveNode and resolveAllNodes could be used.
They resolve either a single node in all possible ways; or all nodes in
all possible ways, returning a "multiPhylo" object. Note that in the
latter case the number of trees can be quite large. From the phytools
doc: "For resolveNode applied to a multifurcation with n descendants,
the number of resolved trees will be equal to the number of possible
rooted trees of n taxa. (For instance, three for a trifurcation, 15 for
a quadrifurcation, and so on.) For resolveAllNodes the number of fully
resolved trees will be equal to the product of numbers for resolveNode
applied to each multifurcation separately. (For instance, 45 for a tree
containing one trifurcation and one quadrifurcation.)" To get a random
set of resolved trees, rather than all possible trees (because this
number can be high), you could start with one multifurcating node in the
tree, resolve it in all ways using resolveNode, pick one of those
resolutions, then move to the next node & so on. I will try to post a
formal solution & then share it to the list.

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 6/21/2017 10:38 AM, Laura Jackson wrote:

Hi all,

I am using the ape package to randomly resolve polytomies using
'multi2di'
and wondering if there is a way to use this function to get a single
output
tree file that contains multiple different randomly resolved trees using
some number of resamplings?

Thanks,
-Laura



___
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/


Re: [R-sig-phylo] A possible alternate MRCA function to APE\'s getMRCA

2017-06-09 Thread Liam J. Revell
On the other hand, phytools does have a function - the somewhat 
imprecisely named fastMRCA - which can find the MRCA of just a pair of 
species much faster than getMRCA (however still slower than or only 
about as fast as Joseph & Klaus's solutions).


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 6/9/2017 5:22 AM, Liam J. Revell wrote:


Juan. findMRCA was written before getMRCA existed, but the latter was
faster so now it just calls getMRCA internally. 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 6/9/2017 1:57 AM, Juan Antonio Balbuena wrote:

Package phytools includes a function, findMRCA, that is supposed to work
very efficiently with large trees. you may wish to compare it with your
function.

Cheers

Juan

--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
University of Valencia
http://www.uv.es/~balbuena <http://www.uv.es/%7Ebalbuena>
P.O. Box 22085
http://www.uv.es/cophylpaco
<http://www.uv.es/cavanilles/zoomarin/index.htm>
46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel. +34 963
543 658fax +34 963 543 733

*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.



<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=emailclient>

  Libre de virus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=emailclient>



<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


___
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/


___
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 possible alternate MRCA function to APE\'s getMRCA

2017-06-09 Thread Liam J. Revell
Juan. findMRCA was written before getMRCA existed, but the latter was 
faster so now it just calls getMRCA internally. 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 6/9/2017 1:57 AM, Juan Antonio Balbuena wrote:

Package phytools includes a function, findMRCA, that is supposed to work
very efficiently with large trees. you may wish to compare it with your
function.

Cheers

Juan

--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
University of Valencia
http://www.uv.es/~balbuena <http://www.uv.es/%7Ebalbuena>
P.O. Box 22085
http://www.uv.es/cophylpaco <http://www.uv.es/cavanilles/zoomarin/index.htm>
46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel. +34 963
543 658fax +34 963 543 733

*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.



<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=emailclient>
Libre de virus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=emailclient>


<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


___
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/


Re: [R-sig-phylo] Extracting a clade for LTT

2017-05-08 Thread Liam J. Revell
Just to add to Joseph's totally correct comment, if your object is of 
class "multiPhylo" (that is, a list of trees) you can run:


outgroup<-c("outgroup_A","outgroup_B") ## change to your outgroup(s)
ingroup<-lapply(trees,drop.tip,tip=outgroup)
class(ingroup)<-"multiPhylo"

For some "multiPhylo" objects, for instance those read from a NEXUS 
file, you may also want to first run:


trees<-.uncompressTipLabel(trees)

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 5/8/2017 7:01 AM, Joseph W. Brown wrote:

Hi David.

Sounds like you want drop.tip from ape to get rid of the outgroup. You need 
only pass in the tree and the outgroup(s) name(s).

extract.clade will so something similar, but you need to calculate the mrca for 
each tree first to pass in the node id.

HHT.
JWB

Joseph W. Brown
Post-doctoral Researcher, Smith Laboratory
University of Michigan
Department of Ecology & Evolutionary Biology
Room 2071, Kraus Natural Sciences Building
Ann Arbor MI 48109-1079
josep...@umich.edu




On 8 May, 2017, at 07:31, David Buckley <dbuck...@mncn.csic.es> wrote:

Probably a very easy question, but I could’t find a straightforward answer for 
it…
I have a posterior distribution of trees all rooted with a 
not-so-closely-related outgroup. I’d like to perform some diversification 
analyses (LTT, etc.) just for the ingroup, obviating the outgroup. Is there an 
easy way to extract the ingroup (or remove the outgroup) from all the trees 
before performing the analyses? I have tried to do it ‘manually’, deleting the 
outgroup taxa in Mesquite, but it looks to me that the LTT plots are still 
considering some branch lengths from the ingroup to the outgroup clade (kind of 
considering a stem-origin, not a crown-origin for the ingroup clade…).

Sorry if the question is too naïve…

best

david



David Buckley
Dpt. Biodiversity and Evolutionary Biology
Museo Nacional de Ciencias Naturales, MNCN-CSIC
c/José Gutiérrez Abascal 2
28006-Madrid
Spain
Phone: +34 91 411 13 28 ext. 1126
dbuck...@mncn.csic.es
https://www.researchgate.net/profile/David_Buckley4 
<https://www.researchgate.net/profile/David_Buckley4>
http://scholar.google.com/citations?user=qEFTmfkJ=en 
<http://scholar.google.com/citations?user=qEFTmfkJ=en>













[[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/



___
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] Applying standard error in phylogenetic signal measurement using lambda

2017-04-27 Thread Liam J. Revell

Hi Ting-Wen.

If you could (off-list) send me the simplest possible reproducible 
example of the error (with your input data files or a saved R workspace) 
I would be more than happy to look into it.


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 4/27/2017 4:11 AM, Chen, Ting-Wen wrote:

Dear all,

I’m measuring phylogenetic signal for a set of continuous traits using the 
function “phylosig”. I try to apply standard error of measurements in Pagel’s 
lambda, but the R gives this error message:

'Error in solve.default(V) :
  Lapack routine dgesv: system is exactly singular: U[1,1] = 0’

It seems to be a problem when the function tries to invert the matrix? Does 
anybody know how to solve this problem? I have tried to multiply all trait 
values and standard errors by e.g. 100, and for some traits it works but for 
some not…

Any suggestion will be very appreciated. Thank you!

All the best
Ting-Wen

--
Ting-Wen Chen
Animal Ecology (AG Scheu)
J.F. Blumenbach Institute of Zoology and Anthropology
Georg August University Göttingen
Untere Karspüle 2
D-37073 Göttingen, Germany


[[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 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/

  1   2   3   4   5   >