Search
Question: Cannot read Biom file
0
gravatar for channen1221
9 months ago by
channen12210 wrote:

Hi there

I am terrible in R - its my worst nightmare. And i only post this because I am desperate. 

I have a .biom file (json version; format: Biological Observation Matrix 1.0.0). However when trying to import to RStudio I get an error message:

Error in read_biom(biom_file = BIOMfilename) : 
  Both attempts to read input file:

either as JSON (BIOM-v1) or HDF5 (BIOM-v2).
Check file path, file name, file itself, then try again.

I'm not entirely certain what I need to change or if i'm not using the correct packages. 

 

Thanks

ADD COMMENTlink modified 9 months ago by Axel Klenk920 • written 9 months ago by channen12210
0
gravatar for Axel Klenk
9 months ago by
Axel Klenk920
Switzerland
Axel Klenk920 wrote:

Hi Channen1221,

we need a little bit of information to help you.

First of all, please show us the command(s) you have entered.

Attaching the output of

sessionInfo()

is also a good idea.

Cheers,

 - axel

ADD COMMENTlink written 9 months ago by Axel Klenk920

Hi  all,

I have the same error. 

I have my otu_table.biom constructed by Qiime 1.9 and my metadata file and I tried to import in Phyloseq and until now I have not couldn't; I changed my otu_table.biom to json with this command

biom convert -i otu_table.biom -o otu_table_json.biom --table-type="OTU table" --to-json

However, with this file, I have not couldn't,

jsonbiomfile = "C/Users/metagenomic/Desktop/otu_table_json.biom"
jsonbiomfile = "C/Users/metagenomic/Desktop/metadata_ITS.txt"

biom_file <- paste(jsonbiomfile, "otu_table_json.biom", sep = "")
map_file <- paste(jsonbiomfile, "metadata_ITS.txt", sep = "")

read_biom(biom_file)

then I got this message

Error in read_biom(biom_file) : Both attempts to read input file:
C/Users/metagenomic/Desktop,otu_table_json.biom
either as JSON (BIOM-v1) or HDF5 (BIOM-v2).
Check file path, file name, file itself, then try again.

 

Please if you have any advice, I appreciate that, thanks in advance

 

 

ADD REPLYlink written 7 weeks ago by voteroj10

Dear voteroj,

without looking at the read_biom() code, I guess it is trying to tell you that there is a problem with your

filename.  These look like Windows paths and I'd suggest to simply add a colon to the drive letter, as in

jsonbiomfile = "C:/Users/metagenomic/Desktop/otu_table_json.biom"

(untested, I'm on linux)

Hope this helps.

 

ADD REPLYlink written 7 weeks ago by Axel Klenk920

Thanks Axel, 

I tried, but again I got the same message 

jsonbiomfile = "C:/Users/metagenomic/Desktop"
jsonbiomfi = "C:/Users/metagenomic/Desktop/metadata_ITS.txt"

biom_file <- paste(jsonbiomfile, "otu_table_json.biom", sep = "")
map_file <- paste(jsonbiomfi, "metadata_ITS.txt", sep = "")

biom_file
read_biom(biom_file)

Error in read_biom(biom_file) : Both attempts to read input file:
C:/Users/metagenomic/Desktopotu_table_json.biom
either as JSON (BIOM-v1) or HDF5 (BIOM-v2).
Check file path, file name, file itself, then try again.

:(

 

ADD REPLYlink written 7 weeks ago by voteroj10

use file.path() instead of paste(), or biom_file <- file.choose() ; but instead of typing stuff and hoping that it works, check that it makes sense, for instance, do you actually have a file at C/Users/metagenomic/Desktop,otu_table_json.biom ?

ADD REPLYlink modified 7 weeks ago • written 7 weeks ago by Martin Morgan ♦♦ 22k

 Hi Martin, Thanks for your answer, 

I tested your recommendation and the error is the same.

and well after I reviewed some post in github, and I red  phyloseq manual for import .biom table, I have couldn't  understand what is the problem, I have my file in the desktop as you see in the first part of my script 

jsonbiomfile = "C:/Users/metagenomic/Desktop"

But then it appears  

C:/Users/metagenomic/Desktopotu_table_json.biom

I don't know why; please if you have another text or place to visit please don't hesitate to tell me, I want to learn and is my first time,

Thanks in advance,

 

 

ADD REPLYlink written 7 weeks ago by voteroj10
1

HI Martin,

I tried this

#####Input .biom
jsonbiomfile = "C:/Users/metagenomic/Desktop/otu_table_json.biom"
read_biom(jsonbiomfile)
x = read_biom(jsonbiomfile)
header(x)
biom_shape(x)
nrow(x)
ncol(x)
rownames(x)
colnames(x)
matrix_element_type(x)
biom_data(x)

and it's works!!!!

 

ADD REPLYlink written 7 weeks ago by voteroj10

Ouch, apologies for providing misleading help by posting a quick reply when I was about to leave my office... I had completely overlooked your paste() call...

In your call to paste(), you're explicitly asking for no (empty) separator between file path and filename by setting argument sep = "". It would have worked if you had used sep = "/" (and "C:").

?paste

However, as Martin has told you, it is much better to use file.path() instead of paste() because it will pick the right path separator for your OS by default.

?file.path

 

ADD REPLYlink written 7 weeks ago by Axel Klenk920
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 213 users visited in the last hour