joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
571 stars 187 forks source link

tax_table() changing row names from otu_1 to sp1 #886

Open hkr01 opened 6 years ago

hkr01 commented 6 years ago

The output from dada2 leaves me with an OTU, taxonomy and sample information file. I'm trying to create a phyloseq object from these 3 files using:

OTU = otu_table(spc, taxa_are_rows = TRUE) TAX = tax_table(tax) ENV = sample_data(env) ps<-phyloseq(OTU,TAX, ENV)

But I'm getting the error "Component taxa/OTU names do not match." I think this is because its changing otu_1 to sp1, and sp1 is not recognised in the OTU object as the OTUs are still in the format "otu_x" - How can I resolve this?

head(tax) Kingdom Phylum Class Order otu_1 kBacteria pVerrucomicrobia c[Spartobacteria] o[Chthoniobacterales] otu_2 kBacteria pAcidobacteria cAcidobacteriia oAcidobacteriales otu_3 kBacteria pBacteroidetes c[Saprospirae] o[Saprospirales] otu_4 kBacteria pProteobacteria cDeltaproteobacteria oSyntrophobacterales otu_5 kBacteria pAcidobacteria cAcidobacteriia oAcidobacteriales otu_6 kBacteria pProteobacteria cDeltaproteobacteria oSyntrophobacterales head(TAX) Taxonomy Table: [6 taxa by 7 taxonomic ranks]: ta1 ta2 ta3 ta4
sp1 "kBacteria" "pVerrucomicrobia" "c[Spartobacteria]" "o[Chthoniobacterales]" sp2 "kBacteria" "pAcidobacteria" "cAcidobacteriia" "oAcidobacteriales"
sp3 "kBacteria" "pBacteroidetes" "c[Saprospirae]" "o[Saprospirales]"
sp4 "kBacteria" "pProteobacteria" "cDeltaproteobacteria" "oSyntrophobacterales" sp5 "kBacteria" "pAcidobacteria" "cAcidobacteriia" "oAcidobacteriales"
sp6 "kBacteria" "pProteobacteria" "cDeltaproteobacteria" "oSyntrophobacterales"

insectnate commented 6 years ago

I am also having this problem while importing a tax table from QIIME2. Any advice?

MSMortensen commented 6 years ago

Hi, This might be late, but if you try to directly change a data.frame to a phyloseq tax_table it will throw away your column and row names. To avoid this try using: TAX = tax_table(as.matrix(tax))

KaraS106 commented 1 year ago

Hi- I am having this problem as well I used TAX = tax_table(as.matrix(tax))

which fixed the row header- but all my ASVs are still as "sp1" "sp2" etc

Screenshot 2023-05-23 at 7 01 54 AM
marcinschmidt commented 8 months ago

I had a similar problem and found such solution:

#ps is your phyloseq object
taxt <- tax_table(ps)@.Data
#the taxt is a matrix you can manipulate freely
tax_table(ps)@.Data <- taxt

fixes both column and row names.