This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Identifying mutations between haplotypes using haploNet (pegas) in R

I think this might be an easy question, but I could not solve it after reading the pegas documentation. I want to plot an haplotype network using a FASTA file and identify which mutations are separatting the distinct haplotypes.

Example:

fa <- read.FASTA("example.fa")
haps <- haplotype(fa)
haps50 <- subset(haps, minfreq = 50)
(network <- haploNet(haps50))

plot(network, size = attr(network, "freq"),show.mutation=1,labels=T)

enter image description here

How can I identify the position of the mutation in my FASTA file that is separating for example haplotype XX from V?

Extra question: Would it be also possible to know for example, what is the haplotype sequence of one of the haplotypes? For example haplotype V, which is quite frequent?

r pegas haplotypes phylogenetics

1 answer

Yes! We can get the sequence of each haplotype by using function diffHaplo in R package pegas.

For example,

1. generate test data

data(woodmouse)
x <- woodmouse[sample(15, size = 110, replace = TRUE),]
h <- haplotype(x)
(net <- haploNet(h))

Haplotype network with:
15 haplotypes
14 links
54 alternative links
link lengths between 2 and 14 steps
Now, we have 15 haplotypes.

2. get the sequence

as.data.frame(diffHaplo(h,1:15))

The sequences are as follows:
pos I II III IV V VI VII VIII IX X XI XII XIII XIV II.1
1 30 T T T T T T T T C T T T T T T
2 33 C C C C C C C C C T C C C C C
3 35 A A A A A A A G A A A A A A A
4 36 T T T T T T C T T T T T T C T
5 42 C C C T C C C C C C C C C C C
6 51 C T C T C C C C T C T C C C T
7 54 A G A A A A A A A A A A A A G
8 60 T T T T C T T T T T T T T T T
......

Hi Jie Ping, I run into this answer and I´m currently analyzing haplotypes with pegas. I have the following doubt, maybe you could help me. Why is the diffHaplo() function returning the last haplotype as II.1 if when we call h its calls the last haplotype as XV? I´ll appreciate very much your answer!

Log in to answer this question.