This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to make combinations of genotypes given an allele dataframe?

Given a pandas data frame where (I'm new to this so I'm not even sure how to represent this here):

Name SNP1 SNP2 SNP3 SNP4
Allele1 A C T G
Allele2 C T G A
Allele3 C G A A

How do I create all the combinations of alleles (possible genotypes): Allele1/Allele1, Allele1/Allele2, Allele1/Allele3, Allele2/Allele2, Allele2/Allele3, Allele3/Allele3, like so:

Name SNP1 SNP2 SNP3 SNP4
Allele1/1 AA CC TT GG
Allele1/2 AC CT TG GA
Allele1/3 AC CG TA GA
Allele2/2 CC TT GG AA
Allele2/3 CC TG GA AA
Allele3/3 CC GG AA AA
python pandas matrix dataframe

0 answers

No answers yet.

Log in to answer this question.