# Adjust\_batch() error

**URL:** <https://forum.biobakery.org/t/adjust-batch-error/1892>\
**Category:** MMUPHin\
**Created:** [April 5, 2021, 7:50pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892 "2021-04-05T19:50:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mary\_Swaney](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/mary_swaney/32/530_2.png) [@Mary\_Swaney](https://forum.biobakery.org/u/Mary_Swaney)\
**Post date:** [April 5, 2021, 7:50pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/1 "2021-04-05T19:50:22Z")

</div>

Hello,

I am trying to adjust for study effects between two microbiome studies and their abundance data using adjust\_batch(), but am receiving the following error:

“Error in relocate\_scale(s\_data, l\_params\_shrink, batchmod, n\_batch, l\_ind) : Features determined to be eligible for batch estimation do not agree with the ones with valid per-batch shrinked parameters!”.

I’m not sure exactly what this means or how to troubleshoot. If this helps, here is the verbose output:

“feature\_abd is counts  
Found 2 batches  
Adjusting for covariate(s) or covariate(s) level(s)  
Pseudo count is not specified and set to half of minimal non-zero value: 5e-01  
Adjusting for (after filtering) 6583 features  
Standardizing data across features  
Estimating batch difference parameters and EB priors  
Performing shrinkage adjustments on batch difference parameters  
Performing batch corrections  
Error in relocate\_scale(s\_data, l\_params\_shrink, batchmod, n\_batch, l\_ind) :  
Features determined to be eligible for batch estimation do not agree with the ones with valid per-batch shrinked parameters!  
In addition: Warning message:  
In check\_batch(df\_batch[[batch]], min\_n\_batch = 2) :  
Batch variable is not a factor as provided and will be converted to one.”

Any guidance would be appreciated! Thank you  
-Mary

---

<div class="post-metadata">

**Author:** ![sma](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@sma](https://forum.biobakery.org/u/sma)\
**Post date:** [April 6, 2021, 1:59am UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/2 "2021-04-06T01:59:22Z")

</div>

Hi -

This is rare situation where something went gone wrong during estimating per-batch shifting and scaling parameters. Would you mind sharing your input data with me? You can reach me at [syma.research@gmail.com](mailto:syma.research@gmail.com).

Thanks!  
Siyuan

---

<div class="post-metadata">

**Author:** ![Mary\_Swaney](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/mary_swaney/32/530_2.png) [@Mary\_Swaney](https://forum.biobakery.org/u/Mary_Swaney)\
**Post date:** [April 7, 2021, 3:43pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/3 "2021-04-07T15:43:52Z")

</div>

Hi Siyuan.

Thanks for the response. I sent my input data to your email. Let me know if you need anything else!

-Mary

---

<div class="post-metadata">

**Author:** ![sma](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@sma](https://forum.biobakery.org/u/sma)\
**Post date:** [April 7, 2021, 9:04pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/4 "2021-04-07T21:04:12Z")

</div>

Hi Mary,

Thanks for sending the data. It seems the error was caused by some rare cases where a feature has zero variance in non-zero values in a single batch. I’ve fixed this and pushed the change to Bioconductor. It’ll take a day or two for the new build to be sync’ed (the new version should be 1.4.2 instead of 1.4.1). Alternatively, you can install the fix directly from GitHub:

`devtools::install_github("biobakery/MMUPHin")`

Let me know if this solves the issue.

Thanks,  
Siyuan

---

<div class="post-metadata">

**Author:** ![Mary\_Swaney](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/mary_swaney/32/530_2.png) [@Mary\_Swaney](https://forum.biobakery.org/u/Mary_Swaney)\
**Post date:** [April 8, 2021, 1:06am UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/5 "2021-04-08T01:06:15Z")

</div>

Hi Siyuan,  
It seems to be working now! Thank you again for the quick responses. I appreciate it.  
-Mary

---

<div class="post-metadata">

**Author:** ![a\_foxx](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@a\_foxx](https://forum.biobakery.org/u/a_foxx)\
**Post date:** [February 1, 2022, 6:22pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/6 "2022-02-01T18:22:34Z")

</div>

Hello,

I am having the same issue with the error + warnings below using MMUPHin version 1.6.2:

Error in relocate\_scale(s\_data, l\_params\_shrink, batchmod, n\_batch, l\_ind) :  
Features determined to be eligible for batch estimation do not agree with the ones with valid per-batch shrinked parameters!  
In addition: Warning messages:  
1: In max(abs(g.new - g.old)/g.old, abs(d.new - d.old)/d.old, na.rm = TRUE) :  
no non-missing arguments to max; returning -Inf  
2: In max(abs(g.new - g.old)/g.old, abs(d.new - d.old)/d.old, na.rm = TRUE) :  
no non-missing arguments to max; returning -Inf

I’d greatly appreciate any further advice with this problem and would be happy to share more info on my data.

AF

---

<div class="post-metadata">

**Author:** ![sma](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@sma](https://forum.biobakery.org/u/sma)\
**Post date:** [February 1, 2022, 7:21pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/7 "2022-02-01T19:21:44Z")

</div>

Hi -

Would you mind sharing the data? Feel free to email me at [syma.research@gmail.com](mailto:syma.research@gmail.com).

Best,  
Siyuan

---

<div class="post-metadata">

**Author:** ![sma](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@sma](https://forum.biobakery.org/u/sma)\
**Post date:** [February 6, 2022, 9:57pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/8 "2022-02-06T21:57:58Z")

</div>

To follow up: the issue has been fixed in GitHub MMUPHin 1.9.1. Update has been pushed to to Bioc release and should be available soon (version 1.8.1).

---

<div class="post-metadata">

**Author:** ![SalmaES](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/salmaes/32/1113_2.png) [@SalmaES](https://forum.biobakery.org/u/SalmaES)\
**Post date:** [February 22, 2022, 8:03pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/9 "2022-02-22T20:03:52Z")

</div>

Hi Siyuan,

I also seem to be getting the same error even after the update (I’ve pasted it below). I’m not sure what to, especially that I know I’ve got 4 batches.

feature\_abd is counts  
Found 4 batches  
Adjusting for covariate(s) or covariate(s) level(s)  
Pseudo count is not specified and set to half of minimal non-zero value: 1e+00  
Adjusting for (after filtering) 90 features  
Standardizing data across features  
Estimating batch difference parameters and EB priors  
Error in if (s2 == 0) s2 ← 1 : missing value where TRUE/FALSE needed  
In addition: Warning message:  
In check\_batch(df\_batch[[batch]], min\_n\_batch = 2) :  
Batch variable is not a factor as provided and will be converted to one.

Thanks a lot!

Salma

---

<div class="post-metadata">

**Author:** ![sma](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@sma](https://forum.biobakery.org/u/sma)\
**Post date:** [February 24, 2022, 11:52pm UTC](https://forum.biobakery.org/t/adjust-batch-error/1892/10 "2022-02-24T23:52:08Z")

</div>

Hi - if you are comfortable, could you email me your data? Thanks, Siyuan  
[syma.research@gmail.com](mailto:syma.research@gmail.com)
