joey711 / biomformat-oldfork Goto Github PK
View Code? Open in Web Editor NEWThis is deprecated. Please post issues at the BioC-synced joey711/biomformat
Home Page: https://github.com/joey711/biomformat
This is deprecated. Please post issues at the BioC-synced joey711/biomformat
Home Page: https://github.com/joey711/biomformat
Current JSON approach is unnecessary with jsonlite, where the table structure will be interpreted automatically, and most-likely in a much more efficient manner than the way it is handled now (always start as list?)
This is the last dangling aspect of a previous issue, which should now be considered closed:
Borrowed migrated from previous post:
Script would go in inst/scripts
and be run as external shell command (e.g. system
) from a new unit test, creating an implicit Suggests-type testing dependency on the availability of an up-to-date biom-format python library
"format", "format_url", "type":, "generated_by", "date", "id"s within rows/columns, "matrix_type", etc are all wrapped in lists ([]
), whereas the specification states these should be string
s: http://biom-format.org/documentation/format_versions/biom-1.0.html
Files created by the write_biom
method cannot be parsed by the official biom-format command-line tools, resulting in the error of TypeError: <filename> does not appear to be a BIOM file!
$ R
R version 3.3.3 (2017-03-06) -- "Another Canoe"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library('biomformat')
> packageVersion('biomformat')
[1] ‘1.2.0’
> biom_file <- system.file("extdata", "rich_sparse_otu_table.biom", package = "biomformat")
> x = read_biom(biom_file)
> outfile = tempfile()
> write_biom(x, outfile)
> system(paste0("cat ", outfile) )
{"id":{},"format":["Biological Observation Matrix 1.0.0-dev"],"format_url":["http://biom-format.org"],"type":["OTU table"],"generated_by":["QIIME revision XYZ"],"date":["2011-12-19T19:00:00"],"rows":[{"id":["GG_OTU_1"],"metadata":{"taxonomy":["k__Bacteria","p__Proteobacteria","c__Gammaproteobacteria","o__Enterobacteriales","f__Enterobacteriaceae","g__Escherichia","s__"]}},{"id":["GG_OTU_2"],"metadata":{"taxonomy":["k__Bacteria","p__Cyanobacteria","c__Nostocophycideae","o__Nostocales","f__Nostocaceae","g__Dolichospermum","s__"]}},{"id":["GG_OTU_3"],"metadata":{"taxonomy":["k__Archaea","p__Euryarchaeota","c__Methanomicrobia","o__Methanosarcinales","f__Methanosarcinaceae","g__Methanosarcina","s__"]}},{"id":["GG_OTU_4"],"metadata":{"taxonomy":["k__Bacteria","p__Firmicutes","c__Clostridia","o__Halanaerobiales","f__Halanaerobiaceae","g__Halanaerobium","s__Halanaerobiumsaccharolyticum"]}},{"id":["GG_OTU_5"],"metadata":{"taxonomy":["k__Bacteria","p__Proteobacteria","c__Gammaproteobacteria","o__Enterobacteriales","f__Enterobacteriaceae","g__Escherichia","s__"]}}],"columns":[{"id":["Sample1"],"metadata":{"BarcodeSequence":["CGCTTATCGAGA"],"LinkerPrimerSequence":["CATGCTGCCTCCCGTAGGAGT"],"BODY_SITE":["gut"],"Description":["human gut"]}},{"id":["Sample2"],"metadata":{"BarcodeSequence":["CATACCAGTAGC"],"LinkerPrimerSequence":["CATGCTGCCTCCCGTAGGAGT"],"BODY_SITE":["gut"],"Description":["human gut"]}},{"id":["Sample3"],"metadata":{"BarcodeSequence":["CTCTCTACCTGT"],"LinkerPrimerSequence":["CATGCTGCCTCCCGTAGGAGT"],"BODY_SITE":["gut"],"Description":["human gut"]}},{"id":["Sample4"],"metadata":{"BarcodeSequence":["CTCTCGGCCTGT"],"LinkerPrimerSequence":["CATGCTGCCTCCCGTAGGAGT"],"BODY_SITE":["skin"],"Description":["human skin"]}},{"id":["Sample5"],"metadata":{"BarcodeSequence":["CTCTCTACCAAT"],"LinkerPrimerSequence":["CATGCTGCCTCCCGTAGGAGT"],"BODY_SITE":["skin"],"Description":["human skin"]}},{"id":["Sample6"],"metadata":{"BarcodeSequence":["CTAACTACCAAT"],"LinkerPrimerSequence":["CATGCTGCCTCCCGTAGGAGT"],"BODY_SITE":["skin"],"Description":["human skin"]}}],"matrix_type":["sparse"],"matrix_element_type":["int"],"shape":[5,6],"data":[[0,2,1],[1,0,5],[1,1,1],[1,3,2],[1,4,3],[1,5,1],[2,2,1],[2,3,4],[2,5,2],[3,0,2],[3,1,1],[3,2,1],[3,5,1],[4,1,1],[4,2,1]]}>
I noticed recently that I lost my metadata column names (both sample_metadata()
and observation_metadata()
) after writing a biom object to file and reading it back in with read_biom()
. I've tracked it down to the way jsonlite::toJSON()
within biomformat::write_biom()
writes the json file. The column names are lost while writing. I haven't yet figured out what modifications of arguments in jsonlite::toJSON()
need to be made to fix the issue. However, I found that with RJSONIO::toJSON()
the issue is resolved.
Here's a demo of the issue in this gist with an example adapted from the write_biom()
help docs: https://gist.github.com/altrickter/978e23dd3bded3cabd75286b994a6a0f.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.