Welcome, Guest. Please Login
YaBB - Yet another Bulletin Board
 
  HomeHelpSearchLogin  
 
rerooting trees in batch files (Read 6337 times)
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
rerooting trees in batch files
Sep 2nd, 2008 at 8:54pm
 
Hi Sergei,

I am just trying to reroot many trees using a batch file, those trees come from a previous NJ. Then I want to use those trees for an analysis with the PAML package.

I find a strange problem, the output rerooted trees of the batch file cannot be readed by PAML, however if I do the same in the GUI of Hyphy, the output rerooted trees can be readed by PAML. For example:
Tree from GUI:
(outgroup:0.10175,((((seq00002:0.00712982,seq00005:0.00294759):0.000123234,seq00
007:0.00289186):0.0118193,(seq00003:1e-05,seq00010:1e-05):0.0210865):0.00905762,
((seq00001:0.00278719,(seq00004:0.00598958,seq00008:0.00815702):0.000217613):0.0
0276009,(seq00006:0.00100167,seq00009:1e-05):0.0103881):0.0227801));
Tree from Batch file:
((((((seq00002:0.00712982,seq00005:0.00294759):0.000123234,seq00007:0.00289186):
0.0118193,(seq00003:1e-05,seq00010:1e-05):0.0210865):0.00905762):0.00905762,((se
q00001:0.00278719,(seq00004:0.00598958,seq00008:0.00815702):0.000217613):0.00276
009,(seq00006:0.00100167,seq00009:1e-05):0.0103881):0.0227801):0.10175,outgroup:
0.10175);

I think both of trees are good, the only one difference is the position of the outgroup. However PAML only likes the first of them, for the other writes:
Error: check #seqs and tree: perhaps too many '('?.

So, maybe it is a bag of PAML. But well, I think perhaps there is a way for obtaining the first rooted tree using a batch file of Hyphy because with the GUI that is possible, is there any way?.

Below, I send you the part of my batch file about this:
[code]/* define the model JC */
     equalFreqs = {{.25}{.25}{.25}{.25}};
     JC69 = {{*,a,a,a}{a,*,a,a}{a,a,*,a}{a,a,a,*}};
     Model JC69model = (JC69, equalFreqs);
     UseModel (JC69model);

     /* build NJ */
     distanceChoice = 0; /* raw distances */
     modelType = 0; /* no rate variation*/
     methodIndex = 1; /* Negative Branch Lengths are Allowed */
     p = InferTreeTopology(1.0); /* in myFunctions.bf */
     treeString = TreeMatrix2TreeString (1); /* treeString stores the tree in Newick format */
     treeString = RerootTree (treeString,0);
     fprintf (stdout,"\nInferred NJ tree: ", treeString);

     OutFile = inputfile + "_tree.tre";
     fprintf (OutFile,CLEAR_FILE);

     fprintf (stdout, "\t[WRITING tree TO ",OutFile,"]\n");            
     fprintf (stdout, "\n\nTree NO Rooted:");      
     fprintf (stdout,"\n", treeString);
     
     NICETY_LEVEL = 3;

     fprintf (stdout, "\n\nOther trees:");      

     Tree treeRoot_outg = treeString;
     fprintf (stdout,"\nInferred NJ tree (before rooting with outgroup, without branch lengths): ", treeRoot_outg);
     fprintf (stdout,"\n");

     treeRoot = RerootTree(treeRoot_outg,"outgroup");
     fprintf (stdout,"\nInferred NJ tree (after rooting with outgroup): ", treeRoot);
     fprintf (stdout,"\n");
     [/code]


Thanks a lot.   :D
Regards,

Miguel





Back to top
 
WWW WWW  
IP Logged
 
Sergei
YaBB Administrator
*****
Offline


Datamonkeys are forever...

Posts: 1658
UCSD
Gender: male
Re: rerooting trees in batch files
Reply #1 - Sep 3rd, 2008 at 9:22am
 
Dear Miguel,

You are using PAML??|??  :P Sigh. You can probably use HyPhy to do the same thing and avoid the rerooting issue altogether. What are you using PAML for if you don't mind my asking? I may be able to tell you how to do an equivalent procedure in HyPhy.

Both trees look OK to me as well.

