Utilities API reference#

For example downloads, see Example datasets API reference. The CyteBase catalog of cloud-hosted datasets is the separate cytebase package, documented at https://docs.nygen.io/CyteBase/.

Store and computation helpers#

cytearc.load_zarr(zarr_loc, mode, storage_options=None, *, source_storage_options=None)#

Open a Zarr group through the compatibility entry point.

Return type:

Group

cytearc.controlled_compute(arr, nthreads)#

Materialize a deferred array with a bounded thread count.

Return type:

ndarray

cytearc.read_gmt(path)#

Read gene sets from a tab-separated GMT file.

The first field is used as the source name, the second description field is ignored, and each remaining non-empty field becomes one target row. A UTF-8 byte order mark at the start of the file, which some editors write, is not part of the first source name.

Parameters:

path (str | PathLike[str]) – Path to a GMT file with at least three fields per non-empty line.

Return type:

DataFrame

Returns:

A DataFrame with source and target columns.

Memory budget refusals#

A call that would hold more than its memory budget at a step raises MemoryBudgetError, a MemoryError whose needed_bytes is the budget that passes the step, budget_bytes the budget and item the step (what a refusal names).

class cytearc.MemoryBudgetError(message, *, needed_bytes, budget_bytes, item)#

A step of a call would hold more memory than the call’s budget.

needed_bytes#

The bytes that the call holds at the step that was refused: what it held before and the step’s own charge. A budget of at least this many bytes lets the call pass that step, except where a count write’s producer hands it a batch beyond the producer’s reservation: that refusal names what the write would reserve with the batch.

budget_bytes#

The memory budget that the step would pass.

item#

What the step’s charge was for, such as "the cells' IDs".

Logging and progress#

CyteArc starts with INFO logs and progress enabled, without timestamps. Notebook sessions do not need an output setup call. For a batch pipeline, configure the independent settings once at startup:

cytearc.configure_output(progress=False, timestamps=True)

Arguments that are omitted retain their current values. configure_output is the primary runtime interface:

  • level controls CyteArc’s log severity.

  • progress controls progress bars, including compute_with_progress. Pipeline progress events are emitted either way (Analysis pipeline API reference).

  • timestamps controls timestamps in CyteArc’s installed log sink.

  • stdlib sends CyteArc’s records to the standard-library logger "cytearc" instead of stdout or the file that set_verbosity chose; stdlib=False restores that destination.

Progress is independent of log level. Setting a quiet level such as WARNING does not disable progress. Call configure_output(progress=False) to suppress progress bars. Interactive notebooks animate these bars. The documentation shows deterministic completed snapshots from the committed notebook cache instead of replaying an animation.

cytearc.configure_output(*, level=None, progress=None, timestamps=None, stdlib=None)#

Configure CyteArc’s logging and progress output.

Unspecified settings retain their current values. The level and timestamps apply to CyteArc’s own log sink, which shows only the records logged through cytearc.logger, so other code’s loguru output keeps its own handlers and levels.

Parameters:
  • level (str | None) – The lowest level that CyteArc’s sink shows, such as "WARNING".

  • progress (bool | None) – Whether to display progress bars. Pipeline progress events are emitted either way.

  • timestamps (bool | None) – Whether log lines start with a timestamp.

  • stdlib (bool | None) – True sends CyteArc’s records, at or above level, to the standard-library logger named "cytearc" instead of stdout or the file that set_verbosity chose, for an application that configures logging. A forwarded record keeps the details of the call that logged it: its module, pathname, lineno, and funcName, and loguru’s level name, such as SUCCESS, as its levelname. A record logged during a pipeline stage carries the run and stage as its cytearc_run_id and cytearc_stage attributes. False restores the stdout sink, or the file that set_verbosity chose.

Return type:

None

cytearc.set_verbosity(level=None, filepath=None)#

Set CyteArc’s logging level and optional output file.

Like configure_output(), this changes only CyteArc’s own sink. It selects stdout or the file, so it also ends a stdlib bridge.

Return type:

None

set_verbosity(level=..., filepath=...) remains the interface for selecting a log level and optional file destination. Use it when a durable batch log is needed; use configure_output for ordinary notebook and console behavior.

An application that configures the standard library’s logging, such as a web service, can receive CyteArc’s records there:

import logging

logging.basicConfig(level=logging.INFO)
cytearc.configure_output(stdlib=True)

With stdlib=True, CyteArc’s sink forwards each of its records at or above level to the standard-library logger named "cytearc", instead of writing it to stdout or to the file that set_verbosity chose. A forwarded record keeps the details of the call that logged it: its level number, loguru’s level name as levelname, such as SUCCESS or TRACE, its message and exception, and the module, pathname, lineno, and funcName of that call. The standard-library handlers then choose the format and destination, so timestamps has no effect. A record logged during a pipeline stage carries the run’s ID and the stage as the attributes cytearc_run_id and cytearc_stage, which the handlers and filters of the "cytearc" logger can read, such as with the format "%(cytearc_stage)s %(message)s"; other forwarded records carry None in both. Handlers that an application adds to loguru find the same values in a record’s extra mapping. configure_output(stdlib=False) restores the stdout sink, or the file that set_verbosity(filepath=...) chose, and set_verbosity() also ends the bridge, because it selects stdout or a file. Importing CyteArc does not change the standard-library logging configuration.

CyteArc’s sink shows only the records that CyteArc logs, and configure_output and set_verbosity change only that sink, so an application or library that also logs with loguru keeps its own handlers, levels, and formats. Loguru prints every record on stderr through its default handler until an application removes that handler; while it is still installed, importing CyteArc’s logging replaces it with a handler of the same sink and settings, including LOGURU_LEVEL, LOGURU_FORMAT, and LOGURU_FILTER, that leaves out CyteArc’s records, which CyteArc’s sink already shows. Handlers that an application added receive CyteArc’s records as well.

cytearc.logger#

CyteArc’s loguru logger, bound to mark each record that it logs. Library code logs through this object, so cytearc.configure_output() controls the CyteArc-owned sink while preserving sinks added by callers.

cytearc.tqdmbar(*args, **kwargs)#

Create a progress bar using CyteArc’s display defaults.

In a context that observes progress (see observe_progress), the bar also reports its updates, even when bars are not displayed.

Return type:

Any

cytearc.tqdm_params#

Default keyword arguments applied by cytearc.tqdmbar(), including bar format, dynamic width, and color. Override any of them per call.

cytearc.compute_with_progress(arr, msg=None, nthreads=1)#

Materialize a deferred array while reporting progress.

Return type:

ndarray

Array helpers#

These operate on plain arrays and are used by CyteArc’s own embeddings, graph construction, trajectory dynamics, and merge code.

cytearc.clean_array(x, fill_val=0)#

Replace non-finite and zero values in a numeric array.

Return type:

NDArray[Any]

cytearc.rescale_array(a, frac=0.9)#

Trim extreme values using a fitted normal distribution.

Return type:

ndarray

cytearc.rolling_window(a, w)#

Apply a centered rolling mean along the first axis.

Return type:

ndarray

cytearc.permute_into_chunks(size, chunk_size, seed=42)#

Split sequential indices into independently permuted chunks.

Return type:

list[ndarray]