# Differential abundance analysis and cage/pen effect

**URL:** <https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752>\
**Category:** General Discussion\
**Tags:** gneiss, ancom, group-significance\
**Created:** [July 19, 2019, 11:05am UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752 "2019-07-19T11:05:59Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterbjarke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/peterbjarke/32/10315_2.png) [@peterbjarke](https://forum.qiime2.org/u/peterbjarke)\
**Post date:** [July 19, 2019, 11:05am UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/1 "2019-07-19T11:05:59Z")

</div>

I am currently using deseq2 for differential abundance analysis. Consider a control-treatment type study where animals are housed in cages/pens and all animals in a given pen receive the same treatment. The only way to account for this using deseq2 is to calculate a median for each OTU and then use cage as the experimental unit. This works but some power is lost. How is this type of analysis handled with gneiss or ancom ?

Best regards,

Peter

---

<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:** [July 22, 2019, 1:06pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/2 "2019-07-22T13:06:11Z")

</div>

Welcome @peterbjarke!

> [@peterbjarke](#):
>
> How is this type of analysis handled with gneiss or ancom ?

In q2-gneiss you could incorporate cage/pen effect into your formula with something like `--p-formula 'main-effect + cage'`.

The ANCOM version currently implemented in q2-composition does not support multivariate formulae, but the R version does.

---

<div class="post-metadata">

**Author:** ![peterbjarke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/peterbjarke/32/10315_2.png) [@peterbjarke](https://forum.qiime2.org/u/peterbjarke)\
**Post date:** [July 22, 2019, 9:38pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/3 "2019-07-22T21:38:03Z")

</div>

Many thanks for the quick answer! In the solution suggested cage is a fixed effect as understand it. Is this correct ? I would like to us cage as a random effect.

Br Peter

---

<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:** [July 22, 2019, 9:42pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/4 "2019-07-22T21:42:14Z")

</div>

> [@peterbjarke](#):
>
> In the solution suggested cage is a fixed effect as understand it. Is this correct ? I would like to us cage as a random effect.

Correct. I do not actually see a way to set random effects with `qiime gneiss lme-regression`. @mortonjt could you please enlighten us?

---

<div class="post-metadata">

**Author:** ![mortonjt](https://forum.qiime2.org/user_avatar/forum.qiime2.org/mortonjt/32/3488_2.png) [@mortonjt](https://forum.qiime2.org/u/mortonjt)\
**Post date:** [August 2, 2019, 3:51pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/5 "2019-08-02T15:51:19Z")

</div>

You can do this by specifying the cage id in `--p-groups`. That'll allow for the cages to be treated as a random effect

---

<div class="post-metadata">

**Author:** ![yanxianl](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanxianl/32/2039_2.png) [@yanxianl](https://forum.qiime2.org/u/yanxianl)\
**Post date:** [August 7, 2019, 1:03pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/6 "2019-08-07T13:03:59Z")

</div>

Hi Jamie,

I found that ANCOM2 was used for the benchmarks while I was reading your [differential ranking paper](https://www.nature.com/articles/s41467-019-10656-5). Do you know if ANCOM2 can be used for differential abundance testing that accounts for nested random effects such as the cages/pens effects? I read the ANCOM2 documentation and tried to contact the authors but got no answers. Could you comment on this?

---

<div class="post-metadata">

**Author:** ![mortonjt](https://forum.qiime2.org/user_avatar/forum.qiime2.org/mortonjt/32/3488_2.png) [@mortonjt](https://forum.qiime2.org/u/mortonjt)\
**Post date:** [August 7, 2019, 1:56pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/7 "2019-08-07T13:56:12Z")

</div>

Hi @yanxianl, sorry I can't comment on that. Theoretically it would be possible, but I'd be worried about interpretation. Should be able to do this in aldex2 and definitely songbird

---

<div class="post-metadata">

**Author:** ![yanxianl](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanxianl/32/2039_2.png) [@yanxianl](https://forum.qiime2.org/u/yanxianl)\
**Post date:** [August 7, 2019, 2:16pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/8 "2019-08-07T14:16:37Z")

</div>

Thanks for the quick reply! I was actually reading the documentation of the [songbird](https://github.com/biocore/songbird) that implements the differential ranking method. Great that the support for nested random effects is much more straightforward in the songbird. Looking forward to its release in the QIIME2 library.

---

<div class="post-metadata">

**Author:** ![mortonjt](https://forum.qiime2.org/user_avatar/forum.qiime2.org/mortonjt/32/3488_2.png) [@mortonjt](https://forum.qiime2.org/u/mortonjt)\
**Post date:** [August 9, 2019, 2:06am UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/9 "2019-08-09T02:06:52Z")

</div>

In case it wasn't clear - songbird assumes fixed effects for everything (since it is just multinomial regression). You can have a fixed effects covariate for cage effect for starters - but it won't do random effects (yet).

---

<div class="post-metadata">

**Author:** ![peterbjarke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/peterbjarke/32/10315_2.png) [@peterbjarke](https://forum.qiime2.org/u/peterbjarke)\
**Post date:** [August 19, 2019, 12:44pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/10 "2019-08-19T12:44:22Z")

</div>

Many thanks! Can you help with with the syntax for specifying more than one group ?

Best regards,  
Peter

---

<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:** [August 21, 2019, 2:49pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/11 "2019-08-21T14:49:46Z")

</div>



---

<div class="post-metadata">

**Author:** ![mortonjt](https://forum.qiime2.org/user_avatar/forum.qiime2.org/mortonjt/32/3488_2.png) [@mortonjt](https://forum.qiime2.org/u/mortonjt)\
**Post date:** [August 21, 2019, 3:09pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/12 "2019-08-21T15:09:12Z")

</div>

Have you seen the cystic fibrosis tutorial? [cfstudy-qiime2-tutorial](https://biocore.github.io/gneiss/docs/v0.4.0/tutorials/qiime2/cfstudy-qiime2-tutorial.html)

If not, maybe that can help with the syntax

---

<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:** [August 21, 2019, 3:19pm UTC](https://forum.qiime2.org/t/differential-abundance-analysis-and-cage-pen-effect/10752/13 "2019-08-21T15:19:55Z")

</div>


