# Adjust\_batch 'Feature table does not appear to be either proportions or counts!'

**URL:** <https://forum.biobakery.org/t/adjust-batch-feature-table-does-not-appear-to-be-either-proportions-or-counts/2487>\
**Category:** MMUPHin\
**Created:** [August 16, 2021, 8:08pm UTC](https://forum.biobakery.org/t/adjust-batch-feature-table-does-not-appear-to-be-either-proportions-or-counts/2487 "2021-08-16T20:08:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drelo](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/drelo/32/566_2.png) [@drelo](https://forum.biobakery.org/u/drelo)\
**Post date:** [August 16, 2021, 8:08pm UTC](https://forum.biobakery.org/t/adjust-batch-feature-table-does-not-appear-to-be-either-proportions-or-counts/2487/1 "2021-08-16T20:08:17Z")

</div>

Dear all,

I performed the demo with the CRC data with no hassle but now while loading my data I have a problem with the dimensions of the data

```auto
MMUPHinTax <- read_tsv("./METADATA/MMUPHin_TAXA.csv")
MMUPHinmeta <- read_tsv("./METADATA/MMUPHin_METAa.csv")
MMUPHinTaxa <- MMUPHinTax %>% column_to_rownames("ID") %>% as.matrix()
MMUPHinMETA <- MMUPHinmeta %>% column_to_rownames("ID")

fit_adjust_batch <- adjust_batch(feature_abd = Taxa,
                                 batch = "study",
                                 covariates = NULL,
                                 data = META,
                                 control = list(verbose = FALSE))

```

The dimensions seem to match at least with this checking. The labels (sample or ID) match so I don’t know what can be causing trouble here.

```auto
> class(MMUPHinMETA)
[1] "data.frame"
> class(MMUPHinTaxa)
[1] "matrix" "array" 
> dim(MMUPHinTaxa)
[1] 807 344
> dim(MMUPHinMETA)
[1] 344 4

```

> Loaded Packages  
> [1] vegan\_2.5-7 lattice\_0.20-41 permute\_0.9-5  
> [4] magrittr\_2.0.1 MMUPHin\_1.4.2 lpsymphony\_1.17.0  
> [7] compositions\_2.0-2 forcats\_0.5.1 stringr\_1.4.0  
> [10] dplyr\_1.0.7 purrr\_0.3.4 readr\_2.0.1  
> [13] tidyr\_1.1.3 tibble\_3.1.3 ggplot2\_3.3.5  
> [16] tidyverse\_1.3.1 nlme\_3.1-152

I already checked [this previous issue](https://forum.biobakery.org/t/error-in-fit-adjust-batch-script-in-the-mmuphin-package/2269) but maybe I am missing something obvious. Thanks in advance for any help on this issue.

I am attaching the files  
[MMUPHin\_TAXA.csv](https://forum.biobakery.org/uploads/short-url/nbHJdWCAJXyL4kPYmsC06MhdkQt.csv) (746.3 KB)  
[MMUPHin\_META.csv](https://forum.biobakery.org/uploads/short-url/aB7BYPJsdFMSFoZUSl3wzfnEMPn.csv) (7.0 KB)

Best,

Andrés

---

<div class="post-metadata">

**Author:** ![drelo](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/drelo/32/566_2.png) [@drelo](https://forum.biobakery.org/u/drelo)\
**Post date:** [August 17, 2021, 7:44pm UTC](https://forum.biobakery.org/t/adjust-batch-feature-table-does-not-appear-to-be-either-proportions-or-counts/2487/2 "2021-08-17T19:44:16Z")

</div>

Sorry for the double post, I updated R and reinstalled MMUPHin but the problem persists.  
Here is the `sessionInfo()` output:

> sessionInfo()  
> R version 4.1.1 (2021-08-10)  
> Platform: x86\_64-pc-linux-gnu (64-bit)  
> Running under: Generic 34 (Generic)
> 
> Matrix products: default  
> BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.17.so
> 
> locale:  
> [1] LC\_CTYPE=es\_UY.UTF-8 LC\_NUMERIC=C  
> [3] LC\_TIME=es\_UY.UTF-8 LC\_COLLATE=es\_UY.UTF-8  
> [5] LC\_MONETARY=es\_UY.UTF-8 LC\_MESSAGES=es\_UY.UTF-8  
> [7] LC\_PAPER=es\_UY.UTF-8 LC\_NAME=C  
> [9] LC\_ADDRESS=C LC\_TELEPHONE=C  
> [11] LC\_MEASUREMENT=es\_UY.UTF-8 LC\_IDENTIFICATION=C
> 
> attached base packages:  
> [1] stats graphics grDevices utils datasets methods base
> 
> other attached packages:  
> [1] vegan\_2.5-7 lattice\_0.20-44 permute\_0.9-5  
> [4] forcats\_0.5.1 stringr\_1.4.0 purrr\_0.3.4  
> [7] tidyr\_1.1.3 tibble\_3.1.3 tidyverse\_1.3.1  
> [10] readr\_2.0.1 ggplot2\_3.3.5 dplyr\_1.0.7  
> [13] magrittr\_2.0.1 MMUPHin\_1.6.1 BiocManager\_1.30.16
> 
> loaded via a namespace (and not attached):  
> [1] nlme\_3.1-152 fs\_1.5.0 usethis\_2.0.1 lubridate\_1.7.10  
> [5] devtools\_2.4.2 bit64\_4.0.5 httr\_1.4.2 rprojroot\_2.0.2  
> [9] tools\_4.1.1 backports\_1.2.1 metafor\_3.0-2 utf8\_1.2.2  
> [13] R6\_2.5.0 DBI\_1.1.1 mgcv\_1.8-36 colorspace\_2.0-2  
> [17] withr\_2.4.2 tidyselect\_1.1.1 prettyunits\_1.1.1 processx\_3.5.2  
> [21] bit\_4.0.4 curl\_4.3.2 compiler\_4.1.1 cli\_3.0.1  
> [25] rvest\_1.0.1 logging\_0.10-108 biglm\_0.9-2.1 xml2\_1.3.2  
> [29] desc\_1.3.0 labeling\_0.4.2 scales\_1.1.1 mvtnorm\_1.1-2  
> [33] DEoptimR\_1.0-9 robustbase\_0.93-8 pbapply\_1.4-3 callr\_3.7.0  
> [37] digest\_0.6.27 pkgconfig\_2.0.3 sessioninfo\_1.1.1 lpsymphony\_1.17.0  
> [41] dbplyr\_2.1.1 fastmap\_1.1.0 rlang\_0.4.11 readxl\_1.3.1  
> [45] rstudioapi\_0.13 farver\_2.1.0 generics\_0.1.0 jsonlite\_1.7.2  
> [49] vroom\_1.5.4 Matrix\_1.3-4 Rcpp\_1.0.7 munsell\_0.5.0  
> [53] fansi\_0.5.0 lifecycle\_1.0.0 stringi\_1.7.3 Maaslin2\_1.6.0  
> [57] mathjaxr\_1.4-0 MASS\_7.3-54 pkgbuild\_1.2.0 grid\_4.1.1  
> [61] parallel\_4.1.1 crayon\_1.4.1 haven\_2.4.3 cowplot\_1.1.1  
> [65] splines\_4.1.1 hash\_2.2.6.1 hms\_1.1.0 ps\_1.6.0  
> [69] pillar\_1.6.2 optparse\_1.6.6 igraph\_1.2.6 pkgload\_1.2.1  
> [73] reprex\_2.0.1 glue\_1.4.2 remotes\_2.4.0 modelr\_0.1.8  
> [77] vctrs\_0.3.8 tzdb\_0.1.2 testthat\_3.0.4 cellranger\_1.1.0  
> [81] getopt\_1.20.3 gtable\_0.3.0 assertthat\_0.2.1 cachem\_1.0.5  
> [85] broom\_0.7.9 pcaPP\_1.9-74 memoise\_2.0.0 cluster\_2.1.2  
> [89] ellipsis\_0.3.2

---

<div class="post-metadata">

**Author:** ![andrewGhazi](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/andrewghazi/32/2950_2.png) [@andrewGhazi](https://forum.biobakery.org/u/andrewGhazi)\
**Post date:** [August 17, 2021, 8:50pm UTC](https://forum.biobakery.org/t/adjust-batch-feature-table-does-not-appear-to-be-either-proportions-or-counts/2487/3 "2021-08-17T20:50:16Z")

</div>

1. You have your abundance table formatted as what I think are supposed to be percentages. You can convert them to proportions in [0,1] by dividing out the sum of each column like so:

`Taxa = Taxa %>% apply(2, function(x) x / sum(x))`

1. You also seem to have duplicate study identifiers. Below I deduplicate the identifiers in the metadata the same way `read_tsv` does it when it reads in the abundances, but you should make sure that this is appropriate.

```auto
META$ID[duplicated(META$ID)] = paste0(META$ID[duplicated(META$ID)], '_1')
META = META %>% as.data.frame() %>% column_to_rownames("ID")

```

`fit_adjust_batch` runs after these two steps for me.

---

<div class="post-metadata">

**Author:** ![drelo](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/drelo/32/566_2.png) [@drelo](https://forum.biobakery.org/u/drelo)\
**Post date:** [August 18, 2021, 9:26pm UTC](https://forum.biobakery.org/t/adjust-batch-feature-table-does-not-appear-to-be-either-proportions-or-counts/2487/4 "2021-08-18T21:26:07Z")

</div>

Dear Andrew, thank you very much for your response. I used the correction and it worked!  
A follow up question, I used this code since I want to see differences between response, considering the study and controlling for age & sex.

```auto
fit_adjust_batch <- adjust_batch(feature_abd = TaXa,
                                 batch = "study",
                                 covariates = c("age", "sex"), 
                                 data = MeTa,
                                 control = list(verbose = FALSE))
TaXa <- TaXa %>% column_to_rownames("ID") %>% as.matrix()
MeTa <- MeTa %>% column_to_rownames("ID")
TaXa = TaXa %>% apply(2, function(x) x / sum(x))
CRC_abd_adj <- fit_adjust_batch$feature_abd_adj # I just recycled this 

fit_lm_meta <- lm_meta(feature_abd = TaXa,
                       batch = "study",
                       exposure = "response",
                       data = MeTa,
                       control = list(verbose = FALSE))
meta_fits <- fit_lm_meta$meta_fits

```

Could you expand on why the results in the response\_R\_forest.pdf (23 species) differ from the bar plot (with just 2 features).  
Inspecting the meta\_fits object I found 40 features/species with p-value \<0.05 (and just 2 with FDR\<0.05). Please find attached these results.

[meta\_fits\_FORUM.tsv](https://forum.biobakery.org/uploads/short-url/4qQ9chdN9c2dgnC2rrovSkwxW1g.tsv) (160.6 KB)  
I replaced the sample by a sequence of numbers in both files  
[META.csv](https://forum.biobakery.org/uploads/short-url/j9KJ2SincEyG4vqUEyvwDQOe5nB.csv) (5.5 KB)  
[TAXA.csv](https://forum.biobakery.org/uploads/short-url/xjjRpmErusdencP0LJeJ5wzuHOl.csv) (744.8 KB)

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![andrewGhazi](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/andrewghazi/32/2950_2.png) [@andrewGhazi](https://forum.biobakery.org/u/andrewGhazi)\
**Post date:** [August 19, 2021, 12:37pm UTC](https://forum.biobakery.org/t/adjust-batch-feature-table-does-not-appear-to-be-either-proportions-or-counts/2487/5 "2021-08-19T12:37:38Z")

</div>

For a bug to get an entry in the forest plot it needs to show up in at least two studies. So you have 40 bugs with a nominal p-value below 0.05, 23 of which show up in at least two studies, and two of which have a q-value below 0.05.

---

<div class="post-metadata">

**Author:** ![drelo](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/drelo/32/566_2.png) [@drelo](https://forum.biobakery.org/u/drelo)\
**Post date:** [August 19, 2021, 9:19pm UTC](https://forum.biobakery.org/t/adjust-batch-feature-table-does-not-appear-to-be-either-proportions-or-counts/2487/6 "2021-08-19T21:19:46Z")

</div>

Thank you very much for the explanation!
