Skip to content

Instantly share code, notes, and snippets.

@pkerpedjiev
Created February 22, 2020 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkerpedjiev/268d7dabf5743b6226f413982e1b4e47 to your computer and use it in GitHub Desktop.
Save pkerpedjiev/268d7dabf5743b6226f413982e1b4e47 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"tads = \"\"\"chr1 1760000 2640000\n",
"chr1 2640000 2760000\n",
"chr1 2760000 5960000\n",
"chr1 5960000 6440000\n",
"chr1 6440000 7960000\n",
"chr1 7960000 8360000\n",
"chr1 8360000 8880000\n",
"chr1 8880000 9600000\n",
"chr1 9600000 10160000\n",
"chr1 10160000 10440000\"\"\"\n",
"\n",
"with open('/tmp/tads.bed', 'w') as f:\n",
" f.write(tads)\n",
" \n",
"import subprocess as sp\n",
"ret = sp.call(['clodius', 'aggregate', 'bedpe', '--chr1-col', '1', '--chr2-col', '1', \n",
" '--from1-col', '2', '--from2-col', '2',\n",
" '--to1-col', '3', '--to2-col', '3', '/tmp/tads.bed'])"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [],
"source": [
"from clodius.tiles.utils import tiles_wrapper_2d\n",
"\n",
"def bed2ddb(filepath, uuid=None, **kwargs):\n",
" from clodius.tiles.bed2ddb import get_2d_tileset_info, get_2D_tiles\n",
"\n",
" return Tileset(\n",
" uuid=uuid,\n",
" tileset_info=lambda: get_2d_tileset_info(filepath),\n",
" tiles=lambda tids: tiles_wrapper_2d(\n",
" tids, lambda z, x, y: get_2D_tiles(filepath, z, x, y)[(x, y)]\n",
" ),\n",
" **kwargs\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [],
"source": [
"import higlass.tilesets as ti\n",
"\n",
"ts = bed2ddb('/tmp/tads.bed.multires.db')"
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b09a92782ba74302a274ff03a5625c1c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HiGlassDisplay(viewconf={'editable': True, 'views': [{'uid': 'IA9Xr33SQJCNpt_LbTu95w', 'tracks': {'top': [{'ty…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from higlass.client import Track, View\n",
"import higlass\n",
"\n",
"(d,s,v) = higlass.display([\n",
" View([\n",
" Track('top-axis'),\n",
" Track('2d-rectangle-domains', position='center', tileset=ts, height=400)\n",
" ], initialXDomain=[0, 20e6])\n",
"])\n",
"d"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"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.6.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment