scatrans.restore_raw_counts

scatrans.restore_raw_counts#

scatrans.restore_raw_counts(adata, layer='counts', inplace=False)[source]#

Restore raw counts from the stored layer (preferred) or adata.raw back into .X.

This is useful when you have done HVG + log1p on .X for visualization, but want to work with (or pass to other tools) the raw counts for the genes currently in the adata (or the preserved set).

It only uses explicitly stored raw data (from store_raw_counts), never attempts to recover from log-transformed data.

Parameters:
  • adata (AnnData) – The AnnData object.

  • layer (str) – The layer name where raw counts were stored (default “counts”).

  • inplace (bool) – If True, modify adata in place and return None. If False (default), return a new AnnData with .X set to raw counts.

Returns:

If not inplace, a copy of adata with raw counts in .X.

Return type:

AnnData or None