sg-ingest
БесплатноБез исполняемых скриптовНе проверенLoad a Spatial Genomics (GenePS / sganalysis) data export into NimbusImage, one dataset per ROI: DAPI + GFP images, cell polygons, Leiden clusters as tags and…
от arjunrajlaboratory★ 22 звезды на GitHubОб этом скилле
NimbusImage — Spatial Genomics ingest
Runbook for a Spatial Genomics data export (sganalysis 0.9.x / sgimage 1.2.x)
via nimbusimage.sg (the sg extra) and the nimbusimage-sg command. Worked example: project Pav_PTR, 4 ROIs, 274-gene panel,
0.101547 µm/px:
| ROI | Cells | Spots | Image (px) | Zip bytes |
|---|---|---|---|---|
| roi_1 | 75,566 | 187.8M | 54,357 × 52,447 | 18.8 GB |
| roi_2 | 70,704 | 180.2M | 52,510 × 64,128 | 18.9 GB |
| roi_3 | 5,044 | 14.4M | 25,262 × 13,574 | 1.6 GB |
| roi_4 | 41,901 | 126.6M | 38,823 × 44,678 | 12.2 GB |
roi_3 timings for ingest (73 s in total): images 60 s (upload and transcode),
polygons 1 s, cell data 2 s, table under 1 s (2.6 MB), transcript store 7 s (277 MB)
plus 2 s to upload. check --recount takes 4 s.
Nothing on the server is specific to Spatial Genomics. The images, polygons,
properties, spatial table, Transcripts overlay, overview raster and Color by Property
are the ones Xenium uses. Read xenium-ingest §6–§9 for how those behave. What this
skill adds is reading the export and converting the transcript list.
pip install 'nimbusimage[sg]' # adds imagecodecs: the masks are zstd
export NI_API_URL=http://localhost:8080/api/v1 NI_API_KEY=... # or NI_USERNAME/NI_PASSWORD
SG=nimbusimage-sg
$SG inventory --export-dir extracted --count-spots # ROIs, cells, genes, spots
$SG check --export-dir extracted --roi roi_3 --recount # local; no server
$SG ingest --export-dir extracted --roi roi_3 --work-dir state/ # every step; prints the dataset id
Or step by step (--export-dir may be the project folder or any parent up to two
levels; the dataset id is the FOLDER id):
DS=$($SG images --export-dir X --roi roi_3 --name "Pav_PTR roi_3")
$SG polygons --export-dir X --roi roi_3 --dataset $DS --cells-out cells.npz
$SG cell-data --export-dir X --roi roi_3 --dataset $DS --cells cells.npz
$SG spatial-table --export-dir X --roi roi_3 --dataset $DS --cells cells.npz --out spatial.zarr.zip
$SG transcripts --export-dir X --roi roi_3 --dataset $DS --cells cells.npz --out transcripts.zarr.zip
$SG verify --export-dir X --roi roi_3 --dataset $DS --cells cells.npz
From Python:
import nimbusimage as ni
from nimbusimage import sg
roi = sg.SGRoi("extracted", "roi_3")
assert sg.check_frame(roi)["fraction"] == 1.0
ds = sg.upload_images(ni.connect(), roi, "Pav_PTR roi_3")
cells = sg.upload_polygons(ds, roi); cells.save("cells.npz")
sg.upload_cell_data(ds, roi, cells)
sg.upload_spatial_table(ds, sg.build_spatial_table(roi, cells, "spatial.zarr.zip"))
sg.register_transcripts(ds, cells, sg.build_transcript_store(roi, "transcripts.zarr.zip"))
The SGCellMap (cells.npz) records the label → annotation id map, the dataset, the
project and ROI, and the pixel size. Every later step refuses a map that belongs to
another dataset or ROI before it writes anything. register_transcripts also refuses
a store built from another ROI.
1. Export anatomy (per ROI)
<project>/basic_results/roi_N/
roi_N_Boundaries.geojson cell polygons, MICRONS, closed rings, id = label
roi_N_CellCoordinates.csv label, area (um^2), center_x, center_y (um)
roi_N_CellxGene.csv raw counts; rows = labels; one column per gene
roi_N_TranscriptList.csv name, x, y, z (um) — no quality, no cell id
roi_N_Segmentation.tiff uint32 cell-label mask, zstd tiles, pyramid
roi_N_DAPI.tiff duplicate of mini_project/.../dapi.tiff
<project>/mini_project/roi_N/
images/dapi.tiff, GFP_image.tiff OME-TIFF uint16, JPEG2000 tiles, pyramid
clusters/matrix_*_cells.h5ad obs leiden, area; obsm X_umap, X_pca; index = label
genes/<project>.hdf5 per-gene points in PIXELS + 467 UNUSED* controls
segmentations/*_{cells,nuclei}.tiff label masks (nuclei have no polygons)
sganalysis.session JSON: shape, res (= um/px)
The cell label is the join key in every file: the GeoJSON id, the CellxGene row,
the h5ad obs index and the mask value. Unzip one ROI at a time, for example
unzip <zip> '*/basic_results/roi_3/*' '*/mini_project/roi_3/*' -d extracted.
2. What each step writes
| Step | NimbusImage result |
|---|---|
images |
A dataset with one channel per file in images/, DAPI first, named from the file (GFP_image → GFP). It reuses the Xenium staging (c00-DAPI.ome.tif) and channel pinning. The JPEG2000 OME-TIFFs transcode without conversion. |
polygons |
px = µm / res, identity orientation, closing vertex dropped, tag cell, create_many batches of 5,000. |
cell-data |
Tags ["cell", "Leiden k"], where cell is whatever polygons --tags used (the map records it). Properties SG Area / area_um2, UMAP / x, y and Clustering / leiden. Values are replaced on a re-run. |
spatial-table |
AnnData zarr v2: raw counts as CSC X plus layers/X_csr. obs has annotation_id, cell_index (= label), cell_type ("Leiden k") and `l |
Установить sg-ingest в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sg-ingest?
Load a Spatial Genomics (GenePS / sganalysis) data export into NimbusImage, one dataset per ROI: DAPI + GFP images, cell polygons, Leiden clusters as tags and a numeric property, UMAP, cell area, the full cell x gene matrix as a spatial table, and the transcript list as a Transcripts overlay. Use when the user mentions Spatial Genomics, GenePS, sganalysis, a DataExport_* zip, basic_results/roi_N, CellxGene.csv, TranscriptList.csv, Boundaries.geojson, or sganalysis.session. Complements xenium-ingest (same server machinery, different inputs).
Как установить скилл sg-ingest?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sg-ingest запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic