For input to the r package SRS, I need a csv file with each column being a sample, and the rows being the taxa. I've been able to make similar outputs using psmelt but it contains all the metadata and the taxa are not in rows.
glom <- tax_glom(ps, taxrank='genus')
otus <- tax_table(glom)
dataexport <- psmelt(glom)
Another problem in those exports is that each domain, phylum, etc has a column with a value, and SRS wants domain;phylum;etc in one column as taxa names.
Does anyone know how to pick and choose which items you want as rows and columns from phyloseq object? Or how to meld all the taxa pieces into one string?
Thank you very much.
ps
otu_table() OTU Table: [ 4282 taxa and 172 samples ]
sample_data() Sample Data: [ 172 samples by 5 sample variables ]
tax_table() Taxonomy Table: [ 4282 taxa by 7 taxonomic ranks ]
refseq() DNAStringSet: [ 4282 reference sequences ]```
From the docs, SRS input:
My guess is to use
abundances(ps)to get the required format, e.g. using the example "dietswap" dataset:Created on 2024-01-18 with reprex v2.1.0
In terms of the taxonomic labels, perhaps:
Created on 2024-01-18 with reprex v2.1.0
Does that solve your problem?