ordered an un-ordered characters in morphological matrix

183 views
Skip to first unread message

Matthew Forister

unread,
Nov 16, 2017, 12:35:30 PM11/16/17
to revbayes-users

Dear list,

I don't have any experience with RevBayes, but I am going through the tutorials and haven't been able to find an answer to a particular question that determines whether or not Rev will work for me.  Question:

Is it possible to analyze an input file of morphological characters in which some of the characters are ordered (1 goes to 2 goes to 3, etc.) and some of the characters are not ordered (1 can change to 2 or 3, etc.)?

If that is possible, then it would be wonderful if someone had an example code executing an analysis with this kind of data that they could share.  

thank you!
Matt

Eduardo Ascarrunz

unread,
Jan 21, 2020, 11:08:54 PM1/21/20
to revbayes-users
Hello everyone,

I'm also new to RevBayes, and I'd also like to know how to handle standard multistate characters. For instance, should I create a separate matrix for the ordered characters and use fnOrderedRateMatrix to make the corresponding transition rate matrix? If so, what is the meaning of the "state 0" that's mentioned in the documentation for fnOrderedRateMatrix? Can I only use the symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and only in that order?

Cheers,

Eduardo

Jo Baker

unread,
Jun 18, 2021, 8:45:57 AM6/18/21
to revbayes-users
Does anybody here have any insight into this question?

I am also trying to do this - I have a morphological matrix with some unordered and some ordered characters (It is known which is which). 

One thing I thought was to separate the matrix into two, and specify fnOrderedRateMatrix for the ordered characters. However, I'm not sure how to handle the variable number of states within the ordered characters given the requirement of the maxState argument.

Some example code or some insight here might be very useful.

Thanks

Jo 

April Wright

unread,
Jun 21, 2021, 4:34:33 PM6/21/21
to revbayes-users
Hey folks,

There are a few ways to approach this issue. The one we usually use in my lab is to separate out the unordered characters and partition them by number of states (as in this tutorial). Then the ordered characters, we separate by maxstate and ordering.

So, for instance, if you had three ordered characters with number of states 4, 5 and 6 in a three character matrix, this would look something like this:

lambda = 1
mu = 1
morpho <- readDiscreteCharacterData("myfile")
vector_morph[1] <- morpho
vector_morph[1].excludeCharacters(2,3)
vector_morph[2].excludeCharacters(1,3)
vector_morph[3].excludeCharacters(1,2)

Q_o1 <- fnOrderedRateMatrix(4, lambda, mu)
Q_o2 <- fnOrderedRateMatrix(5, lambda, mu)
Q_o3 <- fnOrderedRateMatrix(6, lambda, mu)


morph_models[1] ~ dnPhyloCTMC(tree=phylogeny, siteRates=rates_morpho,
                              Q=Q_o1, type="Standard")
morph_models[2] ~ dnPhyloCTMC(tree=phylogeny, siteRates=rates_morpho,
                              Q=Q_o2, type="Standard")
morph_models[3] ~ dnPhyloCTMC(tree=phylogeny, siteRates=rates_morpho,
                              Q=Q_o3, type="Standard")

morph_models[1].clamp(vector_morph[1])
morph_models[2].clamp(vector_morph[2])
morph_models[3].clamp(vector_morph[3])


I'm sure there's a way to make that a nice iterable. But I can't think of it just now. A member of my lab is working on some companion R functions to automate this type of partitioning, and working on importing some additional functionality from the NCL reader library to make RevBayes do this more naturally.

a
Reply all
Reply to author
Forward
0 new messages