Cheers,
Sergei
Back to top
 

Associate Professor
Division of Infectious Diseases
Division of Biomedical Informatics
School of Medicine
University of California San Diego
WWW WWW  
IP Logged
 
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
Re: rerooting trees in batch files
Reply #2 - Sep 3rd, 2008 at 12:45pm
 
Dear Sergei,

Hyphy is the best, I know, D. Posada (my boss) tell me that always  Wink. Hyphy is the most flexible to use, it is perfect for complete analysis where you can study many different things in only one step. That is great!!   Cheesy

Well, I was using PAML (baseml) for an analysis of "marginal" reconstruction of ancestral sequences.

Looking to your answer, this is something apart of this, let me tell you about I also need to do an analysis of positive selection sites (no branches, only the question: what sites have positive selection?). Also I saw PAML could do this by codeml, but I think Hyphy is the best specially for this analysis.
Hyphy has many batch files for this:
NielsenYang.bf
CompareSelectivePressure.bf
MFPositiveSelecton.bf
QuickSelectionDetection.bf
- What is the best of these batchs for this analysis?, I think NielsenYang.bf, but what is your opinion?
- Maybe, is there any batch file for this analysis without the prompt questions?, for do a GY94 1x4, cutoff 0.9 and 8 categories. The idea is to analyze many data sets. If it is not, there is not problem, I am going to work on that very soon.

Finally, let me come back to the rerooting trees question. I think it could be two options to obtanin the tree1 (trees of the previous topic) in the batch file:
First, Is there any way in Hyphy for changing the position of the "outgroup" sequence in the batch file (convert the tree2 in the tree1)? or Second, use a different way to reroot the tree in the batch file for obtaining the tree1, like the GUI works.

Regards,  Cool
Miguel




Back to top
 
WWW WWW  
IP Logged
 
Sergei
YaBB Administrator
*****
Offline


Datamonkeys are forever...

Posts: 1658
UCSD
Gender: male
Re: rerooting trees in batch files
Reply #3 - Sep 3rd, 2008 at 7:04pm
 
Dear Miguel,

HyPhy doesn't include built in marginal reconstruction, but the new version I am writing at the moment can easily do it. Are you interested in trying it?

As far as site-by-site analysis goes, I would probably recommend FEL or dNdSRateAnalysis.bf

Take a look at Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login Login for more details and also for notes on how to override the prompts.

I am not sure I understand your question about rerooting the trees, though Sad

Cheers,
Sergei
Back to top
 

Associate Professor
Division of Infectious Diseases
Division of Biomedical Informatics
School of Medicine
University of California San Diego
WWW WWW  
IP Logged
 
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
Re: rerooting trees in batch files
Reply #4 - Sep 3rd, 2008 at 9:17pm
 
Dear Sergei,

Great, so Ok I would like to try the marginal reconstruction of the new version. Let me know when you finish it.  Smiley    

Thanks for your recommendation about estimate positive selection by site. I am going to see those options.  Cool    

About the question of rerooting trees   Embarrassed  , I mean if you look at the two trees that I send you in the first message, both of trees come from the same data file, and each tree comes from a different "way or methodology" in hyphy (the first comes from the GUI and the second comes from my batch file which I also attached in the first message), you can see that both of them are the same tree but the newick format was wrote in a different way. Right? Smiley
Then, other programs (like PAML or FigTree, FigTree said "Missing ',' in tree") do not read the newick tree from my batch file (but they read the newick tree from GUI), very strange but I think that it is a problem of the other programs.   Shocked
I have to work with many data sets so I will need to use a batch file of hyphy. So I asked you if it was possible to obtain from the batch file the rooted tree in the same newick than the rooted tree from the GUI.
Well, that is very difficult to explain  Sad  , it does not matter, I will find another way to obtain many NJ rooted trees that the other programs can read.


Again, thanks a lot for all and for your answer so fast,  Cheesy  
Regards,

Miguel




Back to top
« Last Edit: Sep 4th, 2008 at 12:27am by Miguel »  
WWW WWW  
IP Logged
 
Sergei
YaBB Administrator
*****
Offline


Datamonkeys are forever...

Posts: 1658
UCSD
Gender: male
Re: rerooting trees in batch files
Reply #5 - Sep 4th, 2008 at 7:48am
 
