{ "cells": [ { "cell_type": "markdown", "id": "c7451d98-b6f2-4d5f-b57f-c3a800d937c9", "metadata": {}, "source": [ "# Process and save Enformer genomic intervals" ] }, { "cell_type": "markdown", "id": "3b30b38e-fdd0-4c04-8b50-576e8f09dc30", "metadata": {}, "source": [ "## Set up wandb" ] }, { "cell_type": "code", "execution_count": 1, "id": "d374bd3d-c131-4086-ad8b-a9b8c01bd1e0", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[34m\u001b[1mwandb\u001b[0m: Using wandb-core as the SDK backend. Please refer to https://wandb.me/wandb-core for more information.\n", "\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33mavantikalal\u001b[0m (\u001b[33mgrelu\u001b[0m) to \u001b[32mhttps://api.wandb.ai\u001b[0m. Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n" ] } ], "source": [ "import wandb\n", "import pandas as pd\n", "\n", "wandb.login(host=\"https://api.wandb.ai\")\n", "project_name='enformer'" ] }, { "cell_type": "code", "execution_count": 2, "id": "b356a72f-628a-4fbb-9e95-df9c38d3bedf", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Tracking run with wandb version 0.19.7" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /code/github/gReLU-applications/enformer/wandb/run-20250305_234119-9gws7tjk" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run prep-intervals-human to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View project at https://wandb.ai/grelu/enformer" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run at https://wandb.ai/grelu/enformer/runs/9gws7tjk" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "run = wandb.init(entity='grelu', project=project_name, job_type='preprocessing', name='prep-intervals-human',\n", " settings=wandb.Settings(\n", " program_relpath='data_human.ipynb',\n", " program_abspath='/code/github/gReLU-applications/enformer/data_human.ipynb'\n", " ))" ] }, { "cell_type": "markdown", "id": "82818c93-972b-4426-9420-b8e1957b3d4e", "metadata": {}, "source": [ "## Load intervals" ] }, { "cell_type": "code", "execution_count": 3, "id": "e2c21829-cc9f-4c74-a3a2-376cc9c88851", "metadata": {}, "outputs": [], "source": [ "sequences_path = '/gstore/data/resbioai/grelu/enformer/sequences.bed'" ] }, { "cell_type": "code", "execution_count": 4, "id": "02bc916e-2322-4676-bc93-c0838384a0ce", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
chromstartendsplit
0chr189283861059458train
1chr4113630947113762019train
2chr111842772018558792train
\n", "
" ], "text/plain": [ " chrom start end split\n", "0 chr18 928386 1059458 train\n", "1 chr4 113630947 113762019 train\n", "2 chr11 18427720 18558792 train" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "intervals = pd.read_table(sequences_path, header=None)\n", "intervals.columns = ['chrom', 'start', 'end', 'split']\n", "intervals.head(3)" ] }, { "cell_type": "markdown", "id": "01824d66-4434-400a-a030-16d9237efde1", "metadata": {}, "source": [ "## Resize intervals" ] }, { "cell_type": "code", "execution_count": 5, "id": "f7915dc8-2cca-427a-918d-8bf12a995ec5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/conda/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
chromstartendsplit
0chr188956181092226train
1chr4113598179113794787train
2chr111839495218591560train
3chr168577291385969521train
4chr3158353420158550028train
\n", "
" ], "text/plain": [ " chrom start end split\n", "0 chr18 895618 1092226 train\n", "1 chr4 113598179 113794787 train\n", "2 chr11 18394952 18591560 train\n", "3 chr16 85772913 85969521 train\n", "4 chr3 158353420 158550028 train" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from grelu.sequence.utils import resize\n", "intervals = resize(intervals, 196608)\n", "intervals.head()" ] }, { "cell_type": "markdown", "id": "2b079e2e-8ad5-4cac-808a-3f6ab84e1bb3", "metadata": {}, "source": [ "## Save" ] }, { "cell_type": "code", "execution_count": 6, "id": "2f0b7a9f-3760-4ae1-8ef3-cee84090a41f", "metadata": {}, "outputs": [], "source": [ "intervals.to_csv(\"human_intervals.tsv\", index=False, sep=\"\\t\")" ] }, { "cell_type": "code", "execution_count": 7, "id": "d5b7b1fd-7c09-498d-9fdf-53332321ae25", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "artifact = wandb.Artifact('human_intervals', type='dataset')\n", "artifact.add_file(local_path=\"human_intervals.tsv\", name=\"data.tsv\")\n", "run.log_artifact(artifact)" ] }, { "cell_type": "code", "execution_count": 8, "id": "bbfe1c93-c9fa-48e2-9291-5532597f761e", "metadata": {}, "outputs": [ { "data": { "text/html": [], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run prep-intervals-human at: https://wandb.ai/grelu/enformer/runs/9gws7tjk
View project at: https://wandb.ai/grelu/enformer
Synced 6 W&B file(s), 0 media file(s), 2 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20250305_234119-9gws7tjk/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "run.finish()" ] }, { "cell_type": "code", "execution_count": null, "id": "10041781-c2a0-44c0-b2db-388bc455645d", "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.11.9" } }, "nbformat": 4, "nbformat_minor": 5 }