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

Error in (function (edges, n = max(edges), directed = TRUE) : At type_indexededgelist.c:117 : cannot create empty graph with negative number of vertices, Invalid value #43

Closed Leran10 closed 1 year ago

Leran10 commented 2 years ago

Hi,

I encountered this error when running taxatree_plots() function on my lm model. I checked around and it seems that the it is looking for numeric edge format but being provided with other format. But I'm not sure where to adjust my edge format to numeric? And I didn't encounter this error when I run this function in other datasets.

Thanks! Leran

david-barnett commented 2 years ago

Hi Leran, did you leave the ranks argument of taxatree_models as the default NULL ? I think there's a bug there I need to fix. If you did leave it as NULL, could you try naming the ranks you want to model in a vector c("phylum", "class", ... etc)

Please let me know if this helps?

(likewise for the previous issues where I have responded to you with follow-up questions, I would really appreciate it if you could reply again with any updates, it would be very helpful for me as I keep improving microViz 🙂 )

Leran10 commented 2 years ago

Thanks for your reply, David, and I apologize for taking so long! Below is the code that I used:

CD.longitudinal.key <- taxatree_plotkey(
  data = CD.longitudinal.lm_models,
  taxon_renamer = function(x) stringr::str_remove(x, "[PFG]: "),
  rank == "Phylum" | rank == "Genus" & prevalence > 0.25,
  !grepl("Kingdom", taxon)
) + 
  scale_x_continuous(expand = expansion(mult = 0.2))

So as you can see I didn't leave rank parameter to NULL but set it to specific ranks.

BTW, microViz is a great tool and thanks for this excellent work.

Leran

david-barnett commented 1 year ago

improved robustness of taxatree plots in 0.10.2