Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8f86c6f
progress capture
MikeLippincott Jun 8, 2026
ac290a9
progress capture
MikeLippincott Jun 9, 2026
d1c3ee2
add new webapp
MikeLippincott Jun 9, 2026
fa10bfa
add new webapp
MikeLippincott Jun 9, 2026
602836d
add limitors
MikeLippincott Jun 9, 2026
df7e22e
track file
MikeLippincott Jun 9, 2026
1742338
adding new
MikeLippincott Jun 9, 2026
4a32650
add new site
MikeLippincott Jun 9, 2026
8c8cf60
fix crashing by adding caching
MikeLippincott Jun 9, 2026
905b43d
fix app startup crash caused by loading large data at import time
gwaybio Jun 10, 2026
c06f75e
adding webapp page fixes
MikeLippincott Jun 18, 2026
77d41bf
resolve merge conflict in app.py
gwaybio Jun 19, 2026
bc1b511
remove large data files from LFS, gitignore CRISPR files
gwaybio Jun 19, 2026
4688235
revert 0.data-download changes; clean up webapp dead code
gwaybio Jun 19, 2026
d20ef8a
remove stale download_data.sh from 0.data-download
gwaybio Jun 19, 2026
c01664f
webapp gardening: clean deps, lint, update README, remove Justfile
gwaybio Jun 19, 2026
670f0e1
make webapp self-contained and HF Spaces ready
gwaybio Jun 19, 2026
f9ffaa8
add .hfignore and update README frontmatter for HF Spaces Docker/Stre…
gwaybio Jun 19, 2026
9830a3c
add HF Spaces update instructions to README
gwaybio Jun 19, 2026
c28a170
Add Dockerfile and README for HF Spaces Docker deployment
gwaybio Jun 19, 2026
a7d63b9
Add HF Spaces badge to root README
gwaybio Jun 19, 2026
d148713
Add GitHub Action to auto-deploy webapp to HF Spaces on main
gwaybio Jun 19, 2026
b84b9f4
Update READMEs to document auto-deploy via GitHub Actions
gwaybio Jun 19, 2026
df8ddd4
minor tweaks
gwaybio Jun 19, 2026
bae50c0
Remove requirements.txt — pyproject.toml + uv.lock are authoritative
gwaybio Jun 19, 2026
3562730
Move preprocessing.ipynb to 5.drug-dependency as notebook 9
gwaybio Jun 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .gitattributes
Empty file.
33 changes: 33 additions & 0 deletions .github/workflows/deploy-space.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy to HF Spaces

on:
push:
branches: [main]
paths:
- "9.webapp/**"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: Install huggingface_hub
run: pip install huggingface_hub

- name: Push to HF Spaces
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
cd 9.webapp
hf upload WayScience/gene-dependency-explorer . . \
--repo-type space \
--exclude ".venv/**" \
--exclude "**/__pycache__/**" \
--exclude "**/*.pyc" \
--exclude "**/*.egg-info/**" \
--exclude "data/CRISPRGeneEffect.parquet" \
--exclude "data/CRISPR_gene_dictionary.parquet" \
--commit-message "deploy from ${{ github.sha }}"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
__pycache__
2.train-VAE/parameter_sweep
.DS_Store
9.webapp/gene_dependency_webapp.egg-info
9.webapp/data/CRISPRGeneEffect.parquet
9.webapp/data/CRISPR_gene_dictionary.parquet
*.pyc
64 changes: 64 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
repos:
- repo: https://gitlab.com/vojko.pribudic.foss/pre-commit-update
rev: v0.9.0 # Insert the latest tag here

hooks:
- id: pre-commit-update
args: [--exclude, black, --keep, isort]
# Formats import order
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black", "--filter-files"]

#Code formatter for both python files and jupyter notebooks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider running precommit on this file (and all other files in this repo) as well

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.17
hooks:
# Run the formatter.
- id: ruff-format

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa-isort
additional_dependencies: [isort==5.6.4]
args: [--profile=black]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
hooks:
- id: prettier
types_or: [markdown, yaml, json, html, css, python, r]

- repo: https://github.com/hadialqattan/pycln
rev: v2.6.0
hooks:
- id: pycln
args: [--config=pyproject.toml]
exclude: |
(?x)^(
2\.segment_images/scripts/.*\.py$|
3\.cellprofiling/scripts/.*\.py$
)$
# additional hooks found with in the pre-commit lib
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace # removes trailing white spaces
- id: mixed-line-ending # removes mixed end of line
args:
- --fix=lf

