# Xtfrm error with Maaslin2 default example in R

**URL:** <https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216>\
**Category:** MaAsLin\
**Created:** [April 28, 2023, 8:08am UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216 "2023-04-28T08:08:25Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![antagomir](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/antagomir/32/2122_2.png) [@antagomir](https://forum.biobakery.org/u/antagomir)\
**Post date:** [April 28, 2023, 8:08am UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/1 "2023-04-28T08:08:25Z")

</div>

Maaslin2 1.13.0

I was running the ready-made example in the function `Maaslin2` help page:

```auto
input_data <- system.file(
             'extdata','HMP2_taxonomy.tsv', package="Maaslin2")

input_metadata <-system.file(
             'extdata','HMP2_metadata.tsv', package="Maaslin2")

fit_data <- Maaslin2(
             input_data, input_metadata,'demo_output', transform = "AST",
             fixed_effects = c('diagnosis', 'dysbiosisnonIBD','dysbiosisUC','dysbiosisCD', 'antibiotics', 'age'),
             random_effects = c('site', 'subject'),
             normalization = 'NONE',
             reference = 'diagnosis,nonIBD',
             standardize = FALSE)

```

This leads to the following error:

```auto
....
2023-04-28 10:41:54.896843 INFO::Writing heatmap of significant results to file: demo_output/heatmap.pdf
Error in xtfrm.data.frame(x) : cannot xtfrm data frames
In addition: Warning messages:
1: Model failed to converge with 1 negative eigenvalue: -5.6e+00 
2: Model failed to converge with 1 negative eigenvalue: -1.1e+01 
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
  Model failed to converge with max|grad| = 0.00291214 (tol = 0.002, component 1)
4: Model failed to converge with 1 negative eigenvalue: -2.1e+02 
5: Model failed to converge with 1 negative eigenvalue: -2.2e+02 

```

Information my R session:

```auto
> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS: /home/xxx/bin/R-4.3.0/lib/libRblas.so 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C                 
 [9] LC_ADDRESS=C LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Mariehamn
tzcode source: system (glibc)

attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods  
[8] base     

other attached packages:
 [1] doRNG_1.8.6 rngtools_1.5.2                 
 [3] foreach_1.5.2 ANCOMBC_2.2.0                  
 [5] lubridate_1.9.2 forcats_1.0.0                  
 [7] stringr_1.5.0 dplyr_1.1.2                    
 [9] purrr_1.0.1 readr_2.1.4                    
[11] tidyr_1.3.0 tibble_3.2.1                   
[13] ggplot2_3.4.2 tidyverse_2.0.0                
[15] knitr_1.42 MicrobiomeStat_1.1             
[17] Maaslin2_1.13.0 ALDEx2_1.32.0                  
[19] zCompositions_1.4.0-1 truncnorm_1.0-9                
[21] NADA_1.6-1.1 survival_3.5-5                 
[23] MASS_7.3-59 tidySummarizedExperiment_1.10.0
[25] patchwork_1.1.2.9000 mia_1.8.0                      
[27] MultiAssayExperiment_1.26.0 TreeSummarizedExperiment_2.8.0 
[29] Biostrings_2.68.0 XVector_0.40.0                 
[31] SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.0    
[33] Biobase_2.60.0 GenomicRanges_1.52.0           
[35] GenomeInfoDb_1.36.0 IRanges_2.34.0                 
[37] S4Vectors_0.38.0 BiocGenerics_0.46.0            
[39] MatrixGenerics_1.12.0 matrixStats_0.63.0             
[41] BiocStyle_2.28.0 rebook_1.9.0                   

loaded via a namespace (and not attached):
  [1] bitops_1.0-7 DirichletMultinomial_1.42.0
  [3] doParallel_1.0.17 httr_1.4.5                 
  [5] numDeriv_2016.8-1.1 backports_1.4.1            
  [7] tools_4.3.0 utf8_1.2.3                 
  [9] R6_2.5.1 vegan_2.6-4                
 [11] lazyeval_0.2.2 mgcv_1.8-42                
 [13] rhdf5filters_1.12.0 permute_0.9-7              
 [15] withr_2.5.0 gridExtra_2.3              
 [17] cli_3.6.1.9000 logging_0.10-108           
 [19] biglm_0.9-2.1 sandwich_3.0-2             
 [21] mvtnorm_1.1-3 robustbase_0.95-1          
 [23] pbapply_1.7-0 proxy_0.4-27               
 [25] yulab.utils_0.0.6 foreign_0.8-84             
 [27] scater_1.28.0 decontam_1.20.0            
 [29] readxl_1.4.2 rstudioapi_0.14            
 [31] RSQLite_2.3.1 generics_0.1.3             
 [33] Matrix_1.5-4 biomformat_1.28.0          
 [35] ggbeeswarm_0.7.1 fansi_1.0.4                
 [37] DescTools_0.99.48 DECIPHER_2.28.0            
 [39] lifecycle_1.0.3 multcomp_1.4-23            
 [41] yaml_2.3.7 rhdf5_2.44.0               
 [43] grid_4.3.0 blob_1.2.4                 
 [45] crayon_1.5.2 dir.expiry_1.8.0           
 [47] lattice_0.21-8 beachmat_2.16.0            
 [49] CodeDepends_0.6.5 pillar_1.9.0               
 [51] optparse_1.7.3 statip_0.2.3               
 [53] boot_1.3-28.1 gld_2.6.6                  
 [55] estimability_1.4.1 codetools_0.2-19           
 [57] glue_1.6.2 data.table_1.14.8          
 [59] Rdpack_2.4 vctrs_0.6.2                
 [61] treeio_1.24.0 cellranger_1.1.0           
 [63] gtable_0.3.3 cachem_1.0.7               
 [65] xfun_0.39 rbibutils_2.2.13           
 [67] Rfast_2.0.7 coda_0.19-4                
 [69] pcaPP_2.0-3 modeest_2.4.0              
 [71] timeDate_4022.108 iterators_1.0.14           
 [73] statmod_1.5.0 gmp_0.7-1                  
 [75] TH.data_1.1-2 ellipsis_0.3.2             
 [77] nlme_3.1-162 phyloseq_1.44.0            
 [79] bit64_4.0.5 filelock_1.0.2             
 [81] fBasics_4022.94 irlba_2.3.5.1              
 [83] vipor_0.4.5 rpart_4.1.19               
 [85] colorspace_2.1-0 DBI_1.1.3                  
 [87] Hmisc_5.0-1 nnet_7.3-18                
 [89] ade4_1.7-22 Exact_3.2                  
 [91] tidyselect_1.2.0 emmeans_1.8.5              
 [93] timeSeries_4021.105 bit_4.0.5                  
 [95] compiler_4.3.0 graph_1.78.0               
 [97] htmlTable_2.4.1 BiocNeighbors_1.18.0       
 [99] expm_0.999-7 DelayedArray_0.25.0        
[101] plotly_4.10.1 checkmate_2.2.0            
[103] scales_1.2.1 DEoptimR_1.0-12            
[105] spatial_7.3-16 digest_0.6.31              
[107] minqa_1.2.5 rmarkdown_2.21.3           
[109] base64enc_0.1-3 htmltools_0.5.5            
[111] pkgconfig_2.0.3 lme4_1.1-33                
[113] sparseMatrixStats_1.12.0 lpsymphony_1.28.0          
[115] stabledist_0.7-1 fastmap_1.1.1              
[117] rlang_1.1.0 htmlwidgets_1.6.2          
[119] DelayedMatrixStats_1.22.0 energy_1.7-11              
[121] zoo_1.8-12 jsonlite_1.8.4             
[123] BiocParallel_1.34.0 BiocSingular_1.16.0        
[125] RCurl_1.98-1.12 magrittr_2.0.3             
[127] Formula_1.2-5 scuttle_1.10.0             
[129] GenomeInfoDbData_1.2.10 Rhdf5lib_1.22.0            
[131] munsell_0.5.0 Rcpp_1.0.10                
[133] ape_5.7-1 viridis_0.6.2              
[135] RcppZiggurat_0.1.6 CVXR_1.0-11                
[137] stringi_1.7.12 rootSolve_1.8.2.3          
[139] stable_1.1.6 zlibbioc_1.46.0            
[141] plyr_1.8.8 parallel_4.3.0             
[143] ggrepel_0.9.3 lmom_2.9                   
[145] splines_4.3.0 hash_2.2.6.2               
[147] multtest_2.56.0 hms_1.1.3                  
[149] igraph_1.4.2 reshape2_1.4.4             
[151] ScaledMatrix_1.7.1 rmutil_1.1.10              
[153] XML_3.99-0.14 evaluate_0.20              
[155] BiocManager_1.30.20 nloptr_2.0.3               
[157] tzdb_0.3.0 getopt_1.20.3              
[159] clue_0.3-64 rsvd_1.0.5                 
[161] xtable_1.8-4 Rmpfr_0.9-2                
[163] e1071_1.7-13 tidytree_0.4.2             
[165] viridisLite_0.4.1 class_7.3-21               
[167] gsl_2.1-8 lmerTest_3.1-3             
[169] memoise_2.0.1 beeswarm_0.4.0             
[171] cluster_2.1.4 timechange_0.2.0   

```

---

<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:** [April 28, 2023, 2:15pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/2 "2023-04-28T14:15:14Z")

</div>

This should be fixed in the development version, try `remotes::install_github("biobakery/Maaslin2")`

---

<div class="post-metadata">

**Author:** ![antagomir](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/antagomir/32/2122_2.png) [@antagomir](https://forum.biobakery.org/u/antagomir)\
**Post date:** [April 29, 2023, 3:12pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/3 "2023-04-29T15:12:42Z")

</div>

Yes it works. Thank you!

---

<div class="post-metadata">

**Author:** ![jkcopes](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jkcopes](https://forum.biobakery.org/u/jkcopes)\
**Post date:** [May 12, 2023, 2:15pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/4 "2023-05-12T14:15:01Z")

</div>

Hello,

I am still having this same issue during the same step as mentioned above (as the program is trying to write the heatmaps to file):

**Error in xtfrm.data.frame(x) : cannot xtfrm data frames**

R version: 4.3.0  
Maaslin2 version: 1.7.3 downloaded from your github recommendation above

---

<div class="post-metadata">

**Author:** ![nearinj](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/nearinj/32/2135_2.png) [@nearinj](https://forum.biobakery.org/u/nearinj)\
**Post date:** [May 12, 2023, 4:33pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/5 "2023-05-12T16:33:27Z")

</div>

Hi there,

Could you post an R session info, along with the command you are trying to run and the command you used to install the updated Maaslin2.

Thanks,  
Jacob

---

<div class="post-metadata">

**Author:** ![jkcopes](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jkcopes](https://forum.biobakery.org/u/jkcopes)\
**Post date:** [May 12, 2023, 7:29pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/6 "2023-05-12T19:29:58Z")

</div>

Hi Jacob,

The command I used to install:  
remotes::install\_github(“biobakery/Maaslin2”)

session info:

> sessionInfo()  
> R version 4.3.0 (2023-04-21)  
> Platform: x86\_64-pc-linux-gnu (64-bit)  
> Running under: Ubuntu 22.04.2 LTS

Matrix products: default  
BLAS: /usr/lib/x86\_64-linux-gnu/blas/libblas.so.3.10.0  
LAPACK: /usr/lib/x86\_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:  
[1] LC\_CTYPE=en\_CA.UTF-8 LC\_NUMERIC=C  
[3] LC\_TIME=en\_CA.UTF-8 LC\_COLLATE=en\_CA.UTF-8  
[5] LC\_MONETARY=en\_CA.UTF-8 LC\_MESSAGES=en\_CA.UTF-8  
[7] LC\_PAPER=en\_CA.UTF-8 LC\_NAME=C  
[9] LC\_ADDRESS=C LC\_TELEPHONE=C  
[11] LC\_MEASUREMENT=en\_CA.UTF-8 LC\_IDENTIFICATION=C

time zone: America/Toronto  
tzcode source: system (glibc)

attached base packages:  
[1] stats4 parallel stats graphics grDevices utils datasets  
[8] methods base

other attached packages:  
[1] Maaslin2\_1.7.3 EnhancedVolcano\_1.18.0  
[3] BiocManager\_1.30.20 doRNG\_1.8.6  
[5] rngtools\_1.5.2 foreach\_1.5.2  
[7] mia\_1.8.0 MultiAssayExperiment\_1.26.0  
[9] TreeSummarizedExperiment\_2.8.0 Biostrings\_2.68.0  
[11] XVector\_0.40.0 SingleCellExperiment\_1.22.0  
[13] SummarizedExperiment\_1.30.1 Biobase\_2.60.0  
[15] GenomicRanges\_1.52.0 GenomeInfoDb\_1.36.0  
[17] IRanges\_2.34.0 S4Vectors\_0.38.1  
[19] BiocGenerics\_0.46.0 MatrixGenerics\_1.12.0  
[21] matrixStats\_0.63.0 microbiomeMarker\_1.6.0  
[23] ALDEx2\_1.32.0 zCompositions\_1.4.0-1  
[25] truncnorm\_1.0-9 NADA\_1.6-1.1  
[27] survival\_3.5-5 MASS\_7.3-59  
[29] ANCOMBC\_2.2.0 microViz\_0.10.8  
[31] car\_3.1-2 carData\_3.0-5  
[33] kableExtra\_1.3.4 knitr\_1.40  
[35] DT\_0.27 lubridate\_1.9.2  
[37] forcats\_1.0.0 stringr\_1.5.0  
[39] dplyr\_1.1.2 purrr\_1.0.1  
[41] readr\_2.1.4 tidyr\_1.3.0  
[43] tibble\_3.2.1 tidyverse\_2.0.0  
[45] gridExtra\_2.3 ape\_5.7-1  
[47] reshape2\_1.4.4 scales\_1.2.1  
[49] plyr\_1.8.8 ggrepel\_0.9.3  
[51] microbiome\_1.22.0 pairwiseAdonis\_0.4.1  
[53] cluster\_2.1.4 data.table\_1.14.8  
[55] biomformat\_1.28.0 phyloseq\_1.44.0  
[57] vegan\_2.6-4 lattice\_0.21-8  
[59] permute\_0.9-7 ggplot2\_3.4.2

loaded via a namespace (and not attached):  
[1] gld\_2.6.6 nnet\_7.3-18  
[3] TH.data\_1.1-2 vctrs\_0.6.2  
[5] energy\_1.7-11 digest\_0.6.29  
[7] png\_0.1-8 shape\_1.4.6  
[9] proxy\_0.4-27 pcaPP\_2.0-3  
[11] Exact\_3.2 registry\_0.5-1  
[13] withr\_2.5.0 xfun\_0.39  
[15] ggfun\_0.0.9 memoise\_2.0.1  
[17] commonmark\_1.9.0 ggbeeswarm\_0.7.2  
[19] emmeans\_1.8.5 gmp\_0.6-6  
[21] systemfonts\_1.0.4 gtools\_3.9.4  
[23] tidytree\_0.4.2 zoo\_1.8-12  
[25] GlobalOptions\_0.1.2 pbapply\_1.7-0  
[27] logging\_0.10-108 DEoptimR\_1.0-13  
[29] prettyunits\_1.1.1 Formula\_1.2-5  
[31] httr\_1.4.6 hash\_2.2.6.2  
[33] rhdf5filters\_1.12.1 ps\_1.7.1  
[35] rhdf5\_2.44.0 rstudioapi\_0.14  
[37] generics\_0.1.3 processx\_3.7.0  
[39] base64enc\_0.1-3 curl\_4.3.3  
[41] zlibbioc\_1.46.0 ScaledMatrix\_1.8.1  
[43] ca\_0.71.1 RcppZiggurat\_0.1.6  
[45] GenomeInfoDbData\_1.2.10 xtable\_1.8-4  
[47] ade4\_1.7-22 doParallel\_1.0.17  
[49] evaluate\_0.17 S4Arrays\_1.0.1  
[51] Rfast\_2.0.7 hms\_1.1.3  
[53] glmnet\_4.1-7 irlba\_2.3.5.1  
[55] colorspace\_2.1-0 getopt\_1.20.3  
[57] metagMisc\_0.5.0 readxl\_1.4.2  
[59] magrittr\_2.0.3 viridis\_0.6.3  
[61] ggtree\_3.8.0 robustbase\_0.95-1  
[63] DECIPHER\_2.28.0 cplm\_0.7-11  
[65] scuttle\_1.10.1 class\_7.3-21  
[67] Hmisc\_5.1-0 pillar\_1.9.0  
[69] nlme\_3.1-162 iterators\_1.0.14  
[71] decontam\_1.20.0 plotROC\_2.3.0  
[73] caTools\_1.18.2 compiler\_4.3.0  
[75] beachmat\_2.16.0 stringi\_1.7.8  
[77] TSP\_1.2-4 DescTools\_0.99.48  
[79] minqa\_1.2.5 crayon\_1.5.2  
[81] abind\_1.4-5 scater\_1.28.0  
[83] gridGraphics\_0.5-1 ggtext\_0.1.2  
[85] locfit\_1.5-9.7 bit\_4.0.4  
[87] biglm\_0.9-2.1 rootSolve\_1.8.2.3  
[89] sandwich\_3.0-2 codetools\_0.2-19  
[91] multcomp\_1.4-23 BiocSingular\_1.16.0  
[93] crosstalk\_1.2.0 bslib\_0.4.0  
[95] e1071\_1.7-13 lmom\_2.9  
[97] GetoptLong\_1.0.5 multtest\_2.56.0  
[99] splines\_4.3.0 metagenomeSeq\_1.42.0  
[101] markdown\_1.6 circlize\_0.4.15  
[103] Rcpp\_1.0.9 sparseMatrixStats\_1.12.0  
[105] cellranger\_1.1.0 gridtext\_0.1.5  
[107] blob\_1.2.4 utf8\_1.2.2  
[109] clue\_0.3-64 lme4\_1.1-33  
[111] checkmate\_2.2.0 DelayedMatrixStats\_1.22.0  
[113] Rdpack\_2.4 pkgbuild\_1.3.1  
[115] expm\_0.999-7 gsl\_2.1-8  
[117] ggplotify\_0.1.0 estimability\_1.4.1  
[119] Matrix\_1.5-1 statmod\_1.5.0  
[121] callr\_3.7.3 tzdb\_0.3.0  
[123] svglite\_2.1.1 pkgconfig\_2.0.3  
[125] tools\_4.3.0 cachem\_1.0.6  
[127] tweedie\_2.3.5 rbibutils\_2.2.13  
[129] RSQLite\_2.3.1 viridisLite\_0.4.2  
[131] rvest\_1.0.3 DBI\_1.1.3  
[133] numDeriv\_2016.8-1.1 fastmap\_1.1.0  
[135] rmarkdown\_2.17 grid\_4.3.0  
[137] sass\_0.4.2 patchwork\_1.1.2  
[139] coda\_0.19-4 rpart\_4.1.19  
[141] farver\_2.1.1 mgcv\_1.8-42  
[143] yaml\_2.3.5 foreign\_0.8-82  
[145] cli\_3.6.1 webshot\_0.5.4  
[147] lifecycle\_1.0.3 mvtnorm\_1.1-3  
[149] backports\_1.4.1 BiocParallel\_1.34.1  
[151] timechange\_0.2.0 gtable\_0.3.3  
[153] rjson\_0.2.21 limma\_3.56.1  
[155] CVXR\_1.0-10 jsonlite\_1.8.4  
[157] seriation\_1.4.2 bitops\_1.0-7  
[159] bit64\_4.0.5 Rtsne\_0.16  
[161] yulab.utils\_0.0.6 BiocNeighbors\_1.18.0  
[163] jquerylib\_0.1.4 highr\_0.9  
[165] lazyeval\_0.2.2 htmltools\_0.5.3  
[167] glue\_1.6.2 optparse\_1.7.3  
[169] Wrench\_1.18.0 RCurl\_1.98-1.12  
[171] rprojroot\_2.0.3 treeio\_1.24.0  
[173] boot\_1.3-28 igraph\_1.4.2  
[175] R6\_2.5.1 DESeq2\_1.40.1  
[177] gplots\_3.1.3 Rmpfr\_0.8-9  
[179] labeling\_0.4.2 Rhdf5lib\_1.22.0  
[181] aplot\_0.1.10 nloptr\_2.0.3  
[183] DirichletMultinomial\_1.42.0 DelayedArray\_0.26.2  
[185] tidyselect\_1.2.0 vipor\_0.4.5  
[187] htmlTable\_2.4.1 xml2\_1.3.3  
[189] KernSmooth\_2.23-20 rsvd\_1.0.5  
[191] munsell\_0.5.0 htmlwidgets\_1.5.4  
[193] ComplexHeatmap\_2.16.0 RColorBrewer\_1.1-3  
[195] rlang\_1.1.1 remotes\_2.4.2  
[197] lmerTest\_3.1-3 lpsymphony\_1.28.0  
[199] Cairo\_1.6-0 fansi\_1.0.3  
[201] beeswarm\_0.4.0

Command:  
fit\_data\_lm ← Maaslin2(  
df\_input\_data,  
df\_input\_metadata,  
output = “/home/ROutput/Maaslin\_LM\_default”,  
min\_abundance = 0.0,  
min\_prevalence = 0.1,  
min\_variance = 0.0,  
normalization = “TSS”,  
transform = “LOG”,  
analysis\_method = “LM”,  
max\_significance = 0.1,  
random\_effects = NULL,  
fixed\_effects = c(‘SampleType’),  
correction = “BH”,  
standardize = TRUE,  
cores = 1,  
plot\_heatmap = TRUE,  
plot\_scatter = TRUE,  
heatmap\_first\_n = 50,  
reference = c(“SampleType,Mouse”)  
)

I should also note: this was all working perfectly prior to my update to Ubuntu 22.04.2 LTS and R 4.3.0, with my previously downloaded version of Maaslin2, installed using the command:

if (!require(“BiocManager”, quietly = TRUE))  
install.packages(“BiocManager”)

BiocManager::install(“Maaslin2”)

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![nearinj](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/nearinj/32/2135_2.png) [@nearinj](https://forum.biobakery.org/u/nearinj)\
**Post date:** [May 16, 2023, 10:15pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/7 "2023-05-16T22:15:46Z")

</div>

Hi Julia,

Thanks for the update. Sorry I didn’t get back to you right away. Can you try re-running your install command with:

```auto
remotes::install_github(repo="biobakery/Maaslin2", force=TRUE)

```

Thanks,  
Jacob Nearing

---

<div class="post-metadata">

**Author:** ![jkcopes](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jkcopes](https://forum.biobakery.org/u/jkcopes)\
**Post date:** [May 18, 2023, 1:28pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/8 "2023-05-18T13:28:07Z")

</div>

Hi Jacob,

I re-ran the install with your command:  
`remotes::install_github(repo="biobakery/Maaslin2", force=TRUE)`

Unfortunately the error persists.

Thanks,  
Julia

---

<div class="post-metadata">

**Author:** ![nearinj](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/nearinj/32/2135_2.png) [@nearinj](https://forum.biobakery.org/u/nearinj)\
**Post date:** [May 18, 2023, 3:11pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/9 "2023-05-18T15:11:50Z")

</div>

Hi Julia,

Sorry to hear that didn’t fix your issue. Can you try running these three commands:

```auto
remove.packages("Maaslin2")
purge("Maaslin2")
remotes::install_github(repo="biobakery/Maaslin2", force=TRUE)

```

Once this is done can you then go ahead and restart your R session and computer.

If this still doesn’t work can you then post the results of:

```auto
sessioninfo::session_info(pkgs = "Maaslin2", dependencies = FALSE)

```

Thanks,  
Jacob Nearing

---

<div class="post-metadata">

**Author:** ![jkcopes](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jkcopes](https://forum.biobakery.org/u/jkcopes)\
**Post date:** [May 18, 2023, 6:40pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/10 "2023-05-18T18:40:51Z")

</div>

Hi Jacob,

Great! The update worked. Thanks for all your help!

Julia

---

<div class="post-metadata">

**Author:** ![ericap](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@ericap](https://forum.biobakery.org/u/ericap)\
**Post date:** [October 1, 2023, 10:21am UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/11 "2023-10-01T10:21:42Z")

</div>

Hi Jacob

I’m having the same issue as above.

```auto
> fit_data <- Maaslin2(input_data = as.data.frame(otu_table(cervic_physeq_agg)), 
+ input_metadata = as.data.frame(sample_data(cervic_physeq_agg)),
+ output = "maaslin2_taxa_output_20231001", 
+ fixed_effects = c("cervic_substudy"), min_prevalence = 0.10, 
+ normalization = "TSS", transform="LOG", analysis_method = "LM", standardize = FALSE, 
+ reference = 'cervic_substudy,`control`', plot_heatmap = TRUE)

2023-10-01 21:03:28.909931 INFO::Writing function arguments to log file
2023-10-01 21:03:28.916066 INFO::Verifying options selected are valid
2023-10-01 21:03:28.917001 INFO::Determining format of input files
2023-10-01 21:03:28.917885 INFO::Input format is data samples as columns and metadata samples as rows
2023-10-01 21:03:28.927558 INFO::Formula for fixed effects: expr ~ cervic_substudy

Error in xtfrm.data.frame(x) : cannot xtfrm data frames

```

I have followed the advice above but the error still persists. Any ideas how I can overcome the issue? Session info below.

Thanks for your advice,  
Erica

```auto
> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.5.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Australia/Melbourne
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base     

other attached packages:
 [1] DT_0.29 microbiome_1.22.0 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.3 purrr_1.0.2      
 [8] readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.3 tidyverse_2.0.0 qwraps2_0.5.2 TMB_1.9.6        
[15] Maaslin2_1.15.1 phyloseq_1.44.0  

loaded via a namespace (and not attached):
 [1] DBI_1.1.3 bitops_1.0-7 remotes_2.4.2.1 permute_0.9-7 rlang_1.1.1            
 [6] magrittr_2.0.3 ade4_1.7-22 compiler_4.3.1 mgcv_1.9-0 callr_3.7.3            
[11] vctrs_0.6.3 reshape2_1.4.4 fastmap_1.1.1 pkgconfig_2.0.3 crayon_1.5.2           
[16] XVector_0.40.0 utf8_1.2.3 tzdb_0.4.0 ps_1.7.5 zlibbioc_1.46.0        
[21] GenomeInfoDb_1.36.3 jsonlite_1.8.7 biomformat_1.28.0 rhdf5filters_1.12.1 Rhdf5lib_1.22.1        
[26] parallel_4.3.1 prettyunits_1.2.0 cluster_2.1.4 R6_2.5.1 biglm_0.9-2.1          
[31] stringi_1.7.12 Rcpp_1.0.11 iterators_1.0.14 IRanges_2.34.1 timechange_0.2.0       
[36] Matrix_1.5-4 splines_4.3.1 igraph_1.5.1 tidyselect_1.2.0 rstudioapi_0.15.0      
[41] vegan_2.6-4 codetools_0.2-19 curl_5.0.2 processx_3.8.2 pkgbuild_1.4.2         
[46] lattice_0.21-8 plyr_1.8.8 Biobase_2.60.0 withr_2.5.1 Rtsne_0.16             
[51] desc_1.4.2 survival_3.5-7 getopt_1.20.4 Biostrings_2.68.1 pillar_1.9.0           
[56] BiocManager_1.30.22 foreach_1.5.2 stats4_4.3.1 pcaPP_2.0-3 generics_0.1.3         
[61] rprojroot_2.0.3 RCurl_1.98-1.12 S4Vectors_0.38.2 hms_1.1.3 munsell_0.5.0          
[66] scales_1.2.1 glue_1.6.2 tools_4.3.1 robustbase_0.99-0 data.table_1.14.8      
[71] mvtnorm_1.2-3 rhdf5_2.44.0 grid_4.3.1 optparse_1.7.3 ape_5.7-1              
[76] colorspace_2.1-0 nlme_3.1-163 GenomeInfoDbData_1.2.10 cli_3.6.1 fansi_1.0.4            
[81] gtable_0.3.4 DEoptimR_1.1-2 logging_0.10-108 hash_2.2.6.3 digest_0.6.33          
[86] BiocGenerics_0.46.0 htmlwidgets_1.6.2 htmltools_0.5.6 multtest_2.56.0 lifecycle_1.0.3        
[91] MASS_7.3-60

```

---

<div class="post-metadata">

**Author:** ![nearinj](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/nearinj/32/2135_2.png) [@nearinj](https://forum.biobakery.org/u/nearinj)\
**Post date:** [October 2, 2023, 5:26pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/12 "2023-10-02T17:26:08Z")

</div>

Hello,

Could you run this command so I can see the exact place Maaslin2 was pulled from during your install.

```auto
sessioninfo::session_info(pkgs = "Maaslin2", dependencies = FALSE)

```

Cheers,  
Jacob Nearing

---

<div class="post-metadata">

**Author:** ![ericap](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@ericap](https://forum.biobakery.org/u/ericap)\
**Post date:** [October 3, 2023, 2:30am UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/13 "2023-10-03T02:30:45Z")

</div>

Hi Jacob,

Thanks for getting back to me.

Please see requested output below.

Thanks again for your help.

Best regards  
Erica

```auto
> sessioninfo::session_info(pkgs = "Maaslin2", dependencies = FALSE)
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting value
 version R version 4.3.1 (2023-06-16)
 os macOS Ventura 13.5.1
 system x86_64, darwin20
 ui RStudio
 language (EN)
 collate en_US.UTF-8
 ctype en_US.UTF-8
 tz Australia/Melbourne
 date 2023-10-03
 rstudio 2023.09.0+463 Desert Sunflower (desktop)
 pandoc 3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package * version date (UTC) lib source
 Maaslin2 * 1.15.1 2023-10-01 [1] Github (biobakery/Maaslin2@550f3d1)

 [1] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library

```

---

<div class="post-metadata">

**Author:** ![nearinj](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/nearinj/32/2135_2.png) [@nearinj](https://forum.biobakery.org/u/nearinj)\
**Post date:** [October 3, 2023, 4:47pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/14 "2023-10-03T16:47:43Z")

</div>

Thanks for that!

Can you also post the result of:

`print(Maaslin2:::maaslin2_heatmap)`

Just trying to track down if this is the same bug as others had encountered

Cheers,  
Jacob Nearing

---

<div class="post-metadata">

**Author:** ![ericap](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@ericap](https://forum.biobakery.org/u/ericap)\
**Post date:** [October 4, 2023, 3:51am UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/15 "2023-10-04T03:51:06Z")

</div>

Thanks! Please see below.  
Best regards

Erica

```auto
> print(Maaslin2:::maaslin2_heatmap)
function (output_results, title = NA, cell_value = "qval", data_label = "data", 
    metadata_label = "metadata", border_color = "grey93", color = colorRampPalette(c("darkblue", 
        "grey90", "darkred")), col_rotate = 90, first_n = 50) 
{
    df <- read.table(output_results, header = TRUE, sep = "\t", 
        fill = TRUE, comment.char = "", check.names = FALSE)
    title_additional <- ""
    title_additional <- ""
    if (!is.na(first_n) & first_n > 0 & first_n < dim(df)[1]) {
        if (cell_value == "coef") {
            df <- df[order(-abs(df[[cell_value]])), ]
        }
        else {
            df <- df[order(df[[cell_value]]), ]
        }
        df_sub <- df[1:first_n,]
        for (first_n_index in seq(first_n, dim(df)[1])) {
            if (length(unique(df_sub$feature)) == first_n) {
                break
            }
            df_sub <- df[1:first_n_index,]
        }
        df <- df[which(df$feature %in% df_sub$feature),]
        title_additional <- paste("Top", first_n, sep = " ")
    }
    if (dim(df)[1] < 2) {
        print("There are no associations to plot!")
        return(NULL)
    }
    metadata <- df$metadata
    data <- df$feature
    dfvalue <- df$value
    value <- NA
    if (cell_value == "pval") {
        value <- -log(df$pval) * sign(df$coef)
        value <- pmax(-20, pmin(20, value))
        if (is.null(title)) 
            title <- "(-log(pval)*sign(coeff))"
    }
    else if (cell_value == "qval") {
        value <- -log(df$qval) * sign(df$coef)
        value <- pmax(-20, pmin(20, value))
        if (is.null(title)) 
            title <- "(-log(qval)*sign(coeff))"
    }
    else if (cell_value == "coef") {
        value <- df$coef
        if (is.null(title)) 
            title <- "(coeff)"
    }
    if (title_additional != "") {
        title <- paste(title_additional, "features with significant associations", 
            title, sep = " ")
    }
    else {
        title <- paste("Significant associations", title, sep = " ")
    }
    verbose_metadata <- c()
    metadata_multi_level <- c()
    for (i in unique(metadata)) {
        levels <- unique(df$value[df$metadata == i])
        if (length(levels) > 1) {
            metadata_multi_level <- c(metadata_multi_level, i)
            for (j in levels) {
                verbose_metadata <- c(verbose_metadata, paste(i, 
                  j))
            }
        }
        else {
            verbose_metadata <- c(verbose_metadata, i)
        }
    }
    n <- length(unique(data))
    m <- length(unique(verbose_metadata))
    if (n < 2) {
        print(paste("There is not enough features in the associations", 
            "to create a heatmap plot.", "Please review the associations in text output file."))
        return(NULL)
    }
    if (m < 2) {
        print(paste("There is not enough metadata in the associations", 
            "to create a heatmap plot.", "Please review the associations in text output file."))
        return(NULL)
    }
    a = matrix(0, nrow = n, ncol = m)
    a <- as.data.frame(a)
    rownames(a) <- unique(data)
    colnames(a) <- unique(verbose_metadata)
    for (i in seq_len(dim(df)[1])) {
        current_metadata <- metadata[i]
        if (current_metadata %in% metadata_multi_level) {
            current_metadata <- paste(metadata[i], dfvalue[i])
        }
        if (abs(a[as.character(data[i]), as.character(current_metadata)]) > 
            abs(value[i])) 
            next
        a[as.character(data[i]), as.character(current_metadata)] <- value[i]
    }
    max_value <- ceiling(max(a))
    min_value <- ceiling(min(a))
    range_value <- max(c(abs(max_value), abs(min_value)))
    breaks <- seq(-1 * range_value, range_value, by = 1)
    p <- NULL
    tryCatch({
        p <- pheatmap::pheatmap(a, cellwidth = 5, cellheight = 5, 
            main = title, fontsize = 6, kmeans_k = NA, border = TRUE, 
            show_rownames = TRUE, show_colnames = TRUE, scale = "none", 
            cluster_rows = FALSE, cluster_cols = TRUE, clustering_distance_rows = "euclidean", 
            clustering_distance_cols = "euclidean", legend = TRUE, 
            border_color = border_color, color = color(range_value * 
                2), breaks = breaks, treeheight_row = 0, treeheight_col = 0, 
            display_numbers = matrix(ifelse(a > 0, "+", ifelse(a < 
                0, "-", "")), nrow(a)), silent = TRUE)
    }, error = function(err) {
        logging::logerror("Unable to plot heatmap")
        logging::logerror(err)
    })
    return(p)
}
<bytecode: 0x7faf7dcae1c0>
<environment: namespace:Maaslin2>

```

---

<div class="post-metadata">

**Author:** ![nearinj](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/nearinj/32/2135_2.png) [@nearinj](https://forum.biobakery.org/u/nearinj)\
**Post date:** [October 4, 2023, 5:57pm UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/16 "2023-10-04T17:57:32Z")

</div>

Hi there @ericap

The good news is that the issue you are facing is not the same bug as others had reported in this thread. The bad news is there seems to be something else going on here…

Looking at your Maaslin2 call is there a reason why you put backticks around the term control? Perhaps coding the variable cervic\_substudy as characters (rather than factors) might resolve this issue.

Would it be possible to send us some subset of the data that reproduces this bug so we can figure out where the problematic part of our codebase is in this case?

Cheers,  
Jacob Nearing

---

<div class="post-metadata">

**Author:** ![Keren](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/keren/32/2473_2.png) [@Keren](https://forum.biobakery.org/u/Keren)\
**Post date:** [October 11, 2023, 7:42am UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/17 "2023-10-11T07:42:05Z")

</div>

I had the same error but was able to bypass it when I wrote the input\_metadata and input\_data into tab delimited files, and use the file path as input parameters in the maaslin2 code. something like below:

```
  fit_data = Maaslin2(
    input_data="C:/Users/xxx/Box/input_Genus.txt", 
    input_metadata="C:/Users/xxx/Box/input_meta.txt",
    output = "Genus_out",
    min_prevalence=0.2,
    max_significance = 0.05,
    fixed_effects = c("Age","Sex","Platform"),
         transform = "NONE",
    normalization = "TMM",
    analysis_method="NEGBIN")

```

---

<div class="post-metadata">

**Author:** ![ericap](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@ericap](https://forum.biobakery.org/u/ericap)\
**Post date:** [November 3, 2023, 6:33am UTC](https://forum.biobakery.org/t/xtfrm-error-with-maaslin2-default-example-in-r/5216/18 "2023-11-03T06:33:12Z")

</div>

Hi @nearinj.

Apologies for my delay in getting back to you, I got wrapped up in some other work.

The previous code I posted worked fine prior to updating to R 4.3.1, but replacing as.data.frame(otu\_table(cervic\_physeq\_filtered) with data.frame(otu\_table(cervic\_physeq\_filtered) fixed the error.

The below works:

```auto
fit_data_taxa_output <- Maaslin2(input_data = data.frame(otu_table(cervic_physeq_filtered)), 
                                 input_metadata = data.frame(sample_data(cervic_physeq_filtered)),
                                 output = "maaslin2_taxa_output_0.1_20231103", 
                                 fixed_effects = c("cervic_substudy", "sequence_run"), min_prevalence = 0.10, 
                                 normalization = "TSS", transform="LOG", analysis_method = "LM", standardize = FALSE, 
                                 reference = 'cervic_substudy,control;sequence_run,run1', plot_heatmap = TRUE)

```

@Keren’s solution of writing the data to tab delimited files also worked.

Thanks a lot for your help troubleshooting this.

Erica
