<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Jupyter Blog - Jean-David Harrouet</title><link href="https://jasongrout.github.io/medium-archive/pelican/" rel="alternate"/><link href="https://jasongrout.github.io/medium-archive/pelican/feeds/author-jean-david-harrouet.atom.xml" rel="self"/><id>https://jasongrout.github.io/medium-archive/pelican/</id><updated>2021-02-11T11:36:00+00:00</updated><subtitle>The Project Jupyter blog: news, releases, and community stories, archived from blog.jupyter.org.</subtitle><entry><title>Genomic data visualization in Jupyter</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2021/genomic-data-representation-in-jupyter/" rel="alternate"/><published>2021-02-08T13:29:00+00:00</published><updated>2021-02-11T11:36:00+00:00</updated><author><name>Jean-David Harrouet</name></author><id>tag:jasongrout.github.io,2021-02-08:/medium-archive/pelican/posts/2021/genomic-data-representation-in-jupyter/</id><summary type="html">&lt;p&gt;If there is one thing that recent events tell us, it is that genomic is a large source of data, and that its manipulation and…&lt;/p&gt;
</summary><content type="html">&lt;p&gt;If there is one thing that recent events tell us, it is that genomics is a large source of data, and that its manipulation and understanding allow for the quick development of new drugs and… vaccines.&lt;/p&gt;
&lt;p&gt;We decided to build upon the Jupyter ecosystem and enrich its capabilities in this space, with a genomics data visualization widget.&lt;/p&gt;
&lt;p&gt;In doing so, we chose to leverage the &lt;a href="https://github.com/igvteam/igv.js/"&gt;&lt;code&gt;igv.js&lt;/code&gt;&lt;/a&gt; JavaScript library, developped by the &lt;a href="https://igv.org/"&gt;Integrative Genomics Viewer (IGV)&lt;/a&gt; team, and used by &lt;a href="https://igv.org/app/"&gt;the web app of the same name&lt;/a&gt;. This is all done thanks for the power of &lt;code&gt;ipywidgets&lt;/code&gt; , which helps linking the JS genomic representation object to our Jupyter notebook.&lt;/p&gt;
&lt;p&gt;Hence, we are proud to announce the release of &lt;a href="https://github.com/QuantStack/ipyigv"&gt;&lt;code&gt;ipyigv&lt;/code&gt;&lt;/a&gt;, a Jupyter widget to render genomics data, based on &lt;code&gt;igv.js&lt;/code&gt;!&lt;/p&gt;
&lt;h2 id="installing-ipyigv"&gt;Installing ipyigv&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;ipyigv&lt;/code&gt; is available on PyPI and conda-forge. It can be installed with both pip and &lt;a href="https://github.com/mamba-org/mamba"&gt;mamba&lt;/a&gt; / &lt;a href="https://github.com/conda/conda"&gt;conda&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mamba install -c conda-forge ipyigv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can find additional installation instruction on the &lt;a href="https://github.com/QuantStack/ipyigv"&gt;project’s page on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="rendering-genomic-data"&gt;Rendering genomic data&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;igv.js&lt;/code&gt; consumes genomic data in two chunks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the genome itself as documented &lt;a href="https://github.com/igvteam/igv.js/wiki/Reference-Genome"&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;specificities of the genome underlined as &lt;code&gt;Tracks&lt;/code&gt;, which are displayed alongside or on top of the genome&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;ipyigv&lt;/code&gt; uses the same logic, with a helper function to use the public genomes available. Data is then displayed in an &lt;code&gt;IgvBrowser&lt;/code&gt; widget, a wrapper for the &lt;code&gt;igv.js&lt;/code&gt; browser.&lt;/p&gt;
&lt;p&gt;To make things easier, there are a few public genomes made directly available via a helper &lt;code&gt;Bunch&lt;/code&gt; , &lt;code&gt;PUBLIC_GENOMES&lt;/code&gt; .&lt;/p&gt;
&lt;p&gt;Here is what it looks like:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Creating a genome browser with data from a public genome" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/genomic-data-representation-in-jupyter/images/001-1_fxJcZt6CBqZodRKm-k9vBA.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Creating a genome browser with data from a public genome&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Now that we have created a genome browser, we may add tracks to it. Tracks may be of different sorts, about ten according to &lt;a href="https://github.com/igvteam/igv.js/wiki/Tracks-2.0"&gt;the &lt;code&gt;igv.js&lt;/code&gt; documentation&lt;/a&gt;. Describing all the kinds of tracks is out of the scope of this article, but it should be noted that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a common &lt;code&gt;Track&lt;/code&gt; class is defined with all the common properties. Each track type corresponds to a subclass inheriting &lt;code&gt;Track&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt;in order to ease things out, some class introspection was introduced in order to identify the type of &lt;code&gt;Track&lt;/code&gt; based on the extension of the containing file. As shown below, this allows for instantiating a track by just using the &lt;code&gt;Track&lt;/code&gt; constructor, without knowing the name of the actual subclass being instantiated (e.g. &lt;code&gt;AnnotationTrack&lt;/code&gt; in the example below). Type inference is made through the type of file, or by specifying a &lt;code&gt;type&lt;/code&gt; property.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now, let’s add a &lt;code&gt;Track&lt;/code&gt; to our browser, then remove it:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Adding and removing a track to/from our browser" src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/genomic-data-representation-in-jupyter/images/002-1_681fIddZAaQc8w72MmmIiw.mp4" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Adding and removing a track to/from our browser&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;In this first version, two other functions come in as handy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;browser.search('chr3:1-190,100,300')&lt;/code&gt; would position the browser at the requested position in the genome;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;browser.dump_json()&lt;/code&gt; prepares a JSON representing the configuration of the browser. Handy if you would like to reinstantiate another browser with the same configuration without redoing it manually. Use &lt;code&gt;browser.out&lt;/code&gt; to output the JSON content.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We hope you’ll have fun manipulating genome data in Jupyter, and sharing visual knowledge thanks to &lt;code&gt;ipyigv&lt;/code&gt;!&lt;/p&gt;
&lt;h2 id="acknowledgments"&gt;Acknowledgments&lt;/h2&gt;
&lt;p&gt;The development of ipyigv by &lt;a href="https://twitter.com/Harr0uet"&gt;Jean-David Harrouet&lt;/a&gt; at &lt;a href="https://twitter.com/QuantStack"&gt;QuantStack&lt;/a&gt; was funded as part of the &lt;a href="https://twitter.com/PlasmaBio"&gt;PLASMA&lt;/a&gt; project, led by &lt;a href="https://twitter.com/CVandiedonck"&gt;Claire Vandiedonck&lt;/a&gt;, &lt;a href="https://twitter.com/pierrepo"&gt;Pierre Poulain&lt;/a&gt;, and &lt;a href="https://twitter.com/SCaburet"&gt;Sandrine Caburet&lt;/a&gt;, associate professors at Université de Paris.&lt;/p&gt;
&lt;p&gt;Sponsors to the PLASMA initiative include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/iledefrance"&gt;Région Île-de-France&lt;/a&gt;, via the “Trophées franciliens de l’innovation numérique dans le supérieur” (&lt;a href="https://www.iledefrance.fr/trophees-franciliens-de-linnovation-numerique-dans-le-superieur-les-laureats-2018"&gt;EdTech 2018&lt;/a&gt;) grant program,&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/Univ_Paris"&gt;Université de Paris&lt;/a&gt;, via the &lt;a href="https://u-paris.fr/en/the-initiative-of-excellence-idex-label/"&gt;Initiative of Excellence (IdEx) Label&lt;/a&gt; and its “inovating teaching” grant program,&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/EURGENEPARIS"&gt;EUR G.E.N.E.&lt;/a&gt;, the graduate school on Genetics and Epigenetics,&lt;/li&gt;
&lt;li&gt;the university training “Création, analyse et valorisation de données biologiques omiques” (&lt;a href="https://omics-school.net/"&gt;DU Omiques&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="about-the-author"&gt;About the author&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://www.linkedin.com/in/harrouet/"&gt;Jean-David Harrouet&lt;/a&gt; is an innovator helping companies with their digital transformation.&lt;/p&gt;
&lt;p&gt;He believes that the right mix of coding and business acumen is a way to make life better for many people.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2021/genomic-data-representation-in-jupyter/images/003-1_wACAwVx0PZAsEH8myXyUqg.jpeg" alt="" loading="lazy" data-body-image=""&gt;&lt;/p&gt;
</content><category term="science"/><category term="visualization"/></entry></feed>