KasperSkytte / ampvis2

Tools for visualising microbial community amplicon data
https://kasperskytte.github.io/ampvis2/
GNU General Public License v3.0
66 stars 23 forks source link

amp_heatmap truncates taxa label if it contains white space #93

Closed lixiaopi1985 closed 4 years ago

lixiaopi1985 commented 4 years ago

Hi,

It seems to me that the amp_heatmap function truncates the taxonomy label. For example, "uncultured bacterium" would show "bacterium". Is there away to preserve the full name?

Thanks,

KasperSkytte commented 4 years ago

Hi there

Please provide a minimal reproducible example. I cannot reproduce your issue, see below.

library(ampvis2)
#> Loading required package: ggplot2
otutable <- example_otutable
metadata <- example_metadata

d <- amp_load(otutable = otutable, metadata = metadata)
amp_heatmap(d, tax_aggregate = "Genus", group_by = "Plant")

d$tax$Genus[1]
#> [1] "g__Candidatus Amarilinum"
d$tax$Genus[1] <- "g__Uncultured Bacterium"
amp_heatmap(d, tax_aggregate = "Genus", group_by = "Plant")

Created on 2020-06-02 by the reprex package (v0.3.0)

lixiaopi1985 commented 4 years ago

Hi,

Thanks for the response. I have attached a list of unique genera from one of the field. Issue as shown below:

> sum(B10$tax$Genus == "bacterium") [1] 0

sum(startsWith(B10$tax$Genus, "f__")) [1] 0

amp_heatmap(B10, normalise = F, tax_aggregate = "Genus")

InkedB10_LI

df %>%
        filter(!is.na(Genus)) %>%
        group_by(Sample, Genus) %>%
        summarise(Abundance = sum(Abundance)) %>%
        filter(Sample == "B10_1") %>%
        arrange(-Abundance)
Sample Genus                Abundance  
  <chr>  <fct>                    <dbl>  
  1 B10_1  Pseudarthrobacter        12.9   
  2 B10_1  uncultured               10.1   
  3 B10_1  uncultured bacterium      8.15  
  4 B10_1  Sphingomonas              3.56  
  5 B10_1  Bacillus                  3.55  
  6 B10_1  Nocardioides              1.80  
  7 B10_1  Pseudomonas               1.56  
  8 B10_1  Flavobacterium            1.52  
  9 B10_1  Paenibacillus             1.51  
  10 B10_1  Massilia                  1.34  

B10_unique_genera.txt

KasperSkytte commented 4 years ago

Hi again

I see the problem now. I guess this is a leftover from ampvis v1.x. The amp_rename() internal function is used to pretify taxonomy, and we are used to always remove "uncultured" since they provide no information: https://github.com/MadsAlbertsen/ampvis2/blob/9d768a1297e74242930be15ac61db1bca6314cd1/R/internals.R#L90 But this should be left untouched in my opinion and be up to the user to choose. I have removed it so it only removes QIIME taxonomy prefixes like g__.

Regarding the f__Methyloligellaceae it's because tax_empty = "best" is default. So if there is no classification at the chosen aggregate level, here Genus, it will grab the taxonomy from the lowest level possible.