HyPhy message board
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl
Methodology Questions >> How to >> Joining low-freq states in just one class
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl?num=1165874372

Message started by Jose_Patane on Dec 11th, 2006 at 1:59pm

Title: Joining low-freq states in just one class
Post by Jose_Patane on Dec 11th, 2006 at 1:59pm
Hi all,

I'm trying to develop a 9x9 state matrix , to work with stems in RNAs... I want to accommodate the not-so-frequent states in just one, separate, class... but so far I've only been able to define 16x16 models in HyPhy. How can I achieve that? I don't know whether the following may interfere with setting up such model or not, but no class have 0 frequency (meaning, I can't simply discard one or more classes from the analyses).

Title: Re: Joining low-freq states in just one class
Post by Sergei on Dec 12th, 2006 at 6:03am
Dear Jose,

There should be no difficulty in defining a 9x9 matrix (by simply writing it down) in the batch language code. However you need to 'alias' 7 low-frequency states into 1, which, unfortunately is tedious to do in the current implementation (i.e. one needs to create a temporary dataset in memory which maps 7 states down to 1). I'll write a little example in a short while on how to do that (assuming the RNA alphabet).

Cheers,
Sergei

Title: Re: Joining low-freq states in just one class
Post by Jose_Patane on Dec 12th, 2006 at 7:05am
Thanks for the attention, Sergei... I'll wait until your example is ready then. Cheers

Title: Re: Joining low-freq states in just one class
Post by Sergei on Dec 13th, 2006 at 8:30am
Dear Jose,

Here's a code example for you. You should be able to define the map you need to and after that - the model you need to.

Cheers,
Sergei


Code (]
DataSet        ds          = ReadDataFile  ("../DistributionPackages/data/StemRNA.nex");
DataSetFilter rna16filter = CreateFilter (ds,2);

stateMap = {16,1}; /* how to map the states down, from AA,AC,...UU to a smaller state
                               the example here maps all unpaired states down to 1 */
                               
stateMap [0):

 = 0; /* AA -> State 0 */
stateMap [1]  = 0; /* AC -> State 0 */
stateMap [2]  = 0; /* AG -> State 0 */
stateMap [3]  = 1; /* AU -> State 1 */
stateMap [4]  = 0; /* CA -> State 0 */
stateMap [5]  = 0; /* CC -> State 0 */
stateMap [6]  = 2; /* CG -> State 2 */
stateMap [7]  = 0; /* CU -> State 0 */
stateMap [8]  = 0; /* GA -> State 0 */
stateMap [9]  = 3; /* GC -> State 3 */
stateMap [10] = 0; /* GG -> State 0 */
stateMap [11] = 4; /* GU -> State 4 */
stateMap [12] = 5; /* UA -> State 5 */
stateMap [13] = 0; /* UC -> State 0 */
stateMap [14] = 6; /* UG -> State 6 */
stateMap [15] = 0; /* UU -> State 0 */

stateCount         = 7; /* how many states are there */
characterRemap = "ABCDEFGHIJKLMNOP"; /* just a hack to remap the characters */

newFilterString = "";
newFilterString * 128;

indexVector = {1,16} ["_MATRIX_ELEMENT_COLUMN_"];
unitVector  = {1,16} ["1"];
GetDataInfo (uniqueMap,rna16filter);

/* this code will map all ambiguities to ? */

newFilterString * ("$BASESET:\""+characterRemap[0][stateCount]+"\"\n");
newFilterString * ("$TOKEN: \"X\"=\""+characterRemap[0][stateCount]+"\"\n");

for (seq  = 0; seq < rna16filter.species; seq = seq + 1)
{
     GetString (seqI,rna16filter,seq);
     newFilterString * (">" + seqI + "\n");
     for (site = 0 ; site < rna16filter.sites; site = site + 1)
     {
           GetDataInfo (siteInfo, rna16filter,seq,uniqueMap[site]);
           stateCount = (unitVector*siteInfo)[0];
           if (stateCount != 1)
           {
                 newFilterString * "X";
           }
           else
           {
                 newFilterString * characterRemap[stateMap[(indexVector*siteInfo)[0]];
           }
     }
     newFilterString * "\n";
}

newFilterString * 0;

DataSet              reducedRNA       = ReadFromString (newFilterString);
DataSetFilter reducedRNAFilter = CreateFilter   (reducedRNA,1);

Title: Re: Joining low-freq states in just one class
Post by Jose_Patane on Dec 16th, 2006 at 5:14am
Once again, it helped me a lot... cheers

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