Spaces:
Sleeping
Sleeping
Commit History
-
Clarify UniRef50 lookup histogram
600e4c0 -
Wire Twin UniRef50 FAISS lookup
554a3a8 -
Merge CRISPR lookup and unknown characterization
598817f -
Expand benchmark interpretation text
74cdf21 -
Avoid blocking Space tab load
94485fa -
Update CRISPR benchmark page
a3fb1da
-
Benchmark tab: add Cas-only Pfam-verified reference section
Adds a second benchmark block below the existing Cas+Acr mixed-reference results, using the 175-protein Cas-only reference built from UniProt Pfam-domain xrefs (scripts/analyses/crispr/build_cas_reference_pfam.py). Pfam-based fetch eliminates name-collision false positives that dogged the earlier reference (acriflavin resistance proteins matching AcrIF*, Type-III secretion HrpB matching broad PF09502, etc). Each family is pinned to a verified unique-to-that-family Pfam domain; coverage mixes SwissProt + TrEMBL annotation_score:5. Three panels: UMAP side-by-side, per-family silhouette, four-way aspect comparison + results table. Headline on Cas-only: - Twin-MF wins leave-one-out top-1 (0.874 vs ESM2 0.834, +0.04) and MRR (0.911 vs 0.887). Annotation-quality is better with Twin-MF. - Twin-BP leads 5-NN precision and AUC same-family by a hair. - ESM2 wins silhouette on this set because all 175 are Cas, so its narrow cosine range gives clean relative geometry; silhouette i…29d65cb -
Characterize: add ESM2-vs-Twin-MF signal-strength panel for unknowns
Before the 3-D UMAP gallery view, show a three-panel comparison of ESM2 and Twin-MF on the same 24 uncharacterised proteins: 1. Histogram of top-1 cosine similarities per method 2. Empirical "fraction of unknowns with top-1 cos >= x" (cumulative) 3. Verdict-confidence bucket counts (LOW/MEDIUM/HIGH) Answers directly how much more signal Twin-MF finds on real unknowns than ESM2 does. Plot generated by scripts/analyses/crispr/plot_ unknowns_distribution.py (reads data/unknown_proteins/results.json, re-runnable any time the gallery is rebuilt). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>9907e62 -
Characterize tab: pre-computed gallery of 24 uncharacterised proteins
Flip the tab around so the first thing a user sees is a curated gallery of 24 uncharacterised proteins we fetched from UniProt and ran through the pipeline -- phage hypotheticals (high prior for novel anti-CRISPRs) plus bacterial-hypothetical controls. Both ESM2 and genomenet-twin (MF) verdicts are pre-computed and shipped as a JSON (data/unknown_proteins/ results.json; rebuilt by scripts/analyses/crispr/precompute_unknowns.py). Gallery view: - Summary table (N 'Predicted' / any CRISPR signal per method). - Interactive 3-D Plotly UMAP overlaying the 84-protein CRISPR reference (coloured by family) with the 24 unknowns (coloured by verdict confidence, diamond markers). Hover shows protein id, name, organism, verdict, top-1 hit. - Full HTML table sorted by top-1 cosine descending; confidence pill, verdict text, top-hit family and score, UniProt link. - Method radio toggles both the plot and the table between Twin-MF and ESM2 baseline. Twin-MF flags substantially more…0f2135c -
Add Twin-MF embeddings + UMAP coords for Characterize tab (force past *.npy gitignore)
344 KB Twin-MF embeddings and 800 B x 2 UMAP coords for the CRISPR reference set. Required at runtime by the new Characterize tab. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>2540c3e -
Add Characterize tab: verdict + top-10 + UMAP placement for unknown proteins
New Space tab scoped to the core CRISPR-annotation use case: paste an unknown protein, get a verdict on likely identity plus visual placement on the reference UMAP. - Package Twin-MF CRISPR embeddings and pre-computed UMAP coords (ESM2 + Twin-MF) into the Space repo. - Extend _CRISPR_FILES to recognise Twin-MF alongside Twin-BP and ESM2. - Add get_crispr_umap(method) loader and _crispr_verdict() rule engine: * top_cos below threshold -> "Unlikely CRISPR-related" * top-10 family vote >= 60% -> "Predicted: {family}" (high/medium conf based on vote agreement and cosine margin) * group vote >= 70% -> "CRISPR-related Cas / anti-CRISPR; family unclear" * otherwise -> "mixed signal" with the top-3 family votes. - New Characterize tab UI: sequence textbox, method radio (Twin-MF default, ESM2 baseline alternative), output = verdict card + matplotlib UMAP scatter with query placed at softmax-weighted top-5 centroid + top-10 table with cosine bars. - Exposes /characterize API…70601c4 -
Benchmark: UMAP first, Twin-MF as primary, drop emojis, professional tone
- Reorder sections: UMAP now opens the tab (most visually compelling — AcrIF and other Acr families cluster clearly under Twin-MF where they overlap everything under ESM2). Then heatmap, then sub-cluster, then silhouette, then aspect comparison, then takeaways. - Switch the primary Twin variant shown in plots 1 (UMAP) and 2 (heatmap) and 3 (sub-cluster) from BP to MF, since MF is the more fitting aspect for CRISPR (Cas families = enzymatic function). The intro paragraph explains this choice up front. - Regenerate heatmap + sub-cluster + UMAP plots against Twin-MF. - Remove all emojis from the Benchmark tab. - Reword throughout for a more professional, less conversational tone (no "- ✅ ...", no **Surprising result**, no emoji-led bullets). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>4ecf210 -
Benchmark: replace ROC with silhouette; add URL-hash tab deep-linking
Silhouette score is a ratio-based clustering metric, unaffected by the compressed cosine-range issue that inflated ESM2's pairwise-cosine AUC. Replaces the ROC section with a silhouette analysis: model | mean silhouette ----------------+---------------- ESM2 baseline | +0.044 Twin-BP | +0.093 Twin-CC | +0.014 (*worse* than ESM2 — CC isn't useful for CRISPR) Twin-MF | +0.117 (best — ~3x over ESM2) Silhouette is the clearest single-number evidence that Twin-MF is the best aspect for CRISPR family-clustering, and exposes a useful negative result: training on cellular-component GO similarity actively degrades clustering for this task. Also adds a small JS hook on gr.Blocks that reads the URL hash or ?tab= query param on load and clicks the matching tab. Makes https://.../functional-distance#benchmark open directly on the Benchmark tab. Works for any tab name (distance, lookup, benchmark, api, about). Updates the takeaway bullets: drops the stal…cab3c9b -
Extend Benchmark tab: UMAP, ROC, and BP-vs-CC-vs-MF aspect comparison
Three new analyses packaged and wired into the Benchmark tab: 1. UMAP 2D projection (ESM2 left, Twin-BP right), coloured by CRISPR family, marker-shape by group (cas=circle, acr=triangle). Makes clustering visible at a glance. 2. ROC curves for two binary tasks: same-family pair prediction, and same-group (Cas vs Acr) prediction. Surfaces a counter-intuitive result honestly: ESM2 wins same-family AUC (0.85 vs 0.77) because its narrow cosine band avoids rank inversions; Twin's wider range does fine-grained discrimination that doesn't match coarse labels. 3. Compare all three Twin aspects (BP/CC/MF) + ESM2 on four metrics. Key finding: **Twin-MF wins on bulk structure** (within-vs-between separation = 0.37, best Cas-vs-Acr AUC = 0.68), while Twin-BP wins 5-NN retrieval purity. MF matches biological intuition (Cas families are defined by enzymatic function); BP matches the app's current default for retrieval use. Benchmark tab now explains the BP/CC/…019de53 -
Fix Benchmark tab crash: drop show_download_button (unsupported in this Gradio)
gr.Image doesn't accept show_download_button in the Gradio version the Space is pinned to. The plots still display; users can right-click-save if they need the raw PNG. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>3e6f698 -
Add Benchmark tab: CRISPR clustering comparison ESM2 vs Twin-BP
Package two plots + their CSVs (PNGs via git LFS) and wire a new Benchmark tab between Lookup and API: - data/benchmark/crispr_esm2_vs_twin_heatmap.png (all-vs-all heatmap) - data/benchmark/crispr_subcluster_comparison.png (per-family violins + kNN-purity bars) - data/benchmark/crispr_heatmap_stats.csv, crispr_knn_purity.csv Tab narrative walks through the two views, reports the +0.22 bulk cosine separation and the +0.05 global 5-NN purity, and interprets the AcrIIA "loss" as Twin correctly discriminating a heterogeneous label set. Takeaway section makes the case for using Twin in the app's CRISPR-annotation use case. Also adds *.png to LFS tracking (was missing from the default HF .gitattributes rules; HF Spaces requires binary files via LFS/xet). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>ac2224d -
Add crispr_reference/embeddings_esm2.npy (force past *.npy gitignore)
430 KB of ESM2 mean-pooled embeddings for the 85 CRISPR reference proteins. Required at runtime by the Lookup tab's ESM2 × CRISPR combo. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>525fe76 -
Add Method selector (ESM2 vs genomenet-twin) on Lookup tab
Package ESM2 embeddings of the 85-protein CRISPR reference (from the new build_reference_esm2.py script) alongside the Twin-BP ones. embeddings_esm2.npy is (85, 1280), ~430 KB. get_crispr_reference and search_crispr now take a `method` argument and cache per method. Lookup tab: two radios side-by-side. | method \ reference | UniRef50 | CRISPR curated | |--------------------|----------|----------------| | ESM2 baseline | FAISS | in-memory | | genomenet-twin BP | pending* | in-memory | *Twin × UniRef50 shows a "not yet available" message; the Step 4 SLURM array is running and will unlock that combo once the Twin UniRef50 embeddings + FAISS index are built. Examples rewritten to show the query × method × reference combo directly in each label (10 examples). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>46cf217 -
Lookup: drop k slider, fixed 25, stacked histogram with context pool
- Top-k is now fixed at 25 (no slider). - For UniRef50: fetch a larger pool of 500 top + 500 anti-correlated (no metadata; it's just cosine scores), display top-25 + bottom-25 with UniProt metadata fetched for those 50 only. Histogram shows all 1000 values: green = top-25, red = bottom-25, grey = the 475 + 475 context proteins. So you see where the displayed hits sit within the full distribution of similar and dissimilar proteins. - For CRISPR (N=85): compute all, show top/bottom-25 highlighted and the middle 35 in grey. - Improve UniParc fallback: for UniRef50_UPI* IDs that 404 on the uniref endpoint, fetch /uniparc/{UPI}.json and extract protein name + organism from the first RefSeq/EMBL cross-reference. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>2eb75a4 -
Drop the "available once Step 6 build completes" note in Lookup tab
The CRISPR reference is now packaged into the Space and fully wired into the handler, so the hedging note is stale. Also include the protein count (85) for context. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>ef93148 -
Add crispr_reference/embeddings.npy (force through *.npy gitignore)
344 KB of 85 x 1024 float32 Twin-BP embeddings needed at runtime by the Lookup tab's CRISPR option. Previously skipped by the *.npy rule in .gitignore. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>612f9f0 -
Wire CRISPR reference (Twin-BP) into the Lookup tab
Package the Step 6 outputs into the Space repo: - data/crispr_reference/embeddings.npy (85 x 1024, 344 KB) - data/crispr_reference/metadata.csv (acc, family, group, type, organism) - data/crispr_reference/manifest.json Add get_crispr_reference() (L2-normalizes once at load) and search_crispr() (numpy dot-product top/bottom-k). No FAISS needed at N=85 -- it's a sub-ms matmul. The Lookup tab's "CRISPR reference (Twin-BP)" radio option now works: embed query with Twin-BP, cosine search over the curated set, render top-k + bottom-k + histogram using the same visual style as UniRef50. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>7a5009b -
Lookup: show top-k AND bottom-k + SVG histogram; widen slider to 5-50
Top-k is ~free in FAISS (single search over nprobe cells ~= 48k vectors; sorting k is negligible). So for each query we now run two searches: - search(q, k) -> top-k most similar (cosine near +1) - search(-q, k) -> top-k most anti-corr. (cosine near -1 or 0) The handler renders both as tables (red->green gradient bar per row, marker position relative to the combined min/max so the two tables share a visual scale), plus a compact inline SVG histogram of the combined 2k cosines so you can see how the similar and dissimilar ends compare. Slider: 5-50 step 5, default 25. Examples keep the same sequences but now preset top/bottom-k = 25. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>7189017 -
Add CRISPR example queries to Lookup tab
Eight clickable examples covering the adaptation module (Cas1/2/3), the three major effector types (SpCas9/SaCas9, FnCas12a, LshCas13a), and an anti-CRISPR (AcrIIA4). Each loads the sequence and presets the UniRef50 index + top-10. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>b7457f1 -
Render Lookup hits with per-row similarity gradient bars + scale legend
Replace the Dataframe with an HTML table: each hit gets a mini red-yellow-green gradient bar (0 = dissimilar, 1 = identical cosine) with a black position marker, matching the visual convention of the Distance tab. The header also shows a small scale legend plus the top-k similarity range (e.g., "top-10: 0.847 - 0.978") so users can see how tightly clustered the hits are. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>30323bd -
Redesign Compare tab as Lookup; add UniRef metadata; update header
- Rename "Compare" to "Lookup" and strip it down: input sequence + reference-set radio (UniRef50 / CRISPR) + top-k + button -> single hits table. Heatmaps, stats bars, activation histogram, and .npy downloads are gone; users who need those should use the Distance tab or the API. - Add fetch_uniref_metadata() that calls the UniProt uniref endpoint to return "cluster name — organism — N members" for each hit. In- memory cache; 5 s timeout; benign fallback string on failure. The hits table now has a "description" column so users can see what each UniRef50 cluster actually is, not just the accession. - Update the app header to describe functional distance prediction rather than "compare protein embeddings". - Add requests to requirements.txt (explicit dep, for the metadata fetcher). - CRISPR reference option is exposed in the radio but the handler currently returns a "not yet available" message since the Step 6 SLURM build is queued. Co-Authored-By: Claude Opus 4.7…63e92bf -
Accept long sequences; truncate to ESM2 max len with visible note
Previously the hard 1022-aa cap in validate_protein rejected common CRISPR effectors (SpCas9 = 1368 aa, FnCas12a = 1300 aa, LshCas13a = 1389 aa) on both Compare and Distance tabs. Twin's custom tower and its ESM tokenizer already truncate internally; only fair-esm's batch_converter in embed_esm2 needed explicit truncation. Changes: - validate_protein no longer errors on sequences > 1022 aa - embed_esm2 truncates to ESM2_MAX_LEN = 1022 before batch_converter - Compare tab: blockquote note above the stats table when truncated - Distance tab: orange-bordered notice at the top of the result when either Protein A or B exceeded 1022 aa Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>b9b5e8a -
CRISPR-themed default sequences and example pairs on Distance tab
Replace the insulin/GFP/lysozyme example set with real Cas + Acr sequences fetched from UniProt: SpCas9 (Q99ZW2), SaCas9 (J7RUA5), Cas1/Cas2/Cas3 (E. coli), FnCas12a (A0Q7Q2), LshCas13a (P0DOC6), AcrIIA4 (A0A0E0UT28). New example pairs tell a CRISPR narrative: identical Cas9 -> orthologs -> adaptation partners -> different types -> different substrates -> anti-CRISPR vs target. Matches the intended application of the Twin model (annotating Cas and anti-CRISPR genes). Default Compare protein is now SpCas9; Distance tab defaults to SpCas9 vs SaCas9 (ortholog test). Cas9 family members are truncated from ~1350 aa to the ESM2 limit of 1022 aa; N-terminal region carries most of the signal. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>d8aac5e -
Swap cosine-similarity bar for cosine-distance for consistent direction
Both bars now go green (0 · identical) -> red (2 · opposite) so the marker interpretation is consistent between L2 and cosine. Raw cosine similarity is preserved as a footnote for reference. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>bb16e09 -
Add visual bars for L2 distance and cosine similarity
Instead of a plain numeric table, render each metric as a horizontal gradient bar with a position marker and axis labels. Green = similar, red = dissimilar; the black marker shows where the computed value falls on the 0-2 (L2) or -1-+1 (cos) scale. Easier to read at a glance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>36605ea -
Distance tab first, with example pairs and loading indicator
- Reorder tabs: Distance is now the default/first active tab (matches Space name). - Add 6 curated example pairs on Distance tab spanning identity to no relation (insulin/insulin, chicken/human lysozyme, insulin/IGF-1, insulin/ubiquitin, insulin/GFP, GFP/lysozyme). Click to populate inputs. - Two-stage click on Distance button: immediate "Computing..." message, then replaced by the result. Helps users see that a slow first-aspect load (~15 s) is in progress rather than a frozen UI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>217b9ee -
Add Distance tab for Twin pairwise distance prediction
New tab: two sequences + BP/CC/MF aspect radio -> L2 distance, cosine similarity, and cosine distance using the Twin model's native trained task (L2 on L2-normalized 1024-dim embeddings). Also exposes /distance API endpoint on the Space. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1b562b0 -
Re-add FAISS fallback so missing index doesn't break all panels
When the FAISS dataset repo is still being built (SLURM job 10263003 is populating it), search_faiss raises and Gradio reports "Error" on every output including embeddings and plots. Isolate the failure: catch it, put a single explanatory row in the hits table ("FAISS index not available" with the error message), and let the rest of the Compare tab render normally. Twin has no fallback since the checkpoint is now uploaded and working. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>69b3765 -
Switch Twin to aspect-specific checkpoints with runtime switcher
Replaced the old collapsed-training Twin checkpoint with the newer BP/CC/MF aspect-specific family (train_point_{ASPECT}_20251221_std_ft_bs32ga4), which has real dynamic range in its distance output (cos 0.59-0.96 vs old 0.999). - Three checkpoints hosted in one HF model repo: genomenet/twin-point-1024 - Added BP/CC/MF radio button to the Compare tab (default BP) - Lazy-load: only one aspect cached at a time (memory constraint on cpu-basic) - Each aspect checkpoint contains fine-tuned ESM2 backbone (~2.7 GB per file) - Twin output dim back to 1024 (these use projection_dim=512, unlike the old one) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>54f342f -
Fix Twin embedding dim: 1024 -> 512 (projection_dim=256 in checkpoint)
The "1024" in the run name aa_esm_resnik_1024_contrastive_padding refers to seq_len=1024, not embedding dim. The actual model_aa_best.pt checkpoint was trained with projection_dim=256, so the concat output is 2 * 256 = 512. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>10564c4 -
Remove Twin and FAISS fallbacks; let failures surface explicitly
The try/except wrappers around embed_twin and search_faiss hid real problems behind silent zero-vector / empty-table placeholders. With the Twin checkpoint uploaded and FAISS on the way, we want hard failures so broken dependencies are visible instead of masked. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>a23a826 -
Add FAISS nearest-neighbor search and real Twin model inference
- Add FAISS search over GO-annotated UniRef50 (hosted at genomenet/esm2-uniref50-faiss dataset repo, downloaded on startup) - Replace random Twin placeholder with real inference using the two-tower contrastive encoder (custom AA transformer + frozen ESM2 backbone), checkpoint hosted at genomenet/twin-aa-esm-resnik-1024 model repo - Add top-k slider + hits table to the Compare tab - Graceful fallback to zero vector if Twin checkpoint is not yet uploaded Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>3bd0354 -
Upload folder using huggingface_hub
Verified signature280e291 -
initial commit
Verified signature870bad3