HyPhy message board  
http://www.hyphy.org/cgibin/hyphy_forums/YaBB.pl
HYPHY Package >> Feature Additions >> Implementing a categorical frequency matrix http://www.hyphy.org/cgibin/hyphy_forums/YaBB.pl?num=1301594521 Message started by LeavittJM on Mar 31^{st}, 2011 at 11:02am 
Title: Implementing a categorical frequency matrix Post by LeavittJM on Mar 31^{st}, 2011 at 11:02am
I am implementing a categorical frequency matrix in HYPHY using the ConstructCategoryMatrix command.
However I am having some trouble interpreting the resulting matrix. Do the values for a particular codon still need to be normalized? Thanks! 
Title: Re: Implementing a categorical frequency matrix Post by Sergei on Mar 31^{st}, 2011 at 11:13am
Hi there,
ConstructCategoryMatrix takes a lot of options which control what it generates; one of the options will output normalized posterior probabilities. I'll post an example batch file later today. Sergei 
Title: Re: Implementing a categorical frequency matrix Post by LeavittJM on Mar 31^{st}, 2011 at 12:41pm
Thank you for the quick reply.
I will check out your batch file when you put it up. However, I have one quick question to make sure I understand the output from the ConstructCategoryMatrix command. For a CategoryMatrix of {2,1}, if it gives you {0.1} {0.3}, then there is a distribution of 25% and 75% between the two categories. Thanks again. 
Title: Re: Implementing a categorical frequency matrix Post by Sergei on Apr 1^{st}, 2011 at 12:38am
Hi there,
By default, the function returns conditional likelihoods: Pr (site  rate class). In your example, the probability of observing a site given the model in class 1 is 0.1, and given the model in class 2 is 0.3 Most of the time one wants Pr (rate class  site), which can be obtained by a simple application of the Bayes rule: Code (] Pr (rate class  site) = Pr (siterate class) * Pr (rate class) / Pr (site) [/code):
HTH, Sergei PS I could probably give you more pointers if I had a better idea of what the final objective was. 
Title: Re: Implementing a categorical frequency matrix Post by LeavittJM on Apr 6^{th}, 2011 at 2:41pm
Hi Sergei,
The following code functions correctly, though I had to use for loops instead of matrix functions. Is there a way to do it faster? Thanks for the help, John Code (]ConstructCategoryMatrix(catmat,theLnLik,COMPLETE); ConstructCategoryMatrix (priors, theLnLik, WEIGHTS); result = {Rows(catmat),Columns(catmat)}; for( i=0; i<Rows(catmat); i=i+1) { for(j=0; j<Columns(catmat); j=j+1) { result[i):

Title: Re: Implementing a categorical frequency matrix Post by Sergei on Apr 13^{th}, 2011 at 1:49pm
Hi John,
There really is not a builtin way to do it much faster (in terms of lines of code). HyPhy template batch files contain some HBL functions to do the same, but your code is perfectly adequate. You can define it as a function and include it in other files for later use. Sergei 
HyPhy message board » Powered by YaBB 2.5.2! YaBB Forum Software © 20002023. All Rights Reserved. 