Hello,
I am using phyloseq to analyze my 16S metagenomics data. When running the following code, I find the eror bellow (after code)
Code:
otu_mat<- read_excel(".../Phyloseq2/data.xlsx", sheet = "OTU matrix")
tax_mat<- read_excel("...Phyloseq/Phyloseq2/data.xlsx", sheet = "Taxonomy table")
samples_df <- read_excel("...Phyloseq/Phyloseq2/data.xlsx", sheet = "Samples")phyloseq objects need to have row.names
#define the row names from the otu column
row.names(otu_mat) <- otu_mat$otu
#remove the column otu since it is now used as a row name
otu_mat <- otu_mat %>% select (-otu)
#Idem for the two other matrixes
row.names(tax_mat) <- tax_mat$otu
tax_mat <- tax_mat %>% select (-otu)row.names(samples_df) <- samples_df$sample
samples_df <- samples_df %>% select (-sample)#Transform into matrixes otu and tax tables (sample table can be left as data frame)
otu_mat <- as.matrix(otu_mat)
tax_mat <- as.matrix(tax_mat)#Transform to phyloseq objects
OTU = otu_table(otu_mat, taxa_are_rows = TRUE)
TAX = tax_table(tax_mat)
samples = sample_data(samples_df)carbom <- phyloseq(OTU, TAX, samples)
carbom
Error:
carbom <- phyloseq(OTU, TAX, samples)
Error in validObject(.Object) : invalid class “phyloseq” object:
Component sample names do not match.
Try sample_names()
carbom
Error: object 'carbom' not found
I've noticed that when I open my samples, taxonomy and OTU matrix tables, they have no headers or sample info (usually the firt column of OTU matrix). Please check attached screenshots
Are these tables supposed to look like this here? should they have sample info as well?
Any help would be much appreciated. Thank you.
Leo