{ "cells": [ { "cell_type": "markdown", "id": "9233af61-78a9-45b7-a1c8-e882a780bffe", "metadata": {}, "source": [ "# Process and save Borzoi genomic intervals" ] }, { "cell_type": "markdown", "id": "759f57dc-ef72-46d4-8409-bd7963f72fbd", "metadata": {}, "source": [ "## Set up wandb" ] }, { "cell_type": "code", "execution_count": 1, "id": "63bd594d-3be6-482b-885a-bf273aca4733", "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='borzoi'" ] }, { "cell_type": "code", "execution_count": 2, "id": "01fd2d09-9580-4c78-a0b0-b57df4101eef", "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/borzoi/wandb/run-20250306_054006-tuf1j2g4" ], "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/borzoi" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run at https://wandb.ai/grelu/borzoi/runs/tuf1j2g4" ], "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/borzoi/data_human.ipynb'\n", " ))" ] }, { "cell_type": "markdown", "id": "c9a6badc-b835-4d38-b134-6661960be06f", "metadata": {}, "source": [ "## Load intervals" ] }, { "cell_type": "code", "execution_count": 3, "id": "f6c3dd12-4e0c-43f2-9daf-cd821c85e3ed", "metadata": {}, "outputs": [], "source": [ "intervals_path = '/gstore/data/resbioai/grelu/borzoi-data/hg38/sequences.bed'" ] }, { "cell_type": "code", "execution_count": 4, "id": "8a7a5189-3123-4926-8e75-cece1371ad9f", "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", "
chromstartendfold
0chr48252442182721029fold0
1chr131860479818801406fold0
2chr2189923408190120016fold0
\n", "
" ], "text/plain": [ " chrom start end fold\n", "0 chr4 82524421 82721029 fold0\n", "1 chr13 18604798 18801406 fold0\n", "2 chr2 189923408 190120016 fold0" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "intervals = pd.read_table(intervals_path, header=None)\n", "intervals.columns = ['chrom', 'start', 'end', 'fold']\n", "intervals.head(3)" ] }, { "cell_type": "code", "execution_count": 5, "id": "74efa465-b003-4a81-af6b-8511990ba1f1", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "split\n", "train 41699\n", "val 6910\n", "test 6888\n", "Name: count, dtype: int64" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "intervals['split'] = 'train'\n", "intervals.loc[intervals.fold=='fold3', 'split'] = 'test'\n", "intervals.loc[intervals.fold=='fold4', 'split'] = 'val'\n", "intervals.split.value_counts()" ] }, { "cell_type": "markdown", "id": "2dd99b47-a673-4213-a556-8fadb6b6feca", "metadata": {}, "source": [ "## Resize intervals" ] }, { "cell_type": "code", "execution_count": 6, "id": "bff3f031-c936-422c-9413-b50eedafb5b5", "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", " \n", " \n", " \n", " \n", " \n", " \n", "
chromstartendfoldsplit
0chr48236058182884869fold0train
1chr131844095818965246fold0train
2chr2189759568190283856fold0train
3chr105971190360236191fold0train
4chr1116945627117469915fold0train
\n", "
" ], "text/plain": [ " chrom start end fold split\n", "0 chr4 82360581 82884869 fold0 train\n", "1 chr13 18440958 18965246 fold0 train\n", "2 chr2 189759568 190283856 fold0 train\n", "3 chr10 59711903 60236191 fold0 train\n", "4 chr1 116945627 117469915 fold0 train" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from grelu.sequence.utils import resize\n", "intervals = resize(intervals, 524288)\n", "intervals.head()" ] }, { "cell_type": "markdown", "id": "e065a48d-5033-497d-81c4-d12a8dc33b29", "metadata": {}, "source": [ "## Save" ] }, { "cell_type": "code", "execution_count": 7, "id": "f419b288-dcd4-4076-842f-9211d33f449c", "metadata": {}, "outputs": [], "source": [ "intervals.to_csv(\"human_intervals.tsv\", index=False, sep=\"\\t\")" ] }, { "cell_type": "code", "execution_count": 8, "id": "47205dbe-d0f6-4db2-8df2-ad82e2189b84", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 8, "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": 9, "id": "9d13ced8-8755-4f20-acfb-cb59c5a1c5c2", "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/borzoi/runs/tuf1j2g4
View project at: https://wandb.ai/grelu/borzoi
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-20250306_054006-tuf1j2g4/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "run.finish()" ] }, { "cell_type": "code", "execution_count": null, "id": "c1c5c691-bfcf-4601-9c30-b14e2260be96", "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 }