{ "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_234301-of3e4sm1" ], "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/enformer" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run at https://wandb.ai/grelu/enformer/runs/of3e4sm1" ], "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/enformer/data_mouse.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-mouse.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
0chr43410664734237719train
1chr55220774752338819train
2chr192013686220267934train
\n", "
" ], "text/plain": [ " chrom start end split\n", "0 chr4 34106647 34237719 train\n", "1 chr5 52207747 52338819 train\n", "2 chr19 20136862 20267934 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
0chr43407387934270487train
1chr55217497952371587train
2chr192010409420300702train
3chr146181267162009279train
4chr1565595786756186train
\n", "
" ], "text/plain": [ " chrom start end split\n", "0 chr4 34073879 34270487 train\n", "1 chr5 52174979 52371587 train\n", "2 chr19 20104094 20300702 train\n", "3 chr14 61812671 62009279 train\n", "4 chr15 6559578 6756186 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(\"mouse_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('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": 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-mouse at: https://wandb.ai/grelu/enformer/runs/of3e4sm1
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_234301-of3e4sm1/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 }