HyPhy message board
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl
Methodology Questions >> How to >> likelihood per position/partition
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl?num=1092349408

Message started by gustavo on Aug 12th, 2004 at 3:23pm

Title: likelihood per position/partition
Post by gustavo on Aug 12th, 2004 at 3:23pm
How can I print the likelihood for each position of the alignment or for each partition?
Thanks very much in advance,


gustavo

Title: Re: likelihood per position/partition
Post by Sergei on Aug 12th, 2004 at 5:13pm
Dear Gustavo,

The basic idea is to use a 'ConstructCategoryMatrix' command to tabulate site-by-site likelihood. This gets a little trickier is there are category (rate variation variables) involved, because the command outputs a vector of marginals for each site.

Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login Login

points to an example file (it's self-contained NEXUS) - look at the source of the example in the 'HYPHY' block to see how this works. Just open this a a regular batch file to execute the example.

In the GUI version (Mac and Windows), you can use 'Likelihood->Category Processor' menu from the parameter table window (which you can get to by opening the Object Inspector, finding the tree in the current analysis, opening its window and they choosing 'Tree->Show Parameters in Table' menu) to display a table with site-by-site likelihoods.

Sergei

Title: Re: likelihood per position/partition
Post by Sergei on May 3rd, 2006 at 1:19pm
In case there are rate categories...

Assume for a second that you have a single category variable 'c' with D classes. If you call
ConstructCategoryMatrix on a likelihood function with 'c' in the model and N sites, you'll get an DxN matrix, where the entry in row i and column j tells you the likelihood of site j, given that 'c' takes value from its i-th class.

To compute the likelihood of a site then is simply a matter of computing expected values. You can do this as follows (replace variables as appropriate).


Code (]
/* this needs HyPhy from 2006 for row indexing tricks */

GetInformation (catInfo, c);
ConstructCategoryMatrix (cmx, lf, COMPLETE);
/* extract the second row from catInfo - the weights for each class */
weights = catInfo[1):

[-1];
/* compute the expectations; these will be likelihoods; NOT log-likelihoods */
lkBySite = weights *cmx;
/* compute log-L */
logLBySite = Log (lkBySite);


HyPhy message board » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2024. All Rights Reserved.