Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added iPython Notebook to Count SNPs/Gene #1

Merged
merged 3 commits into from
Aug 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions SNP-to-Gene.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"metadata": {
"name": "",
"signature": "sha256:8b80827953d8aced53bbdd46a64733cad875a09e2849075aa6ee01ede4f78485"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"#download illumina chip files\n",
"url = 'http://www.ebi.ac.uk/arrayexpress/files/A-GEOD-8882/A-GEOD-8882.adf.txt'\n",
"! wget --no-verbose --timestamping --directory-prefix download {url}\n",
"url = 'http://www.ebi.ac.uk/arrayexpress/files/A-GEOD-6434/A-GEOD-6434.adf.txt'\n",
"! wget --no-verbose --timestamping --directory-prefix download {url}"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"2015-08-17 08:17:56 URL:http://www.ebi.ac.uk/arrayexpress/files/A-GEOD-8882/A-GEOD-8882.adf.txt [24316605/24316605] -> \"download/A-GEOD-8882.adf.txt\" [1]\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"2015-08-17 08:18:15 URL:http://www.ebi.ac.uk/arrayexpress/files/A-GEOD-6434/A-GEOD-6434.adf.txt [24862681/24862681] -> \"download/A-GEOD-6434.adf.txt\" [1]\r\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"humanhap550 = set([])\n",
"hh550_fh = open(\"download/A-GEOD-6434.adf.txt\")\n",
"for line in hh550_fh:\n",
" if line.startswith('rs'):\n",
" toks = line.strip().split('\\t')\n",
" humanhap550.add(toks[1])\n",
"\n",
"print(str(len(humanhap550)) + \" SNPs with rs#s on HH550\")\n",
"o_fh = open(\"data/hh550-snp-for-bed.txt\", 'w')\n",
"o_fh.write('\\n'.join(humanhap550))\n",
"o_fh.close()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"561303 SNPs with rs#s on HH550\n"
]
}
],
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"humanomni1 = set([])\n",
"omni1_fh = open(\"download/A-GEOD-8882.adf.txt\")\n",
"for line in omni1_fh:\n",
" if line.startswith('rs'):\n",
" toks = line.strip().split('\\t')\n",
" humanomni1.add(toks[1])\n",
"\n",
"print(str(len(humanomni1)) + \" SNPs with rs#s on HOmni1\")\n",
"o_fh = open(\"data/ho1-snp-for-bed.txt\", 'w')\n",
"o_fh.write('\\n'.join(humanomni1))\n",
"o_fh.close()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"970342 SNPs with rs#s on HOmni1\n"
]
}
],
"prompt_number": 12
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Follow instructions at http://www.gettinggeneticsdone.com/2011/06/mapping-snps-to-genes-for-gwas.html to get a BED file. Use GRCh37/hg19 and dbSNP Common SNPs(142). Name the downloaded files bed-hh550.bed and bed-ho1.bed. Move both of these files to \"data/\""
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#Download Entrez mappings.\n",
"url = 'http://files.figshare.com/230645/entrez.txt'\n",
"! wget --no-verbose --timestamping --directory-prefix download {url}\n",
"\n",
"# add chr to the front to match the UCSC files\n",
"! sed 's/^/chr/' download/entrez.txt > download/chr_entrez.txt"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 15
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Count the overlaps\n",
"! windowBed -w 10000 -c -a download/chr_entrez.txt -b data/bed-hh550.bed > data/hh550-entrez.bed\n",
"! windowBed -w 10000 -c -a download/chr_entrez.txt -b data/bed-ho1.bed > data/ho1-entrez.bed\n"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 16
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Loading