Giter Site home page Giter Site logo

biomformat-oldfork's People

Contributors

jimhester avatar joey711 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

biomformat-oldfork's Issues

Use automagic table structure in jsonlite

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:

joey711/biomformat0#2

write_biom output appears invalid due to improper types in format metadata

"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 strings: 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]]}> 

Lose metadata colnames when writing biom object to file

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.