{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# JointView\n",
"JointView can be used to visualize trans or cis-remote region by composing frames around a hicmat."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import coolbox\n",
"from coolbox.api import *"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'0.3.8'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"coolbox.__version__"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Visualize the cis-remote region:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"tags": [
"nbsphinx-thumbnail"
]
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
],
"text/plain": [
""
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"DATA_DIR = f\"../../../tests/test_data\"\n",
"test_interval = \"chr9:4000000-6000000\"\n",
"empty_interval = \"chr10:4000000-6000000\"\n",
"test_itv = test_interval.replace(':', '_').replace('-', '_')\n",
"\n",
"\n",
"frame1 = XAxis() + GTF(f\"{DATA_DIR}/gtf_{test_itv}.gtf\") + Title(\"GTF\")\n",
"frame1 += BigWig(f\"{DATA_DIR}/bigwig_{test_itv}.bw\") + TrackHeight(2) + MinValue(0)\n",
"frame2 = XAxis()\n",
"frame2 += GTF(f\"{DATA_DIR}/gtf_{test_itv}.gtf\") + TrackHeight(5)\n",
"\n",
"cool1 = Cool(f\"{DATA_DIR}/cool_{test_itv}.mcool\", color_bar=False, style='matrix')\n",
"\n",
"sub_frames = {\n",
" \"top\": frame1,\n",
" \"right\": frame1,\n",
" \"bottom\": frame2,\n",
" \"left\": frame2\n",
"}\n",
"\n",
"jv = JointView(cool1, **sub_frames, space=0, padding_left=0)\n",
"fig = jv.plot(\"chr9:4500000-5000000\", \"chr9:5200000-5850000\")\n",
"fig"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Or you can just use it to compose track in joint style,\n",
"pass one genome region to the `plot` method:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
],
"text/plain": [
""
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cool1 = Cool(f\"{DATA_DIR}/cool_{test_itv}.mcool\", color_bar=False) + \\\n",
" HiCPeaksCoverage(f\"{DATA_DIR}/peak_{test_itv}.bedpe\")\n",
"\n",
"sub_frames = {\n",
" \"top\": frame1,\n",
" \"right\": frame1,\n",
" \"bottom\": frame2,\n",
" \"left\": frame2\n",
"}\n",
"\n",
"jv = JointView(cool1, **sub_frames, space=0, padding_left=0)\n",
"fig = jv.plot(\"chr9:4000000-6000000\")\n",
"fig"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### CLI code"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"%%bash\n",
"\n",
"DATA_DIR=\"../../../tests/test_data\"\n",
"test_itv=\"chr9_4000000_6000000\"\n",
"coolbox \\\n",
" joint_view top - \\\n",
" add XAxis - \\\n",
" add GTF ${DATA_DIR}/gtf_${test_itv}.gtf - \\\n",
" add Title GTF - \\\n",
" joint_view right - \\\n",
" add XAxis - \\\n",
" add BigWig ${DATA_DIR}/bigwig_${test_itv}.bw - \\\n",
" add TrackHeight 2 - \\\n",
" add MinValue 0 - \\\n",
" joint_view center - \\\n",
" add Cool ${DATA_DIR}/cool_${test_itv}.mcool - \\\n",
" goto 'chr9:4500000-5000000' 'chr9:5200000-5850000' - \\\n",
" plot /tmp/test_coolbox_joint_view.svg"
]
}
],
"metadata": {
"@webio": {
"lastCommId": null,
"lastKernelId": null
},
"celltoolbar": "编辑元数据",
"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.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 1
}