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

heatmap error in Galaxy tool #146

Closed bernt-matthias closed 1 year ago

bernt-matthias commented 1 year ago

I'm currently debugging the ampvis2 heatmap Galaxy tool (still based on 2.7.22) which gives an error in the CI since two weeks ago:

Error in if (y[["In situ"]] == "Positive" | (any(y[["In situ"]] %in% c("Variable",  : 
  argument is of length zero
Calls: amp_heatmap -> extractFunctions -> lapply -> FUN -> lapply -> FUN

traceback() gives me

6: FUN(X[[i]], ...)
5: lapply(c(x[["properties"]], x[["metabolism"]]), function(y) {
       if (y[["In situ"]] == "Positive" | (any(y[["In situ"]] %in% 
           c("Variable", "Not Assessed")) & y[["Other"]] == "Positive")) {
           return("POS")
       }
       if (y[["In situ"]] == "Negative" | (y[["In situ"]] == "Not Assessed" & 
           y[["Other"]] == "Negative")) {
           return("NEG")
       }
       if (y[["In situ"]] == "Variable" | (y[["In situ"]] == "Not Assessed" & 
           y[["Other"]] == "Variable")) {
           return("VAR")
       }
       if (all(c(y[["In situ"]], y[["Other"]]) %in% "Not Assessed")) {
           return("NT")
       }
   })
4: FUN(X[[i]], ...)
3: lapply(FGList, function(x) {
       outList <- lapply(c(x[["properties"]], x[["metabolism"]]), 
           function(y) {
               if (y[["In situ"]] == "Positive" | (any(y[["In situ"]] %in% 
                   c("Variable", "Not Assessed")) & y[["Other"]] == 
                   "Positive")) {
                   return("POS")
               }
               if (y[["In situ"]] == "Negative" | (y[["In situ"]] == 
                   "Not Assessed" & y[["Other"]] == "Negative")) {
                   return("NEG")
               }
               if (y[["In situ"]] == "Variable" | (y[["In situ"]] == 
                   "Not Assessed" & y[["Other"]] == "Variable")) {
                   return("VAR")
               }
               if (all(c(y[["In situ"]], y[["Other"]]) %in% "Not Assessed")) {
                   return("NT")
               }
           })
       c(Genus = gsub("^Ca ", "Ca_", x[["name"]]), MiDAS = "POS", 
           outList)
   })
2: extractFunctions(function_data)
1: amp_heatmap(d, normalise = TRUE, tax_aggregate = "Genus", tax_add = NULL, 
       tax_show = 10, showRemainingTaxa = FALSE, tax_empty = "best", 
       plot_values = TRUE, plot_values_size = 4, plot_colorscale = "log10", 
       plot_na = FALSE, measure = "mean", min_abundance = 0.1, textmap = FALSE, 
       plot_functions = TRUE, functions = c("Filamentous"), rel_widths = c(0.75, 
           0.25))

Call is:

plot <- amp_heatmap(d, normalise = TRUE, tax_aggregate = "Genus", tax_add = NULL, tax_show = 10, showRemainingTaxa = FALSE, tax_empty = "best", plot_values = TRUE, plot_values_size = 4, plot_colorscale = "log10", plot_na = FALSE, measure = "mean", min_abundance = 0.1, textmap = FALSE, plot_functions = TRUE, functions = c("MiDAS", "Filamentous", "AOB", "NOB", "GAO"), rel_widths = c(0.75, 0.25))
KasperSkytte commented 1 year ago

Hi Matthias

Thanks for notifying. I've debugged it and it seems there was simply a typo in the MiDAS field guide database from where amp_heatmap pulls the functional information (one entry, Sellimonas). It's fixed in the database, working fine here. In the future, if getting errors related to functional information you can always just use the included data set with ampvis2 midasfunctions and passing it along with the function_data argument. It's not updated often though, the website is the most up-to-date.

bernt-matthias commented 1 year ago

Thanks @KasperSkytte this also fixed the CI problem