Wondering a function to compute nucleotide diversity (pi)

16 views
Skip to first unread message

Yayan Kusuma

unread,
May 6, 2025, 3:58:15 AMMay 6
to dartR
Hello dartR team,

I have been playing around with the dartR package. I find it awesome as so many functions are available, a nearly complete package for population genetic analysis. The great thing about this package is that it also compatible for data set from other RRS approaches not only those that are derived from DArTseq.

However, I am wondering why there isn't any function to calculate nucleotide diversity (pi) within the dartR package (CMIIW). I think it would be wonderful if you could accommodate the calculation of pi, probably within the gl.report.heterozigosity function.

I look forward to it.

Sincerely yours
YK

Jose Luis Mijangos

unread,
May 7, 2025, 1:48:35 AMMay 7
to dartR

Hi YK,

Thanks for your kind words and thoughtful question.

You're absolutely right that nucleotide diversity (pi) is a valuable metric, particularly because it can be compared consistently across studies and species.

However, calculating pi accurately requires data that includes both variant and invariant sites. This is typically possible with whole genome sequencing, but not with most reduced representation sequencing (RRS) methods like ddRAD or DArTseq, where only variable sequences/sites are usually retained and repetitive regions are often excluded. As a result, estimates of pi from such datasets would be biased unless the invariant sites are reconstructed or accounted for.

There is a way around this — for example, starting from the raw sequencing data and retaining invariant sites, similar to the approach used in pixy (see: ksamuk/pixy on GitHub). Because most users work with processed SNP datasets, we’ve held off on implementing pi in dartR to avoid misleading results.

That said, we’re currently working on a method to estimate the number of invariant sites from RRS datasets, which would allow for more robust pi calculations — and we’re hoping to have something ready by next week!

Cheers,
Luis

Yayan Kusuma

unread,
May 8, 2025, 4:06:09 AMMay 8
to da...@googlegroups.com
Dear Luis,

Thanks for the explanation. I learnt a new thing here. Thanks again.  I look forward to the implementation of pi calculation in the future DartR package.

Best,
YK

--
You received this message because you are subscribed to a topic in the Google Groups "dartR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dartr/QuHKLEN6l-E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dartr+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dartr/6a61f9a0-eb02-4d98-9829-a869d9d0a969n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages