-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add CLI tool and Claude Code /zarr skill #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "cell-explorer", | ||
| "description": "Tools for querying cBioPortal cell-level zarr (AnnData) datasets", | ||
| "author": { | ||
| "name": "cBioPortal" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "name": "@cbioportal-cell-explorer/cli", | ||
| "version": "0.1.0", | ||
| "type": "module", | ||
| "bin": { | ||
| "cbioportal-cell-explorer": "./src/main.ts" | ||
| }, | ||
| "exports": "./src/main.ts", | ||
| "scripts": { | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@cbioportal-cell-explorer/zarrstore": "workspace:*", | ||
| "@petamoriken/float16": "^3.9.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^25.3.3", | ||
| "tsx": "^4.21.0", | ||
| "typescript": "^5.9.3" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,80 @@ | ||||||||||||||||||||||||
| import { parseArgs } from "node:util"; | ||||||||||||||||||||||||
| import type { GlobalOpts } from "../util/args.ts"; | ||||||||||||||||||||||||
| import { openStore } from "../util/args.ts"; | ||||||||||||||||||||||||
| import { printTable, printJson } from "../util/format.ts"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export async function embedding(opts: GlobalOpts): Promise<void> { | ||||||||||||||||||||||||
| const { values, positionals } = parseArgs({ | ||||||||||||||||||||||||
| args: opts.rest, | ||||||||||||||||||||||||
| options: { | ||||||||||||||||||||||||
| url: { type: "string" }, | ||||||||||||||||||||||||
| json: { type: "boolean" }, | ||||||||||||||||||||||||
| help: { type: "boolean", short: "h" }, | ||||||||||||||||||||||||
| limit: { type: "string", short: "n" }, | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| allowPositionals: true, | ||||||||||||||||||||||||
| strict: false, | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const key = positionals[0]; | ||||||||||||||||||||||||
| const limit = values.limit ? parseInt(values.limit as string, 10) : undefined; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| const limit = values.limit ? parseInt(values.limit as string, 10) : undefined; | |
| const rawLimit = values.limit as string | undefined; | |
| let limit: number | undefined; | |
| if (rawLimit !== undefined) { | |
| const parsed = Number.parseInt(rawLimit, 10); | |
| if (!Number.isFinite(parsed) || parsed <= 0) { | |
| console.error("`--limit` must be a positive integer."); | |
| process.exit(1); | |
| } | |
| limit = parsed; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,94 @@ | ||||||
| import { parseArgs } from "node:util"; | ||||||
| import type { GlobalOpts } from "../util/args.ts"; | ||||||
| import { openStore } from "../util/args.ts"; | ||||||
| import { printTable, printJson, formatNumber } from "../util/format.ts"; | ||||||
| import { computeStats, computeGroupedStats } from "../util/stats.ts"; | ||||||
| import { resolveGeneName } from "../util/gene.ts"; | ||||||
|
|
||||||
| export async function expression(opts: GlobalOpts): Promise<void> { | ||||||
| const { values, positionals } = parseArgs({ | ||||||
| args: opts.rest, | ||||||
| options: { | ||||||
| url: { type: "string" }, | ||||||
| json: { type: "boolean" }, | ||||||
| help: { type: "boolean", short: "h" }, | ||||||
| "group-by": { type: "string", short: "g" }, | ||||||
| sort: { type: "string" }, | ||||||
| }, | ||||||
| allowPositionals: true, | ||||||
| strict: false, | ||||||
| }); | ||||||
|
|
||||||
| const geneInput = positionals[0]; | ||||||
| if (!geneInput) { | ||||||
| console.error("Usage: cell-explorer expression <gene> [--group-by <obs_column>]"); | ||||||
|
||||||
| console.error("Usage: cell-explorer expression <gene> [--group-by <obs_column>]"); | |
| console.error("Usage: cbioportal-cell-explorer expression <gene> [--group-by <obs_column>]"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import type { GlobalOpts } from "../util/args.ts"; | ||
| import { openStore } from "../util/args.ts"; | ||
| import { printJson } from "../util/format.ts"; | ||
|
|
||
| export async function info(opts: GlobalOpts): Promise<void> { | ||
| const adata = await openStore(opts.url); | ||
|
|
||
| const obsColumns = await adata.obsColumns(); | ||
| const varColumns = await adata.varColumns(); | ||
| const obsmKeys = adata.obsmKeys(); | ||
|
|
||
| if (opts.json) { | ||
| printJson({ | ||
| url: opts.url, | ||
| shape: adata.shape, | ||
| nObs: adata.nObs, | ||
| nVar: adata.nVar, | ||
| attrs: adata.attrs, | ||
| obsColumns, | ||
| varColumns, | ||
| obsmKeys, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| const urlName = opts.url.replace(/\/$/, "").split("/").pop() ?? opts.url; | ||
| console.log(`Dataset: ${urlName}`); | ||
| console.log(`Shape: ${adata.nObs.toLocaleString("en-US")} cells x ${adata.nVar.toLocaleString("en-US")} genes`); | ||
| console.log(); | ||
| console.log(`Obs columns (${obsColumns.length}):`); | ||
| console.log(` ${obsColumns.join(", ")}`); | ||
| console.log(); | ||
| console.log(`Var columns (${varColumns.length}):`); | ||
| console.log(` ${varColumns.join(", ")}`); | ||
| console.log(); | ||
| console.log(`Embeddings (${obsmKeys.length}):`); | ||
| console.log(` ${obsmKeys.length > 0 ? obsmKeys.join(", ") : "(none)"}`); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
binpoints directly at a TypeScript file (./src/main.ts) with a#!/usr/bin/env tsxshebang. When installed vianpx @cbioportal-cell-explorer/cli,tsxwon’t reliably be on the user’s PATH (devDependencies aren’t installed, and even a nested dependency’s bin typically isn’t exposed). To makenpx/global installs work, publish a JS entrypoint (e.g. build todist/and pointbin/exportsthere) or use a small JS shim that invokes an internal TS runner in a way that doesn’t depend ontsxbeing globally available.