[R-sig-phylo] Rooting on a node with resolve.root = TRUE

2015-03-19 Thread Luiz Max Carvalho
Dear phylofolks,

I'm trying to root a tree on an internal (rather than a terminal) branch.
Here is a small example:

library(ape)
t5 - rmtree(N = 1, n = 5, rooted = FALSE)[[1]]
root(t5, node = 6, resolve.root = TRUE)

output:  Error in if (i != N) { : argument is of length zero

root(t5, node = 7, resolve.root = TRUE)

output: Phylogenetic tree with 5 tips and 4 internal nodes.

Tip labels:
[1] t4 t3 t2 t5 t1

Rooted; includes branch lengths.


I don't understand why rooting at node 6 throws an error, while using node
7 is fine. What am I missing?

Cheers,

Luiz

-- 
Luiz Max Fagundes de Carvalho
PhD student, Institute of Evolutionary Biology,  School of Biological
Sciences,
Ashworth Laboratories, Ash 2, office 123
University of Edinburgh, United Kingdom.
http://br.linkedin.com/pub/luiz-max-carvalho/49/687/283

[[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] Count the number of character/state changes in a tree

2015-03-03 Thread Luiz Max Carvalho
Dear Phylofolks,

Suppose I have a phylo object phy and the states at all nodes (internal and
external). Would the following function give me the number of state changes?

get.changes - function(tree, states){
  sum(apply(phy$edge, 1, function(x)  states[x[1]]!=states[x[2]]))
}

If not, what would?

Thanks in advance,

Luiz
-- 
Luiz Max Fagundes de Carvalho
PhD student, Institute of Evolutionary Biology,  School of Biological
Sciences,
Ashworth Laboratories, Ash 2, office 123
University of Edinburgh, United Kingdom.
http://br.linkedin.com/pub/luiz-max-carvalho/49/687/283

[[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] Potential glitch in phymltest

2014-11-07 Thread Luiz Max Carvalho
Hello Phylofolks,

I've been using ape::phymltest() for a while now on a project and I just
realised there is a potential glitch in the function. The reason is that
the order of the models in the 'mdl' object inside the function is
different from the order in .phymltest.model, what causes the cmd object to
mess up.
 The following MWE should do the job of showing my point:
### begin MWE
library(ape)

.phymltest.model -
  c(JC69, JC69+I, JC69+G, JC69+I+G,
K80, K80+I, K80+G, K80+I+G,
F81, F81+I, F81+G, F81+I+G,
F84, F84+I, F84+G, F84+I+G,
HKY85, HKY85+I, HKY85+G, HKY85+I+G,
TN93, TN93+I, TN93+G, TN93+I+G,
GTR, GTR+I, GTR+G, GTR+I+G)

phymltest.test - function(seqfile, format = interleaved, itree = NULL,
  exclude = NULL, execname = NULL, append = TRUE)
{
  N - length(.phymltest.model)
  format - match.arg(format, c(interleaved, sequential))
  fmt - rep(, N)
  if (format != interleaved) fmt[] - -q
  boot - rep(-b 0, N) # to avoid any testing
  mdl - paste(-m, rep(c(JC69, K80, F81,HKY85,F84, TN93,
GTR), each = 4))
  tstv - rep(-t e, N) # ignored by PhyML with JC69 or F81
  inv - rep(c(, -v e), length.out = N)
  ## no need to use the -c option of PhyML (4 categories by default if '-a
e' is set):
  alpha - rep(rep(c(-c 1, -a e), each = 2), length.out = N)
  tree - rep(, N)

  cmd - paste(execname, -i, seqfile, fmt, boot, mdl, tstv, inv, alpha,
tree, --append )
  imod - 1:N
  if (!is.null(exclude)) imod - imod[!.phymltest.model %in% exclude]
  for (i in imod) print(cmd[i])
}

phymltest.test(seqfile = seqname,
  exclude = c(K80, K80+I, K80+G, K80+I+G,
  F81, F81+I, F81+G, F81+I+G,
  F84, F84+I, F84+G, F84+I+G,

  TN93, TN93+I, TN93+G, TN93+I+G),
  execname = execname)
1] execname -i seqname  -b 0 -m JC69 -t e  -c 1  --append 
[1] execname -i seqname  -b 0 -m JC69 -t e -v e -c 1  --append 
[1] execname -i seqname  -b 0 -m JC69 -t e  -a e  --append 
[1] execname -i seqname  -b 0 -m JC69 -t e -v e -a e  --append 
[1] execname -i seqname  -b 0 -m F84 -t e  -c 1  --append 
[1] execname -i seqname  -b 0 -m F84 -t e -v e -c 1  --append 
[1] execname -i seqname  -b 0 -m F84 -t e  -a e  --append 
[1] execname -i seqname  -b 0 -m F84 -t e -v e -a e  --append 
[1] execname -i seqname  -b 0 -m GTR -t e  -c 1  --append 
[1] execname -i seqname  -b 0 -m GTR -t e -v e -c 1  --append 
[1] execname -i seqname  -b 0 -m GTR -t e  -a e  --append 
[1] execname -i seqname  -b 0 -m GTR -t e -v e -a e  --append 

## end MWE

I think it's easily solved by replacing mdl with  paste(-m, rep(c(JC69,
K80, F81, F84HKY85, TN93, GTR), each = 4))

