pylimma.put_eawp

pylimma.put_eawp(slots, original, *, out_layer='pylimma_E', weights_layer='pylimma_weights', uns_key='pylimma', single_matrix=False)[source]

Polymorphic output dispatcher - package a result in a form matching the original input’s class.

This has no direct R counterpart; see module docstring for rationale.

Parameters:
  • slots (dict) – Updated slot values. Typically {‘E’: …, ‘weights’: …, ‘design’: …, …}. ‘E’ is required.

  • original (the object originally passed in by the user) – Determines the output format.

  • out_layer (str) – For AnnData input, the layer name to which the new E is written.

  • weights_layer (str or None) – For AnnData input, the layer name for weights. If None, weights are placed inside adata.uns[uns_key] instead.

  • uns_key (str) – For AnnData input, the adata.uns[…] key for ancillary metadata (design, lib_size, span, targets, etc.).

  • single_matrix (bool, default False) – When True (appropriate for functions whose only meaningful output is the transformed expression matrix, e.g. normalize_between_arrays), ndarray input returns a bare ndarray. When False (the default, for functions with multi-slot output like voom), ndarray input returns a plain dict containing all slots - matching the pre-existing convention.

Returns:

  • ndarray when original is ndarray and single_matrix=True.

  • dict when original is ndarray (default) or a plain dict.

  • EList when original is an EList.

  • None when original is AnnData (side-effects on adata).

Return type:

np.ndarray, dict, EList, or None

Notes

AnnData view semantics. If original is a view (adata[:, mask]), writing to adata.layers / adata.uns triggers anndata’s ImplicitModificationWarning and actualises the view into a standalone copy. The write lands on that copy; the parent AnnData is untouched. This matches scanpy’s convention and is not a pylimma-specific behaviour. To operate in place on a subset, call adata[:, mask].copy() first or subset the parent explicitly. A bare one-liner like pylimma.voom(adata[:, mask]) discards the actualised copy along with the return value; bind the view first (view = adata[:, mask]; pylimma.voom(view)) to keep the result reachable.