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

Taxa cannot be aggregated at rank: Genus #145

Closed bylam closed 1 month ago

bylam commented 3 months ago

I have been facing significant challenges with the "Taxa cannot be aggregated at rank: Genus tax_agg" issue, especially when inconsistencies at the previous taxonomic level are unavoidable, particularly during denovo analysis. I would like to prevent this error from occurring when aggregating data and only aggregate the abundance at the current taxonomic level. I prefer not to modify the original annotation file. Your assistance in resolving this matter would be greatly appreciated.

Thank you for your support and help. I look forward to your response.

david-barnett commented 3 months ago

For quick solutions you could use the microbiome package function aggregate_taxa which will just paste all the ranks above genus together to give you unique but long names, or use the force = TRUE argument in the microViz tax_agg function, which will discard higher rank information, possibly leading to misleading aggregations if you have e.g. g__ or similar "classifications" in your tax table.

A better solution in my opinion (if discrepancies at higher ranks are unavoidable) would be to paste a few ranks together intentionally, with e.g. tax_mutate(class_family_genus = paste(class, family, genus), genus = NULL, family = NULL) to disambiguate any genus level features inconsistently assigned to family or class level groups, but keep manageable length of feature names.

hope this helps

david-barnett commented 1 month ago

assuming this issue is resolved, feel free to open new issue if not :)