HWE report warnings

42 views
Skip to first unread message

Gabriella Scatà

unread,
Mar 8, 2023, 1:40:30 AM3/8/23
to dartR
Hi,
I was using the gl.report.hwe function and I got the following outcome with warnings messages:

Starting gl.report.hwe

  Processing genlight object with SNP data

  Analysing each population separately

`geom_line()`: Each group consists of only one observation.

Do you need to adjust the group aesthetic?

    Reporting significant departures from Hardy-Weinberg

            Equilibrium

    No significant departures

 

Completed: gl.report.hwe

There were 50 or more warnings (use warnings() to see the first 50)


> warnings()

Warning messages:

1: In HardyWeinberg::HWChisq(X[i, ], verbose = FALSE) :

  Expected counts below 5: chi-square approximation may be incorrect

2: In HWf(X) : Monomorphic marker, f set to zero.

3: In HardyWeinberg::HWChisq(X[i, ], verbose = FALSE) :

  Expected counts below 5: chi-square approximation may be incorrect

4: In HardyWeinberg::HWChisq(X[i, ], verbose = FALSE) :

  Expected counts below 5: chi-square approximation may be incorrect


Should I be worried about the warnings saying "Expected counts below 5" ?
And what does it mean "`geom_line()`: Each group consists of only one observation." ?



The code I used is below:
final_dataset_MAF0.05_HWE = gl.report.hwe(
final_dataset,
  subset = "each",
  method_sig = "Exact",
  multi_comp = TRUE,
  multi_comp_method = "BY",
  alpha_val = 0.05,
  pvalue_type = "midp",
  cc_val = 0.5,
  sig_only = TRUE,
  min_sample_size = 5,
  plot.out = TRUE,
  max_plots = 4,
  save2tmp = FALSE,
  verbose = NULL



Thanks a lot!
Best,
Gabriella

Bernd.Gruber

unread,
Mar 8, 2023, 2:01:55 AM3/8/23
to da...@googlegroups.com

Hi Gabriella,

 

This is a warning from the chi2 test as it requires that your counts (genotypes, estimated and observed) need to be above 5 to be valid. You could use an exact fisher test if a particular loci is in doubt.

 

It depends a bit on your sample sizes if I would trust the test (e.g. do you have more like 10 or 100 individuals on your (sub) populations.

 

Regards, Bernd

--
You received this message because you are subscribed to the Google Groups "dartR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dartr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartr/b2567421-3a5c-4b80-ab17-9495acca014en%40googlegroups.com.

Gabriella Scatà

unread,
Mar 8, 2023, 8:22:49 PM3/8/23
to dartR
Hi Bernd,
and thanks so much for your quick reply.

I did use the Exact test in the analysis...as you can see from the code I reported at the bottom of my email:
method_sig = "Exact"

I have 9 populations, most of which have min 20 individuals, but 2 populations have 8 or 11 samples.
I though Fisher Exact test would be more appropriate for smaller sample sizes like this, and still ok as long as you have min 5 individuals per population.
Plus, I used a Locus callrate threshold of 0.98 with MAF 0.01 or 0.05 (i get the same warning messages regardless of the MAF filter used), so I am not sure if it's a problem with rare alleles...

I also tried all types of HWE test approaches with the Exact test and i) without multiple tests corrections, ii) with multiple tests corrections with Bonferroni, iii) with multiple tests corrections with FDR-BY and iv) with multiple tests corrections with FDR-BH, and I get the same warning messages in all cases.
Is there a way for me to test whether the results of these HWE tests are correct?


Also, what does this warning "geom_line()`: Each group consists of only one observation.  Do you need to adjust the group aesthetic?" mean?
Thank you so much as usual for your help and feedback!
Best,
Gabriella

Gabriella Scatà

unread,
Mar 13, 2023, 1:38:00 AM3/13/23
to dartR
Hi Bernd,
I re-ran the gl.report.hwe() analysis with a dataset where I removed the populations with small sample size (pop1=8, pop2 = 11). So, all the other populations remaining in the dataset have minimum 20 individuals.
I re-run gl.report.hwe() always with the method.sign = Exact (Fisher exact test as you recommended), but I still get the same warnings() messages:

CODE:
final_dataset_MAF0.05_HWE = gl.report.hwe(

              final_dataset,

              subset = "each",

              method_sig = "Exact",

              multi_comp = TRUE,

              multi_comp_method = "BY",

              alpha_val = 0.05,

              pvalue_type = "midp",

              cc_val = 0.5,

              sig_only = TRUE,

              min_sample_size = 5,

              plot.out = TRUE,

              max_plots = 4,

              save2tmp = FALSE,

              verbose = NULL

            ) 

>


Outcome messages:

Starting gl.report.hwe

  Processing genlight object with SNP data

  Analysing each population separately

    Reporting significant departures from Hardy-Weinberg

            Equilibrium

    No significant departures

Completed: gl.report.hwe

There were 50 or more warnings (use warnings() to see the first 50)


warnings()

Warning messages:

1: In HardyWeinberg::HWChisq(X[i, ], verbose = FALSE) :

  Expected counts below 5: chi-square approximation may be incorrect

2: In HWf(X) : Monomorphic marker, f set to zero.

3: In HardyWeinberg::HWChisq(X[i, ], verbose = FALSE) :

  Expected counts below 5: chi-square approximation may be incorrect

... (ALL THE SAME warnings) ...

>


With this dataset (with all populations min sample size = 20 individuals), I don't seem to get anymore the warning (?) message "geom_line()`: Each group consists of only one observation.  Do you need to adjust the group aesthetic?". However, I keep getting the warnings "Expected counts below 5: chi-square approximation may be incorrect".

So, I am wondering whether this is normal, if it's an issue with the function or with my data, but with this dataset the sample size of each population is quite good (20) and the MAF threshold applied is quite high (0.05)...so I am not sure why I would incur in the issue of "expected counts below 5" for HWE?


Is there something I am missing? Also, does this message really apply to me as I did not use ChiSquare but Fisher Exact test?


Thanks a lot for any assistance you can provide!

I just need to understand if I can trust the results, I guess.

Thanks!

Gabriella


Jose Luis Mijangos

unread,
Mar 14, 2023, 2:25:22 AM3/14/23
to dartR
Hi Gabriella,

Those warnings came from the testing of simulated data to delineate the acceptance region for HWE, i.e. nothing to be worried about. 

These warning messages have been silenced in the developing version of dartR which can be installed as shown below:

> library(dartR)
> gl.install.vanilla.dartR(flavour = "dev")

Cheers,
Luis 

Gabriella Scatà

unread,
Mar 14, 2023, 2:55:34 AM3/14/23
to dartR
Ok, phew great thank you so much!!
:)

Reply all
Reply to author
Forward
0 new messages