OTU Table Extraction from Phyloseq Object
1
0
Entering edit mode
23 months ago
safiq713 ▴ 10

I want to extract otu table from the phyloseq object:

> physeq_N

phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 1581 taxa and 4 samples ]
sample_data() Sample Data:       [ 4 samples by 1 sample variables ]
tax_table()   Taxonomy Table:    [ 1581 taxa by 8 taxonomic ranks ]

PTU Table is like this

 >otu_table(physeq_N)*

OTU Table:          [1581 taxa and 4 samples]
                     taxa are columns
           e37dba1608aafb21f6c51dd721e39455 6e1a4303bd0c4c67e4b19b18c09221de e18fe870915e68610993c7a077ee6b79 ec4edc4bc6abe7f1978e69c4e0acea7c 7df2cd8fd4882b411c8cf03224a9a77c
           9ef92be0c5a2879062904cf0d17544ff 1f7727dd435fe7255c5eba63d6b033de d424237f7a32df5ff6912973b09183bd 557730296c9ff8394732518bcee9cae1 f983978ebf8ee1da64bb98a3e742eb95

> tax_table(physeq_N)

Taxonomy Table:     [1581 taxa by 8 taxonomic ranks]:
                                 Kingdom    Phylum             Class                 Order                                 Family                             
e37dba1608aafb21f6c51dd721e39455 "Bacteria" "Bacteroidota"     "Bacteroidia"         "Bacteroidales"                       "Bacteroidaceae"                   
6e1a4303bd0c4c67e4b19b18c09221de "Bacteria" "Bacteroidota"     "Bacteroidia"         "Bacteroidales"                       "Bacteroidaceae"                   
e18fe870915e68610993c7a077ee6b79 "Bacteria" "Bacteroidota"     "Bacteroidia"         "Bacteroidales"                       "Bacteroidaceae" 

How can Extract a OTU Table like this:

   Species.ID   Sample 1    sample2 sample 3    sample 4    Domain  Phylum  Class   Order   Family  Genus   Species
    EQAS.001    10  11105   125 524774  Animalia    xxx xx  xxx xxx xxx xxx

Thanks a lot

OTu Table Phyloseq • 3.1k views
ADD COMMENT
1
Entering edit mode
23 months ago
Asaf 10k

cbind(data.frame(otu_table(physeq_N)), data.frame(tax_table(physeq_N)))

ADD COMMENT
0
Entering edit mode

thanks a lot for your kind reply, Exactly I want to get the file this but problem is sample information is missing

I want include samples information as well.

enter image description here

ADD REPLY
1
Entering edit mode

You mean the count matrix? You didn't include both tables in the cbind, only the first one (the otu_table) so you got two table instead of one.

ADD REPLY
0
Entering edit mode

Thanks a lot for your reply. a. What I want, first column as it it is, OTU Name. b. from second to n Column Samples names c. then taxonomy

<OTU name ><samples name><Kingdom><Phylum>

enter image description here

ADD REPLY
0
Entering edit mode

This is really weird, the otu_table should have 1581 rows and 4 columns, unless you changed it somehow. The OTU names are the rownames, when you write the data.frame as csv with write.csv() it will be printed as first column.

ADD REPLY

Login before adding your answer.

Traffic: 1352 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6