Dear Miguel,

I see what you mean about outgroup positioning. Let me put together some example code for you on how to that.

Cheers,
Sergei
Back to top
 

Associate Professor
Division of Infectious Diseases
Division of Biomedical Informatics
School of Medicine
University of California San Diego
WWW WWW  
IP Logged
 
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
Re: rerooting trees in batch files
Reply #6 - Sep 7th, 2008 at 2:24pm
 
Dear Sergei,

Ok, I will be waiting for your code to change the position of the outgroup (please let me know if that is not possible) and for the new batch file on marginal ancestral sequence reconstruction.

Take care,  Cheesy

Miguel
Back to top
 
WWW WWW  
IP Logged
 
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
Re: rerooting trees in batch files
Reply #7 - Sep 22nd, 2008 at 9:08pm
 
Dear Sergei,

Is it possible the Ancestral Sequence Reconstruction for amino acid sequences in Hyphy?

Cheers,

Miguel   Smiley

Back to top
 
WWW WWW  
IP Logged
 
Sergei
YaBB Administrator
*****
Offline


Datamonkeys are forever...

Posts: 1658
UCSD
Gender: male
Re: rerooting trees in batch files
Reply #8 - Sep 23rd, 2008 at 4:20am
 
Dear Miguel,

You can recover the ancestral sequences under any evolutionary model in HyPhy. To reconstruct amino-acid sequences, you need to either fit a codon (assuming you have codon inputs) or an amino-acid model to the data.

Cheers,
Sergei
Back to top
 

Associate Professor
Division of Infectious Diseases
Division of Biomedical Informatics
School of Medicine
University of California San Diego
WWW WWW  
IP Logged
 
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
Re: rerooting trees in batch files
Reply #9 - Sep 25th, 2008 at 8:19am
 
Dear Sergei,

That is great.  :D
After of the study about the reconstruction of ancestral sequences (ASR) under codon models we are interesting now in have a look to the ASR under amino-acid (aa) models.

Then, I see the following aa models in Hyphy: Dayhoff, EIAA, Fitness, Jones
Well, what is your opinion about what of these aa models could generate the best ASR?, or what aa model do you recommend me for the aa ASR?. This is for codon simulate data.  :)

About the batch file of aa ASR.
Yes, my input files are codon data sets so I must translate them to aa data set using, for example, the SeqAlignment.bf.
Well, this is a part of my ASR batch file about the data and the substitution model:

[code]
/* Input Data and model selection*/
inputfile = fileNames[fileCount]; /* codon data sets */

analysisOptions      = {};
analysisOptions["0"] = fileCodes[fileCount];
ExecuteAFile (HYPHY_BASE_DIRECTORY+ "TemplateBatchFiles" + DIRECTORY_SEPARATOR +  "TemplateModels" + DIRECTORY_SEPARATOR + "chooseGeneticCode.def", analysisOptions);

DataSet        ds               = ReadDataFile (fileNames[fileCount]);
DataSetFilter filteredData = CreateFilter (ds,3,"","",GeneticCodeExclusions);
analysisOptions["0"] = "Global";
ExecuteAFile (HYPHY_BASE_DIRECTORY+ "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "GY94.mdl", analysisOptions);
fprintf (stdout, "[WORKING ON FILE ", fileNames[fileCount], "]\n");
.
.
.
/* ASR */
LikelihoodFunction lf = (filteredData, givenTree);
Optimize (res, lf);
DataSet ancestors = ReconstructAncestors(lf);
[/code]
So I just have two questions about the batch file:
1. How could I introduce the translating to aa and the aa model in the first part of the batch file? I did not find examples in the documentation. Could you help me a bit if it is possible?
2. Should I modify the last part about ASR calculation?


Many thanks!

Miguel


Back to top
 
WWW WWW  
IP Logged
 
Miguel
Junior Member
**
Offline


Hi Hyphy!

Posts: 53
CBMSO, CSIC (Spain)
Gender: male
Re: rerooting trees in batch files
Reply #10 - Oct 4th, 2008 at 4:20pm
 
I get it!!.  Smiley


Regards,

Miguel
Back to top
 
WWW WWW  
IP Logged