ALL Metrics
-
Views
-
Downloads
Get PDF
Get XML
Cite
Export
Track
Software Tool Article
Revised

ngsJulia: population genetic analysis of next-generation DNA sequencing data with Julia language

[version 3; peer review: 1 approved, 3 approved with reservations]
PUBLISHED 14 Jul 2023
Author details Author details
OPEN PEER REVIEW
REVIEWER STATUS

This article is included in the RPackage gateway.

This article is included in the Cell & Molecular Biology gateway.

Abstract

A sound analysis of DNA sequencing data is important to extract meaningful information and infer quantities of interest. Sequencing and mapping errors coupled with low and variable coverage hamper the identification of genotypes and variants and the estimation of population genetic parameters. Methods and implementations to estimate population genetic parameters from sequencing data available nowadays either are suitable for the analysis of genomes from model organisms only, require moderate sequencing coverage, or are not easily adaptable to specific applications. To address these issues, we introduce ngsJulia, a collection of templates and functions in Julia language to process short-read sequencing data for population genetic analysis. We further describe two implementations, ngsPool and ngsPloidy, for the analysis of pooled sequencing data and polyploid genomes, respectively. Through simulations, we illustrate the performance of estimating various population genetic parameters using these implementations, using both established and novel statistical methods. These results inform on optimal experimental design and demonstrate the applicability of methods in ngsJulia to estimate parameters of interest even from low coverage sequencing data. ngsJulia provide users with a flexible and efficient framework for ad hoc analysis of sequencing data.ngsJulia is available from: https://github.com/mfumagalli/ngsJulia.

Keywords

high-throughput sequencing data, population genetics, genotype likelihoods, Julia language, pooled sequencing, polyploidy, aneuploidy

Revised Amendments from Version 2

In the revised version, we provide users with a comprehensive online documentation of APIs and CLIs at https://ngsjulia.readthedocs.io. Additionally, all functions have docstring documentation. The methodology behind some of the implementations has been clarified and references on the applicability of said methods have been added. We also rephrased few sentences for clarity as suggested by the reviewer, and fixed few typos. We believe that these changes significantly enhance the user’s experience and simplify the interpretation of results obtained using ngsJulia.

See the authors' detailed response to the review by Lindsay Clark
See the authors' detailed response to the review by Stéphane De Mita

Introduction

Population genetics, i.e., the study of genetic variation within and between groups, plays a central role in evolutionary inferences. The quantification of genetic diversity serves the basis for the inference of neutral1 and adaptive2 events that characterised the history of different populations. Additionally, the comparison of allele frequencies between groups (i.e. cases and controls) is an important aspect in biomedical and clinical sciences.3

In the last 20 years, next-generation sequencing (NGS) technologies allowed researchers to generate unprecedented amount of genomic data for a wide range of organisms.4 This revolution transformed population genetics (therefore also labelled as population genomics) to a data-driven discipline. Data produced by short-read sequencing machines (still the most accessible platform worldwide) consist of a collection of relatively short (approx. 100 base pairs) fragments of DNA which are then mapped or de novo assembled to form a contiguous sequence.4 At each genomic position, all observed sequenced reads are used to infer the per-sample genotype (an operation called ‘genotype calling’) and the inter-samples variability, i.e., whether a particular site is polymorphic (an operation called ‘single-nucleotide polymorphism (SNP) calling’).5

To this end, several software packages have been implemented to perform genotype and SNP calling from NGS data, the most popular ones being samtools/bcftools,6 GATK,7 and freeBayes.8 When, on average, few reads map at each genomic position (a scenario referred to as ‘low-coverage’ or ‘low-depth’), genotypes and SNPs cannot be assigned with confidence due to the high data uncertainty.9,10 Under these circumstances, statistical methods that integrate data uncertainty into genotype likelihoods and propagate it to downstream analyses have been proposed.5 Software packages like ANGSD11 and ngsTools,12 among others reviewed by Lou et al.,13 implement a statistical framework to estimate population genetic metrics from low-coverage sequencing data. Similarly, an affordable generation of sequencing data from large sample sizes can be obtained via pooled sequencing experiments, where assignment of individual samples is typically not retained.14 Several new and popular software for the analysis of pooled sequencing have been proposed in recent years.15,16

Despite these advances, most of these implementations are either tuned and suitable for model organisms only (e.g., with haploid or diploid genomes) or not easily adaptable to novel applications. Therefore, an accessible computational framework for building and testing ad hoc population genetic analyses from NGS data is in dire need. Among programming languages, Julia17 has emerged as both a powerful and easy-to-use dynamically typed language that is widely used in many fields of data sciences, including genomics.18 While several Julia packages are currently available for both population genetic and bioinformatic analyses (e.g., BioJulia), to our knowledge, a suitable framework for custom population genetic analysis from NGS data is not available yet.

Here we present ngsJulia, a set of templates and functions in Julia language to process NGS data and create custom analyses in population genetics. To illustrate its applicability, we further introduce two implementations, ngsPool and ngsPloidy, for the analysis of pooled sequencing data and polyploid genomes, respectively. By extensive simulations, we show the performance of several methods implemented in these programs under various experimental conditions. We also introduce novel statistical methods to estimate population genetic parameters from NGS data and demonstrate their applicability and suggest optimal experimental design. We finally discuss further directions and purposes for ngsJulia and bioinformatics for NGS data analysis.

