david-barnett / microViz

R package for microbiome data visualization and statistics. Uses phyloseq, vegan and the tidyverse. Docker image available.
https://david-barnett.github.io/microViz/
GNU General Public License v3.0
94 stars 10 forks source link

No change in #/Taxa when trying tax_select? #102

Closed david-barnett closed 1 year ago

david-barnett commented 1 year ago

Raised in https://github.com/david-barnett/microViz/discussions/101

Originally posted by **hank00000** February 24, 2023 Looking to subset all methanotrophs/methanogens by using general taxa search "meth", which is in all the taxa of interest's names (ex. Methanolobulus, Methylovirgula, etc). I saw the example used for "Bif" in this package tutorial and thought this would work, but my original and subsetted objects have the same number of taxa after using below code: Example code: --- ```r physeqMETH <- (tax_select(physeq, tax_list = "Meth", n_typos = 0, ranks_searched = "Family")) ``` --- physeq (original): phyloseq-class experiment-level object otu_table() OTU Table: [ 4976 taxa and 68 samples ] sample_data() Sample Data: [ 68 samples by 4 sample variables ] tax_table() Taxonomy Table: [ 4976 taxa by 7 taxonomic ranks ] phy_tree() Phylogenetic Tree: [ 4976 tips and 4953 internal nodes ] --- physeqMETH: phyloseq-class experiment-level object otu_table() OTU Table: [ 4976 taxa and 68 samples ] sample_data() Sample Data: [ 68 samples by 4 sample variables ] tax_table() Taxonomy Table: [ 4976 taxa by 7 taxonomic ranks ] phy_tree() Phylogenetic Tree: [ 4976 tips and 4953 internal nodes ] >
david-barnett commented 1 year ago

Hi @hank00000 The behaviour you report is surprising, and might be a bug:

Could you check the following things for me?

  1. Does the example code with example data work for you? https://david-barnett.github.io/microViz/reference/tax_select.html
# Get example phyloseq object data
data("dietswap", package = "microbiome")
pSeq <- dietswap

a <- pSeq %>% tax_select(tax_list = "Bif", n_typos = 0, ranks_searched = "Genus")
a
  1. Can you double-check for me that all 4976 taxa in physeq actually don't match "Meth" at family level?

I guess this should be pretty obvious from a quick scan of tax_table(physeq) but if a lot of them are matching you could check tax_fix_interactive(physeq)

  1. What version of microViz are you using?
packageVersion("microViz")
hank00000 commented 1 year ago

Hi David,

  1. Yes, it results in only 1 taxa and the original had 130 taxa.
  2. I'm definitely sure there are "Meth" containing groups in the data- for example "Methylomirabilaceae" is present at the family level but the code says no Meth-containing taxa are found.
  3. Version 0.10.7, I only downloaded this package this week.

I'll note that when I first tried this, no error message popped up but I just noticed that no change occurred, but now after re-starting, updating, troubleshooting a bit, trying different taxa levels, it still doesn't work but says "Error in tax_select(physeq, tax_list = "meth", n_typos = 0, ranks_searched = "Family") : No taxa matched."

david-barnett commented 1 year ago

Hi Hank, thanks for checking those things:

The matching is case-sensitive, so "Meth" and "meth" should give different results. Lowercase "meth" probably shouldn't match any families, so the new error would be expected.

Does "Meth", with a capital letter, still match every taxon after your updating/restarting?

If so, could you try a slightly different search, just to check the behaviour, e.g. try "Methylomir"

hank00000 commented 1 year ago

Haha, thanks David. Now I feel silly. I had set my tax_list to 'Capital M' Meth, but not my tax_select command.

ps <- physeq tax_list <- c("Meth") physeqMETH <- (tax_select(physeq, tax_list = "Meth", n_typos = 0, ranks_searched = "Order"))

phyloseq-class experiment-level object otu_table() OTU Table: [ 79 taxa and 68 samples ] sample_data() Sample Data: [ 68 samples by 4 sample variables ] tax_table() Taxonomy Table: [ 79 taxa by 7 taxonomic ranks ] phy_tree() Phylogenetic Tree: [ 79 tips and 77 internal nodes ]

Thanks!

david-barnett commented 1 year ago

No problem, I'm glad to have helped! :) and glad it's not a bug