Anyways, hope to clarify this minor issue.

Cheers,

Luiz

-- 
Luiz Max Fagundes de Carvalho
PhD student, Institute of Evolutionary Biology,  School of Biological
Sciences,
Ashworth Laboratories, Ash 2, office 123
University of Edinburgh, United Kingdom.
http://br.linkedin.com/pub/luiz-max-carvalho/49/687/283

[[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] Sampling bias in discrete trait estimation

2013-11-11 Thread Luiz Max Carvalho
This definitely looks like something. Thanks, Matt!

Cheers,

Luiz


2013/11/11 Matt Pennell mwpenn...@gmail.com

 Hi Luiz,


 Yes, non-random sampling of traits, if not taken into account will
 certainly bias the estimation of the transition parameters. Methods for
 addressing this have been developed by Rich FitzJohn and colleagues
 http://sysbio.oxfordjournals.org/content/58/6/595.short (this was
 discussed in the context of state dependent diversification but also
 applies to regular Mk models, which is just a special case of the BiSSE
 model).

 I am sure there are potentially interesting follow-ups one could do here.

 cheers,
 matt

 On Mon, Nov 11, 2013 at 9:52 AM, Luiz Max Carvalho 
 luizepidemiolo...@gmail.com wrote:

 Dear all,

 Suppose you have  observed K discrete traits for a phylogeny with N tips.
 For some reason, you think your trait sampling is not random, i.e., it may
 be biased towards some particular K's, for example because they're easier
 to sample.

 I imagine this will introduce some bias in the estimation of the
 infinitesimal rate matrix of the Markov model of trait evolution (Q). I
 would like to address this question in a more mathematically precise way.
 Have anyone heard of a study addressing these issues so far, both
 mathematically or using simulation studies?

 Thanks in advance.

 All the best,

 Luiz


 --
 Luiz Max Fagundes de Carvalho, IC, Programa de Computação Científica
 (PROCC), Fundação Oswaldo Cruz, Rio de Janeiro, Brasil.

 https://www.researchgate.net/profile/Luiz_Fagundes_de_Carvalho/?ev=prf_info

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





-- 
Luiz Max Fagundes de Carvalho, IC, Programa de Computação Científica
(PROCC), Fundação Oswaldo Cruz, Rio de Janeiro, Brasil.
https://www.researchgate.net/profile/Luiz_Fagundes_de_Carvalho/?ev=prf_info

[[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] Does anyone know about a function to remove redundancy from a database?

2013-02-19 Thread Luiz Max Carvalho
I've been looking for a function that could scan a DNAbin object and return
just the unique sequences. Does anyone know about a function for that?

Thanks in advance,

-- 
Luiz Max Fagundes de Carvalho, IC, Programa de Computação Científica
(PROCC), Fundação Oswaldo Cruz, Rio de Janeiro, Brasil.
https://www.researchgate.net/profile/Luiz_Fagundes_de_Carvalho/?ev=prf_info

[[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] Does anyone know about a function to remove redundancy from a database?

2013-02-19 Thread Luiz Max Carvalho
Great! Thank you!

2013/2/19 Klaus Schliep klaus.schl...@gmail.com

 Hi Luiz,

 phangorn has a generic unique function for phyDat objects.
 There may be more elegant ways, but this code should work:
 library(phangorn)
 y = as.DNAbin(unique(as.phyDat(x)))

 Cheers,
 Klaus


 On 2/19/13, Luiz Max Carvalho luizepidemiolo...@gmail.com wrote:
  I've been looking for a function that could scan a DNAbin object and
 return
  just the unique sequences. Does anyone know about a function for that?
 
  Thanks in advance,
 
  --
  Luiz Max Fagundes de Carvalho, IC, Programa de Computação Científica
  (PROCC), Fundação Oswaldo Cruz, Rio de Janeiro, Brasil.
 
 https://www.researchgate.net/profile/Luiz_Fagundes_de_Carvalho/?ev=prf_info
 
[[alternative HTML version deleted]]
 
 


 --
 Klaus Schliep
 Phylogenomics Lab at the University of Vigo, Spain




-- 
Luiz Max Fagundes de Carvalho, IC, Programa de Computação Científica
(PROCC), Fundação Oswaldo Cruz, Rio de Janeiro, Brasil.
https://www.researchgate.net/profile/Luiz_Fagundes_de_Carvalho/?ev=prf_info

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