{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Structural variation in the IGH region\n", "\n", "Here we visualize PacBio HiFi long-read sequencing data in the [immunoglobulin heavy chain (IGH)](https://www.ncbi.nlm.nih.gov/gene?Db=gene&Cmd=DetailsSearch&Term=3492) region, with [GENCODE](https://www.gencodegenes.org/) gene annotations. The sequencing data was generated from the HG002 individual from the [Genome in a Bottle](https://www.nist.gov/programs-projects/genome-bottle) cohort. \n", "\n", "Data sources:\n", "- PacBio HiFi sequencing: [URL](ftp://ftp-trace.ncbi.nlm.nih.gov/ReferenceSamples/giab/data/AshkenazimTrio/HG002_NA24385_son/PacBio_CCS_15kb_20kb_chemistry2/GRCh38/HG002.SequelII.merged_15kb_20kb.pbmm2.GRCh38.haplotag.10x.bam)\n", "- Gene annotation: [URL](https://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_41/gencode.v41.annotation.gtf.gz)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import gzip\n", "import lakeview as lv" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'gzip' is not defined", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[1], line 9\u001b[0m\n\u001b[1;32m 6\u001b[0m GENCODE_GTF_PATH \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m../../tests/data/gencode.v40.annotation.gtf.gz\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 7\u001b[0m PACBIO_BAM_PATH \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m../../tests/data/HG002_IGH_PacBio_CCS.bam\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m----> 9\u001b[0m \u001b[39mwith\u001b[39;00m gzip\u001b[39m.\u001b[39mopen(GENCODE_GTF_PATH, \u001b[39m\"\u001b[39m\u001b[39mrt\u001b[39m\u001b[39m\"\u001b[39m) \u001b[39mas\u001b[39;00m f:\n\u001b[1;32m 10\u001b[0m gencode_painter \u001b[39m=\u001b[39m lv\u001b[39m.\u001b[39mGeneAnnotation\u001b[39m.\u001b[39mfrom_gencode(\n\u001b[1;32m 11\u001b[0m f, \u001b[39m\"\u001b[39m\u001b[39mgtf\u001b[39m\u001b[39m\"\u001b[39m, region\u001b[39m=\u001b[39m(CHROMOSOME, (START, END))\n\u001b[1;32m 12\u001b[0m )\n\u001b[1;32m 13\u001b[0m pacbio_painter \u001b[39m=\u001b[39m lv\u001b[39m.\u001b[39mSequenceAlignment\u001b[39m.\u001b[39mfrom_file(\n\u001b[1;32m 14\u001b[0m PACBIO_BAM_PATH, region\u001b[39m=\u001b[39m(CHROMOSOME, (START, END))\n\u001b[1;32m 15\u001b[0m )\n", "\u001b[0;31mNameError\u001b[0m: name 'gzip' is not defined" ] } ], "source": [ "CHROMOSOME = \"chr14\"\n", "VIEW_START = 105679000\n", "VIEW_END = 105776000\n", "START = VIEW_START - int(50e3)\n", "END = VIEW_END + int(50e3)\n", "GENCODE_GFF_PATH = \"../../tests/data/gencode.v43.annotation.gff3.gz\"\n", "PACBIO_BAM_PATH = \"../../tests/data/HG002_IGH_PacBio_CCS.bam\"\n", "\n", "with gzip.open(GENCODE_GFF_PATH, \"rt\") as f:\n", " gencode_painter = lv.GeneAnnotation.from_gencode(\n", " f, region=(CHROMOSOME, (START, END))\n", " )\n", "pacbio_painter = lv.SequenceAlignment.from_file(\n", " PACBIO_BAM_PATH, region=(CHROMOSOME, (START, END))\n", ")\n", "gv = lv.GenomeViewer(3, height_ratios=(1, 8, 2))\n", "pacbio_painter.draw_pileup(\n", " gv.axes[0],\n", " show_mismatches=False,\n", ")\n", "pacbio_painter.draw_alignment(\n", " gv.axes[1],\n", " show_mismatches=False,\n", " sort_by=\"length\",\n", " link_by=\"name\",\n", " max_rows=50,\n", ")\n", "gencode_painter.draw_transcripts(gv.axes[2], max_rows=5, sort_by=\"length\")\n", "\n", "gv.set_xlim((VIEW_START, VIEW_END))\n", "gv.set_xlabel(CHROMOSOME)\n", "gv.set_title(\"PacBio HiFi long-read sequencing\")\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "GenomeViewer(figure=
)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gv" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.16" }, "vscode": { "interpreter": { "hash": "9ac03a0a6051494cc606d484d27d20fce22fb7b4d169f583271e11d5ba46a56e" } } }, "nbformat": 4, "nbformat_minor": 4 }