Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phyloseq taxa don't match error, but TRUE when asked if values match? #1733

Open
hank00000 opened this issue Feb 28, 2024 · 4 comments
Open

Comments

@hank00000
Copy link

hank00000 commented Feb 28, 2024

I originally pulled the OTU table from a phyloseq object and modified it with a normalization method not supported within the package. Now I want to re-create a phyloseq object but am running into issues.

I've created a normalized and relative abundance table and made the row names the OTU sequences, and the column names sampleIDs. I also have a taxa table with row names as OTU sequences, and the tax info as columns. My metadata has rownames as sampleID and the variables as columns.

I get the following affirmations :

rownames(Relative_Abundance) == rownames(tax_table)
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[20] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[39] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[58] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[77] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[96] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[115] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[134] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[153] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[172] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[191] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[210] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[229] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[248] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[267] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[286] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[305] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[324] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

rownames(metadata_subset) == colnames (Relative_Abundance)
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[20] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[39] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[58] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[77] TRUE TRUE TRUE TRUE TRUE

relnormps <- phyloseq(otu_table(Relative_Abundance),
sample_data(metadata_subset),
tax_table(tax_table))

Error in validObject(.Object) : invalid class “phyloseq” object:
Component taxa/OTU names do not match.
Taxa indices are critical to analysis.
Try taxa_names()

Any suggestions? Much appreciated.
Screenshot 2024-02-28 at 10 56 52 AM
Screenshot 2024-02-28 at 10 57 04 AM
Screenshot 2024-02-28 at 10 58 00 AM

@hank00000
Copy link
Author

Note that I've also tried the as.matrix() trick offered in another post, but this didn't change the error. I'd really appreciate any insight.

@ycl6
Copy link

ycl6 commented Mar 21, 2024

Hi @hank00000

Can you try:

relnormps <- phyloseq(otu_table(Relative_Abundance),   # data.frame
                      sample_data(metadata_subset),    # data.frame
                      tax_table(as.matrix(tax_table))) # matrix

@hank00000
Copy link
Author

hank00000 commented Mar 22, 2024

Hi @hank00000

Can you try:

relnormps <- phyloseq(otu_table(Relative_Abundance, taxa_are_rows = TRUE), # data.frame + sample_data(metadata_subset), # data.frame + tax_table(as.matrix(tax_df))) #matrix

Error in validObject(.Object) : invalid class “phyloseq” object:
Component taxa/OTU names do not match.
Taxa indices are critical to analysis.
Try taxa_names()

Checked and the above TRUEs are still valid.

@ycl6
Copy link

ycl6 commented Mar 23, 2024

Hi @hank00000 Hmm, that's strange, How about:

# Check taxa names
identical(taxa_names(otu_table(Relative_Abundance, taxa_are_rows = TRUE)), 
          taxa_names(tax_table(as.matrix(tax_df))))

# Check sample names
identical(sample_names(otu_table(Relative_Abundance,, taxa_are_rows = TRUE)), 
          sample_names(sample_data(metadata_subset)))

Please use the code block markdown for better visualization out of your output.

For example:

``` r
x <- sum(c(1, 2, 3, 4))
x
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants