0

I am trying to run stamppFst() and stamppConvert() with haplotype data. The data I have is a squence of nucleotides in a DNAbin. I have tried to find ways to turn it into a matrix but what I have read goes way over my head since this is the first time I have ever used R.

data

This is an example of one of the data sets I want to use.

I apologize if this is a very basic question. Thanks for any help!

Isaiah
  • 1
  • Welcome to Stack Overflow. We cannot read data into R from images. Please [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including a small representative dataset in a plain text format. You should also include all relevant code, libraries and error messages. – neilfws Dec 06 '22 at 04:25

1 Answers1

0

Use this function:

reformatDNA  <- function(dna){
## DNAbin to matrix

temp <- matrix(as.character(dna),
               nrow=(length(row.names(dna))),
               dimnames=dimnames(dna))

## As DNAbin uses a bitCode, the codes must be translated to standard chars.

                              temp <- car::recode(temp,"'88'='A';
                                      '28'='C'; '04'='-'; '48'='G';
                                      '02'='?'; '18'='T'; 'f0'='N'")

                              temp<- as.data.frame(toupper(temp))
                              return(temp)
                              }