cmmr / rbiom

Interact with Biological Observation Matrix files.
https://cmmr.github.io/rbiom/
Other
12 stars 0 forks source link

XLSX export requires taxonomy character matrix which is not necessarily present at import #6

Closed chrysn closed 1 year ago

chrysn commented 1 year ago

The write.xlsx function fails with "Error: Taxonomy map must be a character matrix." when importing a minimal BIOM file, rather than simply not outputting data that is not present in the object.

To reproduce, use this as test.txt (careful, there are tabs in it):

#OTU ID sample1 sample2
obs1    1.0 0.0
obs2    0.0 2.0

and run

$ biom convert -i test.txt -o test.biom --to-hdf5
$ R
> library('rbiom')
> b <- read.biom('test.biom', tree=FALSE)
> write.xlsx(b, 'test.xlsx')
Error: Taxonomy map must be a character matrix.

As a workaround, I'm running

> b$taxonomy[1,] = c("a")

What is particularly weird is that the taxonomy data injected here is not even emitted in the XLSX -- but then again, maybe I'm not putting it in the right way.

Please consider updating the error handling so that any loaded file can also be saved to XLSX.

dansmith01 commented 1 year ago

Thanks for pointing that out! Fixed!