# diversity metrics and batch effects

**URL:** <https://forum.qiime2.org/t/diversity-metrics-and-batch-effects/12717>\
**Category:** General Discussion\
**Created:** [December 3, 2019, 9:19pm UTC](https://forum.qiime2.org/t/diversity-metrics-and-batch-effects/12717 "2019-12-03T21:19:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yipinto](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yipinto/32/13406_2.png) [@yipinto](https://forum.qiime2.org/u/yipinto)\
**Post date:** [December 3, 2019, 9:19pm UTC](https://forum.qiime2.org/t/diversity-metrics-and-batch-effects/12717/1 "2019-12-03T21:19:29Z")

</div>

I have a project with several sequencing runs. When looking at diversity metrics it seems that I have batch effects. I found the [q2-perc-norm](https://library.qiime2.org/plugins/q2-perc-norm/5/) plugin, but I'm not sure if it safe to use percentile-normalized "counts" for diversity metrics. I was thinking to filter batch specific features (with its pros and cons). Any other idea to deal with batch-effects?  
Thanks!

---

<div class="post-metadata">

**Author:** ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)\
**Post date:** [December 4, 2019, 4:46pm UTC](https://forum.qiime2.org/t/diversity-metrics-and-batch-effects/12717/2 "2019-12-04T16:46:23Z")

</div>

Hi @yipinto,

> [@yipinto](#):
>
> I was thinking to filter batch specific features (with its pros and cons).

I think that approach is all cons, UNLESS if the contaminant features you are filtering are clearly contaminants, e.g., known reagent contaminants or other features that you can positively say will not be found in your samples.

> [@yipinto](#):
>
> I’m not sure if it safe to use percentile-normalized “counts” for diversity metrics.

cc: @cduvallet

> [@yipinto](#):
>
> Any other idea to deal with batch-effects?

See here for some other ideas:

> [@Merging denoised outputs](https://forum.qiime2.org/t/merging-denoised-outputs/12722/2):
>
> Welcome back @Fabs! Yes indeed this looks like a typical batch effect issue. Note that batch effects will be most pronounced with Jaccard distance, since it is measuring the proportion of features that are NOT shared by each pair of samples and if you have even the most subtle differences between runs (say, the sequences could be identical but 1 nt longer in one run) then Jaccard distances will all == 1.0. The solution? The best you can do is attempt to standardize the processing between the…

---

<div class="post-metadata">

**Author:** ![cduvallet](https://forum.qiime2.org/user_avatar/forum.qiime2.org/cduvallet/32/1082_2.png) [@cduvallet](https://forum.qiime2.org/u/cduvallet)\
**Post date:** [December 5, 2019, 4:04am UTC](https://forum.qiime2.org/t/diversity-metrics-and-batch-effects/12717/3 "2019-12-05T04:04:12Z")

</div>

Hi @yipinto!

The output of percentile-normalization is _definitely_ not "counts", and should not be used in metrics that require counts. For example, Chao1 uses the number of singletons and doubletons to calculate alpha diversity, and so would be inappropriate for use with percentile-normalized data.

Unfortunately, we haven't gone through and identified which of the [many metrics available](https://forum.qiime2.org/t/alpha-and-beta-diversity-explanations-and-commands/2282) are appropriate to use with percentile-normalized data, so you'll have to go through and see how each one is calculated and whether they make assumptions about the data that might not be applicable here.

I think one of the most important things to note with the percentile-normalized output is that we add random noise to the zeros (to prevent pile-up of ranks, see more [here](https://cduvallet.github.io/posts/2018/06/fuzzy-zeros)), so any metric that uses zero as a meaningful value will not work for percentile-normalized data.

If you have questions about any specific metrics that you've thought about but can't figure out, feel free to post again and we'll see if we can figure it out together (make sure to tag me and/or @seangibbons so we see the post).

Another option to deal with batch effects (beyond the ones suggested in the post linked by @Nicholas_Bokulich ) is just doing your analyses on a per-batch basis and then comparing results across batches. (e.g. calculating beta-diversity just on samples within each batch, and excluding all cross-batch calculations).

---

<div class="post-metadata">

**Author:** ![seangibbons](https://forum.qiime2.org/user_avatar/forum.qiime2.org/seangibbons/32/2965_2.png) [@seangibbons](https://forum.qiime2.org/u/seangibbons)\
**Post date:** [December 5, 2019, 5:14pm UTC](https://forum.qiime2.org/t/diversity-metrics-and-batch-effects/12717/5 "2019-12-05T17:14:17Z")

</div>

I 100% echo what @cduvallet said here. You probably shouldn't use percentile-normalized data to calculate alpha- (or even beta-) diversity metrics, without putting a lot of thought into your interpretation of the data. Random pseudo-counts to replace zeros is one issue (so metrics like Jaccard don't make sense anymore because there are no longer zeros/absences). Another issue is that any relative abundance information within a sample is lost (i.e. the counts for each taxon are normalized to the control distribution for that taxon _across_ samples). Thus, all percentile-transformed 'abundances' are numbers between 0 and 100. There's no longer any way to distinguish what taxon is more or less abundant _within_ a given sample. So, if this within-sample relative abundance info is necessary for the diversity metric that you are calculating, then you probably shouldn't use percentile normalized output for that calculation.

The original application of percentile normalization is differential abundance testing on a taxon-by-taxon basis (i.e. is 'taxon X' enriched/depleted in cases vs. controls). It works well in this application, but extreme caution is advised for other use cases.

---

<div class="post-metadata">

**Author:** ![jwdebelius](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jwdebelius/32/9655_2.png) [@jwdebelius](https://forum.qiime2.org/u/jwdebelius)\
**Post date:** [July 11, 2020, 6:33pm UTC](https://forum.qiime2.org/t/diversity-metrics-and-batch-effects/12717/6 "2020-07-11T18:33:15Z")

</div>

A post was split to a new topic: [Is Rarified Data appropriate for UniFrac?](https://forum.qiime2.org/t/is-rarified-data-appropriate-for-unifrac/15702)
