Body: <p>I wish to convert a kraken2 or metaphlan2 report into the R package to analyze using Phyloseq.</p>
  <p>I have performed obtained an importation and Phyloseq analysis, but the result was not correct.</p>
  <pre class="lang-r prettyprint-override"><code>library(&quot;phyloseq&quot;)
  library(&quot;biomformat&quot;) 
  otu_Rat11 &lt;- read_biom(&quot;Rat11.biom&quot;) 
  
  otumat_Rat11 = as(biom_data(otu_Rat11), &quot;matrix&quot;) 
  OTU_Rat11 &lt;- otu_table(otumat_Rat11, taxa_are_rows=TRUE) 
  str(OTU_Rat11)
  #Formal class 'otu_table' [package &quot;phyloseq&quot;] with 2 
  #slots ..@ .Data : num [1:1018, 1] 942 433 3007 116765 15103 ... .. ..- 
  #attr(*, &quot;dimnames&quot;)=List of 2 .. .. ..:ℎ[1:1018]&quot;186826&quot;&quot;33958&quot;&quot;1578&quot;
  #&quot;33959&quot;.........:chr[1:1018] &quot;186826&quot; &quot;33958&quot; &quot;1578&quot; &quot;33959&quot;......... :
  # chr &quot;sa1&quot; ..@ taxa_are_rows: logi TRUE
  
  taxmat_Rat11 = as.matrix(observation_metadata(otu_Rat11), rownames.force=TRUE)
  TAX_Rat11 = tax_table(taxmat_Rat11)
  
  physeq_Rat11 = phyloseq(OTU_Rat11, TAX_Rat11)
  str(physeq_Rat11) 
  #Formal class 'phyloseq' [package &quot;phyloseq&quot;] with 5 slots ..@ otu_table:Formal 
  #class 'otu_table' [package &quot;phyloseq&quot;] with 2 slots .. .. ..@ .Data : num 
  #[1:1018, 1] 942 433 3007 116765 15103 ... .. .. .. ..- attr(*, &quot;dimnames&quot;)=List
  # of 2 .. .. .. .. ..:ℎ[1:1018]&quot;186826&quot;&quot;33958&quot;&quot;1578&quot;&quot;33959&quot;.............: chr 
  #[1:7] &quot;taxonomy1&quot; &quot;taxonomy2&quot; &quot;taxonomy3&quot; &quot;taxonomy4&quot; ... ..@ sam_data : NULL ..
  #@ phy_tree : NULL ..@ refseq : NULL –
  </code></pre>
  <p>Now I try to obtain @ sam_data</p>
  <pre><code>sampledata = sample_data(otu_Rat11) 
  #Error in access(object, &quot;sam_data&quot;, errorIfNULL) : sam_data slot is empty.
  </code></pre>
  <p>What do with sample data and how to merge several phyloseq-format datasets from different metagenomes?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-24T10:16:32.713Z
Comments.Text: Is it possible to have an example file for `Rat11.biom`? It's easier to debug with a reproducible result.
  What do you mean by "the result was not correct"?
  What's your code for merging several phyloseq-format datasets from different metagenomes?
Comments.UserDisplayName: Ryan SY Kwan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-29T00:32:56.630Z
Comments.Text: I'm working on this procedure with some difficult. Could you please tell me how do you convert kraken2 report files into the biom format?
Comments.UserDisplayName: Jianwei
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-21T15:59:01.160Z
Comments.Text: I had received the same error. My metadata file was in a matrix format, I converted it into a data.frame and it worked. Pls try and see if it works.
Comments.UserDisplayName: Pooja Kunte
Tags: <r>
Title: Kraken2 or metaphlan2 report to phyloseq
ThreadText: # Kraken2 or metaphlan2 report to phyloseq
  
  (Asked by: username_0 on 2020-07-16)
  
  I wish to convert a kraken2 or metaphlan2 report into the R package to analyze using Phyloseq.
  
  I have performed obtained an importation and Phyloseq analysis, but the result was not correct.
  
  ```r
  library("phyloseq")
  library("biomformat") 
  otu_Rat11 <- read_biom("Rat11.biom") 
  
  otumat_Rat11 = as(biom_data(otu_Rat11), "matrix") 
  OTU_Rat11 <- otu_table(otumat_Rat11, taxa_are_rows=TRUE) 
  str(OTU_Rat11)
  #Formal class 'otu_table' [package "phyloseq"] with 2 
  #slots ..@ .Data : num [1:1018, 1] 942 433 3007 116765 15103 ... .. ..- 
  #attr(*, "dimnames")=List of 2 .. .. ..:ℎ[1:1018]"186826""33958""1578"
  #"33959".........:chr[1:1018] "186826" "33958" "1578" "33959"......... :
  # chr "sa1" ..@ taxa_are_rows: logi TRUE
  
  taxmat_Rat11 = as.matrix(observation_metadata(otu_Rat11), rownames.force=TRUE)
  TAX_Rat11 = tax_table(taxmat_Rat11)
  
  physeq_Rat11 = phyloseq(OTU_Rat11, TAX_Rat11)
  str(physeq_Rat11) 
  #Formal class 'phyloseq' [package "phyloseq"] with 5 slots ..@ otu_table:Formal 
  #class 'otu_table' [package "phyloseq"] with 2 slots .. .. ..@ .Data : num 
  #[1:1018, 1] 942 433 3007 116765 15103 ... .. .. .. ..- attr(*, "dimnames")=List
  # of 2 .. .. .. .. ..:ℎ[1:1018]"186826""33958""1578""33959".............: chr 
  #[1:7] "taxonomy1" "taxonomy2" "taxonomy3" "taxonomy4" ... ..@ sam_data : NULL ..
  #@ phy_tree : NULL ..@ refseq : NULL –
  
  ```
  
  Now I try to obtain @ sam\_data
  
  ```
  sampledata = sample_data(otu_Rat11) 
  #Error in access(object, "sam_data", errorIfNULL) : sam_data slot is empty.
  
  ```
  
  What do with sample data and how to merge several phyloseq-format datasets from different metagenomes?
  
  **Tags:** r
  
  > **Comments:**
  > **username_1**: Is it possible to have an example file for `Rat11.biom`? It's easier to debug with a reproducible result. What do you mean by "the result was not correct"? What's your code for merging several phyloseq-format datasets from different metagenomes?  
  > **username_2**: I'm working on this procedure with some difficult. Could you please tell me how do you convert kraken2 report files into the biom format?  
  > **username_3**: I had received the same error. My metadata file was in a matrix format, I converted it into a data.frame and it worked. Pls try and see if it works.  
  
  ---
  
  ## 0 answers
  
  