Helpful functions

GPMap comes with many helpful functions for enumerating genotype-phenotype maps. This page provides a simple list of those functions.

Get all genotypes from mutations

from gpmap.utils import genotypes_to_mutations

wildtype = "AAA"
genotypes = [
    "AAA",
    "AAB",
    "ABA",
    "BAA",
    "ABB",
    "BAB",
    "BBA",
    "BBB"
]

mutations = genotypes_to_mutations(genotypes)

Get mutation encoding table

from gpmap.utils import get_encoding_table

wildtype = "AA"
mutations = {
    0: ["A", "B"],
    1: ["A", "B"]
}
get_encoding_table(wildtype, mutations)
binary_index_start binary_index_stop binary_repr genotype_index mutation_index mutation_letter wildtype_letter
0 0 1 0 0 NaN A A
1 0 1 1 0 1 B A
2 1 2 0 1 NaN A A
3 1 2 1 1 2 B A

Get mutations from a list of genotypes

from gpmap.utils import mutations_to_genotypes

mutations = {0: ['A', 'B'], 1: ['A', 'B'], 2: ['A', 'B']}

mutations_to_genotypes(mutations)
# ['AAA', 'AAB', 'ABA', 'ABB', 'BAA', 'BAB', 'BBA', 'BBB']

Get binary representation of genotypes

from gpmap.utils import genotypes_to_binary, get_encoding_table

wildtype = 'AAA'

genotypes = [
    "AAA",
    "AAB",
    "ABA",
    "BAA",
    "ABB",
    "BAB",
    "BBA",
    "BBB"
]

mutations = {0: ['A', 'B'], 1: ['A', 'B'], 2: ['A', 'B']}
table = get_encoding_table(wildtype, mutations)
binary = genotypes_to_binary(genotypes, table)
# ['000', '001', '010', '100', '011', '101', '110', '111']

Get a list of missing genotypes from a list of genotypes

from gpmap.utils import get_missing_genotypes

genotypes = ["AAA","BBB"]

get_missing_genotypes(genotypes)
# ['BBA', 'BAB', 'ABB', 'ABA', 'AAB', 'BAA']