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

command to merge a otu_table and tax_table #1645

Open
Robvh-git opened this issue Dec 7, 2022 · 1 comment
Open

command to merge a otu_table and tax_table #1645

Robvh-git opened this issue Dec 7, 2022 · 1 comment

Comments

@Robvh-git
Copy link

Hello,

I have a subsetted phyloseq object "x", containing 9 taxa.

I've created relative abundances of the read data (using microbiome::), so when running otu_table(x) I get relative abundances for each feature. The feature IDs are currently long strings, e.g.: "31fad54be44797f948a21c9e010ec9a7"

When running tax_table(x) I get the taxonomic info per feature ID.

In the relative abundance data (otu_table(x)) I want to replace the long feature ID strings, for the genus (or whole tax information, if only genus is not possible) of each feature id, as shown in tax_table(x).

I can imagine that there is a phyloseq function specifically for doing this, but I cannot seem to find it.

Could anyone please advise me how to do this?

Thanks!

@david-barnett
Copy link

To replace the long taxa ID strings with their classification at genus, you might like the tax_rename function from my package microViz

https://david-barnett.github.io/microViz/reference/tax_rename.html

Example from the documentation:

library(phyloseq)
library(microViz)
data("ibd_phylo", package = "corncob")

ps <- ibd_phylo %>%
  tax_filter(min_prevalence = 3) %>%
  tax_fix()

# show a few of the current, uninformative names
taxa_names(ps) %>% head(15)
#>  [1] "OTU.49"  "OTU.50"  "OTU.52"  "OTU.54"  "OTU.56"  "OTU.57"  "OTU.59" 
#>  [8] "OTU.76"  "OTU.90"  "OTU.92"  "OTU.108" "OTU.142" "OTU.185" "OTU.197"
#> [15] "OTU.200"

# change names to genus classification plus number
psNewNames <- ps %>% tax_rename(rank = "Genus")

taxa_names(psNewNames) %>% head(15)
#>  [1] "Faecalibacterium 203"             "Escherichia/Shigella 081"        
#>  [3] "Clostridium_XlVa 045"             "Lachnospiraceae Family 20"       
#>  [5] "Bacteroides 0825"                 "Flavonifractor 25"               
#>  [7] "Ruminococcaceae Family 05"        "Clostridium_XlVa 028"            
#>  [9] "Faecalibacterium 204"             "Escherichia/Shigella 088"        
#> [11] "Escherichia/Shigella 130"         "Clostridium_XlVa 110"            
#> [13] "Lachnospiraceae Family 58"        "Lachnospiracea_incertae_sedis 34"
#> [15] "Bacteroides 0967"                

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