random_df
Line | Generation | SNP-1 | SNP-2 | SNP-3 | SNP-4 |
---|---|---|---|---|---|
A | 2020A | A | A | A | A |
B | 2020B | A | C | T | G |
C | 2020C | A | C | T | G |
D | 2020D | A | C | T | G |
A | 2020A | A | A | A | A |
data = {'Line': ['A', 'B', 'C', 'D', 'A'], 'Generation': ['2020A', '2020B', '2020C', '2020D', '2020A'],
'SNP-1': ['A', 'A', 'A', 'A', 'A'],
'SNP-2': ['A', 'C', 'C', 'C', 'A'],
'SNP-3': ['A', 'T', 'T', 'T', 'A'],
'SNP-4': ['A', 'G', 'G', 'G', 'A']
}
random_df = pd.DataFrame(data)
grp = random_df.set_index(["Line", "Generation"]).apply(tuple, axis=1).reset_index(drop=True)
hap_groups = random_df.groupby(["Line", "Generation", grp]).size()
How can I use this object to make a line graph for each group? In an ideal world it would be written into a spreadsheet, but if I can graph it in pandas that is great. Will figure out how to add to a spreadsheet later.