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/
582 stars 187 forks source link

Error in validObject(.Object) : invalid class “phyloseq” object: Component sample names do not match. #1315

Open MatiasPezoa21 opened 4 years ago

MatiasPezoa21 commented 4 years ago

Hi everyone, I'm Matias. I have the following problem and I don't know how to solve it, please if someone can help me.

This is the script

taxTabExtra <- addSpecies(taxTab, "~/Resultados secuencias matias/silva_species_assignment_v132.fa", verbose=TRUE) unname(head(taxTab)) -> tabla colnames(tabla) <- c("Kingdom", "Phylum", "Order", "Class", "Family", "Genus")

seqs <- getSequences(seqtab.nochim)

names(seqs) <- seqs alignment <- AlignSeqs(DNAStringSet(seqs), anchor=NA,verbose=FALSE)

phangAlign <- phyDat(as(alignment, "matrix"), type="DNA") dm <- dist.ml(phangAlign) treeNJ <- NJ(dm) fit = pml(treeNJ, data=phangAlign) fitGTR <- update(fit, k=4, inv=0.2) fitGTR <- optim.pml(fitGTR, model="GTR", optInv=TRUE, optGamma=TRUE, rearrangement = "stochastic", control = pml.control(trace = 0),multithread=20)

samdf <- read.csv("~/Resultados secuencias matias/Liquen/Metadatos liquen.csv", header=FALSE, row.names = 1) rownames(seqtab.nochim) %in% rownames(samdf) all(rownames(seqtab) %in% samdf$run)

ps <- phyloseq(otu_table(seqtab.nochim, taxa_are_rows=FALSE), sample_data(samdf), tax_table(taxTab), phy_tree(fitGTR$tree))

And the problem occurs at the end

ps <- phyloseq(otu_table(seqtab.nochim, taxa_are_rows=FALSE),

  • sample_data(samdf),
  • tax_table(taxTab),
  • phy_tree(fitGTR$tree)) Error in validObject(.Object) : invalid class “phyloseq” object: Component sample names do not match. Try sample_names()
ursadhip commented 3 years ago

Error in validObject(.Object) : invalid class “phyloseq” object: Component sample names do not match. Try sample_names()

Yup.. Me, too, getting the same error message.

iebenb commented 2 years ago

The error occurs because the sample names of the OTU table and those of the sample data do not match. You can check this using sample_names() on your OTU table and sample data.

For an example on how to solve this: https://github.com/joey711/phyloseq/issues/1315