Skip to content

MILAB-7420: Multisample CSV/TSV dataset type - #143

Merged
julenmendieta merged 8 commits into
mainfrom
julenmendieta/MILAB-7420_multiSampleTable
Nov 19, 2026
Merged

julenmendieta merged 8 commits into
mainfrom
julenmendieta/MILAB-7420_multiSampleTable

Conversation

@julenmendieta

@julenmendieta julenmendieta commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Adds a "Multisample CSV/TSV" dataset type for long tables that hold all samples in one file, with one column naming the sample (MILAB-7420: peptide count tables, later other preprocessed long tables). Each distinct value of that column becomes a Samples & Data sample that can carry metadata, and the dataset exports a group-to-sample mapping so an import block can put each sample's rows on the S&D sample axis.

What changes

  • New type MultiSampleXsv (kind minor): one CSV/TSV file per group (.gz supported) and a required sampleColumnName.
  • Prerun: reads each file's header for the sample-column picker, and the distinct values of the chosen column via ptabler: read as text (01 and 1 are two samples), empty and whitespace-only values skipped, sorted, at most 3000 per file (more fails with a message naming the column and file).
  • Export: pl7.app/sequencing/data/sampleGroups on [sampleGroupId, sampleId], value = the sample's value in the file, for this type only. Data is the PColumnData/Json payload {keyLength: 2, data}, canonically encoded. Not marked as a linker (pl7.app/isLinkerColumn), since a sample can sit in several files. The group axis carries pl7.app/sampleColumnName, which tells these datasets apart from Bulk Count Matrix.
  • Model: BlockData V20261116 adds xsvFilesToPreprocess (import-dialog scaffolding, not part of the kind contract) with a migration; new output availableXsvColumns.
  • UI: import dialog with a sample-column picker (only columns every file has; fixed to the dataset's column when adding files), checks for mixed CSV/TSV and for a separator or compression unlike the dataset's; "Import samples"; a dataset page for the type.
  • Resources: plain-file header reads request a fixed 1 GiB (measured ~45 MiB up to 2 GB files); gzipped files and the values scan keep ptabler's size-based request (gzip is decompressed whole).
  • Build: SDK 1.90.x, block-tools 2.20.1, package-builder 3.18.0; PL_DOCKER_RELAYER=chunkah in the CI env input and turbo's build env.

For the design review

  • The export brings back the name and shape of the column removed in 221ec91, for the new type only. That commit's spec scoped the removal to Multiplexed FASTQ, and the existing consumer (import-sc-rnaseq-data) still reads this column, so other grouped types can join later without a new name.
  • Grouped types other than this one are unchanged: no column is added for Bulk Count Matrix, Multisample H5AD or Multisample Seurat in this PR.

Impact on existing users

  • Existing dataset types and their exports are unchanged, except:
  • "Import samples" now counts distinct sample names (it summed per-file counts) and shows the prerun's extraction error instead of a spinner that never ends (all grouped types).
  • The multiplexing rules column is written with canonical.encode instead of json.encode on a map: same content, fixed key order. Its bytes change once after the update, so FASTQ Demultiplexing downstream may recompute once.
  • The import dialog refuses mixed CSV/TSV files, and adding files whose separator or compression differs from the dataset's, for every CSV/TSV type (it used to close without creating anything, or accept them).
  • Projects saved with 2.14.0 open and re-run after the update (migration adds an empty xsvFilesToPreprocess).

Validation

  • pnpm check, Tengo unit tests 24/24, model 13/13, UI 88/88, block tests 11/11 (including two new prerun-refusal cases: more than 3000 values, and a sample column missing from a file).
  • Dev build on a remote server: two TSV files → picker → 5 samples (one shared by both files) → metadata → Run.
  • Upgrade check: a copy of a 2.14.0 project with a Multisample Seurat dataset, updated to this build: dataset and sample groups unchanged, re-run completes.
  • Memory of the two prerun ptabler jobs measured on 0.5–2 GB tables, plain and gzipped.
  • Not yet: a consumer reading the new export. The first one is the long-table path of Import V(D)J Data (MILAB-7420, next PR there).

Known limitations

  • Header names come back as polars renders them (duplicate names as name_duplicated_0).
  • A gzipped file is decompressed whole in the prerun.
  • block-tools structure refresh (and pnpm upgrade-sdk) removes the two PL_DOCKER_RELAYER edits, since block-tools 2.20.1's templates don't include it; the software images get the new layering at their next release.
  • Wide tables (one count column per sample) are not covered.

Follow-ups

  • import-sc-rnaseq-data fails on multi-sample H5AD/Seurat datasets of current S&D (it asks for the column removed in 221ec91); confirmed by a run. Fix in a separate PR: emit this column for those types too.

RetriggerView in GreptileConfidence Score: 3/5

Fix the two sample-label issues before merging so valid input names cannot lose or corrupt samples.

Fix All in Claude CodeFindings

  1. P1 Generated labels lose samples ▶
  2. P1 Special name corrupts sample labels ▶
Fix with agent prompt
### Issue 1
ui/src/dialogs/datasets.ts:260-261
**Generated labels lose samples.** If `plate1` contains `A` and `A (plate1)`, and another file also contains `A`, both values in `plate1` get the label `A (plate1)`. `getOrCreateSample` returns the same ID for both, so `mapping[sampleId] = value` overwrites one value. The saved mapping then omits a sample, and importing again cannot repair it.

Make generated labels collision-safe and prevent two distinct values in one file from receiving the same sample ID.

### Issue 2
ui/src/dialogs/datasets.ts:220-223
**Special name corrupts sample labels.** A valid sample value of `__proto__` cannot be stored by assigning a string to that key on `{}`. No own entry is created, and the later lookup returns `Object.prototype` instead of a string. `assignMultiSampleXsvSamples` passes that object to `getOrCreateSample`, which saves it in `sampleLabels` as the sample's name. The displayed count also omits this value.

Use a `Map` or an object without a prototype for the value-to-label lookup.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds Multisample CSV/TSV datasets, with sample-column selection, sample extraction, and exports that connect each file to its samples. The latest update gives repeated values separate samples per file while keeping existing sample IDs.

Important touched types:

  • Long CSV and TSV tables can now create samples from a column.
  • Multisample CSV/TSV datasets export each file’s sample values by group and sample.
  • Sample imports count distinct names and show extraction errors.
  • Builds use updated SDK tools and a package-based image relayer.

Previous threads: the old-mapping replacement issue is fixed. julenmendieta accepted the quoted-newline heading limitation because that input is very unlikely. The empty-replacement thread was manually resolved without explanation.

Reviews (3) · Last reviewed commit: "Review changes. Don't handle same label ..." · Reviewed by Greptile

New dataset type MultiSampleXsv: long CSV/TSV files (one per group, .gz supported) where one column names the samples.

- Prerun reads each file's header for the sample-column picker and the distinct values of the chosen column via ptabler (as text; empty and whitespace-only values skipped; at most 3000 per file)
- "Import samples" creates one sample per distinct value
- Export pl7.app/sequencing/data/sampleGroups on [sampleGroupId, sampleId] (value = the sample's value in the file), for this type only; group axis annotated with pl7.app/sampleColumnName
- BlockData V20261116 adds xsvFilesToPreprocess (dialog scaffolding)
- Import dialog: column picker offers columns every file has; refuses mixed csv/tsv, and a separator or compression unlike the dataset's
- Dataset page for the new type
- Tengo unit tests (header/value parsing, mapping column) and a block test with synthetic tables

Also affects existing types:
- "Import samples" counts distinct sample names and shows extraction errors instead of spinning
- multiplexingRules column data written with canonical.encode
- Tengo: exact bytes of the {keyLength, data} payload; no column before samples are imported
- Block: whitespace-only sample values skipped; more than 3000 values and a missing sample column fail the sampleGroups output
@julenmendieta

Copy link
Copy Markdown
Contributor Author

@greptileai review

Comment thread workflow/src/xsv-parse.lib.tengo Resolved
Comment thread ui/src/dialogs/SyncDatasetDialog.vue Resolved
Comment thread ui/src/dialogs/datasets.ts Resolved
Comment thread ui/src/dialogs/datasets.ts Resolved
@julenmendieta
julenmendieta added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit c4b6711 Nov 19, 2026
12 checks passed
@julenmendieta
julenmendieta deleted the julenmendieta/MILAB-7420_multiSampleTable branch November 19, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants