<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
Dear Julien
<div><br>
</div>
<div>To optimise the display of scores, these are stored at different levels of detail, say for each 1-bp, 10-bp, 50-bp, 100-bp and 500-bp window. (Note: These are not necessarily the actual window sizes). With the display_size option, you are telling the API
 how many scores you need to get back. For instance, if the image is 1200 pixels in width, it doesn’t make sense to return 1,000,000 scores for a 1Mb slice. The API takes care of choosing which window size is more appropriate taking into account the slice and
 display sizes. In your case, I would recommend to get a display_size equal to the slice size to get precise scores and average them as you seem fit.</div>
<div><br>
</div>
<div>I think you could do faster with your algorithm if you would chunk the genome in 1 or 5 Mb slices, get the scores and the exons for that slice and treat the results as you seem fit. Note that the full list of exons will include coding and non-coding exons
 from all sorts of genes (including pseudogenes, ncRNA, etc). I suspect you may want to restrict your analysis a to a given type of exons. To do that, use the sliding slice approach, get the genes you are interested in (make sure the biotype is what you expect),
 get the corresponding transcripts (again, you may want to consider filtering untranslated transcripts) and get the exons for those transcripts. I should note that the exons can overlap entirely (in that case they will have the same stable_id) or partially
 (they would have different stable_id).</div>
<div><br>
</div>
<div>I hope this helps</div>
<div><br>
</div>
<div>Javier</div>
<div><br>
</div>
<div>
<div>
<div>On 16 Jan 2014, at 08:03, Julien Roux <<a href="mailto:julien.roux@unil.ch">julien.roux@unil.ch</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">Dear list,<br>
I have been trying to extract the mean GERP conservation score for all human exons using the Ensembl API.<br>
My script is working properly, however it is quite slow (only ~1000 exons per hour) and I am wondering if there would be a way to speed it up.<br>
I have tried to set "display_size" to 1, but t doesn't seem to give yield the exact mean score (because it is an average of precalculated averages I guess).<br>
I am putting the script below.<br>
Thanks for your help<br>
Julien<br>
<br>
#!/usr/bin/env perl<br>
use strict;<br>
use warnings;<br>
use Bio::EnsEMBL::Registry;<br>
use Bio::EnsEMBL::Utils::Exception qw(throw);<br>
<br>
# This script is inspired by the example script at <a href="http://cvs.sanger.ac.uk/cgi-bin/viewvc.cgi/ensembl-compara/scripts/examples/dna_getConservationScores.pl?root=ensembl&view=markup">
http://cvs.sanger.ac.uk/cgi-bin/viewvc.cgi/ensembl-compara/scripts/examples/dna_getConservationScores.pl?root=ensembl&view=markup</a><br>
<br>
my $reg = "Bio::EnsEMBL::Registry";<br>
my $species = "Homo sapiens";<br>
$reg->load_registry_from_db(<br>
     -host => "<a href="http://ensembldb.ensembl.org">ensembldb.ensembl.org</a>",<br>
     -user => "anonymous",<br>
);<br>
<br>
#get slice adaptor for $species<br>
my $slice_adaptor = $reg->get_adaptor($species, 'core', 'Slice');<br>
<br>
#get exon adaptor for $species<br>
my $exon_adaptor = $reg->get_adaptor($species, 'Core', 'Exon');<br>
<br>
#get method_link_species_set adaptor<br>
my $mlss_adaptor = $reg->get_adaptor("Multi", "compara", "MethodLinkSpeciesSet");<br>
<br>
#get method_link_species_set object for gerp conservation scores for mammals<br>
my $mlss = $mlss_adaptor->fetch_by_method_link_type_species_set_name("GERP_CONSERVATION_SCORE", "mammals");<br>
<br>
#get conservation score adaptor<br>
my $cs_adaptor = $reg->get_adaptor("Multi", 'compara', 'ConservationScore');<br>
<br>
# fetch all exon IDs<br>
my @exon_ids = @{$exon_adaptor->list_stable_ids()};<br>
<br>
foreach my $exon (@exon_ids){<br>
 print $exon, "\n";<br>
 my $slice = $slice_adaptor->fetch_by_exon_stable_id($exon);<br>
<br>
 #get one score per base in the slice<br>
 my $display_size = $slice->end - $slice->start + 1;<br>
 my $scores = $cs_adaptor->fetch_all_by_MethodLinkSpeciesSet_Slice($mlss, $slice, $display_size);<br>
<br>
 # average the scores in the slice<br>
 my $sum = 0;<br>
 my $count = 0;<br>
 my $diff_score;<br>
 foreach my $score (@$scores) {<br>
   if (defined $score->diff_score) {<br>
     $sum += $score->diff_score;<br>
     $count++;<br>
   }<br>
 }<br>
 if ($count > 0){<br>
   $diff_score = $sum / $count;<br>
 }<br>
 if (defined $diff_score){<br>
   print "$exon\t$diff_score\n";<br>
 }<br>
 else {<br>
   print "$exon\tNA\n";<br>
 }<br>
}<br>
close OUT;<br>
exit;<br>
<br>
-- <br>
Julien Roux, PhD<br>
Gilad lab, Department of Human Genetics, University of Chicago<br>
<a href="http://giladlab.uchicago.edu/">http://giladlab.uchicago.edu/</a><br>
920 East 58th Street, CLSC 317, Chicago, IL 60637, USA<br>
tel: +1-773-834-1984   fax: +1-773-834-8470<br>
<br>
<br>
-- <br>
Julien Roux, PhD<br>
Gilad lab, Department of Human Genetics, University of Chicago<br>
http://giladlab.uchicago.edu/<br>
920 East 58th Street, CLSC 317, Chicago, IL 60637, USA<br>
tel: +1-773-834-1984   fax: +1-773-834-8470<br>
<br>
_______________________________________________<br>
Dev mailing list    Dev@ensembl.org<br>
Posting guidelines and subscribe/unsubscribe info: http://lists.ensembl.org/mailman/listinfo/dev<br>
Ensembl Blog: http://www.ensembl.info/<br>
</blockquote>
</div>
<br>
<div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica;  font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>--</div>
<div>Javier Herrero, PhD</div>
<div>Comparative Genomics Project Leader</div>
<div>TGAC, Norwich Research Park</div>
<div>Norwich, NR4 7UH, UK</div>
</div>
</div>
<br>
</div>
</body>
</html>