Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .changeset/per-cluster-centroid-dataset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@platforma-open/milaboratories.sequence-properties.workflow": patch
"@platforma-open/milaboratories.sequence-properties.model": patch
---

Add support for per-cluster centroid datasets (clonotype-clustering). The model accepts a 2-axis `[sampleId, centroidId]` anchor, and the workflow processes the synthetic per-cluster consensus sequence in peptide mode (the upstream "Export consensus sequences as a dataset" feature is peptide-only, so the centroid sequence column is a peptide amino-acid column).
10 changes: 10 additions & 0 deletions model/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ const inputAnchorSpecs = [
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }],
annotations: { "pl7.app/isAnchor": "true" },
},
// Per-cluster centroid dataset (clonotype-clustering). A clonotype-shaped 2-axis
// dataset where the row entity is a cluster: axis[0] = sampleId (real per-sample
// abundance anchor), axis[1] = "pl7.app/clustering/centroidId" (values = real
// clusterId) carrying the synthetic per-cluster centroid sequence. The dedicated
// centroidId axis (not the producer's plain clusterId) keeps anchoring here from
// pulling its clusters table's centroid_*/reference_centroid_* columns.
{
axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/clustering/centroidId" }],
annotations: { "pl7.app/isAnchor": "true" },
},
];

export const platforma = BlockModelV3.create(blockDataModel)
Expand Down
11 changes: 11 additions & 0 deletions workflow/src/main.tpl.tengo
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ detectMode := func(axisSpec) {
if axisSpec.name == "pl7.app/vdj/scClonotypeKey" {
return "antibody_tcr_legacy_sc"
}
// Per-cluster centroid dataset (clonotype-clustering): a synthetic 2-axis
// [sampleId, centroidId] anchor carrying one consensus sequence per cluster. The
// "Export consensus sequences as a dataset" feature is peptide-only (the producer
// gates the export on peptide inputs), so the centroid sequence column is a peptide
// aminoacid column (pl7.app/sequence, pl7.app/feature: "peptide") and the dataset is
// processed in peptide mode — the peptideSequences matcher in prepare() picks it up.
// NOTE: if VDJ/single-cell centroid export is ever re-enabled upstream, this must
// branch on the centroid sequence column's feature instead of assuming peptide.
if axisSpec.name == "pl7.app/clustering/centroidId" {
return "peptide"
}
Comment on lines +63 to +65

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Receptor detection fully deferred to sequence-column domains

Unlike pl7.app/vdj/cloneId / clonotypeKey, the centroidId axis domain carries no VDJ keys (pl7.app/vdj/receptor, pl7.app/vdj/chain), so resolveReceptor will always return seen: false from the axis-level check. Receptor is then determined solely by the d["pl7.app/vdj/chain"] lookup on each sequence column inside the for s in vdjCols loop. If the centroid sequence columns happen to omit that domain key — e.g. a bulk-clustering producer that does not propagate chain metadata — receptorSeen stays false, the default "IG" is used silently, and messages.receptorNotDetected() fires at line 323. The comment says "single-cell centroids still carry the chain domain on the sequence columns", so this is likely safe in practice, but a missing chain annotation on the centroid sequence columns would silently produce IG properties for what might be a TCR dataset.

Prompt To Fix With AI
This is a comment left during a code review.
Path: workflow/src/main.tpl.tengo
Line: 59-61

Comment:
**Receptor detection fully deferred to sequence-column domains**

Unlike `pl7.app/vdj/cloneId` / `clonotypeKey`, the `centroidId` axis domain carries no VDJ keys (`pl7.app/vdj/receptor`, `pl7.app/vdj/chain`), so `resolveReceptor` will always return `seen: false` from the axis-level check. Receptor is then determined solely by the `d["pl7.app/vdj/chain"]` lookup on each sequence column inside the `for s in vdjCols` loop. If the centroid sequence columns happen to omit that domain key — e.g. a bulk-clustering producer that does not propagate chain metadata — `receptorSeen` stays false, the default "IG" is used silently, and `messages.receptorNotDetected()` fires at line 323. The comment says "single-cell centroids still carry the chain domain on the sequence columns", so this is likely safe in practice, but a missing chain annotation on the centroid sequence columns would silently produce IG properties for what might be a TCR dataset.

How can I resolve this? If you propose a fix, please make it concise.

return ""
}

Expand Down
Loading