Open bioinfonext opened 5 years ago
@yogeshgupt a phyloseq
object is made up of multiple R objects, hence the last line of the error message saying
cannot coerce class "structure("phyloseq", package="phyloseq")" to data.frame
This previous issue here has some suggestions on how to save a phyloseq
object into a text file. I don't have experience with writing out phylogenetic trees, but this may be a good start, which uses the ape
package. Good luck!
There is also a function in the microbiome package for this: https://rdrr.io/github/microbiome/microbiome/man/write_phyloseq.html
However, for the manual way I want to strongly suggest future readers with larger data sets to use the way described in the linked issue, which is:
OTU1 = as(otu_table(ps), "matrix")
if(taxa_are_rows(ps)){OTU1 <- t(OTU1)}
# Coerce to data.frame
OTUdf = as.data.frame(OTU1)
This worked in seconds for my 90000 x 350 count table, whereas
OTUdf <- as.data.frame(otu_table(ps))
is still running after 5 hours.
I am trying to write phyloseq object into csv file but it shows error?
physeq_soil phyloseq-class experiment-level object otu_table() OTU Table: [ 67405 taxa and 27 samples ] sample_data() Sample Data: [ 27 samples by 5 sample variables ] tax_table() Taxonomy Table: [ 67405 taxa by 7 taxonomic ranks ] phy_tree() Phylogenetic Tree: [ 67405 tips and 67229 internal nodes ]