Open LChWu opened 4 years ago
Thanks for the feedback!
Yes, this is expected behavior, since when you do filter_taxa(obj, taxon_ranks == 'o', supertaxa = T)
, only taxa that are orders are returned, as well as their supertaxa , so classes with no orders, for example, are not returned. The other classes returned are only included because they were supertaxa of an order.
When people think "I want all taxa the rank of order or above", what they want is something like filter_taxa(obj, taxon_ranks %in% c('k', 'p', 'c', 'o'))
, as you mentioned.
In the future, I expect this will be possible: filter_taxa(obj, taxon_ranks <= 'o')
Its part of a big rewrite of the taxa
package that is slowly progressing. Once that is done, I will emphasize using the >
and <
with taxon ranks for more intuitive subsetting of this kind and things like filter_taxa(obj, taxon_ranks == 'o', supertaxa = T)
wont be used for this purpose, so hopefully that will solve the confusion.
Ok, that makes sense than. Thank you for solving my confusion and also for the great package!
Hello,
I think I discovered something when using
filter_taxon
together withtaxon_ranks
. If a taxon does not have information on the rank you filter for, also withsupertaxa = TRUE
, the taxon will be discarded or maybe reassigned to the root, I am not sure where it disappears to, because the total OTU number does not change.I am not sure if this phenomenum is documented anywhere. I wasn't able to find it so far. Maybe it can be added to describtion of the function or an option can be added to the function to stop this? Is there already one?
Here I reproduced what I found with some data from the metacoder workshop:
Data
Here you can see that all taxa have subtaxa up to order level
notice that here are 194 taxa now, with the filtering above there were only 186 taxa
Now, here are also taxa displayed where the lowest subtaxa is class level, for example 3BR-5I, which were missing in the tree above.
So, is that kind of filtering supposed to work like this? In my data I had a lot of taxa which were not assigned to the rank level I filtered to, that was how I noticed something was off. Would be great if you could add an entry about this phenomenum somewhere.
Thank you!