<div dir="ltr">Dear Miguel,<div><br></div><div>That is fantastic, thank you so much for your help!</div><div><br></div><div style>I'm perhaps an exception to the rule. I had run a CAFE analysis on these data myself, before this was included in the Compara pipeline/API, and so wanted to check and see if my results tallied with the results that you get.</div>
<div style><br></div><div style>I have written a parser for the CAFE data already and so this code will help me to output your data in a format that can run through my parser and allow me to make the direct comparisons, that I discuss above.</div>
<div style><br></div><div style>Many thanks for that code, it works beautifully and with a little modification to the per-internal-node section, it is just what I need!</div><div style><br></div><div style>Yes, I had seen the $<span style="font-family:arial,sans-serif;font-size:13px">cafe_tree-></span>get_expansions and $<span style="font-family:arial,sans-serif;font-size:13px">cafe_tree-></span>get_contractions methods, which look very useful.</div>
<div style><br></div><div style>Once again, many thanks for your assistance!</div><div style><br></div><div style>Kindest regards,</div><div style><br></div><div style>Steve Moss</div><div style><a href="http://about.me/gawbul">http://about.me/gawbul</a></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On 6 June 2013 16:38, Miguel Pignatelli <span dir="ltr"><<a href="mailto:mp@ebi.ac.uk" target="_blank">mp@ebi.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Steve,<br>
<br>
It is a bit frustrating writing a parser for the CAFE output format just to realize that the users want the raw textual output :-S<br>
<br>
Btw, it is not easy for me to understand why you want the raw un-parsed CAFE output. I would say that you would need to parse it anyway to make sense of all those per-node-pair-information, etc...<br>
<br>
Anyway, you can get something similar using the following code:<br>
<br>
my $gene_stable_id = 'ENSFM00250000006933';<br>
my $member = $gene_member_adaptor->fetch_<u></u>by_source_stable_id(undef, $gene_stable_id);<br>
my $gene_tree = $gene_tree_adaptor->fetch_<u></u>default_for_Member($member);<br>
my $cafe_tree = $cafe_tree_adaptor->fetch_by_<u></u>GeneTree($gene_tree);<br>
<br>
print $member->stable_id, "\t";<br>
print $gene_tree->stable_id, "\t";<br>
<br>
my $tree_fmt = '%{-s}%{x-}_%{N}:%{d}';<br>
print $cafe_tree->newick_format('<u></u>ryo', $tree_fmt), "\t";<br>
print $cafe_tree->pvalue_avg, "\n";<br>
<br>
For the per-internal-node information you can use something like:<br>
<br>
for my $node (@{$cafe_tree->get_all_nodes}) {<br>
  my $node_name = $node->is_leaf ? $node->genome_db->short_name : $node->taxon_id;<br>
  my $node_n_members = $node->n_members;<br>
  my $node_pvalue = $node->pvalue || "birth";<br>
  my $dynamics = "[no change]";<br>
  if ($node->is_contraction) {<br>
    $dynamics = "[contraction]";<br>
  } elsif ($node->is_expansion) {<br>
    $dynamics = "[expansion]";<br>
  }<br>
  print "$node_name => $node_n_members ($node_pvalue) $dynamics\n";<br>
}<br>
<br>
If you prefer to get the nodes that are significantly expanded or contracted instead of having to traverse the whole tree, you can use the specialized methods on the API instead.<br>
<br>
Please, let me know if this solves your issue,<br>
<br>
Cheers,<br>
<br>
M;<div class="im"><br>
On 06/06/13 13:55, Steve Moss wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Dear EnsEMBL developers,<br>
<br>
I'm trying to work out how best to retrieve a tree (Newick format?)<br>
showing the significant expansions and contractions, as you can see<br>
here, for example<br>
<a href="http://www.ensembl.org/Homo_sapiens/Gene/SpeciesTree?db=core;g=ENSG00000159917;r=19:44782947-44813601;t=ENST00000291182" target="_blank">http://www.ensembl.org/Homo_<u></u>sapiens/Gene/SpeciesTree?db=<u></u>core;g=ENSG00000159917;r=19:<u></u>44782947-44813601;t=<u></u>ENST00000291182</a>.<br>

<br>
I'm playing around with the API at the moment and pulling some data out,<br>
but it isn't that intuitive. The current CAFEGeneFamily and<br>
CAFEGeneFamilyAdaptor code doesn't seem to have any examples on this and<br>
I can't find anything in the EnsEMBL tutorial information.<br>
<br>
I've been through all my candidate genes, pulled the CAFE gene tree root<br>
IDs for those data, that have a significant CAFE gene gain/loss tree,<br>
but am struggling with where to go from there to build the final<br>
"product" i.e. a text representation of the above graphic?<br>
<br>
Ideally, I would like to be able to output this in a CAFE style output<br>
format (EnsEMBL Family ID, Gene Tree (with species name and gene count),<br>
Family P Value, Nodes P Values), e.g.:<br>
<br></div>
ENSFM00250000006933(((((((((<u></u>Homosapiens_7:6.4,<u></u>Pantroglodytes_1:6.4)_1:2.4,<u></u>Gorillagorilla_1:8.8)_1:6.9,<u></u>Pongoabelii_1:15.7)_1:4.7,<u></u>Nomascusleucogenys_1:20.4)_1:<u></u>8.8,Macacamulatta_1:29.2)_1:<u></u>13.4,Callithrixjacchus_1:42.6)<u></u>_1:22.6,Tarsiussyrichta_0:65.<u></u>2)_1:8.8,(Microcebusmurinus_1:<u></u>57.9,Otolemurgarnettii_1:57.9)<u></u>_1:16.1)_1:16,Tupaiabelangeri_<u></u>1:90)_10.004000((0.000000,0.<u></u>538467),(0.513088,0.543748),(<u></u>0.534524,0.597471),(0.524517,<u></u>0.585395),(0.544478,0.583311),<u></u>(0.568740,0.701965),(0.613489,<u></u>0.272744),(0.541873,0.581644),<u></u>(0.675047,0.563343),(0.591851,<u></u>0.503703))<div class="im">
<br>
Has anyone done this already?<br>
<br>
Kindest regards,<br>
<br>
Steve Moss<br>
<a href="http://about.me/gawbul" target="_blank">http://about.me/gawbul</a><br>

<br></div><div class="im">
______________________________<u></u>_________________<br>
Dev mailing list    <a href="mailto:Dev@ensembl.org" target="_blank">Dev@ensembl.org</a><br>
Posting guidelines and subscribe/unsubscribe info: <a href="http://lists.ensembl.org/mailman/listinfo/dev" target="_blank">http://lists.ensembl.org/<u></u>mailman/listinfo/dev</a><br>
Ensembl Blog: <a href="http://www.ensembl.info/" target="_blank">http://www.ensembl.info/</a><br>
<br>
</div></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
<br>
Miguel Pignatelli, PhD<br>
<br>
Ensembl Developer - Comparative Genomics<br>
European Bioinformatics Institute (EMBL-EBI)<br>
Wellcome Trust Genome Campus, Hinxton<br>
Cambridge - CB10 1SD - UK<br>
Room A3-33<br>
Phone + 44 (0) 1223 494 598<br>
Fax   + 44 (0) 1223 494 468</font></span></blockquote></div>
</div></div>