Dear Community,
I hope you have been well these complicated days and weeks.
I am writing this post because I have a question about obtaining allele frequencies for a number of variants with the Ensembl API. I would like to obtain what is seen in the Ensembl browser, for example:
Where we can see that variant rs1805007 has a lot of information about alleles C and T at the population level.
However, when I try to get this information with the Ensembl API, I am unable to go from the Variation object to the Allele object (array of Allele objects is empty). This is my code:
#!/usr/bin/perl
use strict;
use warnings;
use Bio::EnsEMBL::Registry;
#connect to Ensembl
my $registry = "Bio::EnsEMBL::Registry";
$registry -> load_registry_from_db(
-user => 'anonymous',
-host => 'useastdb.ensembl.org',
-species => 'homo_sapiens' );
#get adaptors
my $variation_adaptor = $registry -> get_adaptor( 'human', 'variation', 'variation' );
my $variation = $variation_adaptor -> fetch_by_name( "rs1805007" );
#print variant info
my @alleles = @{ $variation -> get_all_Alleles };
print( scalar( @alleles ) . "\n" );
foreach my $allele ( @alleles ){
next unless ( defined $allele -> population );
print( "\t\t" . $allele -> population -> name . "\t" .
$allele -> allele . "\t" . $allele -> frequency . "\n" );
}
This program prints only "0" as it is the size of the Allele array. Can anyone please advise how to access the information that can be seen in the browser? Or point to where I am doing something wrong with this code?
Thank you very much :)
Best wishes, Daniela
which version of the API do you have?
Oh, gosh, sorry I did forget to add that crucial bit of information! I am using the Ensembl API v103. Thanks so much Emily!