How to Plot Pie Charts in Haplonet Haplotype Networks {Pegas}

How to plot a network without background connection or labels? R pegas

I believe you can adjust that by setting threshold = 0 in your plot() call, that is:

plot(net, size = attr(net, "freq"), pie=ind.hap, fast = TRUE, legend=F, label=NULL, threshold = 0)

See help for ?pegas::plot.haploNet for more details. Also please note that the post you mention (here) has a bug where the pie-chart is being coloured wrongly (I've made a comment about it and also posted a corrected answer here).

Identifying mutations between haplotypes using haploNet (pegas) in R

The pegas package contains a function diffHaplo, which specifies differences between haplotypes.

diffHaplo(haps50, a = "XX", b = "V")

To extract the DNA sequence of the frequent haplotype V, the indexes in the object of class haplotype will identify, which DNA sequence contains the haplotype.

# haplotype index from its name
i <- which(attr(haps50, "dimnames")[[1]] == "V")
# index of the first sequence with the haplotype
s <- attr(haps50, "index")[[i]][1]

The respective sequence can then be identified in the alignment fa to save or print on screen.

write.dna(fa[s], file = "hapV.fas", format = "fasta", nbcol = -1, colsep = "")
paste(unlist(as.character(fa[s])), collapse = "")


Related Topics



Leave a reply



Submit