smftools.preprocessing.reindex_references_adata#
- smftools.preprocessing.reindex_references_adata(adata, reference_col='Reference_strand', offsets=None, new_col='reindexed', uns_flag='reindex_references_adata_performed', force_redo=False, invert=None)#
Reindex genomic coordinates by adding per-reference offsets.
- Parameters:
adata (
AnnData) -- AnnData object.reference_col (
str(default:'Reference_strand')) -- Obs column containing reference identifiers.offsets (
dict|None(default:None)) -- Mapping of reference to integer offset.new_col (
str(default:'reindexed')) -- Suffix for generated reindexed columns.uns_flag (
str(default:'reindex_references_adata_performed')) -- Flag inadata.unsindicating prior completion.force_redo (
bool(default:False)) -- Whether to rerun even ifuns_flagis set.invert (
dict|bool|None(default:None)) -- Per-reference display-inversion flag(s). Either a single bool applied to every reference, a{ref: bool}mapping, orNone(no inversion, the default). When a reference is inverted, its reindexed coordinate's sign is flipped (-(var_coords + offset)instead ofvar_coords + offset) so that "left of the anchor is negative, right of the anchor is positive" still holds after the reference is displayed in reverse column order. This never touchesX/layers/var_names-- it is purely a reinterpretation of the reindexed coordinate value; callers that render columns are responsible for reordering them to match (seeplotting.plotting_utils._ordered_columns).
- Return type:
Notes
If
offsetsisNoneor missing a reference, the new column mirrors the existingvar_namesvalues (subject to the sign flip above).