https://gist.github.com/wasade/9764043, originally operating on a COO structure that represented BIOM data