{ "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_054113-laagd3z3" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run prep-intervals-mouse 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/laagd3z3" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "run = wandb.init(entity='grelu', project=project_name, job_type='preprocessing', name='prep-intervals-mouse',\n", " settings=wandb.Settings(\n", " program_relpath='data_mouse.ipynb',\n", " program_abspath='/code/github/gReLU-applications/borzoi/data_mouse.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/mm10/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
0chr14625717446453782fold0
1chr28351264183709249fold0
2chr71621835316414961fold0
\n", "
" ], "text/plain": [ " chrom start end fold\n", "0 chr1 46257174 46453782 fold0\n", "1 chr2 83512641 83709249 fold0\n", "2 chr7 16218353 16414961 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 36950\n", "val 6318\n", "test 6101\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
0chr14609333446617622fold0train
1chr28334880183873089fold0train
2chr71605451316578801fold0train
3chr3113560579114084867fold0train
4chr3107306300107830588fold0train
\n", "
" ], "text/plain": [ " chrom start end fold split\n", "0 chr1 46093334 46617622 fold0 train\n", "1 chr2 83348801 83873089 fold0 train\n", "2 chr7 16054513 16578801 fold0 train\n", "3 chr3 113560579 114084867 fold0 train\n", "4 chr3 107306300 107830588 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(\"mouse_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('mouse_intervals', type='dataset')\n", "artifact.add_file(local_path=\"mouse_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-mouse at: https://wandb.ai/grelu/borzoi/runs/laagd3z3
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_054113-laagd3z3/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 }