<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhilash Dhal on Medium]]></title>
        <description><![CDATA[Stories by Abhilash Dhal on Medium]]></description>
        <link>https://medium.com/@adhal?source=rss-15ec57183590------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YBhmM8AksH90Lnhw.jpg</url>
            <title>Stories by Abhilash Dhal on Medium</title>
            <link>https://medium.com/@adhal?source=rss-15ec57183590------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:21:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adhal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Open Source Bioinformatics Part III: GDC to BigQuery]]></title>
            <link>https://medium.com/@adhal/open-source-bioinformatics-part-iii-migrating-from-gdc-to-bigquery-for-genai-potential-f3a9b8f66f46?source=rss-15ec57183590------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3a9b8f66f46</guid>
            <category><![CDATA[computational-biology]]></category>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data-processing]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Abhilash Dhal]]></dc:creator>
            <pubDate>Wed, 11 Sep 2024 17:48:31 GMT</pubDate>
            <atom:updated>2024-09-11T19:47:00.064Z</atom:updated>
            <content:encoded><![CDATA[<h3>Open Source Bioinformatics Part III: Omics Data Processing</h3><h3>Background</h3><p>In the previous <a href="https://medium.com/@adhal/open-source-bioinformatics-tutorials-part-ii-d6a22ab02fde">part of Open Source Bioinformatics</a> series, we explored the elements of <a href="https://portal.gdc.cancer.gov/">Genomic Data Commons(GDC)</a> data portal [3] , GDC <a href="https://docs.gdc.cancer.gov/API/Users_Guide/Getting_Started/">API</a> [1]and how <a href="https://abhilashdhal.com/OmixHub/">OmixHub</a> provided a unified interface for retrieving file data (also called metadata) from the GDC’s API through utility classes <a href="https://omixhub.readthedocs.io/en/latest/_modules/src/Connectors/gdc_endpt_base.html#GDCEndptBase"><strong><em>GDCEndptBase</em></strong></a> and <a href="https://omixhub.readthedocs.io/en/latest/_modules/src/Connectors/gdc_filters.html#GDCQueryFilters"><strong><em>GDCQueryFilters</em></strong></a><strong><em>.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*r0mWnEVTRmhgyrR6QXdtyw.png" /><figcaption>GDC: Distribution of Cases across primary sites [1]</figcaption></figure><p>In this short tutorial, we will go over some more GDC Utilities as well as introduce utilities for google cloud platform, particularly BigQueryUtils as to store retrieved GDC data in a format that will enable downstream ML analysis. Let’s Begin our journey into Omics Data Processing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*46xhqjjLDM-DWphJqHQ2kQ.png" /></figure><h4><strong>Data Processing using GDCEngine Class</strong></h4><blockquote>Recap: Previously, we obtained our output metadata with this code.</blockquote><pre># Imports<br>import sys<br>import os<br>import json<br>import pandas as pd<br>import requests<br>from IPython.display import display, HTML<br><br># Adjust this path to where your src directory is located<br>sys.path.append(&#39;./src&#39;)<br><br><br>from Connectors.gdc_endpt_base import GDCEndptBase<br>from Connectors.gdc_filters import GDCQueryFilters<br><br># Initialize the GDCQueryFilters class and GDC endpoint base class<br>gdc_filters = GDCQueryFilters()<br>gdc_endpt_base_cls = GDCEndptBase()<br><br><br># Create a query filter to retrieve RNA-Seq Data for Breast Cancer in only females<br>custom_params = {<br>    &quot;cases.project.primary_site&quot;: [&quot;Breast&quot;],<br>    &quot;cases.demographic.gender&quot;: [&quot;female&quot;]<br>}<br>custom_rna_seq_filter = gdc_filters.rna_seq_data_filter(field_params=custom_params)<br>output2, table2 = gdc_endpt_base_cls.run_query_filter(&quot;Custom RNA-Seq Filter&quot;, custom_rna_seq_filter, &quot;files&quot;, size=30)</pre><p>After fetching the metadata in a format like, there are several dataprocessing operations needed to materialize the TSV files into a dataframe.</p><pre>id data_format access file_name submitter_id data_category acl type platform file_size created_datetime md5sum updated_datetime file_id data_type state experimental_strategy version data_release<br>0 b11b5fbe-8e5e-402d-9a14-cd2656beb88c TSV open 4e2f3a20-e8a2-4711-995a-c97261572dc3.rna_seq.a... b1433cc3-baab-4e40-b49a-3af058a9d4d8 Transcriptome Profiling [open] gene_expression Illumina 4223658 2022-07-08T02:49:28.738344-05:00 b288ea13e495a33f14b97ced80a545d1 2024-07-29T22:12:53.361344-05:00 b11b5fbe-8e5e-402d-9a14-cd2656beb88c Gene Expression Quantification released RNA-Seq 1 35.0 - 41.0<br>1 0d8af62c-e2cc-4a9e-974b-d854ed05b6ad TSV open 0e81317e-c7a0-4649-8c73-1493a7eb8989.rna_seq.a... 54b7f4bd-7470-4b3f-88f7-47f7c32a7957 Transcriptome Profiling [open] gene_expression Illumina 4217167 2022-07-08T03:22:19.430878-05:00 1b8213a32393b4b3401be5b20c5536d9 2024-07-29T22:41:10.371479-05:00 0d8af62c-e2cc-4a9e-974b-d854ed05b6ad Gene Expression Quantification released RNA-Seq 1 35.0 - 41.0<br>2 a3b9da68-cc78-4d80-8371-e9b947d19d68 TSV open 1ec772b3-a9fd-4221-84e8-4e7acebe7700.rna_seq.a... 1fa80e8a-34c3-48cb-8477-7acafb4346c4 Transcriptome Profiling [open] gene_expression Illumina 4225398 2022-07-08T01:13:31.695619-05:00 7cdb1f1887c1968964795aa6d71a82b9 2024-07-29T22:17:50.171212-05:00 a3b9da68-cc78-4d80-8371-e9b947d19d68 Gene Expression Quantification released RNA-Seq 1 35.0 - 41.0<br>3 cec63a7f-0f8a-4800-933c-8e7afde88198 TSV open b074a7bb-abdb-4ec0-b957-54a32381c54f.rna_seq.a... cff12235-be67-4d7f-b86e-7bfabdcec536 Transcriptome Profiling [open] gene_expression Illumina 4225391 2022-07-08T01:49:50.122560-05:00 e5574d29f83ba3f322485c62840b56da 2024-07-29T22:34:59.093192-05:00 cec63a7f-0f8a-4800-933c-8e7afde88198 Gene Expression Quantification released RNA-Seq 1 35.0 - 41.0</pre><blockquote>Table 1. Output Metadata From GDC for RNA-Seq Gene Expression Quantification.</blockquote><p>A Single file from Fig 1 is show below for a few genes. There are 60000 more columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sb4gV7qCV52vP3XK5zSNzQ.png" /><figcaption><strong>Figure 1. Single Sample RNA-Seq STAR Count Data</strong></figcaption></figure><p>The full pipeline details for STAR count data from fastq files can be found on <a href="https://docs.gdc.cancer.gov/Encyclopedia/pages/STAR_Counts/">here.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7jAwKLDtOtmiIyY6HQ__Q.png" /><figcaption><strong>Figure 2. Process for Normalization of Bulk RNA-Seq Data [2]</strong></figcaption></figure><h3><strong>How to bulk process the data?</strong></h3><p>We will focus on the TSV files after Star alignment and more specifically 2 types of STAR count features (TPM Unstranded Count and Unstranded Count data. Let’s go over how to use OmixHub’s GDC Engine to return a data matrix of samples x gene_features.</p><blockquote><strong>Setup</strong></blockquote><p>Import the necessary libraries, and initialize the GDC Engine class for a list of primary_sites and type of downstream analysis (DE or ML). DE refers to Differential Expression, ML refers to Machine learning.</p><pre># Imports<br>import gevent.monkey<br>gevent.monkey.patch_all(thread=False, select=False)<br><br># Adjust this path to where your src directory is located<br>sys.path.append(&#39;./src&#39;)<br><br># OmixHub module imports<br>from Engines.gdc_engine import GDCEngine<br><br># List of primary sites to process<br>primary_sites = [&#39;Esophagus&#39;, &#39;Lung&#39;, &#39;Breast&#39;]  # Add more sites as needed<br><br># Specify the kind of downstream analysis you want to perform<br>downstream_analysis = &#39;DE&#39;<br><br>params = {<br>    &#39;files.experimental_strategy&#39;: &#39;RNA-Seq&#39;,<br>    &#39;data_type&#39;: &#39;Gene Expression Quantification&#39;<br>}</pre><blockquote><strong>Parameters</strong></blockquote><p>GDCEngine will take in a params dictionary of which <strong><em>‘files.experimental_strategy’ </em></strong>and <strong><em>‘data_type’ </em></strong>govern the type of sequencing experiment and the type of data file that will be fetched. It is also possible to provide a list of <strong><em>primary_sites </em></strong>as an integrated input into params, but for the purposes of the tutorial, we will keep it separate just like the <strong><em>downstream analysis </em></strong>argument.</p><blockquote><strong>Downstream analysis parameter</strong></blockquote><p>The details on the categories of count features can be found on the GDC website[2].</p><ol><li><strong><em>downstream_analysis = DE</em></strong>: Unstranded Count values will be extracted.</li><li><strong><em>downstream_analysis = ML: </em></strong>TPM Unstranded Count values will be extracted.</li></ol><p>The reason for differentiating into DE and ML is to enable downstream application of differential gene expression or machine learning models.</p><p>Differential Gene Expression can only be applied for discrete count data [4]. In the ML mode, both discrete and continuous expression values for all features can be used.</p><blockquote><strong>Intialize the Engine</strong></blockquote><p>Next we initialize the GDC engine with parameters for the <em>experimental_strategy</em> and <em>data_type. </em>The different experimental_strategies and data_types can be found on the GDC portal[1].</p><pre>from google.cloud import bigquery<br># Initialize GDCEngine with basic query params as before<br><br>gdc_eng_inst = GDCEngine(**params)<br></pre><p>So far we have only intialized the engine with <strong><em>‘files.experimental_strategy’ </em></strong>and <strong><em>‘data_type’.</em></strong></p><p>The beauty of the GDCEngine class lies in using asynchronous HTTP requests package called<strong><em> ‘grequests’ </em></strong>to retrieve multiple urls for many many samples for a given primary_site in parallel. For a single <strong><em>primary_site</em></strong> and <strong><em>downstream_analysis, </em></strong>we can fetch the N x P STAR count data matrix with a single line as below.</p><pre># Create Dataset for differential gene expression<br>rna_seq_DGE_data = gdc_eng_inst.run_rna_seq_data_matrix_creation(primary_site=&#39;Kidney&#39;, downstream_analysis=&#39;DE&#39;)</pre><p>After running this, the <strong><em>rna_seq_DGE_data</em></strong> will be a dataframe as show below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5W_Dz4rHPpTDSEhfeWk75Q.png" /><figcaption>Figure 3. Data Matrix Obtained</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*JK96Lk-klJ-ARgFCYx7PFw.png" /><figcaption>Figure 4. Count of Tumor and Normal Tissue Type for Kidney Cancer</figcaption></figure><p>The data is ready for ML or Bioinformatics analysis on your jupyter notebook.</p><p>However, with the growth of cloud computing, there are some interesting google cloud tools such as BigQuery, Cloud Run and VertexAI, which can be leveraged to build GenAI tools for your cancer research. In this context, the migration of this data to google cloud’s BigQuery platform [8] offers the following advantages:</p><ul><li>Cost Effective compared to other platforms (For 1 TiB storage for a full month, you pay $23.552 USD). Query costs range from 0.04$ per slot hour to 0.1$ per slot hour with an option for on-demand pricing [8].</li><li>Well documented client libraries available [9].</li><li>Easy integration with Vertex AI for GenAI applications [10].</li><li>Lots of skill pathways with extensive tutorial into using google cloud products [11].</li></ul><p>Given these advantages, Here is a utility that i created to migrate the data matrix created from GDC into BigQuery.</p><blockquote><strong>Migrating to BigQuery</strong></blockquote><p>BigQuery particularly stands out due to its available table optimizations through clustering and partitioning which can be leveraged to make your data be more compact for storage as well as cheaper to execute queries.</p><pre># OmixHub module imports<br>from Connectors.gcp_bigquery_utils import BigQueryUtils<br><br># Initialize BigQueryUtils with your project<br>project_id = &#39;rnaseqml&#39; # replace the project_id with your project_id<br>table_id = &#39;rnaseqml.rnaseqexpression.expr_clustered&#39; # replace the table_id with your project_id<br>bq_utils = BigQueryUtils(project_id=project_id)<br><br># Define the schema for your table<br>schema = [<br>    bigquery.SchemaField(&quot;case_id&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;file_id&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;expr_unstr_count&quot;, &quot;INTEGER&quot;, mode=&quot;REPEATED&quot;),<br>    bigquery.SchemaField(&quot;tissue_type&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;sample_type&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;primary_site&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;tissue_or_organ_of_origin&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;age_at_diagnosis&quot;, &quot;FLOAT&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;primary_diagnosis&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;race&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;gender&quot;, &quot;STRING&quot;, mode=&quot;NULLABLE&quot;),<br>    bigquery.SchemaField(&quot;group_identifier&quot;, &quot;INTEGER&quot;, mode=&quot;NULLABLE&quot;)<br>]<br><br># Create table with partitioning and clustering<br>bq_utils.create_bigquery_table_with_schema(<br>    table_id=table_id,<br>    schema=schema,<br>    partition_field=&quot;group_identifier&quot;,<br>    clustering_fields=[&quot;primary_site&quot;, &quot;tissue_type&quot;]<br>)<br><br># Process each primary site<br>for site in tqdm(primary_sites):<br>    # Get data from GDC<br>    json_object = gdc_eng_inst.get_data_for_bq(site, downstream_analysis=downstream_analysis, format=&#39;json&#39;)<br><br>    # Load data into BigQuery<br>    job = bq_utils.load_json_data(json_object, schema, table_id)<br>    job.result()  # Wait for the job to complete<br>    print(f&quot;Data for {site} loaded successfully.&quot;)<br><br>print(&quot;All data loaded successfully.&quot;)</pre><h3><strong>Conclusions:</strong></h3><ol><li><a href="https://omixhub.readthedocs.io/en/latest/_modules/src/Engines/gdc_engine.html#GDCEngine"><strong>GDCEngine </strong></a>Class in <a href="https://abhilashdhal.com/OmixHub/"><strong>OmixHub</strong></a> can process cancer data of interest in a few lines of code to enable data matrix creation.</li><li>BigQueryUtils Class in OmixHub can optimize clustering and partitioning of the data matrix to be stored for downstream GenAI applications.</li></ol><h3><strong>References:</strong></h3><ol><li>GDC Data Portal API <a href="https://docs.gdc.cancer.gov/API/Users_Guide/Getting_Started/">https://docs.gdc.cancer.gov/API/Users_Guide/Getting_Started/</a></li><li>Pipeline for Star counts RNA-Seq Data <a href="https://docs.gdc.cancer.gov/Encyclopedia/pages/STAR_Counts/">https://docs.gdc.cancer.gov/Encyclopedia/pages/STAR_Counts/</a></li><li>GDC Data Portal <a href="https://portal.gdc.cancer.gov/">https://portal.gdc.cancer.gov/</a></li><li>OmixHub readthedocs <a href="https://omixhub.readthedocs.io/en/latest/index.html">https://omixhub.readthedocs.io/en/latest/index.html</a></li><li>OmixHub Webpage <a href="https://abhilashdhal.com/OmixHub/">https://abhilashdhal.com/OmixHub/</a></li><li>Anders, S., Huber, W. Differential expression analysis for sequence count data. <em>Genome Biol</em> <strong>11</strong>, R106 (2010). <a href="https://doi.org/10.1186/gb-2010-11-10-r106">https://doi.org/10.1186/gb-2010-11-10-r106</a></li><li>grequests package <a href="https://pypi.org/project/grequests/">https://pypi.org/project/grequests/</a></li><li>Google Cloud Platform <a href="https://cloud.google.com/docs">https://cloud.google.com/docs</a></li><li>Google Cloud Client libraries <a href="https://cloud.google.com/apis/docs/cloud-client-libraries">https://cloud.google.com/apis/docs/cloud-client-libraries</a></li><li>Google Cloud Vertex AI <a href="https://cloud.google.com/vertex-ai/docs">https://cloud.google.com/vertex-ai/docs</a></li><li>Google Cloud Skills <a href="https://cloud.google.com/learn/training/?hl=en">https://cloud.google.com/learn/training/?hl=en</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3a9b8f66f46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Source Bioinformatics tutorials Part II]]></title>
            <link>https://medium.com/@adhal/open-source-bioinformatics-tutorials-part-ii-d6a22ab02fde?source=rss-15ec57183590------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6a22ab02fde</guid>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cancer-research]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[data-preprocessing]]></category>
            <dc:creator><![CDATA[Abhilash Dhal]]></dc:creator>
            <pubDate>Wed, 11 Sep 2024 15:00:15 GMT</pubDate>
            <atom:updated>2024-09-11T19:40:14.889Z</atom:updated>
            <content:encoded><![CDATA[<h3>Retrieval of High dimensional data from genomic data commons (GDC)</h3><p>In <a href="https://medium.com/@adhal/open-source-bioinformatics-tutorials-58bd40dd7f0d">Part I</a>, we explored how to perform differential gene expression(DGE) on a real world bulk RNA sequencing dataset in python. In this tutorial, I will cover some basic concepts involving retrieving data from the <a href="https://portal.gdc.cancer.gov/">Genomic data commons</a>.</p><p><strong>GDC Data Portal Overview</strong></p><ol><li><strong>Multiple primary sites:</strong> GDC provides a unified interface to download datasets. GDC’s interface provides bulk RNA-Sequencing data across 25+ primary sites with cancer diagnosis.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*r0mWnEVTRmhgyrR6QXdtyw.png" /><figcaption>GDC: Distribution of Cases across primary sites</figcaption></figure><p>2.<strong> Multiple disease types per primary site: </strong>After choosing your primary site of interest for cancer research, there exist numerous disease types for the primary site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*vXcpNhSwVigATVVCBHDxkg.png" /><figcaption>Disease Types in Kidney Cancern</figcaption></figure><p>3. <strong>API to enable search and retrieval: </strong>In addition to the UI for downloading datasets, GDC provides an API that enables search and retrieval of very basic to complex queries in json format and multiple python examples as well (<a href="https://docs.gdc.cancer.gov/API/Users_Guide/Search_and_Retrieval/">https://docs.gdc.cancer.gov/API/Users_Guide/Search_and_Retrieval/</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E03JxkA0YG4X5FX6FrPD7A.png" /></figure><p>Fig 3. Overview of GDC’s API.</p><p>4. <strong>Examples of some GDC queries:</strong></p><blockquote>Basic Query to retrieve data from cases endpoint</blockquote><pre>import requests<br>import json<br><br>cases_endpt = &#39;https://api.gdc.cancer.gov/cases&#39;<br><br># The &#39;fields&#39; parameter is passed as a comma-separated string of single names.<br>fields = [<br>    &quot;submitter_id&quot;,<br>    &quot;case_id&quot;,<br>    &quot;primary_site&quot;,<br>    &quot;disease_type&quot;,<br>    &quot;diagnoses.vital_status&quot;<br>    ]<br><br>fields = &#39;,&#39;.join(fields)<br><br>params = {<br>    &quot;fields&quot;: fields,<br>    &quot;format&quot;: &quot;TSV&quot;,<br>    &quot;size&quot;: &quot;100&quot;<br>    }<br><br>response = requests.get(cases_endpt, params = params)<br><br>print(response.content)</pre><blockquote>Complex query to retrieve RNA-Sequencing experiment data uses filters for <strong><em>primary_site, experimental_strategy </em></strong>and<strong><em> data_format.</em></strong></blockquote><pre>import requests<br>import json<br><br>fields = [<br>    &quot;file_name&quot;,<br>    &quot;cases.submitter_id&quot;,<br>    &quot;cases.samples.sample_type&quot;,<br>    &quot;cases.disease_type&quot;,<br>    &quot;cases.project.project_id&quot;<br>    ]<br><br>fields = &quot;,&quot;.join(fields)<br><br>files_endpt = &quot;https://api.gdc.cancer.gov/files&quot;<br><br># This set of filters is nested under an &#39;and&#39; operator.<br>filters = {<br>    &quot;op&quot;: &quot;and&quot;,<br>    &quot;content&quot;:[<br>        {<br>        &quot;op&quot;: &quot;in&quot;,<br>        &quot;content&quot;:{<br>            &quot;field&quot;: &quot;cases.project.primary_site&quot;,<br>            &quot;value&quot;: [&quot;Lung&quot;]<br>            }<br>        },<br>        {<br>        &quot;op&quot;: &quot;in&quot;,<br>        &quot;content&quot;:{<br>            &quot;field&quot;: &quot;files.experimental_strategy&quot;,<br>            &quot;value&quot;: [&quot;RNA-Seq&quot;]<br>            }<br>        },<br>        {<br>        &quot;op&quot;: &quot;in&quot;,<br>        &quot;content&quot;:{<br>            &quot;field&quot;: &quot;files.data_format&quot;,<br>            &quot;value&quot;: [&quot;BAM&quot;]<br>            }<br>        }<br>    ]<br>}<br><br># A POST is used, so the filter parameters can be passed directly as a Dict object.<br>params = {<br>    &quot;filters&quot;: filters,<br>    &quot;fields&quot;: fields,<br>    &quot;format&quot;: &quot;TSV&quot;,<br>    &quot;size&quot;: &quot;2000&quot;<br>    }<br><br># The parameters are passed to &#39;json&#39; rather than &#39;params&#39; in this case<br>response = requests.post(files_endpt, headers = {&quot;Content-Type&quot;: &quot;application/json&quot;}, json = params)<br><br>print(response.content.decode(&quot;utf-8&quot;))</pre><p>Often cancer researchers and data professionals will want to use these systems to retrieve cohorts and datasets of interest to perform downstream analysis. Given the complexity of GDC’s API for retrieving different datasets (particularly for RNA-Sequencing), I created <a href="https://omixhub.readthedocs.io/en/latest/index.html">OmixHub</a> to streamline these core processes and help out the bioinformatics community in accessing this data with a few lines of code in python.</p><blockquote>Getting started with <a href="https://omixhub.readthedocs.io/en/latest/index.html">OmixHub</a>:</blockquote><pre>## Clone the repository<br>git clone https://github.com/adhal007/OmixHub.git<br><br>## setup your environment for conda<br>conda env create -f environment.yaml</pre><blockquote>Building query filters:</blockquote><p>In the root of your clone, create a notebook called gdc_filters.ipynb</p><pre># Imports<br>import sys<br>import os<br>import json<br>import pandas as pd<br>import requests<br>from IPython.display import display, HTML<br><br># Adjust this path to where your src directory is located<br>sys.path.append(&#39;./src&#39;)<br><br><br>from Connectors.gdc_endpt_base import GDCEndptBase<br>from Connectors.gdc_filters import GDCQueryFilters<br><br># Initialize the GDCQueryFilters class and GDC endpoint base class<br>gdc_filters = GDCQueryFilters()<br>gdc_endpt_base_cls = GDCEndptBase()<br><br># Run default query filter with no customization<br>output1, table1 = gdc_endpt_base_cls.run_query_filter(&quot;RNA-Seq Filter&quot;, gdc_filters.rna_seq_filter, &quot;files&quot;, size=30)<br><br># Create a query filter to retrieve RNA-Seq Data for Breast Cancer in only females<br>custom_params = {<br>    &quot;cases.project.primary_site&quot;: [&quot;Breast&quot;],<br>    &quot;cases.demographic.gender&quot;: [&quot;female&quot;]<br>}<br>custom_rna_seq_filter = gdc_filters.rna_seq_data_filter(field_params=custom_params)<br>output2, table2 = gdc_endpt_base_cls.run_query_filter(&quot;Custom RNA-Seq Filter&quot;, custom_rna_seq_filter, &quot;files&quot;, size=30)</pre><p>The output will be printed like:</p><pre>INFO:Connectors.gdc_endpt_base:Testing filter: RNA-Seq Filter<br>INFO:Connectors.gdc_endpt_base:Filter dictionary: {<br>  &quot;op&quot;: &quot;and&quot;,<br>  &quot;content&quot;: [<br>    {<br>      &quot;op&quot;: &quot;in&quot;,<br>      &quot;content&quot;: {<br>        &quot;field&quot;: &quot;data_type&quot;,<br>        &quot;value&quot;: [<br>          &quot;Gene Expression Quantification&quot;<br>        ]<br>      }<br>    },<br>    {<br>      &quot;op&quot;: &quot;in&quot;,<br>      &quot;content&quot;: {<br>        &quot;field&quot;: &quot;files.experimental_strategy&quot;,<br>        &quot;value&quot;: [<br>          &quot;RNA-Seq&quot;<br>        ]<br>      }<br>    },<br>    {<br>      &quot;op&quot;: &quot;in&quot;,<br>      &quot;content&quot;: {<br>        &quot;field&quot;: &quot;files.analysis.workflow_type&quot;,<br>        &quot;value&quot;: [<br>          &quot;HTSeq - Counts&quot;,<br>          &quot;STAR - Counts&quot;<br>        ]<br>      }<br>    }<br>  ]<br>}<br>INFO:Connectors.gdc_endpt_base:URL: https://api.gdc.cancer.gov/files<br>INFO:Connectors.gdc_endpt_base:Params: {<br>  &quot;filters&quot;: &quot;{\&quot;op\&quot;: \&quot;and\&quot;, \&quot;content\&quot;: [{\&quot;op\&quot;: \&quot;in\&quot;, \&quot;content\&quot;: {\&quot;field\&quot;: \&quot;data_type\&quot;, \&quot;value\&quot;: [\&quot;Gene Expression Quantification\&quot;]}}, {\&quot;op\&quot;: \&quot;in\&quot;, \&quot;content\&quot;: {\&quot;field\&quot;: \&quot;files.experimental_strategy\&quot;, \&quot;value\&quot;: [\&quot;RNA-Seq\&quot;]}}, {\&quot;op\&quot;: \&quot;in\&quot;, \&quot;content\&quot;: {\&quot;field\&quot;: \&quot;files.analysis.workflow_type\&quot;, \&quot;value\&quot;: [\&quot;HTSeq - Counts\&quot;, \&quot;STAR - Counts\&quot;]}}]}&quot;,<br>  &quot;size&quot;: 30<br>}<br>INFO:Connectors.gdc_endpt_base:Response status code: 200<br>INFO:Connectors.gdc_endpt_base:Total items: 25259</pre><p><strong><em>output1 </em></strong>above is a dataframe like</p><pre>id data_format access file_name submitter_id data_category acl type platform file_size created_datetime md5sum updated_datetime file_id data_type state experimental_strategy version data_release<br>0 b11b5fbe-8e5e-402d-9a14-cd2656beb88c TSV open 4e2f3a20-e8a2-4711-995a-c97261572dc3.rna_seq.a... b1433cc3-baab-4e40-b49a-3af058a9d4d8 Transcriptome Profiling [open] gene_expression Illumina 4223658 2022-07-08T02:49:28.738344-05:00 b288ea13e495a33f14b97ced80a545d1 2024-07-29T22:12:53.361344-05:00 b11b5fbe-8e5e-402d-9a14-cd2656beb88c Gene Expression Quantification released RNA-Seq 1 35.0 - 41.0<br>1 0d8af62c-e2cc-4a9e-974b-d854ed05b6ad TSV open 0e81317e-c7a0-4649-8c73-1493a7eb8989.rna_seq.a... 54b7f4bd-7470-4b3f-88f7-47f7c32a7957 Transcriptome Profiling [open] gene_expression Illumina 4217167 2022-07-08T03:22:19.430878-05:00 1b8213a32393b4b3401be5b20c5536d9 2024-07-29T22:41:10.371479-05:00 0d8af62c-e2cc-4a9e-974b-d854ed05b6ad Gene Expression Quantification released RNA-Seq 1 35.0 - 41.0<br>2 a3b9da68-cc78-4d80-8371-e9b947d19d68 TSV open 1ec772b3-a9fd-4221-84e8-4e7acebe7700.rna_seq.a... 1fa80e8a-34c3-48cb-8477-7acafb4346c4 Transcriptome Profiling [open] gene_expression Illumina 4225398 2022-07-08T01:13:31.695619-05:00 7cdb1f1887c1968964795aa6d71a82b9 2024-07-29T22:17:50.171212-05:00 a3b9da68-cc78-4d80-8371-e9b947d19d68 Gene Expression Quantification released RNA-Seq 1 35.0 - 41.0<br>3 cec63a7f-0f8a-4800-933c-8e7afde88198 TSV open b074a7bb-abdb-4ec0-b957-54a32381c54f.rna_seq.a... cff12235-be67-4d7f-b86e-7bfabdcec536 Transcriptome Profiling [open] gene_expression Illumina 4225391 2022-07-08T01:49:50.122560-05:00 e5574d29f83ba3f322485c62840b56da 2024-07-29T22:34:59.093192-05:00 cec63a7f-0f8a-4800-933c-8e7afde88198 Gene Expression Quantification released RNA-Seq 1 35.0 - 41.0</pre><p><strong><em>outpu2 </em></strong>is a similar dataframe with more focussed columns as it is a custom filter.</p><p>The screenshot below showcases some of the many useful filters you can find and query data and their corresponding files in GDC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*Mlp5_7yac7W4uk1UQzCkig.png" /></figure><p><strong>Utility of the filters:</strong></p><p>These filters will be particularly important to expand upon their associated files and perform bulk-processing to convert them into dataframes or run other bioinformatics processing. One such example which has been the focus of OmixHub has been to process RNA-Sequencing files to return a dataframe for downstream applications.</p><p>This specific application with RNA-Sequecing samples will be discussed in more detail in the next part.</p><p>If you are interested to check out more functionalities of OmixHub, feel free to check out the links below. If you are interested to contribute or collaborate, feel free to reach to me via my <a href="/service/mailto:adhalbiophysics@gmail.com">email</a>.</p><p><strong>Website link: </strong><a href="https://abhilashdhal.com/OmixHub/index.html">https://abhilashdhal.com/OmixHub/index.html</a></p><p><strong>Github link:</strong></p><p><strong>Readthedocs link: </strong><a href="https://omixhub.readthedocs.io/en/latest/getting_started.html">https://omixhub.readthedocs.io/en/latest/getting_started.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6a22ab02fde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Source Bioinformatics: Part I]]></title>
            <link>https://medium.com/@adhal/open-source-bioinformatics-tutorials-58bd40dd7f0d?source=rss-15ec57183590------2</link>
            <guid isPermaLink="false">https://medium.com/p/58bd40dd7f0d</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[bioinformatics]]></category>
            <category><![CDATA[omics-data-analysis]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <dc:creator><![CDATA[Abhilash Dhal]]></dc:creator>
            <pubDate>Tue, 14 Nov 2023 10:01:18 GMT</pubDate>
            <atom:updated>2024-09-11T15:48:22.241Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Analysis of RNA-Seq data</strong></p><p><strong>Background:</strong></p><p>The global bioinformatics market size is expected to explode 3X from 2019 to 2027. This coupled with the infusion of AI will inherently lead to:</p><ul><li>new omics based technologies (molecular assays, sequencing technologies, optical high-throughput technologies, etc)</li><li>plethora of open source tools for enabling disease specific, assay specific computational analysis.</li><li>demand for more data professionals (data-scientists, analysts and bioinformaticians in the domain.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*wEFQIakl9UROv8gbTcBlDg.jpeg" /><figcaption>Global Bio-info market size expansion (<a href="https://www.openpr.com/news/2264973/bioinformatics-market-report-2021-market-stood-at-8-5-billion">https://www.openpr.com/news/2264973/bioinformatics-market-report-2021-market-stood-at-8-5-billion</a>)</figcaption></figure><p><strong>Dilemma of domain change to bioinformatics for aspiring data professionals:</strong></p><p>Unlike other domains (E-Commerce, Finance, Supply-Chain, Electronics, etc), learning biology and high-throughput technologies have the following complexities:</p><ul><li>High throughput biological datasets (scRNA, bulk RNA, SNP, WGS, peptide arrays, ect</li><li>Categorical features (clinical manifests, sample manifests, gene annotations, etc)</li><li>Lots of documentation (that can be overwhelming to read)</li></ul><p>Given the dilemma faced for a transition into bioiformatics domain, I started building a common platform called <strong>OmixHub (</strong><a href="https://github.com/adhal007/OmixHub">https://github.com/adhal007/OmixHub</a>) to help students get started on exploring different datasets and applying ML/DL algorithms for analysis.</p><p>Here, I present an example of applying differential expression to kidney cancer RNA-Seq dataset with 3 sub-types of cancer using a wrapper with PyDeSeq utilities (<a href="https://github.com/adhal007/OmixHub/blob/main/OmicsUtils/pydeseq_utils.py">https://github.com/adhal007/OmixHub/blob/main/OmicsUtils/pydeseq_utils.py</a>)</p><p><strong>0. Libraries needed</strong></p><pre>import OmicsUtils.pydeseq_utils as pydeseq_utils<br>import pandas as pd</pre><h3>I. Data Processing</h3><blockquote>1.1 Read in counts data and metadata</blockquote><pre>count_data_kidney_cancer = pd.read_csv(&#39;./Transcriptomics/data/processed_data/stranded_first_data_with_labels.csv&#39;)<br>count_data_kidney_cancer<br>count_data_kidney_cancer[[&#39;Case ID&#39;, &#39;Project ID&#39;]]<br>kidney_cancer_count_data = count_data_kidney_cancer.iloc[:, :60660].T<br>counts = kidney_cancer_count_data.copy().reset_index()<br>counts = counts.set_index(&#39;index&#39;)<br>counts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*M2kuVD0zC-oOBYVQTCxb-w.png" /><figcaption>Figure1.1: Counts dataframe for kidney cancer (1643 samples and 60660 genes)</figcaption></figure><blockquote>1.2. Transpose the data for deseq2</blockquote><pre>counts = counts.T<br>counts = pd.concat( [count_data_kidney_cancer[[&#39;Case ID&#39;]], counts],axis=1)<br>counts.rename(columns={&#39;Case ID&#39;:&#39;Geneid&#39;}, inplace=True)<br>counts.set_index(&#39;Geneid&#39;, inplace=True)<br>counts.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_g54CstzPZRyvhLabbRHVA.png" /><figcaption>Figure 1.2. Transposed dataframe</figcaption></figure><blockquote>II. Metadata pre-processing for PyDeSeq</blockquote><blockquote>2.1. Create a metadata dataframe with Case ID and Cancer subtype</blockquote><p>Only 3 cancers from TCGA (Renal Cell Carcinoma) are included in this analysis (Single Factor analysis). But it is fairly straightforward to apply the class in the OmicsHub module for<a href="https://github.com/adhal007/OmixHub/blob/main/OmicsUtils/pydeseq_utils.py">https://github.com/adhal007/OmixHub/blob/main/OmicsUtils/pydeseq_utils.py</a> for multifactor analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*hFWO0YNwBTQXlJi6f_tLgA.png" /><figcaption>Figure 2.1. Metadata for PyDeSeq</figcaption></figure><h3>2.2. Subset the counts data to only include the 3 cancers</h3><p>The original dataframe has 1643 samples, belonging to other cancer conditions as well that we were not intereseted in. Hence we will subset for 3 classes of kidney cancer (<strong>TCGA-KIRP, TCGA-KIRC, TCGA-KICH)</strong></p><pre>counts_rcc = counts[counts.index.isin(TCGA_rcc_metadata.index.values)]</pre><h3>III. Running Deseq2</h3><pre>from importlib import reload<br>import OmicsUtils.pydeseq_utils as pydeseq_utils<br>reload(pydeseq_utils)<br>&lt;module &#39;OmicsUtils.pydeseq_utils&#39; from &#39;/Users/abhilashdhal/Projects/OmicsUtils/pydeseq_utils.py&#39;&gt;<br><br>## Initialize the pydeseq_utils object<br>pydeseq_obj = pydeseq_utils.PyDeSeqWrapper(count_matrix=counts_rcc, metadata=TCGA_rcc_metadata, design_factors=&#39;Condition&#39;, groups = {&#39;group1&#39;:&#39;TCGA-KIRC&#39;, &#39;group2&#39;:&#39;TCGA-KIRP&#39;})<br>design_factor = &#39;Condition&#39;<br>result = pydeseq_obj.run_deseq(design_factor=design_factor, group1 = &#39;TCGA-KIRC&#39;, group2 = &#39;TCGA-KIRP&#39;)</pre><p>Here you can see that the design factor takes only a single factor ‘Condition’ for performing differential analysis. If we set design_factor to</p><pre>[&#39;Condition&#39;, &#39;Tumor&#39;]</pre><p>Then our analysis would incorporate multi-factor inference by PyDeSeq.</p><pre>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Running DESeq2 for groups: {&#39;group1&#39;: &#39;TCGA-KIRC&#39;, &#39;group2&#39;: &#39;TCGA-KIRP&#39;}<br>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Running DESeq2 for groups: {&#39;group1&#39;: &#39;TCGA-KIRC&#39;, &#39;group2&#39;: &#39;TCGA-KIRP&#39;}<br>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Running DESeq2 for groups: {&#39;group1&#39;: &#39;TCGA-KIRC&#39;, &#39;group2&#39;: &#39;TCGA-KIRP&#39;}<br>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Running DESeq2  factor analysis with design factor: C and o<br>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Running DESeq2  factor analysis with design factor: C and o<br>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Running DESeq2  factor analysis with design factor: C and o<br>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Statistical analysis of TCGA-KIRC vs TCGA-KIRP in {&#39;group1&#39;: &#39;TCGA-KIRC&#39;, &#39;group2&#39;: &#39;TCGA-KIRP&#39;}<br>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Statistical analysis of TCGA-KIRC vs TCGA-KIRP in {&#39;group1&#39;: &#39;TCGA-KIRC&#39;, &#39;group2&#39;: &#39;TCGA-KIRP&#39;}<br>13/11//2023 05:59:1699878581 PM - INFO - PyDeSeqWrapper.run_deseq: Statistical analysis of TCGA-KIRC vs TCGA-KIRP in {&#39;group1&#39;: &#39;TCGA-KIRC&#39;, &#39;group2&#39;: &#39;TCGA-KIRP&#39;}<br><br><br>/opt/homebrew/anaconda3/envs/umap-env/lib/python3.11/site-packages/anndata/_core/anndata.py:1897: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.<br>  utils.warn_names_duplicates(&quot;obs&quot;)<br>Fitting size factors...<br>... done in 0.71 seconds.<br><br>Fitting dispersions...<br>... done in 12.99 seconds.<br><br>Fitting dispersion trend curve...<br>... done in 4.57 seconds.<br><br>Fitting MAP dispersions...<br>... done in 14.78 seconds.<br><br>Fitting LFCs...<br>... done in 30.33 seconds.<br><br>/opt/homebrew/anaconda3/envs/umap-env/lib/python3.11/site-packages/anndata/_core/anndata.py:1897: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.<br>  utils.warn_names_duplicates(&quot;obs&quot;)<br>Refitting 10827 outliers.<br><br>/opt/homebrew/anaconda3/envs/umap-env/lib/python3.11/site-packages/anndata/_core/anndata.py:1897: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.<br>  utils.warn_names_duplicates(&quot;obs&quot;)<br>/opt/homebrew/anaconda3/envs/umap-env/lib/python3.11/site-packages/anndata/_core/anndata.py:1897: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.<br>  utils.warn_names_duplicates(&quot;obs&quot;)<br>Fitting size factors...<br>... done in 0.08 seconds.<br><br>Fitting dispersions...<br>... done in 2.75 seconds.<br><br>Fitting MAP dispersions...<br>... done in 2.71 seconds.<br><br>Fitting LFCs...<br>... done in 5.80 seconds.</pre><p>Then to retrieve the result object we need to additionally run the summary function like this on the result variable from the output of PyDeSeq module.</p><pre>result.summary()<br>Running Wald tests...<br>... done in 26.52 seconds.<br><br>Log2 fold change &amp; Wald test p-value: Condition TCGA-KIRC vs TCGA-KIRP<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*Eei9zg3_Vi_GfIq5SuRfhA.png" /><figcaption>Figure 3.1 Result dataframe of differential gene expression</figcaption></figure><h3>IV. Data Interpretation/Visualization of the results</h3><h3>4.1. Merging gene annotations</h3><blockquote><strong>In order to better visualize the results we need to merge the gene annotations</strong></blockquote><p>In the dataframes above, the ```ENSG***``` are the gene_ids from the emsemble database for each gene. Corresponding to each gene_id there maybe multiple gene_names as well as other annotation variables. In a typically RNA-Seq experiment, we want to be able to showcase some of the top genes that are identified after our statistical analysis. For that purpose we will only be merging gene names with the gene_ids.</p><pre>gene_annotation = pd.read_csv(&#39;./Transcriptomics/data/gene_annotation/gene_id_to_gene_name_mapping.csv&#39;)<br><br>results_df = result.results_df<br>results_df_filtered = results_df.dropna()<br>results_df_filtered = results_df_filtered.reset_index()<br>results_df_filtered[&#39;nlog10&#39;] = -1*np.log10(results_df_filtered.padj)<br><br>results_df_filtered = results_df_filtered.merge(gene_annotation, left_on=&#39;index&#39;, right_on=&#39;gene_id&#39;)<br>results_df_filtered  = results_df_filtered .replace([np.inf, -np.inf], 300)<br>results_df_filtered.sort_values(&#39;padj&#39;, ascending=False)</pre><p>NOTE: gene_annotations are always available as GTX files and (OmixHub) <a href="https://github.com/adhal007/OmixHub/blob/main/OmicsUtils/pydeseq_utils.py">https://github.com/adhal007/OmixHub/</a> has a method to directly obtain the .tsv version from a .gtx file. (Please check out the documentation and leave a comment)</p><h3>4.2. Screening differentially expressed genes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*0udIkQF0hHrAEiy-t5wzaw.png" /></figure><blockquote>Applying outlier threshold for log2FoldChange and nlog10 padj using tukey’s fences</blockquote><pre>k = 3.0<br>log2_threshold = k*(np.percentile(results_df_filtered[&#39;log2FoldChange&#39;], 75) - np.percentile(results_df_filtered[&#39;log2FoldChange&#39;], 25)) + np.percentile(results_df_filtered[&#39;log2FoldChange&#39;], 75)<br>log10_threshold = k*(np.percentile(results_df_filtered[&#39;nlog10&#39;], 75) - np.percentile(results_df_filtered[&#39;nlog10&#39;], 25)) + np.percentile(results_df_filtered[&#39;nlog10&#39;], 75)<br>print(f&quot;The threshold for log2FoldChange is {log2_threshold}&quot;)<br>print(f&quot;The threshold for nlog10 is {log10_threshold}&quot;)<br>The threshold for log2FoldChange is 3.0146824737036013<br>The threshold for nlog10 is 61.22039206963072<br>#picked1 and picked2 simulate user lists of genes to label by color<br>picked1 = random.choices(population=results_df_filtered.gene_name.tolist(), weights = results_df_filtered.nlog10.tolist(), k = 250)<br>picked2 = random.choices(population=results_df_filtered.gene_name.tolist(), weights = results_df_filtered.nlog10.tolist(), k = 300)<br>picked2 = [x for x in picked2 if x not in picked1]<br><br>def map_color(a):<br>    log2FoldChange, gene_name, nlog10 = a<br>    <br>    if abs(log2FoldChange) &lt; log2_threshold or nlog10 &lt; log10_threshold:<br>        return &#39;Not significant&#39;<br>    if gene_name in picked1:<br>        return &#39;picked1&#39;<br>    if gene_name in picked2:<br>        return &#39;picked2&#39;<br>    <br>    return &#39;Cherry picked&#39;<br><br>results_df_filtered[&#39;color&#39;] = results_df_filtered[[&#39;log2FoldChange&#39;, &#39;gene_name&#39;, &#39;nlog10&#39;]].apply(map_color, axis = 1)<br><br>#picked3 and picked24 simulate user lists of genes to label by shape<br>df = results_df_filtered.copy()<br>picked3 = random.choices(df.gene_name.tolist(), weights = df.nlog10.tolist(), k = 250)<br>picked4 = random.choices(df.gene_name.tolist(), weights = df.nlog10.tolist(), k = 300)<br>picked4 = [x for x in picked4 if x not in picked3]<br><br>def map_shape(symbol):<br>    if symbol in picked3:<br>        return &#39;picked3&#39;<br>    if symbol in picked4:<br>        return &#39;picked4&#39;<br>    <br>    return &#39;not_important&#39;<br><br>df[&#39;shape&#39;] = df.gene_name.map(map_shape)<br>df.head()</pre><p>Here in the above code, we have created</p><ul><li>automated thresholding using outlier sum statistics for log2fold change and -log(P_adj) to screen for highly expressed and significant genes in a data driven manner.</li><li>some mappings for different significant genes that were picked so we can visualize them via a scatter plot.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zb-ayJiDsVTm-00_yVzcew.png" /><figcaption>Figure 4.2. Shows the color and shape column used for plotting</figcaption></figure><h3>4.3. Plot differentially expressed genes</h3><blockquote>Full volcano plot: To see the scale of fold change and significance of p-values</blockquote><pre>ax1 = sns.scatterplot(data = df, x = &#39;log2FoldChange&#39;, y = &#39;nlog10&#39;,<br>                    hue = &#39;color&#39;, hue_order = [&#39;Not significant&#39;, &#39;picked1&#39;, &#39;picked2&#39;, &#39;Cherry picked&#39;],<br>                    palette = [&#39;lightgrey&#39;, &#39;orange&#39;, &#39;purple&#39;, &#39;grey&#39;],<br>                    style = &#39;shape&#39;, <br>                    style_order = [&#39;picked3&#39;, &#39;picked4&#39;, &#39;not_important&#39;],<br>                    markers = [&#39;^&#39;, &#39;s&#39;, &#39;o&#39;], <br>                    size = &#39;baseMean&#39;, sizes = (40, 400),<br>                    )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*yuT2bPStbYXF0WOjxf4I4w.png" /></figure><blockquote>Zoomed in and well annotated plot</blockquote><pre>plt.figure(figsize = (6,6))<br>ax = sns.scatterplot(data = df, x = &#39;log2FoldChange&#39;, y = &#39;nlog10&#39;,<br>                    hue = &#39;color&#39;, hue_order = [&#39;Not significant&#39;, &#39;picked1&#39;, &#39;picked2&#39;, &#39;Cherry picked&#39;],<br>                    palette = [&#39;lightgrey&#39;, &#39;orange&#39;, &#39;purple&#39;, &#39;grey&#39;],<br>                    style = &#39;shape&#39;, <br>                    style_order = [&#39;picked3&#39;, &#39;picked4&#39;, &#39;not_important&#39;],<br>                    markers = [&#39;^&#39;, &#39;s&#39;, &#39;o&#39;], <br>                    size = &#39;baseMean&#39;, sizes = (40, 400))<br><br>ax.axhline(log10_threshold, zorder = 0, c = &#39;k&#39;, lw = 2, ls = &#39;--&#39;)<br>ax.axvline(log2_threshold, zorder = 0, c = &#39;k&#39;, lw = 2, ls = &#39;--&#39;)<br>ax.axvline(-log2_threshold, zorder = 0, c = &#39;k&#39;, lw = 2, ls = &#39;--&#39;)<br><br><br><br>## print texts for only very top genes<br>texts = []<br>for i in range(len(df)):<br>    if df.iloc[i].nlog10 &gt; 150 and abs(df.iloc[i].log2FoldChange) &gt; 6.5:<br>        texts.append(plt.text(x = df.iloc[i].log2FoldChange, y = df.iloc[i].nlog10, s = df.iloc[i].gene_name,<br>                             fontsize = 8, weight = &#39;bold&#39;))<br>        <br># adjust_text(texts, arrowprops = dict(arrowstyle = &#39;-&#39;, color = &#39;k&#39;))<br><br>plt.legend(loc = 1, bbox_to_anchor = (1.4,1), frameon = False, prop = {&#39;weight&#39;:&#39;bold&#39;})<br><br>for axis in [&#39;bottom&#39;, &#39;left&#39;]:<br>    ax.spines[axis].set_linewidth(2)<br>    <br>ax.spines[&#39;top&#39;].set_visible(False)<br>ax.spines[&#39;right&#39;].set_visible(False)<br><br>ax.tick_params(width = 2)<br>ax.set_xlim(-10, 10)<br>ax.set_ylim(100, 400)<br>plt.xticks(size = 12, weight = &#39;bold&#39;)<br>plt.yticks(size = 12, weight = &#39;bold&#39;)<br><br>plt.xlabel(&quot;$log_{2}$ fold change&quot;, size = 15)<br>plt.ylabel(&quot;-$log_{10}$ FDR&quot;, size = 15)<br>plt.title(&#39;Differential gene expression in TCGA-KIRC vs TCGA-KIRP&#39;, weight=&#39;bold&#39;, size = 15)<br>plt.savefig(&#39;volcano.png&#39;, dpi = 300, bbox_inches = &#39;tight&#39;, facecolor = &#39;white&#39;)<br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*_e5jEafK-bw4OytFRw4aww.png" /></figure><h3>CONCLUDING REMARKS:</h3><p>In this article, we have learnt have to use PyDeSeq quickly for analysis a real dataset available on NIH’s Genomic Data Commons (<a href="https://gdc.cancer.gov/developers/gdc-application-programming-interface-api">https://gdc.cancer.gov/developers/gdc-application-programming-interface-api</a>). Additionally, I’ve also provided exposure into how to structure your analysis, streamline your code and build open-source tools for bioinformatics related software.</p><h3>STAY TUNED:</h3><ul><li>Please leave a like if you found this useful, and reach out if you want to contribute to the <strong>OmixHub (</strong><a href="https://github.com/adhal007/OmixHub">https://github.com/adhal007/OmixHub</a>).</li><li>In the next article, I will showcase how OmixHub streamlines Data Operations for genomic data commons.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58bd40dd7f0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Anaconda on MacOS ventura 13.2.1 with HomeBrew and activating Conda]]></title>
            <link>https://medium.com/@adhal/setting-up-anaconda-on-macos-ventura-13-2-1-0de3baa81d52?source=rss-15ec57183590------2</link>
            <guid isPermaLink="false">https://medium.com/p/0de3baa81d52</guid>
            <category><![CDATA[anaconda]]></category>
            <category><![CDATA[zsh-shell]]></category>
            <category><![CDATA[environment]]></category>
            <dc:creator><![CDATA[Abhilash Dhal]]></dc:creator>
            <pubDate>Sun, 29 Oct 2023 08:54:24 GMT</pubDate>
            <atom:updated>2023-10-29T09:01:56.396Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>As of today October 29, 2023 all the following methods works, install the zsh with:</li></ol><pre>sh -c “$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)&quot;</pre><p>ON macOS ventura 13.2.1 or any other mac, the above download will activate zsh.</p><p>2. <strong>Anaconda Installation: </strong>You will need to run source /bin/activate followed by conda init zsh. For example: I installed anaconda python 3.11 Version using HomeBrew</p><pre>brew install - cask anaconda</pre><p>3. <strong>Check the path of anaconda3:</strong></p><p>Bash command to check the path:</p><pre>which python3</pre><p>On the macOS ventura 13.2.1, the path of anaconda3 based on homebrew install will be:</p><pre>/opt/homebrew/anaconda3/bin/python3</pre><p>4. Now source the /bin/activate in the anaconda3<br>example sources</p><pre>source /Users/my_username/opt/anaconda3/bin/activate</pre><p>5. Initialize conda in zsh</p><pre>conda init zsh</pre><p>6. Check if it is working</p><pre>conda list</pre><p>Output</p><pre># packages in environment at /opt/homebrew/anaconda3:<br>#<br># Name                    Version                   Build  Channel<br>_anaconda_depends         2023.09         py311_openblas_1  <br>abseil-cpp                20211102.0           hc377ac9_0  <br>aiobotocore               2.5.0           py311hca03da5_0  <br>aiofiles                  22.1.0          py311hca03da5_0  <br>aiohttp                   3.8.5           py311h80987f9_0  <br>aioitertools              0.7.1              pyhd3eb1b0_0  <br>aiosignal                 1.2.0              pyhd3eb1b0_0  <br>aiosqlite                 0.18.0          py311hca03da5_0  <br>alabaster                 0.7.12             pyhd3eb1b0_0  <br>anaconda-anon-usage       0.4.2           py311hd6b623d_0  <br>anaconda-catalogs         0.2.0           py311hca03da5_0  <br>anaconda-client           1.12.1          py311hca03da5_0  <br>...<br>zlib-ng                   2.0.7                h80987f9_0  <br>zope                      1.0             py311hca03da5_1  <br>zope.interface            5.4.0           py311h80987f9_0  <br>zstandard                 0.19.0          py311h80987f9_0  <br>zstd                      1.5.5                hd90d995_0  </pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0de3baa81d52" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>