I have a dataframe called SNP with 6000 columns and 500 rows. The dataframe looks like the following table:
|sample | SNP1 | SNP2 | SNP3 |
|:--------------|---------:|---------:|---------:|
|s1 | AA | TT | GG |
|s2 | CC | AT | AA |
|s3 | AT | CC | AA |
I have to rearrange the format for analysis. What I'd like to do is for each character (I mean "AA", "CC", "AT" for 2nd column, SNP1, for example) in every SNP column, I want to make 2 consecutive rows for each sample and then want to split the characters and assigned them into the newly created two rows for a sample. For your convenience, the below table format I want to make it:
|sample | SNP1 | SNP2 | SNP3 |
|:--------------|---------:|---------:|---------:|
|s1 | A | T | G |
|s1 | A | T | G |
|s2 | C | A | A |
|s2 | C | T | A |
|s3 | A | C | A |
|s3 | T | C | A |
It will be highly appreciated if someone can help me to solve.
N.B: I have added a screenshot of datafram in case the format I added is displaced, I am new here.