gl.report.heterozygosity (individual Ho)

38 views
Skip to first unread message

Manuela Cascini

unread,
May 13, 2024, 9:03:47 PMMay 13
to dartR
Hi Luis,

could you please clarify how the function gl.report.heterozygosity calculates observed heterozygosity (Ho) per individual? I was expecting: number of heterozygotes / n_Ind, but in the R documentation Ho is defined as: 
  • Observed heterozygosity (Ho) = number of homozygotes / n_Ind, where n_Ind is the number of individuals without missing data.

Thank you,
Manuela

Jose Luis Mijangos

unread,
May 13, 2024, 9:28:06 PMMay 13
to dartR
Hi Manuela,

Yes, that's a typo in the documentation! However the code correctly calculates heterozygosity as the number of heterozygotes / n_Ind. 

This typo has been already fixed in the dartRverse. We are not maintaining dartR anymore and it will be retired soon. We recommend using instead the "dartRverse", see the below link for an explanation and how to install it:


Cheers,
Luis 

Manuela Cascini

unread,
May 13, 2024, 10:11:07 PMMay 13
to da...@googlegroups.com
Thanks Luis,
I will join the dartRverse then!

Cheers,
Manuela

--
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/1efa2ce0-0e5f-479e-9a7c-178750998483n%40googlegroups.com.

wing...@gmail.com

unread,
May 14, 2024, 2:06:59 AMMay 14
to dartR
Hi Luis,

Apologies for jumping in on another thread, but I am also having an issue with calculating individual observed heterozygosity (Ho) per individual: namely, that the function does not return standardized metrics even when the number of invariant sites are specified. However, the method works fine when calculating adjusted metrics at the population level. E.g.: 
"gl.report.heterozygosity(x = rh10, n.invariant = ld.report[7, 2], method = "pop", nboots = 100, conf = 0.95, CI.type = "norm")" returns a data frame with 14 rows (the number of pops) x 37 columns (including Ho.adj, etc.)
"gl.report.heterozygosity(x = rh10, n.invariant = ld.report[7, 2], method = "ind", nboots = 100, conf = 0.95, CI.type = "norm")" returns:
 Starting gl.report.heterozygosity
  Processing genlight object with SNP data
  Calculating observed heterozygosity for individuals
  Note: No adjustment for invariant loci (n.invariant set to 0)
Starting gl.colors
Selected color type 2
Completed: gl.colors
and a data frame with 94 rows (the number of individuals) x 4 columns (ind.name, Ho, f.hom.ref, f.hom.alt).

I've tried using both traditional dartR and the dartRverse packages, but have the same result. Is this a known issue, and/or is there a work-around? Happy to send the full code/data if needed.

Thanks,
Sean.

Jose Luis Mijangos

unread,
May 14, 2024, 9:47:04 PMMay 14
to dartR
Hi Sean,

You can try the following code: 

library(dartR.base)
t1 <- platypus.gl
# estimate heterozygoty by individual
r1 <- gl.report.heterozygosity(t1,method = "ind")
# getting invariant sites
r2 <- gl.report.secondaries(t1)
n_invariant <- r2[r2$Param=="n.invariant","Value"]
# standardize heterozygosity using invariant sites
r1$Ho_invariant <- (r1$Ho * r1$n.Loc) / (r1$n.Loc + n_invariant)
head(r1)

Before estimating invariant sites, it is important to be mindful of not using any filter that might drop secondaries. 

Cheers,
Luis 


wing...@gmail.com

unread,
May 16, 2024, 9:13:42 PMMay 16
to dartR
Hi Luis,

Thanks for the work around: just a note that "$n.Loc" is not a component of the output from "gl.report.heterozygosity", so I have used "nLoc(t1)" in that code instead.

Cheers,
Sean.

Jose Luis Mijangos

unread,
May 16, 2024, 9:21:41 PMMay 16
to dartR
Hi Sean,

Yes,  "$n.Loc" it is a component of the output of gl.report.heterozygosity.  Yu might need to install the developing version of dartR.base, see tutorial in the link below:
Number of loci used to calculate Ho differ between individuals. So, if you use nLoc(t1) it will not be completely accurate.

Cheers,
Luis 

wing...@gmail.com

unread,
May 17, 2024, 3:53:07 AMMay 17
to dartR
Hi Luis,

Apologies for that - have updated to the dev version of dartR.base and all looks okay now. Can confirm that using that approach does alter autosomal heterozygosity slightly across the samples.

Thanks for your help!
Sean.

Reply all
Reply to author
Forward
0 new messages