Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
39fe889
lots of new stuff, mainly for haplotype networks
emmanuelparadis Oct 12, 2020
5995f95
fixed positions of link labels with different symbol sizes
emmanuelparadis Oct 13, 2020
2f3b69a
some bug fixes
emmanuelparadis Oct 17, 2020
e464a63
a few fixes
emmanuelparadis Nov 6, 2020
ce7312f
various updates
emmanuelparadis Nov 20, 2020
4754563
added 2 arguments to write.vcf()
emmanuelparadis Nov 20, 2020
ae9e3f7
a few fixes
emmanuelparadis Nov 25, 2020
73f72ef
improved write.vcf()
emmanuelparadis Feb 7, 2021
55bbd95
many changes and fixes preparing for v. 1.0
emmanuelparadis Feb 10, 2021
a8ecbfd
Fst now runs in case of single population (fixes #51)
courtiol Feb 19, 2021
5398af7
Merge pull request #52 from courtiol/Fis
emmanuelparadis Feb 24, 2021
424ad59
updated vignette
emmanuelparadis Feb 24, 2021
5cddb39
improved write.vcf()
emmanuelparadis Mar 22, 2021
81d9e48
haplotype.DNAbin() works (again) empty objects
emmanuelparadis Mar 24, 2021
7add7cf
sync with CRAN pegas 1.0
emmanuelparadis Apr 8, 2021
50fe0fb
fix user's pie color palette in plotting haplo nets
emmanuelparadis Apr 14, 2021
5f79dd5
updates for ape 1.0-1 on CRAN
emmanuelparadis May 17, 2021
b37a858
fix issue #59
emmanuelparadis Jul 17, 2021
9d36980
simplified summary.haplotype()
emmanuelparadis Aug 11, 2021
d657429
fix in haplotype.character()
emmanuelparadis Sep 14, 2021
b2dc5d3
fix bug in plotting haploNet (see issue #55)
emmanuelparadis Sep 24, 2021
ca87072
moved adegenet from Imports to Suggests
emmanuelparadis Oct 17, 2021
e3f4b19
updated ape.sty
emmanuelparadis Dec 15, 2021
34de466
fix a bug in theta.s()
emmanuelparadis Feb 4, 2022
166ed5e
fix 'bg' in plot.haploNet
emmanuelparadis Mar 10, 2022
bbfe4af
DOS-style VCF files are now supported
emmanuelparadis May 5, 2022
e5b5cb1
MMD() new returns its data
emmanuelparadis May 12, 2022
47d3737
new function nullAlleles2NA + new option in dist.asd()
emmanuelparadis May 16, 2022
46ca939
bug fixed with 'bg' with 'pie'
emmanuelparadis Jun 27, 2022
eec5587
pie colours failed if more groups than haplotypes
emmanuelparadis Jul 5, 2022
54e9b63
pie colours failed if more groups than haplotypes
emmanuelparadis Jul 5, 2022
a0c14b3
added note in replot.Rd
emmanuelparadis Jul 28, 2022
10b2548
added a not in ?plot.haploNet
emmanuelparadis Sep 19, 2022
6d738ba
updating files for pegas 1.2
emmanuelparadis Feb 23, 2023
369ba0f
faster C code for mst()
emmanuelparadis Apr 18, 2023
406e81f
fixed tajima.test
emmanuelparadis May 15, 2023
4da4da1
faster sorting of distances in mst.c
emmanuelparadis Aug 8, 2023
c80584d
fix issues 80 and 81
emmanuelparadis Sep 28, 2023
76a11f7
fixed issue #81
emmanuelparadis Oct 5, 2023
7885ed3
updated .Rd files with new \item def
emmanuelparadis Oct 19, 2023
31ec9c0
rmst now returns similar networks with the same data
emmanuelparadis Nov 21, 2023
ea273cf
update for pegas 1.3 on CRAN
emmanuelparadis Dec 13, 2023
e8dc77f
fix rmst() with n=2 haplotypes
emmanuelparadis Jan 28, 2024
4fb8f67
new algo in rmst()
emmanuelparadis Feb 9, 2024
4a4b6e7
fixed and improved plot.haploNet()
emmanuelparadis Mar 6, 2024
b7f27a9
fix a few bugs
emmanuelparadis Jun 24, 2024
8f16f48
improved haploNet() and mjn() with 0 or 1 haplotype as input
emmanuelparadis Mar 7, 2025
2b85473
update man pages wrt adegenet status on CRAN
emmanuelparadis Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ This repository contains:

More information on pegas (including description of data structures):

http://ape-package.ird.fr/pegas.html
http://emmanuelparadis.github.io/pegas.html
12 changes: 6 additions & 6 deletions pegas/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Package: pegas
Version: 0.14
Date: 2020-09-16
Version: 1.3-0.4
Date: 2025-12-04
Title: Population and Evolutionary Genetics Analysis System
Authors@R: c(person("Emmanuel", "Paradis", role = c("aut", "cre", "cph"), email = "[email protected]", comment = c(ORCID = "0000-0003-3092-2199")),
person("Thibaut", "Jombart", role = c("aut", "cph"), comment = c(ORCID = "0000-0003-2226-8692")),
person("Zhian N.", "Kamvar", role = c("aut", "cph"), comment = c(ORCID = "0000-0003-1458-7108")),
person("Brian", "Knaus", role = c("aut", "cph"), comment = c(ORCID = "0000-0003-1665-4343")),
person("Klaus", "Schliep", role = c("aut", "cph")),
person("Klaus", "Schliep", role = c("aut", "cph"), comment = c(ORCID = "0000-0003-2941-0161")),
person("Alastair", "Potts", role = c("aut", "cph"), comment = c(ORCID = "0000-0003-0919-7279")),
person("David", "Winter", role = c("aut", "cph"), comment = c(ORCID = "0000-0002-6165-0029")))
Depends: R (>= 3.2.0), ape (>= 5.3-11), adegenet
Depends: R (>= 3.2.0), ape (>= 5.3-11)
Imports: graphics, utils, methods
Suggests: rgl, snpStats
Suggests: rgl, snpStats, adegenet
ZipData: no
Description: Functions for reading, writing, plotting, analysing, and manipulating allelic and haplotypic data, including from VCF files, and for the analysis of population nucleotide sequences and micro-satellites including coalescent analyses, linkage disequilibrium, population structure (Fst, Amova) and equilibrium (HWE), haplotype networks, minimum spanning tree and network, and median-joining networks.
License: GPL (>= 2)
URL: http://ape-package.ird.fr/pegas.html
URL: https://emmanuelparadis.github.io/pegas.html
41 changes: 24 additions & 17 deletions pegas/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,35 @@ useDynLib(pegas, .registration = TRUE)

export(alleles2loci, allelicrichness, amova, as.igraph.haploNet,
as.loci, as.network.haploNet, diffHaplo, dist.hamming,
dist.haplotype.loci, dist.asd, dist.snp, expand.genotype, F2,
F3, F4, Fst, genind2loci, geod, geoTrans, geoTrans2, getAlleles,
getGenotypes, getINFO, getPloidy, getPhi, H, haploNet,
haploFreq, hap.div, haplotype, heterozygosity, hw.test,
is.phased, is.snp, LD, LD2, LDscan, LDmap, loci2alleles,
loci2genind, loci2SnpMatrix, mjn, msn, mst, MMD, nuc.div,
plotNetMDS, proba.genotype, R2.test, rangePOS, rarefactionplot,
read.gtx, read.loci, read.vcf, replot, rhost, rmst, rr.test,
Rst, selectQUAL, site.spectrum, stairway, sw, tajima.test,
dist.haplotype.loci, dist.asd, expand.genotype, F2, F3, F4,
Fst, genind2loci, geod, geoTrans, geoTrans2, getAlleles,
getGenotypes, getHaploNetOptions, getINFO, getPloidy, getPhi,
H, haploNet, haploFreq, hap.div, haplotype, heterozygosity,
hw.test, is.phased, is.snp, LD, LD2, LDscan, LDmap,
loci2alleles, loci2genind, loci2SnpMatrix, mjn, msn, mst, MMD,
mutations, nuc.div, nullAlleles2NA, plotNetMDS, proba.genotype,
R2.test, rangePOS, rarefactionplot, read.gtx, read.loci,
read.vcf, replot, rhost, rmst, rr.test, Rst, selectQUAL,
setHaploNetOptions, site.spectrum, stairway, sw, tajima.test,
theta.h, theta.k, theta.msat, theta.s, unphase, theta.tree,
theta.tree.hetero, VCFheader, VCFlabels, VCFloci, write.loci,
write.pegas.amova)
write.pegas.amova, write.vcf)

importFrom(ape, as.evonet, as.phylo, BOTHlabels, branching.times,
base.freq, dist.dna, dist.nodes, floating.pie.asp,
base.freq, dist.dna, dist.nodes, fancyarrows, floating.pie.asp,
GC.content, latag2n, perm.rowscols, polar2rect, rcoal,
rect2polar, seg.sites)
importFrom(adegenet, df2genind, genind2df)
#importFrom(adegenet, df2genind, genind2df)
importFrom(graphics, abline, axis, barplot, hist, lines, lines.default, locator,
matplot, mtext, par, polygon, plot, plot.default, rect, segments,
strheight, symbols, text, xinch)
matplot, mtext, par, points, polygon, plot, plot.default, rect,
segments, strheight, strwidth, symbols, text, xinch)
importFrom(grDevices, colorRampPalette, dev.cur, devAskNewPage,
deviceIsInteractive, rainbow, rgb)
importFrom(stats, as.dist, cmdscale, cophenetic, density, dist, integrate,
na.omit, nlminb, pbeta, pchisq, pnorm, printCoefmat, rpois, sd,
uniroot, weighted.mean)
importFrom(utils, as.roman, combn, edit, read.table, write.csv, write.table)
median, na.omit, nlminb, pbeta, pchisq, pnorm, printCoefmat, rpois,
sd, setNames, uniroot, weighted.mean)
importFrom(utils, as.roman, combn, edit, packageVersion, read.table,
write.csv, write.table)
importFrom(methods, new)

