Skip to contents

This function uses the statistic set in the parameter stat_keep from function to choose the SNP to keep when two SNPs are in LD. When a SNP is selected to be filtered out in each pairwise comparison, the function stores its name in a list. In subsequent pairwise comparisons, if the SNP is already in the list, the other SNP will be kept.


  threshold = 0.2,
  pop.limit = ceiling(nPop(x)/2),
  verbose = NULL



Name of the genlight object containing the SNP data [required].


Output from function [required].


Threshold value above which loci will be removed [default 0.2].


Minimum number of populations in which LD should be more than the threshold for a locus to be filtered out. The default value is half of the populations [default ceiling(nPop(x)/2)].


Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log; 3, progress and results summary; 5, full report [default 2, unless specified using gl.set.verbosity].


The reduced genlight object.


Custodian: Luis Mijangos -- Post to


if (FALSE) {
test <-
test <- gl.filter.callrate(test,threshold = 1)
res <-
res_2 <- gl.filter.ld(x=test,ld_report = res)
res_3 <-
if ((requireNamespace("snpStats", quietly=TRUE) & (requireNamespace("fields", quietly = TRUE)))) {
test <- gl.filter.callrate(, threshold = 1)
test <- gl.filter.monomorphs(test)
test <- test[,1:250]
report <-
res <- gl.filter.ld(x=test,ld_report = report)
#> Starting gl.filter.callrate 
#>   Processing genlight object with SNP data
#>   Warning: data include loci that are scored NA across all individuals.
#>   Consider filtering using gl <- gl.filter.allna(gl)
#>   Warning: Data may include monomorphic loci in call rate 
#>                     calculations for filtering
#>   Recalculating Call Rate
#>   Removing loci based on Call Rate, threshold = 1 

#> Completed: gl.filter.callrate 
#> Starting gl.filter.monomorphs 
#>   Processing genlight object with SNP data
#>   Identifying monomorphic loci
#>   Removing monomorphic loci and loci with all missing 
#>                        data
#> Completed: gl.filter.monomorphs 
#> Starting 
#>   Processing genlight object with SNP data
#>   Calculating pairwise LD in population SEVERN_ABOVE 
#>   Calculating pairwise LD in population SEVERN_BELOW 
#>   Calculating pairwise LD in population TENTERFIELD 

#> Completed: 
#> Starting gl.filter.ld 
#>   Processing genlight object with SNP data
#>   Summary of filtered dataset
#>     LD for loci > 0.2 
#>     Original No. of loci : 250 
#>     No. of loci retained: 151 
#>     No. of populations:  3 
#> Completed: gl.filter.ld