2

Let's have two matrices, one DNA sequence alignment and one consisting of binary characters.

dna <- matrix(c("a", "a", "a", "t", "a", "a", 
                "t", "t", "a", "g", "c", "c"), 
              ncol = 4, dimnames = list(LETTERS[1:3], NULL))

bi <- matrix(c(0,0,1,0,1,1,1,0,0,1,0,0), 
             ncol = 4, dimnames = list(LETTERS[1:3], NULL))

We can reconstruct the phylogenetic relationships with the phangorn package:

library(phangorn)
dnatr <- optim.pml(pml(tree = rtree(3, tip.label = LETTERS[1:3]), 
                       data = phyDat(dna)), 
                   optNni = TRUE)
bitr <- optim.pml(pml(tree = rtree(3, tip.label = LETTERS[1:3]), 
                      data = phyDat(bi, type= "USER", levels = c(0,1))),
                  optNni = TRUE)
                  

Function phangorn::pmlPart should run partitioned analyses, but it does not combine the phylogenetic information in partitions to reconstruct a single phylogeny.

tr = pmlPart(~ edge + nni, object = list(dnatr, bitr))

How can I set up a partitioned analysis that uses mixed datatypes (DNA sequences and a binary character)?

nya
  • 2,138
  • 15
  • 29

1 Answers1

3

You are almost there, the following code should work:

tr = pmlPart(edge + nni ~ . , object = list(dnatr, bitr))

The documentation on CRAN is unfortunately a bit outdated. Please make sure you have the latest development version of phangorn from github (remotes::install_github("KlausVigo/phangorn")) installed.

PS: For tree rearrangements you need at least 4 tips, so with your example will ignore the nni term.

klash
  • 341
  • 1
  • 2