Viewer classes (Jupyter objects you control from Python)#
Two classes share one viewer API:
Widget(alsocellucid.Widget): the notebook widgetshow_anndata()returns, shown in a cell’s output and reached through the notebook’s own connection;AnnDataViewer: the same API for a viewer in a browser tab of its own, served from this machine (a script, an SSH tunnel).
They are designed for two-way interaction:
Viewer → Python: hooks/events like
@viewer.on_selectionPython → Viewer: actions – every action of the viewer is a method, like
viewer.highlight_cells(...)– each a step of the viewer’s history
If you prefer a minimal interface, start with Jupyter (notebook embedding + hooks).
Fast path#
A) Any AnnData, in a notebook#
import cellucid
viewer = cellucid.Widget(
adata,
dataset_name="My study",
dataset_id="my-study-v1",
)
viewer # the cell's output shows it (show_anndata() shows it for you)
B) A Cellucid-ready AnnData (written by prepare()), in a browser tab#
from cellucid import AnnDataViewer
viewer = AnnDataViewer("my_study.h5ad") # names itself (uns['cellucid'])
print(viewer.viewer_url) # open it in a browser; in a notebook a link is shown
Practical path (what you can do with a viewer)#
1) Register hooks (viewer → Python)#
@viewer.on_selection
def on_selection(event):
cells = event.get("cells", [])
print("Selected", len(cells))
@viewer.on_ready
def on_ready(event):
print("Viewer ready:", event)
2) Drive the UI from Python (Python → viewer)#
Every action of the viewer – everything a person can do, and everything an agent reads – is a method, generated from the action catalogue (the full list):
viewer.color_by(field={"source": "obs", "key": "cell_type"})
viewer.highlight_cells(cells=[0, 1, 2], color="#00ff00")
viewer.camera_reset(view="live")
fields = viewer.fields_list() # a read
Each returns an ActionRequest without waiting for
the viewer; request.result() (in a notebook, in a later cell) is the
viewer’s answer – a read’s result, or a change’s outcome – and raises
ActionError with the viewer’s reason when it did
not apply the action. A refusal nobody collects is printed to sys.stderr
unless you take it over:
@viewer.on_command_error
def on_command_error(event):
print("Refused:", event["requestId"], event["reason"])
viewer.act(type, **params) sends any action named in data
(viewer.act("color.by", field=...)); cellucid.jupyter.action_catalog()
lists them all (Python → frontend actions).
3) Robust scripts: wait for readiness#
A browser-tab viewer answers while your code runs, so it can wait:
viewer.wait_for_ready(timeout=30)
(A notebook widget hears the viewer only between cells; there, use
@viewer.on_ready or read viewer.state.ready in a later cell — see
Jupyter (notebook embedding + hooks).)
4) Pull results, or capture a session#
summary = viewer.pull(adata) # highlights, labels, scores -> adata.obs
request = viewer.request_session()
session = request.result(timeout=60) # in a notebook: in the next cell
plan = session.apply(adata) # what applying the step shown would change
See Round trip (results back from the viewer, columns and gene sets into it) for the round trip, and Sessions (.cellucid-session files) for applying a session back to AnnData.
5) The history: turns, changes, sessions loaded#
with viewer.turn("Mark the T cells"): # one turn of the history, undone together
viewer.color_by(field={"source": "obs", "key": "cell_type"})
viewer.highlight_cells(cells=adata.obs["cell_type"] == "T cell", label="T cells")
@viewer.on_history_change
def on_history_change(event):
print(event["kind"], event["head"])
viewer.history.last_change # the latest change, or None
viewer.history_undo() # the history's actions are methods too
loading = viewer.load_session("analysis.cellucid-session")
A turn’s actions carry its id (python- and 12 hexadecimal digits) and
label; turns do not nest. viewer.history is a
LiveHistory: the latest history_changed event
and a hook on each; the history is changed through the generated history_*
methods. viewer.load_session(...) adds a session file’s trackers beside the
person’s own and returns a LoadSessionRequest
(loading.result() in a later cell:
{"tracker": {"id", "name"}, "head"}).
6) Read and change the data mapping#
viewer.mapping_set(
embeddings={
"enabled": [{"key": "X_tsne", "columns": [0, 1]}],
"defaults": {"1d": None, "2d": {"key": "X_tsne", "columns": [0, 1]}, "3d": None},
},
)
Nothing waits. mapping_set() (the mapping.set action) changes the groups
it names and leaves the others as they are (knn=None is “no neighbour
graph”; leaving knn out keeps the one shown). The viewer reports its
mapping once the dataset loads and again whenever it changes: the applied
mapping is viewer.data_mapping from a later cell; a mapping the viewer
refuses fails the request with the reason.
print(viewer.data_mapping["embeddings"]) # a later cell
Lifecycle and cleanup (important)#
Under the hood, a viewer starts a local server on a background thread of the kernel: on port 8765, or the next free port when 8765 is taken (a printed note says so).
Best practices:
If you create many viewers in a long-running notebook, call
viewer.stop()when done.If you repeatedly re-run a cell, you may end up with multiple servers unless the old viewer is stopped.
API reference#
Widget#
- class cellucid.jupyter.Widget(data, height=600, *, latent_key=None, gene_id_column=None, normalize_embeddings=None, centroid_min_points=None, dataset_name=None, dataset_id=None, obs_keys=None, embedding_keys=None, knn_key=None, expression_source=None, vector_field_default=None, modality=None, web_source_url='https://www.cellucid.com', cache_bytes=None)[source]#
Bases:
AnnDataViewer,AnyWidgetThe Cellucid viewer as a notebook widget.
The same viewer API as
AnnDataViewer– hooks (@viewer.on_selection,on_hover,on_click,on_ready, …),viewer.state, actions (one method per action of the catalogue:color_by,highlight_cells,history_get, …;act), sessions – shown in a notebook cell’s output and reached through the notebook’s own connection: no port, proxy or server address, so it works in JupyterLab, Jupyter Notebook 7, VS Code, Google Colab, marimo and Databricks alike.show_anndata()creates one and shows it; aWidgetmade directly is shown by making it a cell’s output.The page is the Cellucid app at
web_source_url(https://www.cellucid.com by default), loaded by the browser; the dataset never leaves this kernel except to that page, through the widget.The viewer’s messages reach Python between cells, as every notebook widget’s do. So, in the cell that asks:
wait_for_ready()andwait_for_event()cannot wait for the viewer and raise at once with what to do instead;request_session()asks now, and itsresult()(orapply_session_to_anndata(adata, request)) collects the session in a later cell;hooks run, and
viewer.stateupdates, whenever the kernel is idle;actions (
color_by,highlight_cells,pushand the rest) wait for nothing: they go as soon as the viewer can take them, and the request each returns is collected withresult()in a later cell.
Example:
viewer = cellucid.Widget(adata) viewer # the cell's output shows the viewer @viewer.on_selection def handle(event): print(len(event["cells"]))
- Parameters:
data (str | Path | anndata.AnnData | mudata.MuData)
height (int)
latent_key (str | None)
gene_id_column (str | None)
normalize_embeddings (bool | None)
centroid_min_points (int | None)
dataset_name (str | None)
dataset_id (str | None)
obs_keys (Sequence[str] | None)
embedding_keys (Mapping[str, EmbeddingKeySpec] | None)
knn_key (str | None)
expression_source (str | None)
vector_field_default (str | None)
modality (str | None)
web_source_url (str)
cache_bytes (int | None)
- height#
Height of the viewer in pixels.
- web_source_url#
Where the browser loads the Cellucid app from.
- __init__(data, height=600, *, latent_key=None, gene_id_column=None, normalize_embeddings=None, centroid_min_points=None, dataset_name=None, dataset_id=None, obs_keys=None, embedding_keys=None, knn_key=None, expression_source=None, vector_field_default=None, modality=None, web_source_url='https://www.cellucid.com', cache_bytes=None)[source]#
Prepare the dataset for the viewer; the viewer starts when the widget is shown.
- Parameters:
data (str | Path | anndata.AnnData | mudata.MuData) – AnnData or MuData object, or path to a file or folder Cellucid reads (
show_anndata()lists them).height (int) – Height of the viewer in pixels.
web_source_url (str) – Where the browser loads the Cellucid app:
https://www.cellucid.com, or the address of a copy you host (no query, fragment or trailing slash).latent_key (str | None)
gene_id_column (str | None)
normalize_embeddings (bool | None)
centroid_min_points (int | None)
dataset_name (str | None)
dataset_id (str | None)
obs_keys (Sequence[str] | None)
embedding_keys (Mapping[str, EmbeddingKeySpec] | None)
knn_key (str | None)
expression_source (str | None)
vector_field_default (str | None)
modality (str | None)
cache_bytes (int | None)
- Return type:
None
Every other argument is
show_anndata()’s.
- wait_for_ready(timeout=30.0)[source]#
Return the viewer’s
readypayload, waiting for it if it has not arrived.In the cell that showed the widget (or any cell before the viewer loaded) this cannot wait – the viewer loads once the cell ends – and raises at once;
@viewer.on_readyruns when it is ready.
- property viewer_url: str#
its page lives in the cell’s output.
- Type:
A widget has no address of its own
- clear_web_cache()[source]#
A widget keeps no web build: the browser loads the app from
web_source_url.- Return type:
- ensure_web_ui_cached(*, force=True, show_progress=True)[source]#
A widget keeps no web build: the browser loads the app from
web_source_url.
- debug_connection(timeout=5.0)[source]#
Return a structured report of this widget’s connection.
Says where the app is loaded from, which outputs are connected and whether the channel is open, what the viewer last reported, and the commands it refused. It waits for nothing, so it works in any cell.
- stop()[source]#
Stop the viewer: its page keeps the last view, and what was served is let go.
The output stays on screen, frozen; Python stops answering it, and the served store – the object’s snapshot, its matrices laid out in files of the temporary folder – is removed. A widget is stopped by itself when the cell that showed it runs again (its output is replaced) and when it is closed (
close()).- Return type:
Widget has every method of AnnDataViewer below except the ones about its
server and web build (viewer_url, server_url, clear_web_cache,
ensure_web_ui_cached).
AnnDataViewer#
- class cellucid.AnnDataViewer(data, port=None, auto_open=True, *, latent_key=None, gene_id_column=None, normalize_embeddings=None, centroid_min_points=None, dataset_name=None, dataset_id=None, obs_keys=None, embedding_keys=None, knn_key=None, expression_source=None, vector_field_default=None, modality=None, client_server_url=None, web_source_url='https://www.cellucid.com', web_cache_dir=None, allowed_hosts=None, cache_bytes=None)[source]#
Bases:
ViewerActionsInteractive viewer for AnnData objects, in a browser tab of its own.
This machine serves the Cellucid page and the data, and the page talks back over a WebSocket; open
viewer_urlin a browser (in a notebook,display()shows a link to it). The viewer reads the AnnData store itself, in place, with range requests: only what a view needs is read, and nothing is converted first. Supports bidirectional communication via hooks.To show the viewer inside a notebook cell, use
show_anndata()orcellucid.jupyter.Widget: the same API, reached through the notebook’s own connection.Supports every file and folder Cellucid reads (
.h5adand AnnData Zarr,.h5muand MuData Zarr,.loom, 10x.h5andouts/, MatrixMarket folders,.rds/.rda/.RData, gzipped or not), served as it is on disk – an AnnData, MuData, Loom or 10x file not in priority order, and an in-memory AnnData or MuData, as a store in priority order made as the page reads it (an object’s expression matrices laid out gene-major in the background), removed when the viewer stops.Example
>>> viewer = AnnDataViewer( ... adata, ... dataset_name="Example", ... dataset_id="example", ... ) >>> viewer.display() >>> >>> @viewer.on_selection ... def analyze_selection(event): ... subset = adata[event['cells']] ... sc.pl.violin(subset, ['gene1', 'gene2']) >>> >>> # From an .h5ad file, read in place >>> viewer = AnnDataViewer( ... "/path/to/data.h5ad", ... dataset_name="Example", ... dataset_id="example", ... )
- Event Hooks:
Register callbacks to respond to user interactions in the viewer:
@viewer.on_selection def handle(event): print(event['cells']) # list of selected cell indices @viewer.on_hover def handle(event): print(event['cell']) # hovered cell index @viewer.on_click def handle(event): print(event['cell']) # clicked cell index @viewer.on_ready def handle(event): print("Viewer loaded!") @viewer.on_command_error def handle(event): print(event['command'], event['reason']) # a command failed @viewer.on_data_mapping def handle(event): print(event['origin'], event['mapping']) # what the viewer plots @viewer.on_history_change def handle(event): print(event['kind'], event['head']) # the history changed @viewer.on_message def handle(event): print(event) # raw message dict
- Parameters:
data (str | Path | anndata.AnnData | mudata.MuData)
port (int | None)
auto_open (bool)
latent_key (str | None)
gene_id_column (str | None)
normalize_embeddings (bool | None)
centroid_min_points (int | None)
dataset_name (str | None)
dataset_id (str | None)
obs_keys (Sequence[str] | None)
embedding_keys (Mapping[str, EmbeddingKeySpec] | None)
knn_key (str | None)
expression_source (str | None)
vector_field_default (str | None)
modality (str | None)
client_server_url (str | None)
web_source_url (str)
web_cache_dir (str | Path | None)
allowed_hosts (Sequence[str] | None)
cache_bytes (int | None)
- __init__(data, port=None, auto_open=True, *, latent_key=None, gene_id_column=None, normalize_embeddings=None, centroid_min_points=None, dataset_name=None, dataset_id=None, obs_keys=None, embedding_keys=None, knn_key=None, expression_source=None, vector_field_default=None, modality=None, client_server_url=None, web_source_url='https://www.cellucid.com', web_cache_dir=None, allowed_hosts=None, cache_bytes=None)[source]#
Initialize the AnnData viewer.
- Parameters:
data (str | Path | anndata.AnnData | mudata.MuData) – AnnData or MuData object, or path to a file or folder Cellucid reads (see above). A leading
~in a path is expanded to the user’s home directory.port (int | None) – Port for the data server. None takes 8765 – the one local port Cellucid registers with Google, so Google Drive files open (community annotation’s GitHub sign-in works only on www.cellucid.com) – or, when another viewer holds it, the next free port, said in a printed note (cellucid-r’s
cellucid_view()does the same). A port given is used or refused.auto_open (bool) – Show where the viewer is when created: a link in a notebook (
display()), its address on the console.latent_key (str | None) –
obsmarray (a latent space such as scVI or PCA) the viewer’s outlier filter measures in, instead of the data’s ownuns['cellucid']['defaults']['latentKey']. The viewer reads the outlier quantiles the data stores for it, or computes them on first use.gene_id_column (str | None) – Exact column in
var(raw.varwithexpression_source="raw") whose values name the genes. If None, genes are named by the index.normalize_embeddings (bool | None) – Whether the viewer scales embeddings into its coordinate range.
centroid_min_points (int | None) – The fewest cells a category needs to get outlier quantiles (10 when None).
dataset_name (str | None) – Exact non-empty human-readable name without surrounding whitespace or control characters. Defaults to
uns['cellucid']['name'], else the file’s name, orAnnData (<n> cells)for an object.dataset_id (str | None) – Portable 1-180 byte ASCII identifier beginning with a letter or digit and otherwise using letters, digits,
.,_, or-; no trailing.or Windows device name. Defaults touns['cellucid']['id'], else made from the file’s name without its extension, or from the object’s label (AnnData (N cells)) (said in one line: sessions are kept under it).obs_keys (Sequence[str] | None) – Exact
obscolumns the viewer shows, in this order. If None, every column is shown.embedding_keys (Mapping[str, EmbeddingKeySpec] | None) – The embedding of a dimension slot, such as
{"2d": "X_tsne"}or{"2d": ("X_pca", [2, 0])}with 0-based columns. Slots not named follow the default rule, and a deterministic best guess applies when no slot resolves.knn_key (str | None) – The
obspmatrix the viewer draws as the neighbour graph, such as"connectivities"; read only when a view draws it. None follows the viewer’s default rule.expression_source (str | None) –
"X","raw", or"layer:<name>"; None follows the viewer’s default rule (rawwhen it holds more genes thanXorXis scaled, as Scanpy reads genes; elseX).vector_field_default (str | None) – The vector field the overlay opens on:
<field>of an obsm array<field>_<basis>drawn overX_<basis>(velocityforvelocity_umap).modality (str | None) – The modality a multimodal dataset (a MuData) opens on; None opens the default one. Set only for multimodal data.
client_server_url (str | None) – Exact browser-reachable data server base URL.
web_source_url (str) – Origin publishing the web asset inventory.
web_cache_dir (str | Path | None) – Directory holding the active verified web build.
allowed_hosts (Sequence[str] | None) – Extra
Hostnames the data server answers to. Required whenclient_server_urlpoints at a reverse proxy such asjupyter-server-proxy: name that proxy’s host here.cache_bytes (int | None) – What the data server keeps of what it makes for a store served in priority order, in bytes (least recently used first out); None keeps a 64th of the machine’s memory, 0 nothing (as
cellucid.serve_anndata()’s).
- Return type:
None
- property on_selection: Callable[[Callable[[dict[str, Any]], None]], Callable[[dict[str, Any]], None]]#
Decorator to register a selection handler.
Called when user selects cells (lasso, shift-click, etc.)
- Event data:
cells: list[int] - indices of selected cells, unique and ascending
source: str - selection method (‘lasso’, ‘knn’, ‘proximity’, ‘annotation’, …)
Example:
@viewer.on_selection def handle(event): selected = adata[event['cells']] sc.pl.violin(selected, 'gene1')
- property on_hover: Callable[[Callable[[dict[str, Any]], None]], Callable[[dict[str, Any]], None]]#
Decorator to register a hover handler.
Called when user hovers over a cell.
- Event data:
cell: int | None - cell index (None if not hovering over cell)
position: dict - {x, y, z} world coordinates
Example:
@viewer.on_hover def handle(event): if event['cell'] is not None: print(f"Cell {event['cell']}: {adata.obs.iloc[event['cell']]}")
- property on_click: Callable[[Callable[[dict[str, Any]], None]], Callable[[dict[str, Any]], None]]#
Decorator to register a click handler.
Called when user clicks on a cell.
- Event data:
cell: int - clicked cell index
button: int - mouse button (0=left, 1=middle, 2=right)
shift: bool - shift key held
ctrl: bool - ctrl/cmd key held
Example:
@viewer.on_click def handle(event): print(f"Clicked cell {event['cell']}")
- property on_ready: Callable[[Callable[[dict[str, Any]], None]], Callable[[dict[str, Any]], None]]#
Decorator to register a ready handler.
Called when viewer finishes loading and is ready for interaction.
- Event data:
n_cells: int - number of cells in dataset
dimensions: int - embedding dimensionality (1, 2, or 3)
Example:
@viewer.on_ready def handle(event): print(f"Loaded {event['n_cells']} cells")
- property on_command_error: Callable[[Callable[[dict[str, Any]], None]], Callable[[dict[str, Any]], None]]#
Decorator to register a handler for a failed Python → viewer command.
Called when a command this viewer sent – an action (
viewer.color_by(...),viewer.act(...)), a session request – was refused by the viewer instead of carried out. An action returns its request at once, so its method has returned by the time the failure arrives: this hook (or the request’sresult(), which raises the same reason) is how a notebook learns that the viewer is unchanged.Registering a handler also silences the notice Cellucid otherwise prints to
sys.stderr, so reporting happens once, where you chose.- Event data:
command: str - the command type that failed:
"action","requestSessionBundle", …requestId: str or None - the request it fails (an action’s
request.request_id); None for a command that names nonereason: str - what the viewer reported, in one line
Like every hook, this runs on the viewer channel’s thread, not in your cell: an exception raised here is logged (logger
cellucid.viewer_channel) and never reaches the notebook, the callbacks after it do not run, and the event is not recorded inviewer.stateor handed towait_for_event. Record the failure and raise from your own code. An action that did apply is answered too: its request’sresult()returns its outcome.Example:
rejected = [] @viewer.on_command_error def handle(event): rejected.append(event) viewer.color_by(field={"source": "obs", "key": "cell_type"}) ... if rejected: raise RuntimeError(rejected[-1]["reason"])
- property on_data_mapping: Callable[[Callable[[dict[str, Any]], None]], Callable[[dict[str, Any]], None]]#
Decorator to register a handler for the viewer’s data mapping.
Called when the viewer reports which stored arrays it plots and reads: once after the dataset loads, and again whenever the mapping changes – from the viewer’s controls, a session, or this notebook’s
mapping_set(). The viewer sends it because this package listsdata_mappingamong the events ofGET /_cellucid/protocol.- Event data:
origin: str - why the mapping is what it is:
"default","best_guess","session","user", or"notebook"(this notebook’smapping_set())mapping: dict - the complete data mapping, in canonical form
Example:
@viewer.on_data_mapping def handle(event): print(event["mapping"]["embeddings"])
- property on_history_change: Callable[[Callable[[dict[str, Any]], None]], Callable[[dict[str, Any]], None]]#
Decorator to register a handler for every change of the viewer’s history.
Called when a step is recorded (by the person, an agent, or this notebook), the step shown moves (undo, redo, a jump, another branch), the history’s structure is edited (a rename, a note, a bookmark, a delete, a restore), a tracker is started, used, renamed or removed, or a session is loaded.
viewer.historykeeps the latest.- Event data:
kind: str -
"step","moved","edited","tracker"or"loaded"tracker: str - the id of the tracker in use
head: str - the step shown
step: str or None - the step recorded (
"step"), else Nonebranch: str or None - the id of the active branch
Example:
@viewer.on_history_change def handle(event): if event["kind"] == "step": print("recorded", event["step"])
- property history: LiveHistory#
The viewer’s history, live (
LiveHistory): the latest change it told, a hook on each change, and its history read as a session. The history is changed through the generatedhistory_*methods (history_undo(),history_jump(step=...),history_note_add(...), …).
- turn(label)[source]#
Make every action sent inside the
withblock one turn of the viewer’s history.The State panel shows the turn’s steps as one group, labelled
labeland by this notebook, and undoes them together (Undo turn), as it does an agent’s turn. Yields the turn’s id. Turns do not nest.Example:
with viewer.turn("Normalise and cluster"): viewer.color_by(field={"source": "obs", "key": "leiden"}) viewer.highlight_cells(cells=adata.obs["leiden"] == "3", label="Leiden 3")
- load_session(session)[source]#
Load a session file into the viewer: its trackers are added beside the person’s own (nothing of theirs is replaced), and the file’s tracker shown is shown.
The session must be of the dataset this viewer shows. Returns the
LoadSessionRequest; its result is{"tracker": {"id", "name"}, "head"}(in a notebook, collect it in a later cell).Example:
viewer.load_session("analysis.cellucid-session")
- Return type:
- Parameters:
session (str | Path | CellucidSession)
- property on_message: Callable[[Callable[[dict[str, Any]], None]], Callable[[dict[str, Any]], None]]#
Decorator to register a raw message handler.
Called for every validated current-schema message from the viewer. Use it to observe the complete event stream while debugging.
- Event data:
event: str - the event type
… other fields depend on event type
Example:
@viewer.on_message def handle(event): print(f"Got message: {event}")
- register_hook(event, callback)[source]#
Register a callback for an event (non-decorator style).
- Parameters:
- Return type:
- Returns:
The callback function
Example:
def my_handler(event): print(event['cells']) viewer.register_hook('selection', my_handler)
- wait_for_event(event, timeout=30.0, *, predicate=None)[source]#
Block until the next event of the given type arrives.
- Parameters:
- Returns:
The payload of the first matching event that arrives after the call (an event recorded before it is not returned).
- Return type:
- Raises:
TimeoutError – No matching event arrived within
timeout.
- wait_for_ready(timeout=30.0)[source]#
Return the viewer’s
readypayload, waiting for it if it has not arrived.Raises
TimeoutErrorwhen it does not arrive withintimeoutseconds (None waits forever).
- request_session()[source]#
Ask the viewer for its session – its whole history – without waiting.
The request is sent at once (or as soon as the viewer connects) and the viewer answers in the background with a
.cellucid-sessionfile of format 4: every tracker of the dataset’s history, each step, and the values each step shows (conversations of the chat bar are left out). Collect it with the returned request’sresult()(aCellucidSession). In a notebook widget the answer arrives once the cell that asked has finished, so collect it in a later cell:request = viewer.request_session() # next cell session = request.result() plan = session.apply(adata) # what would change, one row each plan.apply()
- Returns:
The request;
request.donesays whether the answer arrived.- Return type:
- property data_mapping: dict[str, Any] | None#
The data mapping the viewer last reported, or None before it reported one.
This is a copy of the
mappingof the latestdata_mappingevent: which embedding fills each dimension slot, the bound vector fields, and – for an AnnData source – the neighbour graph, the gene names, the expression matrix and the latent space. Editing the copy changes nothing; usemapping_set()(themapping.setaction).
- property data_mapping_origin: str | None#
Why the viewer’s data mapping is what it is, or None before it reported one.
- act(action, /, **params)[source]#
Apply (or read) one action of the viewer, by its dotted type.
Every action has a method of its own as well (
viewer.color_by(...)isviewer.act("color.by", ...));actis the same for an action named in data, and every action is listed bycellucid.jupyter.action_catalog(). Parameters are checked by the catalogue and converted the same way for every action: cells (x-cells) as rows, a boolean mask or obs names; one number per cell (x-values) as an array; everything else as JSON (NumPy values and pandas indexes as lists). A parameter writteninin the catalogue isin_as a method’s keyword.The action is sent at once (or as soon as the viewer connects) and the viewer applies it as a person’s control would: one step of its history, labelled as this notebook’s, undone like any other. Nothing waits: the returned request’s
result()waits for the outcome – a read’s result – and raisesActionErrorwith the viewer’s reason when it did not apply the action. In a notebook widget the answer arrives once the cell has finished, so collect it in a later cell:request = viewer.fields_list() # next cell fields = request.result()
Example:
viewer.act("color.by", field={"source": "obs", "key": "cell_type"}) viewer.highlight_cells(cells=adata.obs["leiden"] == "3", label="Leiden 3")
- Return type:
- Parameters:
- property results: list[ViewerResult]#
highlight groups, user-defined fields (labels, clusters), scores, gene sets, the visible and the open cells.
Raises
RuntimeErrorbefore the viewer has sent them all once (it does when its dataset has opened): run the cell again then; and while the viewer shows a dataset this viewer did not serve (one opened in it instead), whose cells are not this dataset’s.- Type:
Every result the viewer holds, as of the last event it sent
- pull(adata, *, highlights=True, fields=True, scores=True, visibility=False, gene_sets=True, include_pushed=False, highlight_prefix='cellucid_highlight__', field_prefix='', on_conflict='error', prune=True)[source]#
Write everything made in this viewer onto
adata, in place, in one call.Every highlight group, user-defined field (labels, annotations, clusters), score and gene set the viewer holds – see
cellucid.pull()for the columns, their names and dtypes, and every option.adatais the AnnData or MuData the viewer shows, cells in the same order. Nothing is waited for: the viewer sent its results as they were made, so in a notebook a lasso drawn and this run in the next cell finds the lasso.Example:
summary = viewer.pull(adata) summary.columns # what was written, by obs column adata.uns["cellucid"]["gene_sets"]
- property obs_names: Index | None#
The obs names of the cells this viewer shows, in the order it names them (their original order), or None when this process cannot read them (a format only the browser reads).
Taken from what is served (
AnnDataServer.obs_names): an object’s names as they were when it was shown – its cells put back in their original order when it was read from a file in priority order – whatever is done to it after; a file’s at the version it is served as. A viewer that stopped keeps the last ones.
- property selection: Selection | None#
The viewer’s last selection (lasso, k-NN, proximity, annotation), or None before the first: its cells as rows of
obsand, when this process has them, their obs names.
- subset(adata, which=None)[source]#
The cells of a highlight group, or of the last selection, as a new AnnData.
- Parameters:
adata (
Any) – The AnnData (or MuData) the viewer shows, cells in its order (an object holding them in another order is refused, aspull()refuses it).which (
str|None) – A highlight group, by id ("highlight_3") or by its label;"visible"for the cells the filters leave visible; None for the last selection.
- Return type:
- Returns:
adata[cells].copy()(to_memory()for a backed AnnData).
- gene_sets(*, symbols=False)[source]#
Every gene set the viewer holds: the notebook’s, the shown marker genes result’s (one per group) and the shown gene signature’s, by name (a name used again is
"name (2)", as everywhere in Cellucid).Each set’s genes are identifiers – the var index, as
adata.var_namesholds them – or, withsymbols=True, the names the viewer shows for them: those of the var column its data mapping names the genes by (such asfeature_name), else the identifiers themselves.cellucid.write_gmt()writes them as a GMT file.
- push(values, key=None)[source]#
Show a column in the viewer as a field: labels as a categorical, numbers as a continuous field. Pushing the same key again replaces it.
The
field.pushaction, made from a Python column (its own method,viewer.field_push(...), takes the codes and values as the viewer stores them).- Parameters:
values (
Any) – Apandas.Series–adata.obs["leiden"], a score – aligned to the viewer’s cells by its index (obs names), or an array or list of one value per cell inobsorder. Categorical, string, object and bool values become a categorical (missing values have no category; a bool’s labels are"false"and"true"); numbers a continuous field (missing: no value).key (
str|None) – The field’s name in the viewer; the Series’ name when None. A field of that name the notebook did not push is never replaced: the viewer refuses it, and says why.
- Returns:
its result is
{"name", "kind", "id"}once the viewer added the field (resultslists it from then on; in a notebook, from the next cell). The column is sent at once, or, for a format only the browser reads, once the viewer has said how many cells it has (a cell run before that, “Run All”, is fine). A column the viewer refuses, or that does not fit the dataset once it is known, fails the request with the reason (printed unless acommand_errorhook handles it).- Return type:
The
ActionRequest
- apply_session_to_anndata(adata, request, *, tracker=None, branch=None, step=None, dry_run=True, overwrite=False, keep_session=False, timeout=60.0, cleanup_file=True)[source]#
Plan or apply the session a
request_session()request brought to an AnnData.The one way to get the viewer’s state into an object, in a notebook widget and a browser-tab viewer alike (cellucid-r’s
cellucid_apply_session(object, request)): ask, then apply – in a notebook, in a later cell, since the viewer answers between cells:request = viewer.request_session() # next cell plan = viewer.apply_session_to_anndata(adata, request) # what would change report = plan.apply()
tracker,branchandstepchoose the state applied: by default the step the viewer shows (the active tracker’s head); any step of any tracker is the state as it was after that step. Every other keyword buttimeout(the wait for the session; a notebook widget’s cell cannot wait, and says so at once when the answer has not arrived) andcleanup_file(delete the session file the viewer sent once it is read and planned: the plan, and a record kept withkeep_session, need it no longer;request.result().save(...)first keeps a copy) isapply_cellucid_session_to_anndata()’s.
- debug_connection(timeout=5.0)[source]#
Return a structured connectivity/debug report for this viewer.
Includes: :rtype:
dict[str,Any]server health/info probes
exact id/path-keyed identity probes for every declared dataset
whether the viewer’s channel (its WebSocket) is connected
Python→viewer ping/pong roundtrip over the channel
frontend debug snapshot (URL/origin/userAgent as seen by the iframe)
recent_events["command_errors"]: the commands the viewer refused instead of applying
- ensure_web_ui_cached(*, force=True, show_progress=True)[source]#
Establish one complete verified web build in this viewer’s cache.
- display()[source]#
Say where the viewer is: a link to its browser tab in a notebook, its address on the console otherwise.
This viewer runs in a browser tab of its own (the page and its channel are served by this machine). To show a viewer inside a notebook cell, use
show_anndata()orcellucid.jupyter.Widget.
- send_message(message)[source]#
Send one command to the viewer.
This is the low-level API for sending commands to the frontend. The command travels on the viewer’s channel (a WebSocket the viewer opens to this server). Before the viewer has connected – the cell output is still loading, or the page is reconnecting – the command waits and is sent, in order, the moment it connects.
An
actionwhose parameters hold NumPy arrays (cells asuint32original positions, a column’s values) travels as one binary frame, the arrays little-endian; every other command as JSON text. Useact()(or an action’s own method) for actions: it checks the parameters by the catalogue and returns the request its answer completes.- Parameters:
message (
dict) – Dict with the command’s exact keys (the shared protocol’scommands).- Return type:
- Returns:
True when the command was sent now, False when it is waiting for the viewer to connect.
Example:
viewer.send_message({"type": "freeze"})
- stop()[source]#
Stop the data server and cleanup all resources.
This method: 1. Stops the underlying data server (which removes its served store’s scratch folder) 2. Removes the viewer from the active viewers set 3. Clears all hooks 4. Logs the cleanup
Safe to call multiple times after a successful stop.
Action methods (generated)#
Every action of the catalogue, as a method of both classes. They are
generated from the catalogue the package ships (scripts/generate_actions.py,
never written by hand), so this list is exactly the viewer’s actions.
- class cellucid.jupyter.ViewerActions[source]#
Bases:
objectEvery action of the catalogue as a method (mixed into the viewer).
- analysis_cancel(*, analysis, in_='panel')[source]#
Stop an analysis.
Stop a running analysis; what it was showing stays, nothing else changes.
Action
analysis.cancel. It reads only and changes nothing;request.result()is what it reads.- Parameters:
analysis ({"markers", "differential", "dotplot", "signature", "composition", "correlation"}) – An analysis with a Run button.
in ("panel" or int) – Default
'panel'.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_close()[source]#
Close the open analysis.
Close the analysis open in the Analysis panel (its settings and result stay).
Action
analysis.close. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_composition_get(*, in_='panel')[source]#
Read composition options.
The composition analysis’s options, pages and result state.
Action
analysis.composition.get. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_composition_set(*, options, in_='panel', show=False)[source]#
Set composition options.
Change options of the composition analysis (only those given); nothing runs.
Action
analysis.composition.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
options (dict) – Keys:
barsBy(optional),cellTypes(optional),cells(optional),condition(optional),correction(optional),method(optional),onlyTypes(optional),order(optional),samples(optional),values(optional).in ("panel" or int) – Default
'panel'.show (bool) – Also open it in the Analysis panel (with in “panel”), as another analysis’s “send to” does. Default
False.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_correlation_get(*, in_='panel')[source]#
Read correlation options.
The correlation analysis’s options, pages and result state.
Action
analysis.correlation.get. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_correlation_set(*, options, in_='panel', show=False)[source]#
Set correlation options.
Change options of the correlation analysis (only those given); nothing runs.
Action
analysis.correlation.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_detailed_set(*, in_='panel', plot=OMIT, plot_options=OMIT, variable=OMIT)[source]#
Choose what the detailed analysis plots.
The variable the detailed analysis plots (a field or a gene, by name, or none), the plot, and options of that plot (only those given); it updates by itself.
Action
analysis.detailed.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
in ("panel" or int) – Default
'panel'.plot (str) – The plot, by its id as the Plot select offers it for the variable’s kind. Optional: left out, the viewer decides.
plot_options (list) – Options of the plot, each by its name and value. Optional: left out, the viewer decides.
variable (None or dict) – What to plot: a column of the cells (categorical_obs, continuous_obs) or a gene (gene_expression) by name, or null for nothing. Keys:
key,type. Optional: left out, the viewer decides.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_differential_get(*, in_='panel')[source]#
Read differential expression options.
The differential expression analysis’s options, pages and result state.
Action
analysis.differential.get. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_differential_set(*, options, in_='panel', show=False)[source]#
Set differential expression options.
Change options of the differential expression analysis (only those given); nothing runs.
Action
analysis.differential.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
options (dict) – Keys:
categoriesA(optional),categoriesB(optional),compare(optional),correction(optional),excludeGenes(optional),excludePattern(optional),field(optional),foldChange(optional),labels(optional),matrix(optional),maxAdjP(optional),method(optional),minCells(optional),minCellsPerSample(optional),minLog2FC(optional),minPct(optional),onlyGenes(optional),onlyGenesList(optional),pConvention(optional),pageA(optional),pageB(optional),replicates(optional),within(optional),withinCategories(optional),withinField(optional).in ("panel" or int) – Default
'panel'.show (bool) – Also open it in the Analysis panel (with in “panel”), as another analysis’s “send to” does. Default
False.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_dotplot_get(*, in_='panel')[source]#
Read dot plot options.
The dot plot analysis’s options, pages and result state.
Action
analysis.dotplot.get. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_dotplot_set(*, options, in_='panel', show=False)[source]#
Set dot plot options.
Change options of the dot plot analysis (only those given); nothing runs.
Action
analysis.dotplot.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
options (dict) – Keys:
cells(optional),colorMap(optional),cutoff(optional),geneSets(optional),groupBy(optional),groupOrder(optional),groups(optional),matrix(optional),maxDotSize(optional),meanOnlyExpressing(optional),plot(optional),scale(optional),swapAxes(optional).in ("panel" or int) – Default
'panel'.show (bool) – Also open it in the Analysis panel (with in “panel”), as another analysis’s “send to” does. Default
False.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_list()[source]#
List the analyses.
Each analysis of the panel and each analysis window: which is open, its pages, whether it has a result, is running, or is stale and why.
Action
analysis.list. It reads only and changes nothing;request.result()is what it reads.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_markers_get(*, in_='panel')[source]#
Read marker genes options.
The marker genes analysis’s options, pages and result state.
Action
analysis.markers.get. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_markers_set(*, options, in_='panel', show=False)[source]#
Set marker genes options.
Change options of the marker genes analysis (only those given); nothing runs.
Action
analysis.markers.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
options (dict) – Keys:
cells(optional),compareAgainst(optional),correction(optional),direction(optional),excludeGenes(optional),excludePattern(optional),foldChange(optional),groupBy(optional),matrix(optional),maxAdjP(optional),maxPctRef(optional),method(optional),minCells(optional),minLog2FC(optional),minPctIn(optional),onlyGenes(optional),onlyGenesList(optional),pConvention(optional),rankBy(optional),referenceGroup(optional),restIncludes(optional),smallGroups(optional),testGroups(optional),topN(optional).in ("panel" or int) – Default
'panel'.show (bool) – Also open it in the Analysis panel (with in “panel”), as another analysis’s “send to” does. Default
False.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_open(*, analysis, window=False)[source]#
Open an analysis.
Show an analysis in the Analysis panel, or open it in a new floating window with the panel’s settings.
Action
analysis.open. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
analysis ({"markers", "differential", "dotplot", "signature", "composition", "quick", "detailed", "correlation"}) – The analysis: markers (marker genes), differential (differential expression), dotplot, signature (gene signature), composition, quick, detailed, correlation.
window (bool) – Open it in a new floating window. Default
False.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_pages_set(*, analysis, pages, in_='panel')[source]#
Choose the pages of an analysis.
The highlight pages an analysis compares (by name, “Rest of <page>” for the rest of a page’s cells); nothing runs.
Action
analysis.pages.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
analysis ({"markers", "differential", "dotplot", "signature", "composition", "quick", "detailed", "correlation"}) – The analysis: markers (marker genes), differential (differential expression), dotplot, signature (gene signature), composition, quick, detailed, correlation.
pages (list) – See the action’s summary.
in ("panel" or int) – Default
'panel'.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_quick_set(*, categorical=OMIT, continuous=OMIT, in_='panel')[source]#
Choose the fields of the quick analysis.
The categorical columns whose composition and the continuous columns whose statistics the quick analysis shows (only the kinds given; before a choice it shows the first two of each); it updates by itself.
Action
analysis.quick.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
categorical (list) – Categorical columns of the cells, by name (their composition). Optional: left out, the viewer decides.
continuous (list) – Continuous columns of the cells, by name (their statistics). Optional: left out, the viewer decides.
in ("panel" or int) – Default
'panel'.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_result(*, analysis, in_='panel', top=20)[source]#
Read an analysis result.
The top rows of an analysis’s result table (N a parameter), with what it was computed on and whether it is stale.
Action
analysis.result. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_run(*, analysis, in_='panel')[source]#
Run an analysis.
Run an analysis with its options and pages, and wait for its result.
Action
analysis.run. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_signature_get(*, in_='panel')[source]#
Read gene signature options.
The gene signature analysis’s options, pages and result state.
Action
analysis.signature.get. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_signature_set(*, options, in_='panel', show=False)[source]#
Set gene signature options.
Change options of the gene signature analysis (only those given); nothing runs.
Action
analysis.signature.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
options (dict) – Keys:
bins(optional),controlSize(optional),geneSets(optional),layout(optional),maxRank(optional),method(optional),plotType(optional),rescale(optional),seed(optional).in ("panel" or int) – Default
'panel'.show (bool) – Also open it in the Analysis panel (with in “panel”), as another analysis’s “send to” does. Default
False.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_size_set(*, analysis, expanded)[source]#
Size an analysis’s expanded view.
The size and splits an analysis’s expanded view opens at, remembered per analysis; a person sets them by resizing it.
Action
analysis.size.set. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
analysis ({"markers", "differential", "dotplot", "signature", "composition", "quick", "detailed", "correlation"}) – The analysis: markers (marker genes), differential (differential expression), dotplot, signature (gene signature), composition, quick, detailed, correlation.
expanded (dict) – The expanded view’s box and its splits, in CSS pixels. Keys:
footerHeight,height,optionsWidth,statsWidth,width.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_view_set(*, analysis, view, in_='panel')[source]#
Change how an analysis is shown.
Open or close its option groups, and choose what its result shows (marker genes: list or heatmap, the group listed, the heatmap’s look; gene signature: the set shown; the options of the plot its expanded view draws); nothing runs.
Action
analysis.view.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
analysis ({"markers", "differential", "dotplot", "signature", "composition", "correlation"}) – An analysis with an options form.
view (dict) – What to change of how the analysis is shown (only the keys given). Keys:
group(optional),groups(optional),heatmap(optional),more(optional),plot(optional),set(optional),show(optional).in ("panel" or int) – Default
'panel'.in_ (Literal['panel'] | int)
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_window_close(*, window)[source]#
Close an analysis window.
Close a floating analysis window (its settings and result go with it; undo brings it back).
Action
analysis.window.close. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
window (int) – A floating analysis window, by its number (1 is the first open).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_window_collapse(*, window, collapsed)[source]#
Collapse or expand an analysis window.
Fold a floating analysis window to its title bar, or unfold it again; its analysis is kept.
Action
analysis.window.collapse. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_window_copy(*, window)[source]#
Copy an analysis window.
Open a new floating window with a window’s analysis and settings.
Action
analysis.window.copy. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
window (int) – A floating analysis window, by its number (1 is the first open).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- analysis_window_place(*, window, left, top, width, height)[source]#
Move or resize an analysis window.
Give a floating analysis window a place and size; it is kept inside the window.
Action
analysis.window.place. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- annotation_suggest(*, field, category, label, evidence=OMIT, ontology_id=OMIT)[source]#
Suggest a label.
Suggest a label for a category in the person’s name, with their upvote, as the voting dialog’s New suggestion does, and publish that suggestion alone: the person’s own file in the community annotation repository is written as published now plus this suggestion (a pull request when they cannot write to the repository), which others see on their next Pull. A label already suggested for the category is refused with its id (vote on it instead). Asked of the person first; the history cannot take it back. Refused until the person has connected the repository and signed in to GitHub.
Action
annotation.suggest. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome. It publishes for others to see, so the viewer asks the person first, from Python too, as when an agent runs it;request.result()waits for their answer (call it again if its timeout passes first).- Parameters:
field (dict) – A categorical column of the cells by name (source “obs”). Keys:
key,source.category (str) – A category label as the legend shows it.
label (str) – The label suggested.
evidence (str) – Why: the markers or reasoning behind it. Optional: left out, the viewer decides.
ontology_id (str) – Its ontology term, when known. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- annotation_suggestions(*, field, category=OMIT, cursor=OMIT)[source]#
Read the community annotation.
The labels suggested for the categories of a field by the community annotation of the dataset shown (its connected GitHub repository), with their votes, the person’s own vote and each category’s consensus, as the voting dialog and the legend show them; whether the field is open for voting, and when this browser last pulled. One page holds what fits a tool result; `next` starts the following one.
Action
annotation.suggestions. It reads only and changes nothing;request.result()is what it reads.- Parameters:
field (dict) – A categorical column of the cells by name (source “obs”). Keys:
key,source.category (str) – One category; every category of the field when left out. Optional: left out, the viewer decides.
cursor (int) – Where the page starts: the next of the last page; the first page when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- annotation_vote(*, field, category, suggestion, vote)[source]#
Vote on a suggested label.
Vote a suggested label of a category up or down (none takes the person’s vote back) and publish that vote alone: the person’s own file in the community annotation repository is written as published now plus this vote (a pull request when they cannot write to the repository), which others see on their next Pull. Nothing else of the person’s is published, and a vote that changes nothing publishes nothing. Asked of the person first; the history cannot take it back. Refused until the person has connected the repository and signed in to GitHub.
Action
annotation.vote. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome. It publishes for others to see, so the viewer asks the person first, from Python too, as when an agent runs it;request.result()waits for their answer (call it again if its timeout passes first).- Parameters:
field (dict) – A categorical column of the cells by name (source “obs”). Keys:
key,source.category (str) – A category label as the legend shows it.
suggestion (str) – The suggestion, by its id or its label (annotation_suggestions); suggestions with the same label are one suggestion.
vote ({"up", "down", "none"}) – up, down, or none to take the person’s vote back.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
Set the navigation mode.
Navigate a view by orbit, planar or free-fly (O, P and G); views with linked cameras share one mode.
Action
camera.navigation.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
view (str) – A view: “View N” as the Compare views list numbers its rows (the live view is View 1 while it is shown, the kept views follow in the order they were kept).
mode ({"orbit", "planar", "free"}) – “orbit”, “planar” or “free” (free-fly).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_path_clear()[source]#
Clear the camera path.
Delete every keyframe of the camera path; playback stops where the camera is.
Action
camera-path.clear. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_path_duration_set(*, seconds, keyframe=OMIT)[source]#
Set a camera path transition time.
Set how long the camera takes from one keyframe to the next, or from every keyframe to its next.
Action
camera-path.duration.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_path_keyframe_add(*, camera=OMIT, embedding=OMIT, label=OMIT)[source]#
Add a camera path keyframe.
Save a camera as the next keyframe of the camera path (before the return to start, when there is one).
Action
camera-path.keyframe.add. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
camera (dict) – The camera to save; omitted, the selected view’s camera now. Keys:
freefly,navigationMode,orbit. Optional: left out, the viewer decides.embedding (dict or None) – The embedding the keyframe was recorded on; omitted, the one the selected view shows. Keys:
columns,key. Optional: left out, the viewer decides.label (str) – The keyframe’s label; omitted, “KF n”. Unique among the keyframes. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_path_keyframe_move(*, keyframe, direction)[source]#
Move a camera path keyframe.
Move a keyframe one place earlier (up) or later (down) in the camera path.
Action
camera-path.keyframe.move. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
keyframe (str) – A keyframe, by its label as the Camera path list shows it.
direction ({"up", "down"}) – “up” one place earlier, “down” one place later.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_path_keyframe_remove(*, keyframe)[source]#
Delete a camera path keyframe.
Delete one keyframe of the camera path.
Action
camera-path.keyframe.remove. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
keyframe (str) – A keyframe, by its label as the Camera path list shows it.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_path_keyframe_rename(*, keyframe, label)[source]#
Rename a camera path keyframe.
Give a keyframe another label, unique among the keyframes.
Action
camera-path.keyframe.rename. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_path_loop_back_set(*, enabled)[source]#
End the camera path at its start.
Add or remove a last keyframe that returns the camera to the first one (two keyframes or more).
Action
camera-path.loop-back.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
enabled (bool) – true to end with the return, false to remove it.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_path_playback_set(*, autoplay=OMIT, easing=OMIT, loop=OMIT, position_interpolation=OMIT, rotation_interpolation=OMIT, speed=OMIT)[source]#
Set camera path playback.
Set how the camera path plays: interpolation, easing, speed of automatic transitions, loop and autoplay.
Action
camera-path.playback.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
autoplay (bool) – Start playing as soon as the path has two keyframes. Optional: left out, the viewer decides.
easing ({"linear", "ease-in-out", "ease-in", "ease-out"}) – How each transition speeds up and slows down. Optional: left out, the viewer decides.
loop (bool) – Play the path again from its start when it ends. Optional: left out, the viewer decides.
position_interpolation ({"catmull-rom", "linear", "bezier"}) – How positions between keyframes are drawn. Optional: left out, the viewer decides.
rotation_interpolation ({"slerp", "linear"}) – How the view direction turns between keyframes. Optional: left out, the viewer decides.
speed (int) – Speed of automatic transitions, 1 (very slow) to 100 (very fast). Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_reset(*, view)[source]#
Reset the camera.
Put a view’s camera back to its starting place, keeping its navigation mode (the R key).
Action
camera.reset. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
view (str) – A view: “View N” as the Compare views list numbers its rows (the live view is View 1 while it is shown, the kept views follow in the order they were kept).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- camera_set(*, view, camera)[source]#
Place the camera.
Set the camera of a view (views with linked cameras follow); a camera gesture records one of these.
Action
camera.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
view (str) – A view: “View N” as the Compare views list numbers its rows (the live view is View 1 while it is shown, the kept views follow in the order they were kept).
camera (dict) – A camera: its navigation mode, and its orbit and free-fly poses (the one the mode drives is used). Keys:
freefly,navigationMode,orbit.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- category_delete(*, field, category, unassigned_label='unassigned')[source]#
Delete a category.
Move every cell of one category into the unassigned category. A column from the file becomes a new column (the original moves to Deleted fields); a column made in the app is edited in place.
Action
category.delete. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- category_merge(*, field, category, into)[source]#
Merge two categories.
Move every cell of one category into another. A column from the file becomes a new column (the original moves to Deleted fields); a column made in the app is edited in place.
Action
category.merge. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- category_rename(*, field, category, name)[source]#
Rename a category.
Give one category of a categorical column another label; its original label stays known.
Action
category.rename. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- cells_export(*, format='csv', page=OMIT)[source]#
Export the highlighted cells.
Write the highlighted cells of a highlight page as a file, as the Highlights list’s export buttons do: an obs-column CSV (every open cell, a true/false column per highlight, which cellucid.pull() in Python and cellucid_pull() in R read back) or an .h5ad subset of the highlighted cells with their expression rows. The .h5ad reads the cells’ expression first; its time and bytes are estimated from this connection before it starts.
Action
cells.export. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
format ({"csv", "h5ad"}) – csv: the obs-column CSV; h5ad: an AnnData file of the highlighted cells. Default
'csv'.page (str) – The highlight page; the page shown when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- cells_open(*, mode, allocation='proportional', count=OMIT, embedding=OMIT, field=OMIT, method=None, seed=None)[source]#
Open a share of the cells.
Read the dataset again with every cell, or with exactly `count` cells chosen by a subsample method; highlights, labels, views and filters are kept for the cells still open.
Action
cells.open. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
mode ({"all", "subsample"}) – See the action’s summary.
allocation ({"proportional", "balanced"}) – Stratified: how the cells are split over the categories. Default
'proportional'.count (int) – Subsample: how many cells. Optional: left out, the viewer decides.
embedding (str) – Spatial: the obsm embedding it thins. Optional: left out, the viewer decides.
field (str) – Stratified: the categorical column it is stratified by. Optional: left out, the viewer decides.
method ({"uniform", "blocks", "stratified", "spatial", null}) – Subsample: how the cells are chosen; null for the file’s default. Default
None.seed (int or None) – Subsample: its seed; null for the file’s. Default
None.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- cells_read_genes(*, cells)[source]#
Read genes for more cells.
Read every gene for the first `cells` open cells (a dataset stored cell by cell reads genes for a sample of the open cells); stopping keeps what was read.
Action
cells.read-genes. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
cells (int) – How many of the open cells; more than are open reads every one.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- cells_values(*, cells, fields)[source]#
Read values of cells.
The values of named cells (original positions) in each field or gene asked for.
Action
cells.values. It reads only and changes nothing;request.result()is what it reads.- Parameters:
cells (cells (rows, a boolean mask or obs names)) – Cells by original position (their row in the file’s obs).
fields (list) – See the action’s summary.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- cells_visibility_set(*, cells, visible)[source]#
Hide or show cells.
Hide or show cells one by one in the selected view, on top of every filter.
Action
cells.visibility.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
cells (cells (rows, a boolean mask or obs names)) – Cells by original position, or null for every cell.
visible (bool) – true to show them, false to hide them.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- color_by(*, field)[source]#
Colour the cells by a field or gene.
Colour the view in focus by a column of the cells (source “obs”) or a gene (source “var”), reading it first when needed; null clears the colouring.
Action
color.by. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict or None) – The field or gene by name; null colours the cells by nothing. Keys:
key,source.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- color_category(*, field, category, color)[source]#
Colour one category.
Give one category of a categorical column another colour.
Action
color.category. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- color_continuous_colormap(*, field, colormap)[source]#
Choose a colour map.
The colour map a continuous field or gene is drawn with.
Action
color.continuous.colormap. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – The continuous field or gene the view in focus is coloured by, by name. Keys:
key,source.colormap ({"viridis", "plasma", "inferno", "magma", "cividis", "turbo", "twilight", "coolwarm", "bluered", "spectral", "rdylbu", "rdbu", "piyg", "prgn", "brbg", "seismic", "ylgnbu", "ylorrd", "ylorbr", "gnbu", "bupu", "rdpu", "purd", "orrd", "blues", "greens", "reds", "purples", "oranges", "greys", "heat", "hot", "cool", "jet", "rainbow", "ocean", "terrain", "spring", "summer", "autumn", "winter", "bone", "copper", "pink"}) – The colour map by its id (viridis, magma, coolwarm, …).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- color_continuous_log(*, field, enabled)[source]#
Log colour scale.
Colour a continuous field or gene on a log scale, or a linear one.
Action
color.continuous.log. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- color_continuous_range(*, field, min, max)[source]#
Set the colour range.
The values the colour map spans for a continuous field or gene that is rescaled to a range.
Action
color.continuous.range. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- color_continuous_rescale(*, field, enabled)[source]#
Rescale colours to the visible range.
Stretch the colour map over the visible range of a continuous field or gene, or over all its values.
Action
color.continuous.rescale. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- color_continuous_zero_gray(*, field, enabled)[source]#
Gray for zero.
Draw a gene’s zeros in gray beneath the expressing cells, or in the colour map’s lowest colour.
Action
color.continuous.zero-gray. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- dataset_open(*, name, kind='any')[source]#
Open a dataset.
Open a dataset by the name the person gives: a built-in sample, one of their datasets (My datasets), a link, or an accession the link box takes. It replaces the open dataset; that one’s history stays kept in this browser and the new one starts its own. A whole-file download is asked about first.
Action
dataset.open. It opens another dataset in place of the one the viewer shows, as an agent in the viewer does. A notebook’s viewer shows the dataset its notebook serves, so the viewer refuses it from Python: show another dataset withcellucid.show_anndata()orcellucid.serve_anndata().- Parameters:
name (str) – A sample’s name or id, a name from My datasets, a link to a dataset (a file, a Zarr store, a dataset folder, a CELLxGENE, Zenodo, Figshare or GitHub address), an accession (GSE123456, a DOI), or a Cellucid server (localhost:8765).
kind ({"any", "sample", "my-datasets", "link"}) – Where to look for the name: any (samples, then My datasets, then as a link), sample, my-datasets or link. Default
'any'.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
Make a share link.
The public link that opens the dataset shown on www.cellucid.com for anyone, with its “Open in Cellucid” badge and an embed snippet, as Share in Session › Open data makes them; what a link carried to grant access is left out. Refused for a dataset no link reopens (a file of this computer, a notebook’s, a server on this computer).
Action
dataset.share-link. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome. It publishes for others to see, so the viewer asks the person first, from Python too, as when an agent runs it;request.result()waits for their answer (call it again if its timeout passes first).- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- dataset_summary()[source]#
Read the dataset summary.
The open dataset: its name, citation, how many cells (and how many are open), genes, embeddings and fields.
Action
dataset.summary. It reads only and changes nothing;request.result()is what it reads.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- datasets_list()[source]#
List the datasets to open.
The datasets this tab can open by name: the built-in samples and the person’s own datasets opened before in this browser (My datasets, each with its size and what this browser keeps of it), with the one open now.
Action
datasets.list. It reads only and changes nothing;request.result()is what it reads.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- display_reset()[source]#
Reset the camera and display.
The Reset camera button: the selected view’s camera, its dimension’s navigation mode, the background, the render mode and the smoke resolutions back to their defaults.
Action
display.reset. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_categories(*, field)[source]#
Read the categories of a field.
Each category of a categorical field with its cells, the cells shown in the active view, its colour and whether it is shown.
Action
field.categories. It reads only and changes nothing;request.result()is what it reads.- Parameters:
field (dict) – A field by name: source “obs” for a column of the cells, “var” for a gene; key is the name as shown. Keys:
key,source.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_consensus(*, key, field, mapping, settings, provenance)[source]#
Build the consensus column.
The community annotation’s consensus for a categorical column as a column of its own: each cell gets the agreed label of its category, or the status of a category without one (disputed, pending); built again under the same name, it is replaced. The outcome of each category is named in the parameters, so it replays by name on any dataset with the same column and categories.
Action
field.consensus. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
key (str) – The consensus column’s name.
field (dict) – The annotated column the consensus is of. Keys:
key,source.mapping (list) – The outcome of each category of the column (a category left out is pending).
settings (dict) – The consensus rule it was built with. Keys:
minAnnotators,threshold.provenance (dict) – Where the votes came from. Keys:
branch,commit,pulledAt,repository.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_create_from_pages(*, key, pages, intersection_labels=OMIT, overlap='first', overlap_label='Overlap', uncovered_label='Unassigned')[source]#
Make a field from highlight pages.
A new categorical column whose categories are highlight pages: each page’s cells take its label; cells on several pages follow the overlap rule.
Action
field.create-from-pages. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
key (str) – The new column’s name.
pages (list) – The pages, in order (first and last refer to it), each with its category label.
intersection_labels (list) – With overlap “intersections”: the label of each combination of pages that has cells. Optional: left out, the viewer decides.
overlap ({"first", "last", "overlap-label", "intersections"}) – Cells on several pages: the first page’s label, the last’s, the overlap label, or one label per combination of pages. Default
'first'.overlap_label (str) – The label of cells on several pages when overlap is “overlap-label”. Default
'Overlap'.uncovered_label (str) – The category of cells on no page; empty leaves them without one. Default
'Unassigned'.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_delete(*, field)[source]#
Delete a field.
Remove a column of the cells or a gene from the lists; it can be restored from Deleted fields until purged.
Action
field.delete. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – A field by name: source “obs” for a column of the cells, “var” for a gene; key is the name as shown. Keys:
key,source.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_duplicate(*, field, name=OMIT)[source]#
Duplicate a field.
Copy a column of the cells or a gene as a new field (named “<name> (copy)” unless a name is given) and colour by the copy.
Action
field.duplicate. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_export(*, field)[source]#
Export a field.
Write a column of the cells (categorical or continuous) as an obs-column CSV, as its Export button in Color by does: every open cell and its value, which cellucid.pull() in Python and cellucid_pull() in R read back.
Action
field.export. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
field (dict) – A column of the cells by name (source “obs”), categorical or continuous. Keys:
key,source.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_purge(*, field)[source]#
Purge a deleted field.
Confirm a deletion: the field leaves Deleted fields and can no longer be restored there (undo still brings it back).
Action
field.purge. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – The deleted field by the name it had when deleted. Keys:
key,source.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_push(*, key, kind, categories, n_obs, cells, values)[source]#
Add a column of values.
A notebook’s column as a field of the cells: categorical (codes into its categories) or continuous; a later push of the same name replaces it.
Action
field.push. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
key (str) – The column’s name.
kind ({"categorical", "continuous"}) – See the action’s summary.
categories (list or None) – A categorical column’s categories (its values are codes into them; the largest code is “no category”); null for a continuous one.
n_obs (int) – The cells of the dataset the column belongs to.
cells (cells (rows, a boolean mask or obs names)) – The cells the values are of, as original positions; null for every cell in order.
values (array of numbers, one per cell) – One value per cell named: a code (categorical) or a number (continuous).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_rename(*, field, name)[source]#
Rename a field.
Give a column of the cells or a gene another name; its original name stays known, and renaming it back to that name restores it.
Action
field.rename. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_restore(*, field)[source]#
Restore a deleted field.
Bring back a deleted field under its name, as it was when deleted.
Action
field.restore. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – The deleted field by the name it had when deleted. Keys:
key,source.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_revert_name(*, field)[source]#
Restore a field’s original name.
Give a renamed field back the name it has in the file.
Action
field.revert-name. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – A field by name: source “obs” for a column of the cells, “var” for a gene; key is the name as shown. Keys:
key,source.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- field_summary(*, field, by, top=50, visible_only=False)[source]#
Summarise a field per category.
A continuous field or a gene per category of a categorical field (cells, mean, median, range, share above zero), or a categorical field’s top categories per category.
Action
field.summary. It reads only and changes nothing;request.result()is what it reads.- Parameters:
field (dict) – A field by name: source “obs” for a column of the cells, “var” for a gene; key is the name as shown. Keys:
key,source.by (dict) – The categorical obs field to group the cells by. Keys:
key,source.top (int) – For a categorical field: at most this many of its categories per group. Default
50.visible_only (bool) – Only the cells the active view shows. Default
False.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- fields_list(*, kind=OMIT, query=OMIT)[source]#
List the fields.
The cell annotations (obs fields) with their kind and, for a categorical one, how many categories it has.
Action
fields.list. It reads only and changes nothing;request.result()is what it reads.- Parameters:
kind ({"categorical", "continuous"}) – Only fields of this kind. Optional: left out, the viewer decides.
query (str) – Only fields whose key contains this text (any case). Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- figure_export()[source]#
Export the figure.
Write the figure of the view shown (every view in a grid when the settings say so) as its Download button does, with the figure export’s settings as they are (figure_export_set changes them: format, size, labels, legend, style): one SVG or PNG file, or several in one ZIP archive. Refused, saying why, when the figure cannot reproduce what the view shows (a render mode other than points, an overlay it cannot draw).
Action
figure.export. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- figure_export_set(*, auto_text_size=OMIT, background=OMIT, background_color=OMIT, depth_sort=OMIT, download=OMIT, dpi=OMIT, emphasize_selection=OMIT, export_all_views=OMIT, font_family=OMIT, font_sizes=OMIT, frame=OMIT, height=OMIT, include_axes=OMIT, include_legend=OMIT, legend_position=OMIT, optimized_target_count=OMIT, preview=OMIT, reference_grid=OMIT, selection_muted_opacity=OMIT, show_orientation=OMIT, size_preset=OMIT, svg_strategy=OMIT, title=OMIT, title_follows_dataset=OMIT, width=OMIT, x_label=OMIT, y_label=OMIT)[source]#
Change figure export settings.
Set Figure export options: size, frame, background, fonts, title and axis labels, axes, legend, preview, what Export downloads; only those given change, nothing is exported.
Action
figure-export.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
auto_text_size (bool) – Size the text from the figure’s size (font_sizes is then null). Optional: left out, the viewer decides.
background ({"viewer", "white", "transparent", "custom"}) – The background: the viewer’s, white, transparent or custom. Optional: left out, the viewer decides.
background_color (str) – The custom background colour, lowercase #rrggbb. Optional: left out, the viewer decides.
depth_sort (bool) – Draw 3D points back to front. Optional: left out, the viewer decides.
download ({"svg", "png", "svg+png", "png-multi", "all"}) – What Export downloads. Optional: left out, the viewer decides.
dpi ({150, 300, 600}) – The resolution of a PNG. Optional: left out, the viewer decides.
emphasize_selection (bool) – Fade the cells that are not highlighted. Optional: left out, the viewer decides.
export_all_views (bool) – Export every view of the multiview, side by side. Optional: left out, the viewer decides.
font_family ({"Arial, Helvetica, sans-serif", "Helvetica, Arial, sans-serif", "\"Times New Roman\", Times, serif"}) – The font of every text. Optional: left out, the viewer decides.
font_sizes (dict or None) – Text sizes in pixels while auto_text_size is off, else null. Keys:
axis_label,base,centroid_label,legend,ticks,title. Optional: left out, the viewer decides.frame (dict or None) – The part of the view exported (needs the preview on), or null for the whole view. Keys:
lock_aspect,rect. Optional: left out, the viewer decides.height (int) – Plot height in CSS pixels. Optional: left out, the viewer decides.
include_axes (bool) – Draw the axes. Optional: left out, the viewer decides.
include_legend (bool) – Draw the legend. Optional: left out, the viewer decides.
legend_position ({"right", "bottom"}) – Where the legend goes. Optional: left out, the viewer decides.
optimized_target_count (int) – How many points an optimized SVG keeps. Optional: left out, the viewer decides.
preview (dict) – The preview in the panel and the colour-vision deficiency it simulates. Keys:
colorblind_mode,enabled. Optional: left out, the viewer decides.reference_grid (bool) – Draw a reference grid. Optional: left out, the viewer decides.
selection_muted_opacity (float) – The opacity of the faded cells, 0 to 1. Optional: left out, the viewer decides.
show_orientation (bool) – Draw the 3D orientation indicator. Optional: left out, the viewer decides.
size_preset ({"screen-half", "screen", "1200x900", "1600x1200", "1920x1080"}) – The size preset shown in the panel. Optional: left out, the viewer decides.
svg_strategy ({"full-vector", "optimized-vector", "hybrid", null}) – How an SVG draws many points, or null until chosen. Optional: left out, the viewer decides.
title (str or None) – The figure title while it does not follow the dataset, else null. Optional: left out, the viewer decides.
title_follows_dataset (bool) – The title is the dataset’s name (title is then null). Optional: left out, the viewer decides.
width (int) – Plot width in CSS pixels. Optional: left out, the viewer decides.
x_label (str) – The x axis label. Optional: left out, the viewer decides.
y_label (str) – The y axis label. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_category_all(*, field, visible)[source]#
Show or hide every category.
Show or hide every category of a categorical column that has open cells, and the cells without a category.
Action
filter.category.all. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_category_cell_count(*, field, category, count, seed=0)[source]#
Keep N cells of a category.
Show only `count` cells of one category, a random sample drawn with `seed` (the same seed and count show the same cells; a larger count adds cells); null shows all its cells again.
Action
filter.category.cell-count. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_category_missing(*, field, visible)[source]#
Show or hide cells without a category.
Show or hide the cells of a categorical column that have no category (the legend’s Missing row).
Action
filter.category.missing. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_category_visibility(*, field, categories, visible)[source]#
Show or hide categories.
Show or hide the cells of one or more categories of a categorical column.
Action
filter.category.visibility. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_continuous_range(*, field, min, max)[source]#
Set a visible range.
Show only the cells whose value of a continuous field or gene lies in [min, max]; the colours follow when they are rescaled to the range.
Action
filter.continuous.range. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_continuous_reset(*, field)[source]#
Reset a visible range.
Show every value of a continuous field or gene again.
Action
filter.continuous.reset. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – The continuous field or gene the view in focus is coloured by, by name. Keys:
key,source.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_enable(*, field, kind, enabled)[source]#
Turn a filter on or off.
Turn a field’s category, range or outlier filter off (its settings kept) or on again.
Action
filter.enable. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_outlier(*, field, threshold)[source]#
Filter outliers.
Hide the cells of each category that lie furthest from it in the latent space: those above the threshold quantile (1 hides none).
Action
filter.outlier. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- filter_remove(*, field, kind)[source]#
Remove a filter.
Remove a field’s category, range or outlier filter: every cell it hid is shown again.
Action
filter.remove. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – The field or gene whose filter it is, by name. Keys:
key,source.kind ({"category", "continuous", "outlier"}) – See the action’s summary.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- gene_set_save(*, name, genes, description='')[source]#
Keep a gene set.
A named list of genes, kept with the dataset for analyses and sessions; a later set of the same name replaces it.
Action
gene-set.save. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- genes_search(*, query, limit=20)[source]#
Search the genes.
Gene names matching what is typed, best first, as the gene search box ranks them.
Action
genes.search. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_category(*, field, category, color=OMIT, page=OMIT)[source]#
Highlight a category.
Add the cells of one category of a field, as the selected view shows them, as a group.
Action
highlight.category. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – A categorical field, by name. Keys:
key,source.category (str or float or bool) – The category, by its label as the legend shows it.
color (str) – The colour of the page the group goes on. With `page`, the colour of the page made (an existing page must already have it). Without, the page shown when it has this colour, else the first page that has it, else a new page of it. Optional: left out, the viewer decides.
page (str) – The page the group goes on, by name; a page of that name is made when there is none. Omitted: the page shown, or with `color`, a page of that colour. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_cells(*, cells, color=OMIT, label=OMIT, page=OMIT, tool='annotation')[source]#
Highlight cells.
Add a group of cells to a highlight page: a confirmed selection, or cells an agent or notebook names.
Action
highlight.cells. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
cells (cells (rows, a boolean mask or obs names)) – Cells by original position (0-based row of obs), each once, in any order.
color (str) – The colour of the page the group goes on. With `page`, the colour of the page made (an existing page must already have it). Without, the page shown when it has this colour, else the first page that has it, else a new page of it. Optional: left out, the viewer decides.
label (str) – The group’s label; omitted, “Highlight (N cells)”. A label already on the page gets “ (2)”, “ (3)”, …. Optional: left out, the viewer decides.
page (str) – The page the group goes on, by name; a page of that name is made when there is none. Omitted: the page shown, or with `color`, a page of that colour. Optional: left out, the viewer decides.
tool ({"annotation", "lasso", "proximity", "knn"}) – The selection tool that made the cells (annotation for cells named directly). Default
'annotation'.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_clear_all()[source]#
Clear every highlight.
Remove every group of every highlight page; the pages stay.
Action
highlight.clear-all. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_group_remove(*, group, page=OMIT)[source]#
Remove a highlight group.
Remove one group from a highlight page.
Action
highlight.group.remove. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_group_toggle(*, group, enabled, page=OMIT)[source]#
Show or hide a highlight group.
Turn one group of a page on or off; a group that is off highlights nothing.
Action
highlight.group.toggle. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_page_clear(*, page=OMIT)[source]#
Clear a highlight page.
Remove every group of one highlight page; the page stays.
Action
highlight.page.clear. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
page (str) – The page, by name; omitted, the page shown. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_page_combine(*, pages, operation, name=OMIT)[source]#
Combine two highlight pages.
Make a page of the cells in both pages (intersection) or in either (union), and show it.
Action
highlight.page.combine. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_page_create(*, color=OMIT, name=OMIT)[source]#
Make a highlight page.
Add an empty highlight page and show it.
Action
highlight.page.create. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_page_delete(*, page)[source]#
Delete a highlight page.
Delete a highlight page and its groups; the last page cannot be deleted.
Action
highlight.page.delete. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
page (str) – A highlight page, by its name as its tab shows it.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_page_recolor(*, page, color)[source]#
Recolour a highlight page.
Set the colour a highlight page has in its tab, the analyses and the category builder.
Action
highlight.page.recolor. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_page_rename(*, page, name)[source]#
Rename a highlight page.
Give a highlight page another name, unique among the pages.
Action
highlight.page.rename. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_page_switch(*, page)[source]#
Show a highlight page.
Show another highlight page: its groups are the highlighted cells.
Action
highlight.page.switch. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
page (str) – A highlight page, by its name as its tab shows it.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- highlight_range(*, field, min, max, color=OMIT, page=OMIT)[source]#
Highlight a range of values.
Add the cells whose value of a continuous field or gene lies in a range, as the selected view shows them, as a group.
Action
highlight.range. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
field (dict) – A continuous field or a gene, by name. Keys:
key,source.min (float) – The smallest value included.
max (float) – The largest value included.
color (str) – The colour of the page the group goes on. With `page`, the colour of the page made (an existing page must already have it). Without, the page shown when it has this colour, else the first page that has it, else a new page of it. Optional: left out, the viewer decides.
page (str) – The page the group goes on, by name; a page of that name is made when there is none. Omitted: the page shown, or with `color`, a page of that colour. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_anndata_save(*, file=OMIT)[source]#
Save AnnData with this state.
Write a new Cellucid-ready AnnData file (.zarr.zip) of the whole open dataset with the state shown applied, as Python and R apply a session: renamed labels, user-defined fields and highlight groups as obs columns, gene sets in uns and var, and a record of what was applied; never over the dataset’s own file.
Action
history.anndata.save. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
file (str) – The new file’s name (.zarr.zip is added when it does not end so); “<dataset> with this state.zarr.zip” when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_bookmark_set(*, step, name)[source]#
Bookmark a step.
Give a step a bookmark name, unique in its tracker (jump to it by name), or remove it with null. Bookmark before destructive or heavy work.
Action
history.bookmark.set. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_apply(*, branch, name=OMIT, tracker=OMIT)[source]#
Apply a branch’s steps here.
Apply a branch’s own steps again, by name, on top of the step shown, as a new branch (no values are merged; a step that does not apply here is flagged).
Action
history.branch.apply. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
branch (str) – A branch by its name or its id (history_summary lists them).
name (str) – A name, unique among its kind (compared without case and extra spaces); no length limit. Optional: left out, the viewer decides.
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_archive(*, branch, archived, tracker=OMIT)[source]#
Archive a branch.
Hide a branch from the graph and the pickers, or show it again; it is kept and can be shared. Main cannot be archived.
Action
history.branch.archive. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_cancel()[source]#
Cancel a new branch.
Forget the branch “Branch here” set to start with the next change.
Action
history.branch.cancel. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_create(*, step, name=OMIT)[source]#
Branch here.
Show a step and start a new branch from it with the next change (a branch exists from its first step); the name defaults to the next “Branch n”.
Action
history.branch.create. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_delete(*, branch, tracker=OMIT, with_sub_branches=False)[source]#
Delete a branch.
Move a branch’s own steps (those no other branch starts from) to Recently deleted, where they can be restored; with with_sub_branches, the branches that start from it too. Main and locked branches cannot be deleted.
Action
history.branch.delete. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
branch (str) – A branch by its name or its id (history_summary lists them).
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
with_sub_branches (bool) – Also delete every branch that starts from it. Default
False.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_lock(*, branch, locked, tracker=OMIT)[source]#
Lock a branch.
Lock a branch (no new step, rename, delete or compaction until unlocked; a change at its tip starts a new branch), or unlock it.
Action
history.branch.lock. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_rename(*, branch, name, tracker=OMIT)[source]#
Rename a branch.
Give a branch another name, unique in its tracker.
Action
history.branch.rename. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
branch (str) – A branch by its name or its id (history_summary lists them).
name (str) – A name, unique among its kind (compared without case and extra spaces); no length limit.
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_set_main(*, branch, tracker=OMIT)[source]#
Make a branch main.
Make a branch the tracker’s main one, what sharing, replay and loading default to.
Action
history.branch.set-main. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_switch(*, branch, tracker=OMIT)[source]#
Switch branch.
Show a branch’s last step and continue on it; an agent’s turn continues on it too.
Action
history.branch.switch. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_branch_without(*, step, name=OMIT)[source]#
Branch without a step.
Make a new branch from a step’s parent that applies the later steps of the path again without it, by name; nothing existing changes. The report says what did not apply.
Action
history.branch.without. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_clear(*, keep_state)[source]#
Clear the history.
Start the branch “Fresh start” from the opening step with nothing behind it: keeping the state shown (one squashed step from the dataset as opened to it), or from the dataset as opened (the branch starts with the next change). Every branch stays, archivable; either way it is kept in Recently changed and can be undone there.
Action
history.clear. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
keep_state (bool) – True keeps the state shown as one step; false starts over from the dataset as opened.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_diff(*, a, b)[source]#
Compare two steps.
What differs between the state after two steps, part by part (filters, labels, highlights, …); the steps may be of two trackers.
Action
history.diff. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_get(*, all_branches=False, branch=OMIT, cursor=OMIT, fields=OMIT, limit=200, since=OMIT, tracker=OMIT)[source]#
Read the history.
The steps taken on this dataset, who took each (person, agent, notebook), branches and the step shown.
Action
history.get. It reads only and changes nothing;request.result()is what it reads.- Parameters:
all_branches (bool) – Every branch, not only the path to the step shown. Default
False.branch (str) – The path to this branch’s tip (by its name or id) instead of the path to the step shown; not with all_branches. Optional: left out, the viewer decides.
cursor (str) – Where the page starts: the next of the last page (its last step’s id); the first page when left out. Optional: left out, the viewer decides.
fields (list) – What to add to each step: params (each parameter in words), notes, bookmark. Optional: left out, the viewer decides.
limit (int) – The steps of one page (200 when left out: well under what a tool result carries). Default
200.since (float) – Only the steps recorded at or after this time (milliseconds since 1970: a step’s “at”), so a second read lists what came since. Optional: left out, the viewer decides.
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_group_create(*, from_, to, name)[source]#
Group steps.
Name a run of consecutive steps of one branch as a group (a folder; nothing is changed or merged). It holds whole turns; a step is in one group at most. Group a multi-step analysis under a short name.
Action
history.group.create. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_group_extend(*, group, to, tracker=OMIT)[source]#
Add steps to a group.
Extend a group to a later step of its branch, taking in every step between (whole turns, none of another group).
Action
history.group.extend. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_group_remove(*, group, tracker=OMIT)[source]#
Ungroup.
Remove a group; its steps stay as they are.
Action
history.group.remove. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_group_rename(*, group, name, tracker=OMIT)[source]#
Rename a group.
Give a group another name, unique in its tracker.
Action
history.group.rename. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
group (str) – A group by its name or its id (history_summary lists them).
name (str) – A name, unique among its kind (compared without case and extra spaces); no length limit.
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_journal_empty(*, entry=OMIT, tracker=OMIT)[source]#
Empty Recently deleted.
Drop what Recently deleted keeps (one entry, or all of them) so its values can be freed; it can no longer be restored.
Action
history.journal.empty. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_journal_undo(*, entry, tracker=OMIT)[source]#
Restore from Recently deleted.
Undo an edit of the history (a delete, a rename, a note, …) from Recently deleted: exactly as it was when nothing changed it since, else as new objects (“X (restored)”, removed steps applied again as a branch). Undoing a rename whose old name was taken since is refused, naming the name to use instead.
Action
history.journal.undo. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_jump(*, at=OMIT, bookmark=OMIT, step=OMIT)[source]#
Show a step.
Show the state after any step of the tracker in use, on any branch, as clicking it in the timeline does; nothing is undone or lost. Name exactly one of step, bookmark or at.
Action
history.jump. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
at (float) – A time (milliseconds since 1970): show the last step at or before it on the branch shown. Optional: left out, the viewer decides.
bookmark (str) – A bookmark’s name (any case): show the step it marks. Optional: left out, the viewer decides.
step (str) – A step of the tracker in use, by its id (history_get lists the steps). Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_methods(*, branch=OMIT, tracker=OMIT)[source]#
Write the methods paragraph.
The methods paragraph of a branch (main when left out): the dataset and its citation, the cells used, each step that changed the analysis, the tracker’s notes as its opening, and the Cellucid version.
Action
history.methods. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_note_add(*, target, text, from_reply=False)[source]#
Add a note.
Write a note on a step, a branch, a turn or a tracker. End each turn that changed something with a one-line summary note on the turn.
Action
history.note.add. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
target (dict or dict or dict or dict or dict) – What the note is on: a step, a branch, a group, a turn, or a tracker itself.
text (str) – Markdown: emphasis, inline code and http(s) links; shown without HTML.
from_reply (bool) – Taken from the agent’s final reply (the turn summary written for an agent that wrote none). Default
False.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_note_edit(*, note, text, tracker=OMIT)[source]#
Edit a note.
Change a note’s text. An agent edits only its own notes; the person edits any.
Action
history.note.edit. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
note (str) – A note, by its id (history_step and history_summary list them).
text (str) – Markdown: emphasis, inline code and http(s) links; shown without HTML.
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_note_remove(*, note, tracker=OMIT)[source]#
Remove a note.
Remove a note. An agent removes only its own notes; the person removes any.
Action
history.note.remove. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_pseudocode(*, branch=OMIT, tracker=OMIT)[source]#
Write the pseudocode.
A branch’s steps (main when left out) as pseudocode, one line each, as recorded.
Action
history.pseudocode. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_recording_pause(*, tracker=OMIT)[source]#
Pause recording.
Pause the history of a tracker: changes still apply but make no step until it is resumed, and an agent’s change cannot be undone on its own meanwhile. Ask the person first.
Action
history.recording.pause. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_recording_resume(*, tracker=OMIT)[source]#
Resume recording.
Record again: what differs from the step shown becomes one squashed step (“While paused: …”), by everyone who acted meanwhile; nothing when nothing differs.
Action
history.recording.resume. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_redo()[source]#
Redo.
Show the step after the one shown now on the branch last taken, as the State panel’s Redo does.
Action
history.redo. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_replay(*, saved, branch=OMIT, mapping=OMIT, name=OMIT, tracker=OMIT)[source]#
Replay a saved history.
Apply a saved state’s branch (its main branch when left out) again here, step by step by name, in a new tracker linked to it; with a mapping, other names are used for fields, categories and genes. The report says what did not match.
Action
history.replay. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
saved (str) – A saved state of this browser (history_saved_list).
branch (str) – Its branch; its main branch when left out. Optional: left out, the viewer decides.
mapping (dict) – Names to use in place of the recorded ones, each from its recorded name (the replay report offers them: a step’s missing names what matched nothing here). A category is named by its field’s recorded key. Keys:
categories,fields,genes. Optional: left out, the viewer decides.name (str) – A name, unique among its kind (compared without case and extra spaces); no length limit. Optional: left out, the viewer decides.
tracker (str) – Its tracker, by name or id; its tracker shown when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_report(*, as_='file', file=OMIT, pictures='none')[source]#
Make the printable report.
The State panel’s printable report of the branch shown up to the step shown (the dataset, the methods text, every step with who took it, its parameters, what it changed and its notes, then the pseudocode), as an .html file the person receives (asked first) or as its text; with pictures of the views after the steps chosen (a file only).
Action
history.report. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
as ({"file", "text"}) – file: an .html file downloaded to the person’s computer, which they open, print or save as PDF; text: the same HTML document in the result (no pictures). Default
'file'.file (str) – The file’s name; the dataset’s name and “history report” when left out. Optional: left out, the viewer decides.
pictures ({"none", "default"} or list) – The steps that get a picture of the views after them (each is shown in turn and drawn, then the history returns to the step shown). A file only. Default
'none'.as_ (Literal['file', 'text'])
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_save(*, content='history', name=OMIT, results='include')[source]#
Save the history in this browser.
Keep the history (every tracker), the current state only, or the steps only as a named saved state of this browser (history_saved_list lists them; replay or load it later).
Action
history.save. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
content ({"history", "state", "steps"}) – history: the trackers and branches with their values; state: the current state only, without its history (one squashed step “Shared state”); steps: the steps only, no cells or values (a replay plan for any dataset). Default
'history'.name (str) – Its name; the dataset’s name and the time when left out. Optional: left out, the viewer decides.
results ({"include", "recompute"}) – Analysis results: include them, or leave them out to compute again on open from their recorded inputs (smaller; always so for steps). Default
'include'.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_saved_delete(*, saved)[source]#
Delete a saved state.
Remove one saved state of this browser (an autosave or a named save, by its id from history_saved_list) with every value only it held; it cannot be brought back. The history shown stays open.
Action
history.saved.delete. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
saved (str) – Its id (history_saved_list).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_saved_list()[source]#
List saved states.
The histories kept in this browser (each dataset’s autosave and the named saves): name, dataset, trackers, steps, size, and whether this version opens them.
Action
history.saved.list. It reads only and changes nothing;request.result()is what it reads.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_search(*, bookmarked=OMIT, by=OMIT, domain=OMIT, flagged=OMIT, has_note=OMIT, kind=OMIT, step_kind=OMIT, text=OMIT, tracker=OMIT)[source]#
Search the history.
The steps whose label, parameters, notes or bookmark match, filtered by who took them, their kind, the part of the state they changed, notes, bookmarks and flags.
Action
history.search. It reads only and changes nothing;request.result()is what it reads.- Parameters:
bookmarked (bool) – Optional: left out, the viewer decides.
by ({"person", "agent", "python", "r", "replay", "outside"}) – Who took them. Optional: left out, the viewer decides.
domain ({"cells", "mapping", "field-overlays", "gene-sets", "views", "active-field", "filters", "colors", "visibility", "highlights", "camera", "camera-path", "settings", "analysis", "layout"}) – The part of the state they changed. Optional: left out, the viewer decides.
flagged (bool) – Stale, or no longer applying. Optional: left out, the viewer decides.
has_note (bool) – Optional: left out, the viewer decides.
kind ({"state", "view", "layout"}) – What their action changes. Optional: left out, the viewer decides.
step_kind ({"root", "action", "outside", "squashed"}) – What they are: root, action, outside (changed outside an action) or squashed. Optional: left out, the viewer decides.
text (str) – Words to find (any case). Optional: left out, the viewer decides.
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
Share the history as a file.
Write a session file to share: the history (trackers and branches chosen; the tracker in use, its main and shown branches by default), the current state only, or the steps only; with or without notes, conversations, Recently deleted, times and where the dataset opens from.
Action
history.share. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
chats (bool) – Conversations kept with the trackers (never with a state). Default
False.content ({"history", "state", "steps"}) – history: the trackers and branches with their values; state: the current state only, without its history (one squashed step “Shared state”); steps: the steps only, no cells or values (a replay plan for any dataset). Default
'history'.file (str) – The file’s name; the dataset’s name when left out. Optional: left out, the viewer decides.
include (list) – The trackers to include, each with its branches (its main and shown branches when left out); the tracker in use when left out. Optional: left out, the viewer decides.
journal (bool) – Recently deleted (never with a state). Default
False.notes (bool) – Notes and bookmarks (never with a state). Default
True.results ({"include", "recompute"}) – Analysis results: include them, or leave them out to compute again on open from their recorded inputs (smaller; always so for steps). Steps only always recompute, whatever is given. Default
'include'.source ({"full", "name"}) – full: the dataset’s name and where it opens from; name: its name only. Default
'full'.times ({"exact", "dates", "none"}) – exact; dates (each rounded down to its day); none. When left out: exact for a history or steps, none for a state. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_squash(*, from_, to)[source]#
Merge steps into one.
Replace consecutive steps of one branch (from first to last, whole turns; a group’s are its steps) with one squashed step from the first one’s state to the last one’s; elsewhere it replays as values only. Refused when another branch starts inside; the steps go to Recently deleted. An agent squashes only its own turn’s steps.
Action
history.squash. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_stale(*, tracker=OMIT)[source]#
List stale results.
Steps whose result no longer matches its inputs (the cells, the mapping, a highlight changed since), each with the step that made it stale and why.
Action
history.stale. It reads only and changes nothing;request.result()is what it reads.- Parameters:
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_step(*, step, tracker=OMIT)[source]#
Read a step.
One step in full: its parameters, pseudocode, who took it and when, what it changed and read, its notes and bookmark, and why it is stale.
Action
history.step. It reads only and changes nothing;request.result()is what it reads.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_step_delete(*, step)[source]#
Delete a step.
Move one step to Recently deleted; only the later steps that changed or read what it changed are applied again, and one that no longer applies is kept, flagged.
Action
history.step.delete. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
step (str) – A step of the tracker in use, by its id (history_get lists the steps).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_step_revert(*, step)[source]#
Revert a step.
Add a step that puts back exactly what a step changed, when no later step on the path changed the same parts (else use Branch without a step).
Action
history.step.revert. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
step (str) – A step of the tracker in use, by its id (history_get lists the steps).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_summary(*, tracker=OMIT)[source]#
Summarise the history.
The history at a glance: trackers, branches (fork step, tip, steps, main, locked, archived), bookmarks, turns with their summaries, stale results and Recently deleted, without the steps. Read it before acting on the history.
Action
history.summary. It reads only and changes nothing;request.result()is what it reads.- Parameters:
tracker (str) – A tracker by its name or its id (history_summary lists them); the tracker in use when left out. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_tour_start()[source]#
Start the guided tour.
Play the State panel’s guided tour of the branch shown, from the opening to the step shown: each step is shown in turn with its caption and notes (a camera step is flown to), for a talk or a class. It returns once the tour plays; the person pauses, steps or stops it, or history_tour_stop does.
Action
history.tour.start. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_tour_stop()[source]#
Stop the guided tour.
Stop the guided tour, as its Stop button does: the history returns to the step shown before it began (unless the person made a step meanwhile).
Action
history.tour.stop. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_tracker_remove(*, tracker)[source]#
Remove a tracker.
Move a tracker to Recently deleted, where it can be restored; when it is the one in use, the one used before it is shown first.
Action
history.tracker.remove. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
tracker (str) – A tracker by its name or its id (history_summary lists them).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_tracker_rename(*, tracker, name)[source]#
Rename a tracker.
Give a tracker another name, unique among this dataset’s trackers.
Action
history.tracker.rename. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_tracker_start(*, name=OMIT, start='opened')[source]#
Start another tracker.
Start a new tracker, an independent tree of steps on this dataset: from the dataset as opened (the default), or from what is shown.
Action
history.tracker.start. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
name (str) – A name, unique among its kind (compared without case and extra spaces); no length limit. Optional: left out, the viewer decides.
start ({"opened", "shown"}) – opened: the dataset as it was opened; shown: what is shown now. Default
'opened'.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_tracker_use(*, tracker)[source]#
Use another tracker.
Show another tracker’s step shown and record into it.
Action
history.tracker.use. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
tracker (str) – A tracker by its name or its id (history_summary lists them).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_turn_undo(*, turn, only_own=False)[source]#
Undo a turn.
Take back one agent or notebook turn on the branch shown: show the step before it, or, with only_own, delete only the turn’s own steps (applying the others again) when someone else’s steps came in between.
Action
history.turn.undo. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_undo()[source]#
Undo.
Show the state before the step shown now, as the State panel’s Undo does; the step stays in the history, to redo.
Action
history.undo. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- history_verify(*, branch, keep=False, tracker=OMIT)[source]#
Verify a branch.
Replay a branch on this dataset into a scratch tracker and compare every part of the state at the end with its last step: reproduced exactly, or the first step whose values differ.
Action
history.verify. It moves the viewer’s history, as the person’s Undo, Redo or a click on a step does, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- layout_get()[source]#
Read the layout.
The sidebar’s sections (docked or floating, where, open or closed), whether the sidebar shows and how wide, and the theme.
Action
layout.get. It reads only and changes nothing;request.result()is what it reads.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- layout_panel_dock(*, panel)[source]#
Dock a section.
Put a floating sidebar section back into the sidebar, where it was.
Action
layout.panel.dock. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
panel (str) – A sidebar section by its title (Visualization, Navigation, …) or its id.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- layout_panel_float(*, panel, height=OMIT, left=OMIT, top=OMIT, width=OMIT)[source]#
Undock a section.
Tear a sidebar section off into a floating window, at a given place and size or beside the sidebar.
Action
layout.panel.float. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
panel (str) – A sidebar section by its title (Visualization, Navigation, …) or its id.
height (float) – Height in CSS pixels (kept at least its header and first row). Optional: left out, the viewer decides.
left (float) – Distance of its left edge from the left of the window, in CSS pixels. Optional: left out, the viewer decides.
top (float) – Distance of its top edge from the top of the window, in CSS pixels. Optional: left out, the viewer decides.
width (float) – Width in CSS pixels (kept at least its smallest working width). Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- layout_panel_place(*, panel, left, top, width, height)[source]#
Move or resize a floating section.
Give a floating sidebar section a place and size; it is kept inside the window.
Action
layout.panel.place. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
panel (str) – A sidebar section by its title (Visualization, Navigation, …) or its id.
left (float) – Distance of its left edge from the left of the window, in CSS pixels.
top (float) – Distance of its top edge from the top of the window, in CSS pixels.
width (float) – Width in CSS pixels (kept at least its smallest working width).
height (float) – Height in CSS pixels (kept at least its header and first row).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- layout_section_open(*, section, open)[source]#
Open or close a section.
Open or close a section of the sidebar (docked or floating).
Action
layout.section.open. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- layout_sidebar_show(*, shown)[source]#
Show or hide the sidebar.
Show the sidebar beside the plot, or hide it to give the plot the whole window.
Action
layout.sidebar.show. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
shown (bool) – True shows the sidebar, false hides it.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- layout_sidebar_width(*, width)[source]#
Resize the sidebar.
Set the sidebar’s width (kept between its narrowest and widest).
Action
layout.sidebar.width. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
width (float) – Width in CSS pixels.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- layout_theme_set(*, theme)[source]#
Choose the theme.
Show the app light or dark.
Action
layout.theme.set. It changes the viewer’s layout, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
theme ({"light", "dark"}) – See the action’s summary.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- mapping_set(*, embeddings=OMIT, expression=OMIT, gene_names=OMIT, highly_variable=OMIT, knn=OMIT, latent=OMIT, log1p=OMIT, modality=OMIT, vector_fields=OMIT)[source]#
Change the data mapping.
Choose which stored arrays are the embeddings, neighbour graph, genes (modality, expression matrix, gene names, log1p, highly variable), latent space and vector fields; groups not named stay as they are. Applied as one change: refused, nothing changes.
Action
mapping.set. It changes the data’s meaning (fields, labels, filters, highlights, results), as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
embeddings (dict) – The embeddings views can show, sorted by key then columns, and the default of each dimension. Keys:
defaults,enabled. Optional: left out, the viewer decides.expression (str or None) – “X”, “raw”, “layer:<name>”, or null for no genes. Optional: left out, the viewer decides.
gene_names (str) – “index”, or “column:<var column>”. Optional: left out, the viewer decides.
highly_variable (str or None) – The boolean var column marking highly variable genes, or null. Optional: left out, the viewer decides.
knn (str or None) – The obsp neighbour graph, or null for none. Optional: left out, the viewer decides.
latent (str or None) – The obsm latent space outlier filters use, or null. Optional: left out, the viewer decides.
log1p (list) – Each expression matrix that holds log1p values, with its base (null: e). Optional: left out, the viewer decides.
modality (str) – The modality genes are read from (a dataset of several). Optional: left out, the viewer decides.
vector_fields (list) – Vector fields bound to enabled embeddings, sorted by embedding then key. Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- my_datasets_forget(*, name, saved_states=False)[source]#
Forget a dataset of My datasets.
Remove one dataset from My datasets, as its Forget in My datasets › All… does: the entry and, for a file or folder of this computer, the browser’s handle of it; its saved states only when asked. The dataset itself is not touched, and nothing brings the entry back but opening it again.
Action
my-datasets.forget. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- setting_set(*, setting, value)[source]#
Change a setting.
Set one render, navigation, overlay or tool setting of the sidebar; settings.list names each, with its kind, range and choices.
Action
setting.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- settings_list(*, section=OMIT)[source]#
List the settings.
Every setting of the sidebar with its label, section, kind, value, range or choices, and whether it can be changed now.
Action
settings.list. It reads only and changes nothing;request.result()is what it reads.- Parameters:
section (str) – Only the settings of the sidebar section with this title (Visualization, Navigation, …). Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- stored_list()[source]#
List what this browser keeps.
Everything kept in this browser for later visits, as the Stored dialog lists it: per dataset (its file’s name and host) the converted copies, downloads, downloaded parts and gene indexes with their sizes; then the saved states, My datasets, the connection speeds and the decoder choices; and how much room the browser gives the site.
Action
stored.list. It reads only and changes nothing;request.result()is what it reads.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- stored_remove(*, connection_speeds=False, dataset=OMIT, decoder_choices=False, everything=False, items=OMIT, my_datasets=False, saved_states=False)[source]#
Remove what this browser keeps.
Remove what the Stored dialog removes: kept items by id, all a dataset’s kept items, every saved state, My datasets (the list and the files’ handles), the connection speeds, the decoder choices, or everything (Remove all). An item an open tab uses stays until that tab closes. Nothing brings it back; the dataset opens again more slowly the first time.
Action
stored.remove. It acts outside the viewer’s state and history (a file the person receives in the browser, a publication, or what the browser keeps for later visits), which Undo does not take back, and records no step;request.result()is its outcome.- Parameters:
connection_speeds (bool) – The connection speeds remembered per host. Default
False.dataset (str) – Every kept item of the dataset with this file name (stored_list). Optional: left out, the viewer decides.
decoder_choices (bool) – The decoder choices measured in this browser. Default
False.everything (bool) – Everything no open tab uses, as Remove all. Default
False.items (list) – Kept items by id (stored_list). Optional: left out, the viewer decides.
my_datasets (bool) – My datasets: the list and the handles of its files (my_datasets_forget forgets one). Default
False.saved_states (bool) – Every saved state of this browser (history_saved_delete deletes one). Default
False.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_cameras_link(*, linked)[source]#
Link cameras.
Let views that show the same embedding share one camera, or give each view its own.
Action
view.cameras.link. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
linked (bool) – true to link, false to unlink.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_clear()[source]#
Remove every kept view.
Remove every kept view and show the live view alone (as View 1).
Action
view.clear. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_embedding_cycle(*, view, dimension)[source]#
Next embedding of a dimension.
The 1, 2 and 3 keys: a view showing another dimension shows this dimension’s default; one already showing it moves to the next enabled embedding.
Action
view.embedding.cycle. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
view (str) – A view: “View N” as the Compare views list numbers its rows (the live view is View 1 while it is shown, the kept views follow in the order they were kept).
dimension ({1, 2, 3}) – The dimension: 1, 2 or 3.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_embedding_default(*, view, dimension)[source]#
Show the default embedding.
Show the dataset’s default embedding of one dimension in a view; the view follows that default from then on.
Action
view.embedding.default. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
view (str) – A view: “View N” as the Compare views list numbers its rows (the live view is View 1 while it is shown, the kept views follow in the order they were kept).
dimension ({1, 2, 3}) – The dimension: 1, 2 or 3.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_embedding_set(*, view, embedding)[source]#
Show an embedding.
Show one enabled embedding in a view; the view keeps it when the data mapping changes its defaults.
Action
view.embedding.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_focus(*, view)[source]#
Select a view.
Select the view the sidebar edits and the camera controls drive.
Action
view.focus. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
view (str) – A view: “View N” as the Compare views list numbers its rows (the live view is View 1 while it is shown, the kept views follow in the order they were kept).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_keep(*, branch=OMIT)[source]#
Keep the view.
Freeze the selected view as a panel of the multiview, with its colouring, filters and camera, and select it; with a branch, the view as it is at the last step of that branch of the history (to compare branches side by side).
Action
view.keep. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
branch (str) – A branch of the tracker in use, by its name: the kept view shows what the selected view shows at its last step (colouring, filters, hidden cells, camera). Optional: left out, the viewer decides.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_layout_set(*, layout)[source]#
Set the view layout.
Show every view side by side (grid) or the selected view alone (single).
Action
view.layout.set. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
layout ({"grid", "single"}) – “grid” or “single”.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_picture(*, height=480, legend=True, view=OMIT, width=640)[source]#
Take a picture of a view.
A PNG of a view as the figure export draws it (points, legend), returned as base64; nothing is downloaded.
Action
view.picture. It reads only and changes nothing;request.result()is what it reads.- Parameters:
height (int) – The plot’s height in pixels. Default
480.legend (bool) – Draw the colour legend beside the plot. Default
True.view (str) – The view: “View N” as the Compare views list numbers it; the selected view when left out. Optional: left out, the viewer decides.
width (int) – The plot’s width in pixels (the picture adds its margins and the legend). Default
640.
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- view_remove(*, view)[source]#
Remove a view.
Remove a view; removing the live view (View 1) hides it while two or more kept views remain.
Action
view.remove. It changes how the cells are shown, as one step of the viewer’s history, which the person can undo;request.result()is its outcome andrequest.stepthe step.- Parameters:
view (str) – A view: “View N” as the Compare views list numbers its rows (the live view is View 1 while it is shown, the kept views follow in the order they were kept).
- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
- views_state()[source]#
Read the views.
Each open view: its name (what actions name it by), its title, the representation it shows, what it is coloured by, its filters and camera; the layout; the highlight pages with their groups.
Action
views.state. It reads only and changes nothing;request.result()is what it reads.- Returns:
The request, sent at once (or as soon as the viewer connects). In a notebook widget its answer arrives once the cell has finished: collect it in a later cell.
- Return type:
ActionRequest, ActionError and OMIT#
- class cellucid.jupyter.ActionRequest(viewer, request_id, action, waiter)[source]#
Bases:
objectOne action sent to the viewer (
AnnDataViewer.act(), or the action’s own method).The viewer answers it once: with its outcome – a read’s result – and the history step it made, or with why it did not apply it.
donesays whether the answer arrived;result()returns it. Nothing has to collect a request: an action applies whether or not anyone waits for it.- Parameters:
viewer (AnnDataViewer)
request_id (str)
action (str)
waiter (_EventWaiter)
- __init__(viewer, request_id, action, waiter)[source]#
- Parameters:
viewer (AnnDataViewer)
request_id (str)
action (str)
waiter (_EventWaiter)
- Return type:
None
- action#
The action’s dotted type (
color.by).
- property step: dict[str, Any] | None#
The history step the action made,
{"id", "label"}, once it was answered; None before, for a read, and for a change that changed nothing.
- result(timeout=60.0)[source]#
The action’s outcome, waiting up to
timeoutseconds for it (None: forever): a read’s result (JSON: dicts, lists, text and numbers), a change’s outcome (counts and names), or None.Raises
ActionErrorwith the viewer’s reason when it did not apply the action,TimeoutErrorwhen no answer arrived in time, andRuntimeErrorwhen the viewer stopped or the request was cancelled – or, in a notebook widget, when the answer has not arrived yet: the viewer answers between cells, so collect it in a later cell.
- exception cellucid.jupyter.ActionError(action, request_id, reason)[source]#
Bases:
RuntimeErrorThe viewer did not apply an action:
reasonsays why, in the viewer’s words (a name that does not resolve names what does).
- cellucid.jupyter.OMIT#
leave it out, and the viewer applies the action’s own default. Its one value is
OMIT.- Type:
The default of an optional action parameter
SessionRequest#
- class cellucid.jupyter.SessionRequest(viewer, request_id, waiter)[source]#
Bases:
objectA session the viewer was asked for (
AnnDataViewer.request_session()).donesays whether the viewer answered;result()returns the session – its history, every tracker, as a.cellucid-sessionfile of format 4. A request that is never collected is withdrawn bycancel(), or when the viewer stops.- Parameters:
viewer (AnnDataViewer)
request_id (str)
waiter (_EventWaiter)
- __init__(viewer, request_id, waiter)[source]#
- Parameters:
viewer (AnnDataViewer)
request_id (str)
waiter (_EventWaiter)
- Return type:
None
- result(timeout=60.0)[source]#
The session, waiting up to
timeoutseconds for it (None: forever).Returns the
CellucidSession(the same one on every call), read and checked whole. RaisesTimeoutErrorwhen it did not arrive in time, andRuntimeErrorwhen the viewer could not capture it – or, in a notebook widget, when it has not arrived yet: the viewer answers between cells, so collect it in a later cell.- Return type:
- Parameters:
timeout (float | None)
LiveHistory and LoadSessionRequest#
- class cellucid.jupyter.LiveHistory(viewer)[source]#
Bases:
objectThe history of a viewer, as it changes (
viewer.history).last_changeis the latesthistory_changedthe viewer sent ({"kind", "tracker", "head", "step", "branch"}), withtracker,headandbranchread from it;on_change()runs a callback on each change;read()asks the viewer for its history as a session (the same reading model as a file:Tracker, branches, steps as a table). The history is changed through the viewer’s generatedhistory_*methods, each returning itsActionRequest; an action the viewer cannot carry out yet is refused with the viewer’s reason (request.result()raises it).- Parameters:
viewer (AnnDataViewer)
- __init__(viewer)[source]#
- Parameters:
viewer (AnnDataViewer)
- Return type:
None
- property last_change: dict[str, Any] | None#
The latest change the viewer told (a copy), or None before the first.
- property branch: str | None#
The id of the active branch, as of the latest change (None when the viewer names none).
- on_change(callback)[source]#
Run
callback(change)on every change of the viewer’s history (a decorator too).
- read()[source]#
Ask the viewer for its history now, as a session:
.result()is theCellucidSession(in a notebook, collect it in a later cell).- Return type:
- class cellucid.jupyter.LoadSessionRequest(viewer, request_id, name, waiter)[source]#
Bases:
objectA session file pushed into the viewer (
AnnDataViewer.load_session()).donesays whether the viewer answered;result()returns what it shows then:{"tracker": {"id", "name"}, "head"}.- Parameters:
viewer (AnnDataViewer)
request_id (str)
name (str)
waiter (_EventWaiter)
- __init__(viewer, request_id, name, waiter)[source]#
- Parameters:
viewer (AnnDataViewer)
request_id (str)
name (str)
waiter (_EventWaiter)
- Return type:
None
- name#
The file’s name, as the loaded tracker records it.
- result(timeout=60.0)[source]#
What the viewer shows once the file is loaded, waiting up to
timeoutseconds (None: forever):{"tracker": {"id", "name"}, "head"}.Raises
RuntimeErrorwith the viewer’s reason when it did not load the file (another dataset’s session, a damaged file),TimeoutErrorwhen no answer arrived in time – or, in a notebook widget, when the answer has not arrived yet: the viewer answers between cells.
Edge cases (do not skip)#
Not running in a notebook#
show_anndata()refuses outside a notebook and names the browser-tab alternatives; anAnnDataViewer’sdisplay()prints its address.
Re-running cells#
Each
AnnDataViewerstarts a local server on a port, and eachWidgetkeeps its dataset (for an in-memory object, the store it serves and the files a cell-major matrix is laid out in) until it is stopped. Callviewer.stop()on viewers you no longer use.
Waiting in a notebook cell#
A
Widgethears the viewer only between cells: its waiting calls raise at once in the cell that would wait, and say what to do instead (Supported environments matrix).
Callbacks and exceptions#
Hook callbacks run in registration order (
on_messagecallbacks first), on the viewer channel’s thread. An exception a callback raises is logged with its traceback (loggercellucid.viewer_channel) and never reaches the notebook. The event is recorded inviewer.stateand handed towait_for_eventbefore any callback runs, and the callbacks after a failing one still run (several failures are logged together, as oneExceptionGroup). The channel stays open.
Troubleshooting (symptom → diagnosis → fix)#
Symptom: “viewer.display() prints a URL instead of showing a viewer”#
Fix:
That is an
AnnDataViewer, which runs in a browser tab: open the URL. To show the viewer in a notebook cell, useshow_anndata()orcellucid.Widget.
Symptom: “Hooks never fire”#
Fix:
Check the viewer is ready:
viewer.state.ready(in a later cell, for a widget), orviewer.wait_for_ready()for a browser-tab viewer.Temporarily register
@viewer.on_messageto see raw events and confirm communication.
Symptom: “I have too many running servers”#
Fix:
Call
viewer.stop()on old viewers.Restart the kernel if you’ve lost track of old viewer instances.
See also#
Jupyter (notebook embedding + hooks) for the function-level entry point (
show_anndata)Server (browser tab + local HTTP server) for serving in a browser tab