netmap.downstream.edge_selection.chunked_argsort

netmap.downstream.edge_selection.chunked_argsort(unsadata, layer_name='sorted', chunk_size=500, dtype=None)[source]

Compute np.argsort on adata.X in chunks to reduce peak memory usage.

Processes unsadata.X row-by-row in batches of chunk_size, writing the sorted column-index order for each row into a pre-allocated layer. The integer dtype is chosen automatically to be as small as possible given the number of variables.

Parameters:
  • unsadata (anndata.AnnData) – AnnData object to process. Modified in-place by adding layers[layer_name].

  • layer_name (str) – Name of the new layer to create. Defaults to 'sorted'.

  • chunk_size (int) – Number of rows (cells) to process per iteration. Defaults to 500.

  • dtype (numpy.dtype or None) – Integer dtype for the output array. If None, uint16 is used when n_vars < 65535, otherwise uint32.

Returns:

None. Modifies unsadata in-place by adding layers[layer_name].