- repo: local
hooks:
- id: shellcheck
name: shellcheck
description: Test shell scripts with shellcheck
entry: shellcheck
language: python
types: [shell]
require_serial: true # shellcheck can detect sourcing this way
238 changes: 238 additions & 0 deletions 5.drug-dependency/9.precompute_webapp_pca_embeddings.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "notice-cell",
"metadata": {},
"source": [
"# Precompute PCA Embeddings for Webapp\n",
"\n",
"> **Note:** This notebook was a one-time preprocessing step run to generate the pre-computed PCA\n",
"> parquet files bundled with the `9.webapp/` Streamlit app. It is **not intended to be re-run**\n",
"> without modification.\n",
">\n",
"> The helper functions below (`load_model_data`, `single_load_data`, `latent_load_data`) were\n",
"> originally defined in `9.webapp/app_utils.py` but were removed from the app once the pre-computed\n",
"> parquets replaced runtime PCA computation. They are reproduced here for provenance.\n",
">\n",
"> **Dependencies that are no longer in the webapp environment:**\n",
"> - `CRISPRGeneEffect.parquet` and `CRISPR_gene_dictionary.parquet` (large gitignored DepMap files\n",
"> — download via `0.data-download/` first)\n",
"> - `sklearn` (`scikit-learn`) — not in `9.webapp/pyproject.toml`\n",
">\n",
"> **Outputs** (written to `9.webapp/data/`):\n",
"> - `pca_embeddings_single_dependencies.parquet`\n",
"> - `pca_embeddings_latent_reactome.parquet`\n",
"> - `pca_embeddings_latent_corum.parquet`\n",
"> - `pca_embeddings_latent_drug.parquet`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6c08a8f0",
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import pandas as pd\n",
"from sklearn.decomposition import PCA"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "paths-cell",
"metadata": {},
"outputs": [],
"source": [
"# Paths — run from repo root or adjust accordingly\n",
"REPO_ROOT = pathlib.Path().resolve().parent # goes up from 5.drug-dependency/ to repo root\n",
"WEBAPP_DIR = REPO_ROOT / \"9.webapp\"\n",
"DATA_DIR = WEBAPP_DIR / \"data\"\n",
"RESULTS_DIR = REPO_ROOT / \"5.drug-dependency\" / \"results\"\n",
"\n",
"print(f\"Repo root: {REPO_ROOT}\")\n",
"print(f\"Webapp data: {DATA_DIR}\")\n",
"print(f\"Results dir: {RESULTS_DIR}\")"
]
},
{
"cell_type": "markdown",
"id": "helpers-header",
"metadata": {},
"source": [
"## Helper functions\n",
"\n",
"Originally from `9.webapp/app_utils.py`, reproduced here for provenance."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "load-model-data-cell",
"metadata": {},
"outputs": [],
"source": [
"def load_model_data(dependency_file, gene_dict_file):\n",
" \"\"\"Load and preprocess gene dependency data and gene dictionary.\"\"\"\n",
" dependency_df = pd.read_parquet(dependency_file)\n",
" print(dependency_df.shape)\n",
"\n",
" gene_dict_df = (\n",
" pd.read_parquet(gene_dict_file).query(\"qc_pass\").reset_index(drop=True)\n",
" )\n",
" gene_dict_df.entrez_id = gene_dict_df.entrez_id.astype(str)\n",
"\n",
" entrez_genes = [\n",
" x[1].strip(\")\").strip()\n",
" for x in dependency_df.iloc[:, 1:].columns.str.split(\"(\")\n",
" ]\n",
" entrez_intersection = list(\n",
" set(gene_dict_df.entrez_id).intersection(set(entrez_genes))\n",
" )\n",
" gene_dict_df = gene_dict_df.set_index(\"entrez_id\").reindex(entrez_intersection)\n",
"\n",
" dependency_df.columns = [\"ModelID\"] + entrez_genes\n",
" dependency_df = dependency_df.loc[:, [\"ModelID\"] + gene_dict_df.index.tolist()]\n",
" dependency_df.columns = [\"ModelID\"] + gene_dict_df.symbol_id.tolist()\n",
" dependency_df = dependency_df.dropna(axis=\"columns\")\n",
" return dependency_df, gene_dict_df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "single-load-cell",
"metadata": {},
"outputs": [],
"source": [
"def single_load_data():\n",
" \"\"\"Load CRISPR gene dependency scores merged with cell line metadata.\"\"\"\n",
" dependency_file = DATA_DIR / \"CRISPRGeneEffect.parquet\"\n",
" gene_dict_file = DATA_DIR / \"CRISPR_gene_dictionary.parquet\"\n",
" cancer_type_input_file = DATA_DIR / \"Model.parquet\"\n",
"\n",
" dependency_df, _ = load_model_data(dependency_file, gene_dict_file)\n",
" dependency_df = dependency_df.set_index(\"ModelID\")\n",
" cancer_type_df = pd.read_parquet(cancer_type_input_file)\n",
" combined_df = dependency_df.merge(\n",
" cancer_type_df[[\"ModelID\", \"OncotreePrimaryDisease\"]], on=\"ModelID\", how=\"left\"\n",
" )\n",
" return combined_df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "latent-load-cell",
"metadata": {},
"outputs": [],
"source": [
"def latent_load_data():\n",
" \"\"\"Load latent score parquets and pivot to wide format for PCA.\"\"\"\n",
" reactome_df = pd.read_parquet(RESULTS_DIR / \"all_reactome_results.parquet\")\n",
" corum_df = pd.read_parquet(RESULTS_DIR / \"all_corum_results.parquet\")\n",
" drug_df = pd.read_parquet(RESULTS_DIR / \"all_drug_results.parquet\")\n",
"\n",
" reactome_df[\"feature\"] = reactome_df[\"reactome_pathway\"]\n",
" reactome_df = reactome_df.drop(\n",
" columns=[\"model\", \"latent_dim_total\", \"init\", \"seed\", \"z\", \"reactome_pathway\"]\n",
" )\n",
" corum_df[\"feature\"] = corum_df[\"reactome_pathway\"]\n",
" corum_df = corum_df.drop(\n",
" columns=[\"model\", \"latent_dim_total\", \"init\", \"seed\", \"z\", \"reactome_pathway\"]\n",
" )\n",
" drug_df[\"feature\"] = drug_df[\"name\"]\n",
" drug_df = drug_df.drop(\n",
" columns=[\"model\", \"latent_dim_total\", \"init\", \"seed\", \"z\", \"name\"]\n",
" )\n",
"\n",
" meta_cols = [\"ModelID\", \"OncotreePrimaryDisease\"]\n",
" reactome_meta = reactome_df[meta_cols].drop_duplicates()\n",
" corum_meta = corum_df[meta_cols].drop_duplicates()\n",
" drug_meta = drug_df[meta_cols].drop_duplicates()\n",
"\n",
" reactome_matrix = reactome_df.pivot(\n",
" index=\"ModelID\", columns=\"feature\", values=\"latent_score\"\n",
" ).merge(reactome_meta, on=\"ModelID\", how=\"left\")\n",
" corum_matrix = corum_df.pivot(\n",
" index=\"ModelID\", columns=\"feature\", values=\"latent_score\"\n",
" ).merge(corum_meta, on=\"ModelID\", how=\"left\")\n",
" drug_matrix = drug_df.pivot(\n",
" index=\"ModelID\", columns=\"feature\", values=\"latent_score\"\n",
" ).merge(drug_meta, on=\"ModelID\", how=\"left\")\n",
"\n",
" return reactome_matrix, corum_matrix, drug_matrix"
]
},
{
"cell_type": "markdown",
"id": "pca-header",
"metadata": {},
"source": [
"## Compute and save PCA embeddings"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6cdc8f80",
"metadata": {},
"outputs": [],
"source": [
"def compute_pca(df, metadata_columns) -> pd.DataFrame:\n",
" print(df.shape[0], \"rows before dropping NA\")\n",
" df = df.dropna()\n",
" print(df.shape[0], \"rows after dropping NA\")\n",
" metadata_df = df[metadata_columns].copy()\n",
" feat_cols = df.columns.drop(metadata_columns)\n",
" if \"source\" in feat_cols:\n",
" feat_cols = feat_cols.drop(\"source\")\n",
" pca_input = df[feat_cols].apply(pd.to_numeric, errors=\"coerce\")\n",
" pca = PCA(n_components=2, random_state=0)\n",
" pca_embedding = pca.fit_transform(pca_input)\n",
" metadata_df[\"PCA1\"] = pca_embedding[:, 0]\n",
" metadata_df[\"PCA2\"] = pca_embedding[:, 1]\n",
" return metadata_df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "run-pca-cell",
"metadata": {},
"outputs": [],
"source": [
"combined_df = single_load_data()\n",
"reactome_matrix, corum_matrix, drug_matrix = latent_load_data()\n",
"\n",
"pca_single_df = compute_pca(combined_df, [\"ModelID\", \"OncotreePrimaryDisease\"])\n",
"pca_latent_reactome_df = compute_pca(reactome_matrix, [\"OncotreePrimaryDisease\", \"ModelID\"])\n",
"pca_latent_corum_df = compute_pca(corum_matrix, [\"OncotreePrimaryDisease\", \"ModelID\"])\n",
"pca_latent_drug_df = compute_pca(drug_matrix, [\"OncotreePrimaryDisease\", \"ModelID\"])\n",
"\n",
"pca_single_df.to_parquet(DATA_DIR / \"pca_embeddings_single_dependencies.parquet\")\n",
"pca_latent_reactome_df.to_parquet(DATA_DIR / \"pca_embeddings_latent_reactome.parquet\")\n",
"pca_latent_corum_df.to_parquet(DATA_DIR / \"pca_embeddings_latent_corum.parquet\")\n",
"pca_latent_drug_df.to_parquet(DATA_DIR / \"pca_embeddings_latent_drug.parquet\")\n",
"\n",
"print(\"Done — parquets written to\", DATA_DIR)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.12.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to run into conflicts when I merge my PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe! if the files are the same, then there should be no issue

Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions 9.webapp/.hfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.venv/
__pycache__/
*.pyc
*.egg-info/
.DS_Store
2 changes: 2 additions & 0 deletions 9.webapp/.streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[server]
fileWatcherType = "none"
18 changes: 18 additions & 0 deletions 9.webapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.12-slim

WORKDIR /app

COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev

COPY . .

EXPOSE 7860

CMD ["uv", "run", "streamlit", "run", "app.py", \
"--server.address", "0.0.0.0", \
"--server.port", "7860", \
"--server.headless", "true", \
"--server.fileWatcherType", "none"]
Loading