{ "cells": [ { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/dhimmels/Documents/serg/rephetio/construct/gwas-catalog/ensembl/src\n", "* Processing 'api'\n", "\n", "* Working with module 'ensembl'\n", "* Cloning from remote 'https://github.com/Ensembl/ensembl.git'\n", "* Enabling git hooks\n", "\n", "* Working with module 'ensembl-compara'\n", "* Cloning from remote 'https://github.com/Ensembl/ensembl-compara.git'\n", "* Enabling git hooks\n", "\n", "* Working with module 'ensembl-funcgen'\n", "* Cloning from remote 'https://github.com/Ensembl/ensembl-funcgen.git'\n", "* Enabling git hooks\n", "\n", "* Working with module 'ensembl-io'\n", "* Cloning from remote 'https://github.com/Ensembl/ensembl-io.git'\n", "* Enabling git hooks\n", "\n", "* Working with module 'ensembl-variation'\n", "* Cloning from remote 'https://github.com/Ensembl/ensembl-variation.git'\n", "* Enabling git hooks\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Cloning into 'bioperl-live'...\n", "Note: checking out 'bioperl-release-1-6-1'.\n", "\n", "You are in 'detached HEAD' state. You can look around, make experimental\n", "changes and commit them, and you can discard any commits you make in this\n", "state without impacting any branches by performing another checkout.\n", "\n", "If you want to create a new branch to retain commits you create, you may\n", "do so (now or later) by using -b with the checkout command again. Example:\n", "\n", " git checkout -b new_branch_name\n", "\n", "HEAD is now at 83dcde3... * bump point version * sync minor doc changes\n", "Cloning into 'ensembl-git-tools'...\n", "Cloning into 'ensembl'...\n", "Cloning into 'ensembl-compara'...\n", "Cloning into 'ensembl-funcgen'...\n", "Cloning into 'ensembl-io'...\n", "Cloning into 'ensembl-variation'...\n" ] } ], "source": [ "%%bash\n", "\n", "#Create an installation directory\n", "mkdir src\n", "cd src\n", "\n", "#Take a clone of BioPerl from GitHub and change to the correct version:\n", "git clone https://github.com/bioperl/bioperl-live.git\n", "cd bioperl-live\n", "git checkout bioperl-release-1-6-1\n", "cd -\n", "\n", "#Install the Ensembl git tools to allow easy management of the Ensembl repos.\n", "git clone https://github.com/Ensembl/ensembl-git-tools.git\n", "export PATH=$PWD/ensembl-git-tools/bin:$PATH\n", "\n", "#Install the APIs that you need. You can install all the APIs using the git ensembl command:\n", "git ensembl --clone api" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [], "source": [ "snps = ['rs1333049', 'rs2248462', 'rs225190', 'rs225212', 'rs2252865', 'rs2252996']\n", "with open('SNP_list_sorted.txt', 'w') as write_file:\n", " write_file.write('\\n'.join(sorted(snps)))" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "rs1333049\n", "unfetched rs1333049\n", "rs2248462\n", "unfetched rs2248462\n", "rs225190\n", "unfetched rs225190\n", "rs225212\n", "unfetched rs225212\n", "rs2252865\n", "unfetched rs2252865\n", "rs2252996" ] }, { "name": "stderr", "output_type": "stream", "text": [ "UNIVERSAL->import is deprecated and will be removed in a future perl at src/bioperl-live/Bio/Tree/TreeFunctionsI.pm line 94.\n", "\n", "-------------------- WARNING ----------------------\n", "MSG: Binary file calc_genotypes not found. Please, read the ensembl-variation/C_code/README.txt file if you want to use LD calculation\n", "\n", "FILE: Variation/DBSQL/LDFeatureContainerAdaptor.pm LINE: 674\n", "CALLED BY: Variation/DBSQL/LDFeatureContainerAdaptor.pm LINE: 607\n", "Date (localtime) = Mon Jun 22 18:03:46 2015\n", "Ensembl API version = 80\n", "---------------------------------------------------\n" ] } ], "source": [ "%%perl\n", "\n", "use lib \"src/bioperl-live\";\n", "use lib \"src/ensembl/modules\";\n", "use lib \"src/ensembl-compara/modules\";\n", "use lib \"src/ensembl-variation/modules\";\n", "use lib \"src/ensembl-funcgen/modules\";\n", "\n", "use strict;\n", "use warnings;\n", "use Bio::EnsEMBL::Registry;\n", "\n", "open (IN, \"SNPs_in_LD.tsv\");\n", "\n", "my $reg = 'Bio::EnsEMBL::Registry';\n", "$reg->load_registry_from_db(-host => 'ensembldb.ensembl.org',-user => 'anonymous');\n", "my $va = $reg->get_adaptor( 'human', 'variation', 'variation' );\n", "\n", "while () {\n", " print $_;\n", " my $v = $va->fetch_by_name($_);\n", " if (!$v) {\n", " print 'unfetched ' . $_;\n", " next;\n", " }\n", " my @vfs = @{ $v->get_all_VariationFeatures };\n", " \n", " foreach my $vf (@vfs){ \n", " my $ld = $vf->get_all_LD_values;\n", " my @pops = @{ $vf->get_all_LD_Populations };\n", " my @ldvs = @{ $ld->get_variations };\n", " \n", " foreach my $pop (@pops) {\n", " \n", " if ($pop->name =~ /1000GENOMES/) {\n", " \n", " foreach my $ldv (@ldvs) { \n", " if ($ldv->stable_id ne $_) {\n", " my @ldvfs = @{ $ldv->get_all_VariationFeatures };\n", " \n", " foreach my $ldvf (@ldvfs) {\n", " my @tvs = @{ $ldvf->get_all_TranscriptVariations };\n", " my $r2 = $ld->get_r_square($vf, $ldvf, $pop); \n", " \n", " foreach my $tv (@tvs) {\n", " my $gene = $tv->transcript->get_Gene;\n", " \n", " if ($r2) { \n", " print OUT $v->stable_id, \"\\t\", $ldv->stable_id, \"\\t\", $gene->external_name, \"\\t\", $r2, \"\\t\", $pop->name, \"\\n\";\n", " }\n", " }\n", " }\n", " }\n", " }\n", " }\n", " }\n", " }\n", " }" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.3" } }, "nbformat": 4, "nbformat_minor": 0 }