mutcleaner.cleaners.ctxm_custom_cleaner#

Functions

expand_mutations(dataset[, mutation_column, ...])

Expand single and double mutation records into a long-format table.

map_ambler_positions(dataset, mapping[, ...])

Remap mutation positions from Ambler numbering to sequence numbering.

mutcleaner.cleaners.ctxm_custom_cleaner.expand_mutations(dataset, mutation_column='mut_info', label_column='fitness', sep=',')[source]#

Expand single and double mutation records into a long-format table.

Each input row contains two single mutations (described by separate wild-type amino acid, position, and mutant amino acid columns) along with their individual fitness values and a combined double-mutation fitness value. This function unpacks each row into three records: the first single mutation, the second single mutation, and the double mutation, each paired with its corresponding label value.

Parameters:
  • dataset (DataFrame) – Input DataFrame. Must contain the columns WT_AA1, Pos1, Mut1, WT_AA2, Pos2, Mut2, fitness1, fitness2, and fitness.

  • mutation_column (str) – Name of the output column holding the mutation descriptor. Defaults to "mut_info".

  • label_column (str) – Name of the output column holding the label (fitness) value. Defaults to "fitness".

  • sep (str) – Separator used to join the two single mutations into a double mutation descriptor. Defaults to ",".

Return type:

DataFrame

Returns:

Long-format DataFrame with two columns named according to mutation_column and label_column.

mutcleaner.cleaners.ctxm_custom_cleaner.map_ambler_positions(dataset, mapping, mutation_column='mut_info', sep=',')[source]#

Remap mutation positions from Ambler numbering to sequence numbering.

The mutation descriptors in the dataset use Ambler numbering, which is not aligned with the true amino acid sequence numbering. This function rewrites each mutation descriptor by replacing its wild-type-plus-position prefix (e.g. "S70") according to the provided mapping, while keeping the trailing mutant amino acid unchanged. Both single and multi-mutation records (joined by sep) are handled.

Parameters:
  • dataset (DataFrame) – Input DataFrame containing the mutation descriptor column.

  • mapping (dict[str, str]) – Mapping from Ambler-numbered prefixes to sequence-numbered prefixes (e.g. {"S70": "S66"}). Prefixes consist of the wild-type amino acid followed by the position. Prefixes absent from the mapping are left unchanged.

  • mutation_column (str) – Name of the column holding the mutation descriptor. Defaults to "mut_info".

  • sep (str) – Separator splitting multiple mutations within a single descriptor. Defaults to ",".

Return type:

DataFrame

Returns:

The input DataFrame with mutation_column updated in place to use the remapped positions.