Methods

Implementation

ngsJulia was built in Julia language (Julia Programming Language, RRID:SCR_021666) and requires the packages ‘GZip’, ‘Combinatorics’, and ‘ArgParse’. Auxiliary scripts to process output files were built in R (R Project for Statistical Computing, RRID:SCR_001905) version 3.6.3 and require the package ‘getopt’. ngsJulia receives gzipped mpileup input files which can be generated using samtools.19 Output files are in text file format and can be easily parsed for producing summary plots and for further analyses. Scripts for some downstream analyses are provided in ngsJulia.

Operation

ngsJulia is compatible with all major operating systems and is maintained at https://github.com/mfumagalli/ngsJulia. Documentation and tutorials are available via this GitHub repository and archived at Zenodo20 at the time of writing. All analyses in the manuscript are performed in Julia language and R.

ngsJulia implements functions to read and parse gzipped mpileup files and to output gzipped text files on various calculations (e.g., genotype and allele frequency likelihoods) and estimations (e.g., allele frequencies), as requested by the user. ngsJulia also allows for several data filtering options, including on global and per-sample depth, proportion or count of minor allele, and base quality. Finally, several options for SNP and biallelic and triallelic polymorphisms calling are available.

Nucleotide, genotype and allele frequency likelihoods

ngsJulia provides utilities to calculate nucleotide and genotype likelihoods, i.e., the probability of observed sequencing data given a specific nucleotide or genotype,21 for an arbitrary ploidy level, as in Soraggi et al.22 We now describe how such quantities are calculated in ngsJulia.

Following the notation in Soraggi et al.,22 for one sample and one site, we let O be the observed NGS data, Y the ploidy, and G the genotype. Therefore, G has values in 01Y, i.e., the number of derived (or alternate) alleles.

In the simplest form, genotype likelihoods can be calculated by considering individual base qualities as probabilities of observing an incorrect nucleotide.21 We adopt the calculation of genotype likelihoods for an arbitrary ploidy level POGY as proposed in Soraggi et al.22 From the genotype likelihoods with POGY=1, the two most likely alleles are identified by sorting POGY=1 values after pooling all sequencing reads together across all samples. This operation will restrict the range of possible genotypes to biallelic variation only. Note that this calculation is still valid for monomorphic sites, although the actual assignment of the minor allele is meaningless.

We now describe how to estimate Fa,n, the frequency of allele aACGT at site n. Similarly to Kim et al.,23 the log-likelihood function for Fa,n is given by:

(1)
logPOnFa,n=i=1CnPOnci,n=aY=1Fn
where ci,n is the ith read at site n, and Cn is the total depth across all samples. Function 1 is maximised to obtain a maximum likelihood estimate (MLE) of the sample allele frequency, F̂n, either with a grid- or golden-section- search algorithm.

SNP calling

To perform SNP calling, we implement a likelihood-ratio test (LRT) with one degree of freedom with null hypothesis H0:Fn=0 and alternate hypothesis H1:Fn=F̂n, as described by Kim et al.23 Additionally, we develop a test for a site being biallelic or triallelic. The former can be interpreted as a further evidence of polymorphism, while the latter as a condition not to be met for the site being included in further estimations, as our models assume at most two alleles. The log-likelihood of site n being biallelic is equal to POnGn=ijY=1 while the log-likelihood being triallelic is equal to POnGn=ijzY=1, with i, j, and z being the most, second most, and third most likely allele with Y=1 (i.e. haploid genotype G), respectively. An LRT with one degree of freedom can be conducted to assess whether POnGn=iY=1 is significantly greater than POnGn=ijY=1, or the latter is significantly greater than POnGn=ijzY=1.

Allele frequency, site frequency spectrum and association test from pooled sequencing data

Several estimators of population parameters from pooled sequencing data are implemented in ngsPool, a separate program which uses functions in ngsJulia. We now describe the statistical framework for the analysis of pooled sequencing data.

In case of data with unknown sample size, the MLE of the population allele frequency Fn is calculated as in Equation 1 with F01. With known sample size, the same equation is used to calculate sample allele frequency likelihoods POnFn=f,24 for instance with f01M×Y for M samples of equal ploidy Y. From these likelihoods, we can calculate both the MLE and the expected value with uniform prior probability as estimators of Fn.

A simple estimator of the site frequency spectrum (SFS) from pooled sequencing data is obtained by counting point-estimates of Fn across all sites. We propose a novel estimator of the SFS implemented in ngsPool. Under the standard coalescent model with infinite sites mutations, we let the probability of derived allele frequency F in a sample of N genomes PF=f to be proportional to 1/fK with f1N1.25 The parameter K determines whether the population is deviating from a model of constant effective population size. For instance, K=1 is equal to the expected distribution of PF under constant population size, while K>1 models a population shrinking and K<1 population growth.