S3method(print, amova)
Expand All @@ -37,6 +39,7 @@ S3method(as.loci, character)
S3method(as.loci, data.frame)
S3method(as.loci, factor)
S3method(as.loci, genind)
S3method(as.loci, matrix)

S3method(H, default)
S3method(H, loci)
Expand Down Expand Up @@ -75,6 +78,8 @@ S3method(theta.s, DNAbin)
S3method(all.equal, haploNet)
S3method(as.phylo, haploNet)
S3method(as.evonet, haploNet)
S3method(cophenetic, haploNet)
S3method(labels, haploNet)
S3method(plot, haploNet)
S3method(print, haploNet)

Expand All @@ -96,6 +101,8 @@ S3method(print, loci)
S3method(rbind, loci)
S3method(summary, loci)

S3method(plot, mjn)

S3method(plot, spectrum)

S3method(lines, stairway)
Expand Down
211 changes: 211 additions & 0 deletions pegas/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,214 @@
CHANGES IN PEGAS VERSION 1.3-0.3


NEW FEATURES

o rmst() has a new option: random = FALSE. The new default
algorithm of this function finds all MSTs for the data and
combines them to create the returned RMST. The results are
identical to those with the random algorithm with a sufficiently
large number of iterations (see PR #86 on GitHub).

o The colour of the alternative links of a haplotype network can
now be changed with the new option $link.color.alt through
setHaploNetOptions().

o haploNet() and mjn() now return a network with a single node and
zero link when given a single haplotype as input. They return
NULL when given an input with zero data.


BUG FIXES

o rmst() failed when given a single distance (i.e., there's only 2
haplotypes): it now calls mst().

o rmst() created an object named "rnt" in the user's workspace.
This is fixed.

o print.haploNet() did not always display correctly link lengths.

o When plotting a haplotype network, modifying the aspect of the
alternative links did not work.

o A bug was fixed in dist.asd(, pairwise.deletion = TRUE) (see
issue #91 on GitHub).



CHANGES IN PEGAS VERSION 1.3


NEW FEATURES

o plot.haploNet() has a new argument 'col.lab' to change the
colors of the haplotype labels. It can be changed through the
option "labels.color" (see ?setHaploNetOptions).

o The R code of mst() has been replaced by a C code which can be
1000 times faster with several 100s observations (this improves
also rmst() and all other functions calling mst()). The code now
scales very nearly as O(n^2) in practice.

o rmst() now returns a network with a "backbone-MST" so that
repeated analyses of the same data are likely to return
graphically similar networks (see issue #82 on GitHub).


BUG FIXES

o tajima.test() may use different sets of sites when computing the
number of segregating sites and the mean pairwise distance. This
has been fixed by adding pairwise.deletion = TRUE to the call to
dist.dna (see issue #77 on GitHub).

o The placement of mutation ticks on alternative links of
haplotype networks has been fixed (see issue #77 on GitHub).



CHANGES IN PEGAS VERSION 1.2


NEW FEATURES

o The new function nullAlleles2NA changes genotypes with at least
one `null allele' into NA.

o MMD() now returns invisibly a list with the plotted data (i.e.,
histogram, empirical density, and expected curve under stable
population).

o dist.asd() has now the option 'pairwise.deletion = FALSE'.


BUG FIXES

o The estimator variance in theta.s() has been corrected (thanks
to Carsten Wiuf) and the help page has been updated.

o plot.haploNet() did not handle correctly the 'bg' argument when
it is a vector of colours. This also affected the plot of MJN
networks.

o VCF files with DOS-style end of lines (i.e., CRLF) are now
supported.

o Argument 'bg' was not always well interpreted in plot.haploNet()
and plot.mjn().


OTHER CHANGES

o There is a new (non-interactive) example in ?replot.

o The help page of plot.mjn() has been clarified about the usage
of the arguments 'shape' and 'bg'.



CHANGES IN PEGAS VERSION 1.1


BUG FIXES

o plot.haploNet() did not use 'bg' correctly when 'pie' was
used. The help page has been clarified that this argument could
also be a function.

o setHaploNetOptions(pie.colors.function = ) did not work
correcly; similarly for 'pie.inner.segments.color'.

o The argument 'scale.ratio' was not always passed correctly among
internal functions when plotting "haploNet" objects (see issue
#59 on GH).

o haplotype.character() failed to work correctly (see issue #61).


OTHER CHANGES

o amova() now accepts distance objects which inherit the class
"dist" (instead of being strictly equal).

o adegenet has been moved from 'Imports' to 'Suggests'.



CHANGES IN PEGAS VERSION 1.0


NEW FEATURES

o The new function mutations() draws mutations on a network (with
many options; see ?mutations).

o The new function write.vcf writes an object of class "loci" into
a VCF file.

o There is a new cophenetic() method for objects of class
"haploNet", and a new labels() method.

o diffHaplo() has been simplified and gains the options 'strict'
and 'trailingGapsAsN' which are passed to ape::seg.sites().

o mjn() has a new option 'quiet = FALSE'; its code has been
improved and is now 10 times faster (25 times with 100 sequences
resulting in running times less than 15 sec). The returned
object have the class c("mjn", "haploNet") and there is a new
plot.mjn() method.

o replot() has been improved: the instructions are more detailed,
there is a new option 'col.identifier' to show the node to be
moved, and the bounding box of the plot is now calculated
correctly so the network does not "shrink" after each move.

o plot.haploNet() has two new options: 'shape' and 'xy' to change
the symbol shapes and their coordinates, respectively.

o There are two new functions, getHaploNetOptions and
setHaploNetOptions, to help users change the graphical
paramaters when plotting haplotype networks.

o There is a new as.loci() method for matrices.

o rmst() implements a new algorithm to stop iterations after no
new links are found: this is controlled by the new options
'stop.criterion' and 'iter.lim'. There is also a new option
'quiet = FALSE'.

o Fst() now runs in the case of a single population, returning the
Fis (and Fit which equates 1).

o There is a new vignette "PlotHaploNet" detailing some aspects of
plotting haplotype networks with pegas, including the new
features and options.


BUG FIXES

o A bug was fixed in geoTrans2().

o as.loci.data.frame() now works with "tibble" objects (thanks to
Jean-Baka Domelevo Entfellner for the fix).

o allelicrichness(, method = "rarefaction") used to return the raw
allelic richness: this is fixed and this function gains the
option 'min.n' to work with this method (common sample size used
for all populations).

o haplotype() on an empty "DNAbin" object returns an empty
"haplotype" object similarly to pegas 0.12 (see issue #53 on GH).


OTHER CHANGES

o adegenet has been moved from 'Depends' to 'Imports'.

o dist.snp() has been removed.



CHANGES IN PEGAS VERSION 0.14


Expand Down
12 changes: 6 additions & 6 deletions pegas/R/Fst.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Fst.R (2019-02-25)
## Fst.R (2021-02-24)

## F-Statistics

## Copyright 2009-2019 Emmanuel Paradis
## Copyright 2009-2021 Emmanuel Paradis

## This file is part of the R-package `pegas'.
## See the file ../DESCRIPTION for licensing issues.
Expand Down Expand Up @@ -43,7 +43,7 @@ Fst <- function(x, pop = NULL, quiet = TRUE, na.alleles = "")
nBYpop <- tabulate(Z$pop)
r <- length(nBYpop) # number of pops
nbar <- N/r
nC <- (N - sum(nBYpop^2)/N)/(r - 1)
nC <- if (r == 1) 0 else (N - sum(nBYpop^2)/N)/(r - 1)
ALLELES <- getAlleles(Z)[[1]]
h <- p <- matrix(0, r, length(ALLELES))
for (i in 1:r) {
Expand All @@ -61,14 +61,14 @@ Fst <- function(x, pop = NULL, quiet = TRUE, na.alleles = "")
}
ptild <- p/(2 * nBYpop)
pbar <- colSums(p)/(2 * N) # for each allele in the locus
s2 <- colSums(nBYpop * (ptild - rep(pbar, each = r))^2)/((r - 1) * nbar)
s2 <- if (r == 1) rep(0, length(ALLELES)) else colSums(nBYpop * (ptild - rep(pbar, each = r))^2)/((r - 1) * nbar)
hbar <- colSums(h)/N # id.
A <- pbar * (1 - pbar) - (r - 1) * s2/r
a <- nbar * (s2 - (A - hbar/4)/(nbar - 1))/nC
b <- nbar * (A - (2*nbar - 1) * hbar/(4*nbar))/(nbar - 1)
c <- hbar/2
res[j, 1] <- 1 - sum(c)/sum(a + b + c)
res[j, 2] <- sum(a)/sum(a + b + c)
res[j, 1] <- if (r == 1) NA else 1 - sum(c)/sum(a + b + c)
res[j, 2] <- if (r == 1) NA else sum(a)/sum(a + b + c)
res[j, 3] <- 1 - sum(c)/sum(b + c)
}
if (!quiet) cat("... Done.\n")
Expand Down
Loading