We optimise the value of K to minimise the Kullback-Liebrel divergence between the expected distribution of PFK and the observed SFS. The latter can be obtained by either counting F̂n across all sites or by integrating over the sample allele frequency probabilities PFn=fOnPOnFn=f (i.e. with a uniform prior distribution). A threshold can be set to ignore allele frequencies with low probability to improve computing efficiency and reduce noise. Within this framework, folding spectra can be generated in case of unknown allelic polarisation.

Finally, we introduce a strategy to perform association tests from pooled sequencing data. Similarly to Kim et al.,23 we propose an LRT with one degree of freedom for null hypothesis H0:fcases=fcontrols and alternate hypothesis H1:fcasesfcontrols. The likelihood of each hypothesis is calculated from POnFn=f and, therefore, this strategy avoids the assignment of counts or per-site allele frequencies. A statistically significant LRT with one degree of freedom suggests a difference in allele frequencies between cases and controls, and possible association between the tested phenotype and alleles.

Ploidy levels and test for multiploidy

We now describe the statistical framework implemented in the program ngsPloidy to estimate ploidy levels and test for multiploidy. When multiple samples are available, two scenarios can be envisaged: (i) all samples have the same ploidy, (ii) each sample can have a different ploidy (multiploidy, i.e. as in tumor genomes).26

The log-likelihood function for a vector of ploidy levels YM=Y1=y1Y2=y2YM=yM for M samples and N sites is defined as:

(2)
log(POY=YM)=m=1Mn=1Nlogi01YmPOnGm,n=iYm=ymPGm,n=iYm=ymFn=F̂n

With F̂n being the MLE of allele frequency at site n. POnGm,n=iYm=ym is the genotype likelihood while PGm,n=iYm=ymFn=F̂n is the genotype probability given the ploidy and allele frequency at site n.

Once F̂n is estimated and the inbreeding is known (or under the assumption of Hardy-Weinberg Equilibrium (HWE)), then genotype probabilities are fully defined. Equation 2 is optimised by maximising the marginal likelihood of each sample separately, assuming independence among samples and sites.

With limited sample size, F̂n is not a good estimator of the population allele frequency and therefore genotype probabilities may not be well defined. In the simplest scenario, genotype probabilities can be set as uniformly distributed, with all genotypes being equally probable. However, the assignment of alleles into ancestral (e.g., wild-type) and derived (e.g., mutant) states is particularly useful to inform on genotype probabilities. Recalling Equation 2, we can substitute PGm,n=iYm=ymFn=F̂n with PGm,n=iYm=ymFn=EFK), where EFK is the expected allele frequency of PF=fK1/fK, as introduced previously. Note that EFK does not depend on the sequencing data for each specific site n.

Note that, in practice, Equation 2 is a composite likelihood function, as samples and sites are not independent observations due to shared population history and linkage disequilibrium, respectively. A solution to circumvent this issue is to perform a bootstrapping procedure, by sampling with replacement segments of the chromosome and estimate ploidy for each bootstrapped chromosome. The distribution of inferred ploidy levels from bootstrapped chromosomes provides a quantitative measurement of confidence in determining the chromosomal ploidy. It is not possible to calculate the likelihood of ploidy equal to one after SNP calling. Nevertheless, the identification of haploid genomes from sequencing data is typically trivial.

Unknown or uncertain ancestral allelic state

So far, we assumed to know which allele can be assigned to an ancestral state, and which one to a derived state. However, in some cases, such assignment is either not possible or associated with a certain level of uncertainty due to, for instance, ancestral polymorphisms or outgroup sequence genome from a closely related species not being available. Under these circumstances, we extend our formulation by adding a parameter underlying the probability that the assigned ancestral state is incorrectly identified.

Let us define R as the ancestral state and a as any possible allele in ACGT. In practice, a can take only two possible values as we select only the two most likely alleles. We label this set of the two most common alleles as A and we assume that the true ancestral state is included in such set. The log-likelihood function of ploidy for a single sample m under unknown ancestral state is:

(3)
log(POYM=ym=n=1NlogaAi01YmPOnGm,n=iYm=ymPGm,n=iYm=ymR=aFn=F̂nPR=a

Where PR=a indicates the probability that allele a is the ancestral state, and it is invariant across sites. If PR=a=0.5, then the equation refers to the scenario of folded allele frequencies, where each allele is equally probable to be the ancestral state.

Finally, note that in a sufficiently large sample size, the major allele is more probable to represent the ancestral state. This probability depends on the shape of the site frequency spectrum, and it is equal to the cumulative distribution of PFK evaluated at F=N/2. We can extend Equation 3 to reflect this parameter uncertainty with a being the major allele in PR=a.

Test for multiploidy

We introduce a novel test for multiploidy. If all samples have the same ploidy yY, then Yi=Yj=y is true for all ij1,2,,M. We propose an LRT for multiploidy with null hypothesis H0:supY=y1=yy2=yyM=y and alternate hypothesis H1:Y=YMLE A large value of LRT is suggestive of multiploidy. Statistical significance can be assessed with the LRT and M1 degrees of freedom.

Data simulation

To benchmark the performance of methods implemented in ngsJulia, we simulated NGS data following a strategy previously proposed by Fumagalli et al.27 available as a stand-alone R script. Briefly, individual genotypes are drawn according to probabilities depending on input parameters. The number of mapped reads at each position is modelled with a Poisson distribution and sequenced bases are sampled with replacement with a probability given by the quality score. As an illustration, the following code

Rscript simulMpileup. R --out test.txt --copy 2x10 --sites 1000 \\--depth 20 --qual 20 ---pool|gzip > test.mpileup.gz

will simulate 10 diploid genomes (--copy 2x10), 1000 base pairs each (--sites 1000) with an average sequencing depth of 20 and base quality of 20 in Phred score (--depth 20 --qual 20) from pooled sequencing (--pool) with results stored in test.mpileup.gz file.

For the analysis of pooled sequencing data, we simulated 100,000 independent sites at sample sizes 20, 50, and 100 from a diploid population with a constant effective population size of 10,000. We imposed the average per-sample sequencing depth to be 0.5, 1, 2, or 5 with an average base quality of 20 in Phred score. To assess the performance of ngsPool, we calculated bias and root mean squared error (RMSE) between the estimated value of the true value, either from the sample or the whole population. While both metrics measure the distance with the true value, the bias retains the direction of the error (i.e. over- or under-estimation). To quantify the accuracy of SNP calling, we calculated F1 scores (the harmonic mean of precision and recall rates).

To simulate data for association test, we assumed an equal number of cases and controls (equal to 150) and 200 SNPs, either causal or non causal. For non causal sites, cases and controls have the same population allele frequency of 0.10. For causal sites, cases and controls have a population allele frequency of 0.09 and 0.04, respectively. These conditions are derived assuming a high risk allele frequency of 0.1, prevalence of 0.2, genotypic relative risk for the heterozygote of 2, genotypic relative risk for the homozygous state of 4. The sample size simulated guarantees at least 80% power with a false positive rate of 0.10.

To illustrate the usage of ngsPloidy, we simulated NGS data of genomes with different ploidy levels (one haploid, eight triploids, one tetraploid) at 1000 sites. NGS data was simulated assuming an average depth of 10 at the haploid level. Code and simulated data sets analysed are available in ngsJulia GitHub repository.

Empirical data

To showcase the applicability of ngsJulia to real data, we deployed to two distinct empirical data sests. To test ngsPool, we used mapped reads of Arabidopsis lyrata produced in a previous study.28 Specifically, We used data belonging to the population B where 25 individuals of A. lyrata have been sequenced by both pool-sequencing and genotyping-by-sequencing. Since GBS harbours data on a fraction of the genome and Pool-seq is whole genome, We restricted the analysis to the base pairs (bp) sequenced by both techniques, for a total of 15202 bp. The mpileup files have been generated with samtools6 (v1.14) and SNP calling in GBS data has been performed with Varscan29 (v2.4.2), resulting in 333 SNPs.

To test ngsPloidy, we reanalysed whole-genome sequencing data of the human fungal pathogen Candida auris from a previous study.30 We processed data for 21 samples, each one consisting of 17 contigs. As the null hypotheses is that these samples are haploid, we tested ploidy levels from 1 to 4. We filtered out sites with a minimum depth lower than 5 and a proportion of minor alleles lower than 0.15. The number of sites analysed per contig ranged from 555 to 754.

Results

ngsJulia implements data structures and functions for an easy calculation of nucleotide and genotype likelihoods (of arbitrary ploidy) which serve the basis of genotype and SNP calling and for the estimation of allele frequencies and other summary statistics. It is particularly suitable for low-coverage sequencing data and for cases when there is high data uncertainty. To demonstrate the use of ngsJulia, we provide two custom applications from its templates and functions.

ngsPool: analysis of pooled sequencing data

We used ngsJulia to implement a separate program, called ngsPool, to perform population genetic analysis from pooled sequencing data. Specifically, ngsPool implements established and novel statistical methods to estimate allele frequencies and site frequency spectra (SFS) and perform association tests from pooled sequencing data.

ngsPool uses functions in ngsJulia to parse mpileup files as input. As an illustration, the following code

julia ngsPool.jl --fin test.mpileup.gz --fout test.out.gz --lrtSnp 6.64

will parse test.mpileup.gz file and write estimates of allele frequencies in test.out.gz file from unknwon sample size after performing SNP calling with an LRT value of 6.64 (--lrtSnp 6.64, equivalent to a p-value of 0.01).

Depending on the options selected by the user, output files contain, various results are printed on the screen, including

  • inferred major allele,

  • inferred minor allele,

  • LRT statistic for SNP calling,

  • LRT for bi- and tri-allelic calling,

  • three estimators of the minor allele frequency at each site.

Additionally, ngsPool can output a file with per-site sample allele frequency likelihoods. The following code

julia ngsPool.jl --fin test.mpileup.gz --fout test.out.gz \\--nChroms 20 --fsaf test.saf.gz

will produce estimates of allele frequencies from the known sample size (specified by --nChroms 20) and allele frequency likelihoods in test.saf.gz file.

These files can then be used to estimate the SFS and perform an association test using two scripts provided in ngsPool. For instance, the code

Rscript poolSFS. R test.saf.gz > sfs.txt

will estimate the SFS, while the code

Rscript poolAssoc. R test.cases.saf.gz test.controls.saf.gz > assoc.txt

will perform an association test assuming two sets of allele frequency likelihood files, one from cases (test.cases.saf.gz) and one from controls (test.controls.saf.gz).

Estimation of allele frequencies

To illustrate the usage of ngsPool, we estimated allele frequencies based on simulated data at different experimental conditions. We sought to compare the performance among different estimators implemented in the program. If the sample size is not provided, ngsPool provides a simple MLE of the population allele frequency assuming haploidy. Alternatively, if the sample size is provided by the user, ngsPool calculates sample allele frequency likelihoods and returns both the MLE and the expected value of the allele frequency using a uniform prior probability.

Results show that the error of estimating allele frequencies decreases with increasing depth and sample size, as expected (Figure 1). Likewise, the error for estimating the population allele frequency is more pronounced for lower sample sizes. MLE values tend to be less biased than expected values and sample estimates appear to be unbiased even at depth 1 for moderate sample size (Figure 1).

30a3b63e-1af0-4bfc-a9ea-2c88a57e8076_figure1.gif

Figure 1. Estimation of minor allele frequencies from pooled sequencing data.

Bias and root mean square error (RMSE) against the reference true value from either the population or sample are provided for each value of depth D (the average number of sequenced reads per base pair) and sample size (on column panels) tested. Three estimators of allele frequencies are considered: a population maximum likelihood estimate (MLE) from unknown sample size and the expected value and MLE from known sample size.

Furthermore, we simulated NGS data at fixed population allele frequency and compared the distribution of true sample allele frequencies and estimated values using a MLE approach from known sample size. Figure 2 shows that most of the deviation from the true population allele frequencies occurs at intermediate frequencies (F equal to 0.5). This effect is more evident for low depth and low sample size (Figure 2).

30a3b63e-1af0-4bfc-a9ea-2c88a57e8076_figure2.gif

Figure 2. Distribution of estimated minor allele frequencies from pooled sequencing data.

True sample allele frequencies (SAF) and maximum likelihood estimates (MLE) are shown at different fixed population allele frequencies F and sample sizes (on rows, 20 and 50) and depths (the average number of sequenced reads per base pair, on columns, 0.5, 1, 2, and 5).

We then assessed the effect of low-frequency variants on SNP calling. Specifically, we calculated F1 scores for SNP calling when the population allele frequency is 0 (not a SNP) or greater than 0 (a SNP). Figure 3 shows how the prediction performance increases with the population allele frequency (F), sample size, and depth (D). For instance, an F1 score greater than 0.75 is obtained with 20 samples only for F=0.05 and D>0.5. On the other hand, the same F1 score is achieved with 50 samples even with F=0.025 and also at F=0.02 but only if D>1.

30a3b63e-1af0-4bfc-a9ea-2c88a57e8076_figure3.gif

Figure 3. Performance of single nucleotide polymorphism (SNP) calling from pooled sequencing data.

F1 scores (harmonic means of precision and recall rates) for predicting either a SNP (true population allele frequency F greater than 0) or not (F=0) are reported are various values of F, sample sizes (on columns, 20 and 50) and depths D (the average number of sequenced reads per base pair).

SNP calling under-performs when there is no variation in the population (F=0), with sequencing errors and sampling statistical uncertainty generating estimates of F greater than 0.

ngsPool implements several methods to estimate the SFS from sample allele frequencies. As described in the methods, a simpler estimator is based on assigning the most likely sample allele frequency at each site (labelled count). ngsPool implements novel estimators of SFS from pooled sequencing data as described in the method section. A script implements an algorithm to fit the theoretical SFS to the observed SFS. The latter can be calculated either by assigning per-site MLE of allele frequencies (labelled Fit_count) or by integrating the uncertainties across all sample allele frequency likelihoods (labelled Fit_afl).

Figure 4 shows the error in estimating either the population or sample SFS at various settings with different methods. The error decreases with increasing depth and sample size. Estimating SFS by fitting the theoretical SFS without assignment of allele frequencies generally outperforms other tested strategies (Figure 4).

30a3b63e-1af0-4bfc-a9ea-2c88a57e8076_figure4.gif

Figure 4. Estimation of site frequency spectrum (SFS) from pooled sequencing data.

Estimates based on counting allele frequencies (Count) or fitting from counted allele frequencies (Fit Count) or from allele frequency likelihoods (Fit afl) are calculated. Root mean square error (RMSE) values between true (either population or sample, on rows) and estimated SFS are reported at various depths D and sample sizes (on columns).

Notably, the novel approach implemented in ngsPool to estimate the parameter K of the SFS distribution (see Methods) allow us to directly quantify the error in inferring demographic events. In fact, all simulations assumed constant population size, equivalent to K=1. Figure 5 shows the estimated values of K by fitting the SFS either by assigning (counting) allele frequencies (Fit_count) or by using allele frequency likelihoods (Fit_afl). For low-to-moderate depth and sample size, estimates of K tend to suggest population expansion (K<1), possibly due to an over-estimation of the abundance of low-frequency alleles. However, the error is reduced when integrating the data uncertainty with sample allele frequency likelihoods, as estimates of K values tend to be closer to the true simulated value of 1 (Figure 5).

30a3b63e-1af0-4bfc-a9ea-2c88a57e8076_figure5.gif

Figure 5. Estimation of parameter K (used to determine if the population is deviating from constant effective population size) of the site frequency spectrum at different depths D and sample sizes (on rows) from pooled sequencing data.

Estimates based on fitting from counted allele frequencies (Fit count) and from allele frequency likelihoods (Fit afl) are reported. Note that the true simulated value of K is 1.

ngsPool implements a script to perform association tests from pooled sequencing data. Specifically, the script calculates an LRT statistic, with null hypothesis being that allele frequencies of cases and controls (or any two groups) are the same, as used by Kim et al.23 It uses sample allele frequency likelihoods and, therefore, it maintains data uncertainty and avoids the assignment of counts or per-site allele frequencies. An LRT statistics significantly greater than 0 indicates a difference in allele frequencies between cases and controls.

Figure 6 compares the distribution of LRT statistics between causal and non causal sites at different experimental scenarios. The distribution of LRT at causal SNPs is skewed towards higher values for increasing depth, indicating more support to find phenptype-SNP association. Nevertheless, a clear separation between the distributions of causal and non causal SNPs is observed at low depth (Figure 6).

30a3b63e-1af0-4bfc-a9ea-2c88a57e8076_figure6.gif

Figure 6. Performance of association test from pooled sequencing data.

The distribution of likelihood-ratio test (LRT) statistics for casual and non causal single-nucleotide polymorphism (SNP) is reported at different depths (the average number of sequenced reads per base pair, on columns).

To illustrate the application of ngsPool to real data, we reanalysed genomic data from Arabidopsis lyrata.28 In this study, authors generated data both by genotype-by-sequencing and by pooled-sequencing, with the former providing ground-truth values for genotype and allele calls. Estimates of minor allele frequencies using ngsPool yield a lower RMSE (0.09372) than estimates from Varscan (0.09783) across all SNPs analysed.

ngsPloidy: analysis of sequencing data from polyploid genomes

We further utilised ngsJulia to implement an additional program, ngsPloidy, for the estimation of ploidy from unknown genotypes. The method implemented is similar to the one proposed by Soraggi et al.22 with some notable differences on the calculation of genotype probabilities (see Methods). Additionally, ngsPloidy includes a novel method to test for multiploidy in the sample. As an illustration, the following code

julia ngsPloidy.jl --fin test.mpileup.gz --nSamples 20 > test.outRscript ploidyLRT. R test.out

will estimate ploidy levels for 20 genomes (--nSamples 20) from test.mpileup.gz file and return LRT values.

Following Equation 2, the genotype probabilities for each tested ploidy are pre-calculated using a script provided in ngsPloidy. This script takes as input the value of parameter K (the shape of the expected SFS), the effective population size, and the probability that the major allele is the ancestral allele. The latter can be either set by the user (e.g., a value of 0.5 would be equivalent to unknown polarisation, as in a folded SFS) or be calculated from the expected population SFS itself. If genotype probabilities are not set, a uniform distribution is assigned. Further options allow for estimation only on called SNPs and/or genotypes.

ngsPloidy uses functions in ngsJulia to parse mpileup files as input. At the end of the computation, various results are printed on the screen, including

  • the number of analysed sites that passed filtering for each sample,

  • a matrix of ploidy log-likelihoods for each sample,

  • the log-likelihood and MLE of the ploidy vector (i.e., the individually estimated ploidy for each sample),

  • LRT scores for the test of multiploidy against all tested ploidy levels.

Additionally, if requested by the user, ngsPloidy can generate output files with several statistics for each site (e.g., estimate allele frequency), and all per-site genotype likelihoods for each sample and the tested ploidy.

To illustrate the usage of ngsPloidy, we deployed it to simulated data of an multiploid sample consisting of one diploid, eight triploid and one tetraploid genomes. We compared the performance of ploidy and multiploidy inference among different choices of genotype probabilities. The latter were derived either from the expected folded population site frequency, from the estimated ancestral population allele frequency, or from the calculated sample allele frequency.

In all tested cases, we inferred the correct vector of marginal ploidy levels. We therefore assessed the confidence in such inference by calculating the LRT statistics of ploidy and multiploidy inferences. Both were calculated by comparing the most against the second most likely vector of ploidy levels or the most likely vector of equal ploidy levels, respectively.

Results show that using the per-site estimate sampled allele frequency yields higher LRT statistics (and therefore confidence) than using expected population allele frequencies (Table 1). We reiterate that for all three cases we correctly identified the patterns of multiploidy. However, we should caution that with lower sample sizes we do not expect inferences using estimated sample allele frequencies to perform well.

Table 1. Confidence values to the correctly assigned ploidy vector and test for multiploidy.

Likelihood-ratio test (LRT) statistics using different methods of incorporating allele frequencies are reported.

Allele frequencyLRT – ploidyLRT - multiploidy
Folded34.19252.72
Ancestral31.49277.91
Sample37.83373.07

To illustrate the applicability of ngsPloidy to real empirical data, we inferred ploidy levels on 21 isolates from an outbreak of Candida auris.30 In all contigs analysed, haploid was inferred as the most likely ploidy and multiploidy was rejected in all samples. These results are consistent with findings from the original study, although the identification of polyploidy in other isolates may be associated with multidrug-resistant phenotypes.31

Discussion

Analyses presented here provide further support for the use of genotype and allele frequency likelihoods in the analysis of NGS data.5 Notably, we demonstrated how probabilistic estimates of population genetic parameters can be obtained in case of pooled sequencing data and short-read data from polyploid genomes. Additionally, we motivated the inference of SFS from allele frequency likelihoods as a direct way to infer demography from raw sequencing data.

ngsJulia offers new possibilities of software prototyping for custom analyses of NGS data for population genetic applications. Furthermore, it facilitates experimental design as it provides a platform to benchmark the efficacy of population genetic analysis from competing sequencing experiments. Finally, ngsJulia has accessible documentation and tutorials to inform users on the theory underpinning the implemented methods. We envisage that further improvements in ngsJulia will include the expansion of suitable input formats and data file types, and the compatibility with additional NGS data type, including from long-read sequencing experiments.32

Conclusions

In this study, we introduce ngsJulia, a series of templates and functions in Julia language to analyse NGS data for population genetic purposes. We present two implementations for the analysis of pooled sequencing data and polyploid genomes, with the inclusion of novel methods. ngsJulia is a suitable framework for prototyping new software and for custom population genetic analyses from NGS data.

Data availability

Underlying data

Simulated data and pipeline to reproduce all results presented here are available at https://doi.org/10.5281/zenodo.5886879.20

Data are available under the terms of the Creative Commons Attribution 4.0 International Public License.

Software availability

Comments on this article Comments (0)

Version 3
VERSION 3 PUBLISHED 31 Jan 2022
Comment
Author details Author details
Competing interests
Grant information
Copyright
Download
 
Export To
metrics
Views Downloads
F1000Research - -
PubMed Central
Data from PMC are received and updated monthly.
- -
Citations
CITE
how to cite this article
Mas-Sandoval A, Jin C, Fracassetti M and Fumagalli M. ngsJulia: population genetic analysis of next-generation DNA sequencing data with Julia language [version 3; peer review: 1 approved, 3 approved with reservations]. F1000Research 2023, 11:126 (https://doi.org/10.12688/f1000research.104368.3)
NOTE: If applicable, it is important to ensure the information in square brackets after the title is included in all citations of this article.
track
receive updates on this article
Track an article to receive email alerts on any updates to this article.

Open Peer Review

Current Reviewer Status: ?
Key to Reviewer Statuses VIEW
ApprovedThe paper is scientifically sound in its current form and only minor, if any, improvements are suggested
Approved with reservations A number of small changes, sometimes more significant revisions are required to address specific details and improve the papers academic merit.
Not approvedFundamental flaws in the paper seriously undermine the findings and conclusions
Version 3
VERSION 3
PUBLISHED 14 Jul 2023
Revised
Views
6
Cite
Reviewer Report 11 Oct 2023
Jens Léon, University of Bonn, Bonn, Germany 
Michael Schneider, Forschungsinstitut fur Biologischen Landbau, Frick, Aargau, Switzerland 
Approved with Reservations
VIEWS 6
First of all, I have to write that we are working on a method to estimate the allele frequency in crops by pool sequencing. Therefore, we are very interested in this new methodology. In this review our research group have ... Continue reading
CITE
CITE
HOW TO CITE THIS REPORT
Léon J and Schneider M. Reviewer Report For: ngsJulia: population genetic analysis of next-generation DNA sequencing data with Julia language [version 3; peer review: 1 approved, 3 approved with reservations]. F1000Research 2023, 11:126 (https://doi.org/10.5256/f1000research.150492.r202079)
NOTE: it is important to ensure the information in square brackets after the title is included in all citations of this article.
Views
8
Cite
Reviewer Report 21 Sep 2023
Nikolay Oskolkov, Department of Biology, National Bioinformatics Infrastructure Sweden, Science for Life Laboratory, Lund University, Lund, Sweden 
Approved with Reservations
VIEWS 8
The authors suggest a population genomics tool written in Julia programming language. They demonstrate the performance of the tool on simulated and real pooled sequencing data. The manuscript is well written and technical details of the tool are well explained. ... Continue reading
CITE
CITE
HOW TO CITE THIS REPORT
Oskolkov N. Reviewer Report For: ngsJulia: population genetic analysis of next-generation DNA sequencing data with Julia language [version 3; peer review: 1 approved, 3 approved with reservations]. F1000Research 2023, 11:126 (https://doi.org/10.5256/f1000research.150492.r202073)
NOTE: it is important to ensure the information in square brackets after the title is included in all citations of this article.
Views
6
Cite
Reviewer Report 14 Aug 2023
Stéphane De Mita, Institut national de la recherche agronomique (INRAE), Paris, France 
Approved
VIEWS 6
After considering the updated version and using the new documentation, I managed to run some tests successfully. However, I ... Continue reading
CITE
CITE
HOW TO CITE THIS REPORT
De Mita S. Reviewer Report For: ngsJulia: population genetic analysis of next-generation DNA sequencing data with Julia language [version 3; peer review: 1 approved, 3 approved with reservations]. F1000Research 2023, 11:126 (https://doi.org/10.5256/f1000research.150492.r187509)
NOTE: it is important to ensure the information in square brackets after the title is included in all citations of this article.
Version 2
VERSION 2
PUBLISHED 29 Nov 2022
Revised
Views
15
Cite
Reviewer Report 21 Feb 2023
Stéphane De Mita, Institut national de la recherche agronomique (INRAE), Paris, France 
Approved with Reservations
VIEWS 15
The article "ngsJulia: population genetic analysis of next-generation DNA sequencing data with Julia language" by Alex Mas-Sandoval and colleagues provides a library for the Julia addressing management of NGS data (provided in the PileUp format), SNP and genotype calling allowing ... Continue reading
CITE
CITE
HOW TO CITE THIS REPORT
De Mita S. Reviewer Report For: ngsJulia: population genetic analysis of next-generation DNA sequencing data with Julia language [version 3; peer review: 1 approved, 3 approved with reservations]. F1000Research 2023, 11:126 (https://doi.org/10.5256/f1000research.141471.r160519)
NOTE: it is important to ensure the information in square brackets after the title is included in all citations of this article.
  • Author Response 16 Nov 2023
    Matteo Fumagalli, Department of Life Sciences, Imperial College London, London, UK
    16 Nov 2023
    Author Response
    Here is a list of random typos or detail-level suggestions:
    • "polidy" in the "Revision" box.
    Unfortunately we cannot modify previous responses to reviewers, but this typo is ... Continue reading
COMMENTS ON THIS REPORT
  • Author Response 16 Nov 2023
    Matteo Fumagalli, Department of Life Sciences, Imperial College London, London, UK
    16 Nov 2023
    Author Response
    Here is a list of random typos or detail-level suggestions:
    • "polidy" in the "Revision" box.
    Unfortunately we cannot modify previous responses to reviewers, but this typo is ... Continue reading
Version 1
VERSION 1
PUBLISHED 31 Jan 2022
Views
49
Cite
Reviewer Report 13 Apr 2022
Lindsay Clark, Roy J. Carver Biotechnology Center, University of Illinois at Urbana-Champaign, Urbana, IL, USA 
Approved with Reservations
VIEWS 49
The manuscript by Mas-Sandoval et al. describes ngsJulia, a collection of functions and scripts in Julia and R for estimating genotype likelihoods from short read DNA sequencing data, as well as estimating allele frequencies in pooled samples, and estimating ploidy ... Continue reading
CITE
CITE
HOW TO CITE THIS REPORT
Clark L. Reviewer Report For: ngsJulia: population genetic analysis of next-generation DNA sequencing data with Julia language [version 3; peer review: 1 approved, 3 approved with reservations]. F1000Research 2023, 11:126 (https://doi.org/10.5256/f1000research.114499.r128232)
NOTE: it is important to ensure the information in square brackets after the title is included in all citations of this article.
  • Author Response 29 Nov 2022
    Matteo Fumagalli, Department of Life Sciences, Imperial College London, London, UK
    29 Nov 2022
    Author Response
    The manuscript by Mas-Sandoval et al. describes ngsJulia, a collection of functions and scripts in Julia and R for estimating genotype likelihoods from short read DNA sequencing data, as well ... Continue reading
COMMENTS ON THIS REPORT
  • Author Response 29 Nov 2022
    Matteo Fumagalli, Department of Life Sciences, Imperial College London, London, UK
    29 Nov 2022
    Author Response
    The manuscript by Mas-Sandoval et al. describes ngsJulia, a collection of functions and scripts in Julia and R for estimating genotype likelihoods from short read DNA sequencing data, as well ... Continue reading

Comments on this article Comments (0)

Version 3
VERSION 3 PUBLISHED 31 Jan 2022
Comment
Alongside their report, reviewers assign a status to the article:
Approved - the paper is scientifically sound in its current form and only minor, if any, improvements are suggested
Approved with reservations - A number of small changes, sometimes more significant revisions are required to address specific details and improve the papers academic merit.
Not approved - fundamental flaws in the paper seriously undermine the findings and conclusions
Sign In
If you've forgotten your password, please enter your email address below and we'll send you instructions on how to reset your password.

The email address should be the one you originally registered with F1000.

Email address not valid, please try again

You registered with F1000 via Google, so we cannot reset your password.

To sign in, please click here.

If you still need help with your Google account password, please click here.

You registered with F1000 via Facebook, so we cannot reset your password.

To sign in, please click here.

If you still need help with your Facebook account password, please click here.

Code not correct, please try again
Email us for further assistance.
Server error, please try again.