gmteunisse / fantaxtic

Fantaxtic - Nested Bar Plots for Phyloseq Data
26 stars 3 forks source link

{X} values required in clr.pal, {<X} provided #34

Closed lxsteiner closed 4 months ago

lxsteiner commented 4 months ago

Hi,

In plot_nested_bar with certain combinations of top and nested tax levels, depending on the previously selected number of top taxa, I keep getting the following error:

Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l,  : 
  Error: 13 values required in clr.pal, 11 provided.

The number of required and provided values keeps changing, depending on the taxonomic levels chosen. I guess it has to do with how many colors and their shades would need to be displayed?

> top_asv <- top_taxa(hpa4k, n_taxa = 20)
> plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
+                 top_level = "Phylum", nested_level = "Class") + 
+   facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) + 
+   theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1))
> plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
+                 top_level = "Class", nested_level = "Order") + 
+   facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) + 
+   theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1))
> plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
+                 top_level = "Order", nested_level = "Family") + 
+   facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) + 
+   theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1))
Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l,  : 
  Error: 14 values required in clr.pal, 13 provided.
> plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
+                 top_level = "Family", nested_level = "Genus") + 
+   facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) + 
+   theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1))
Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l,  : 
  Error: 16 values required in clr.pal, 15 provided.
> plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
+                 top_level = "Order", nested_level = "Genus") + 
+   facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) + 
+   theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1))
Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l,  : 
  Error: 14 values required in clr.pal, 13 provided.
> plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
+                 top_level = "Class", nested_level = "Genus") + 
+   facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) + 
+   theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1))

In the last examples, Genus as nested level is only possible with top level Class.

Could you please explain what exactly that error means? Thanks.

gmteunisse commented 4 months ago

Thanks for your issue. Could you post a minimal reproducible example so I can figure out what could be the problem? A screenshot of your tax_table(top_asv$ps_obj) could also help.


From: LXS @.> Sent: Wednesday, June 5, 2024 3:20:37 PM To: gmteunisse/fantaxtic @.> Cc: Subscribed @.***> Subject: [gmteunisse/fantaxtic] {X} values required in clr.pal, {<X} provided (Issue #34)

Hi,

In plot_nested_bar with certain combinations of top and nested tax levels, depending on the previously selected number of top taxa, I keep getting the following error:

Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l, : Error: 13 values required in clr.pal, 11 provided.

The number of required and provided values keeps changing, depending on the taxonomic levels chosen. I guess it has to do with how many colors and their shades would need to be displayed.

top_asv <- top_taxa(hpa4k, n_taxa = 20) plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,

  • top_level = "Phylum", nested_level = "Class") +
  • facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) +
  • theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1)) plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
  • top_level = "Class", nested_level = "Order") +
  • facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) +
  • theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1)) plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
  • top_level = "Order", nested_level = "Family") +
  • facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) +
  • theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1)) Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l, : Error: 14 values required in clr.pal, 13 provided. plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
  • top_level = "Family", nested_level = "Genus") +
  • facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) +
  • theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1)) Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l, : Error: 16 values required in clr.pal, 15 provided. plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
  • top_level = "Order", nested_level = "Genus") +
  • facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) +
  • theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1)) Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l, : Error: 14 values required in clr.pal, 13 provided. plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
  • top_level = "Class", nested_level = "Genus") +
  • facet_wrap(~Duration + Month, scales = "free_x", nrow = 1) +
  • theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1))

In the last examples, Genus as nested level is only possible with top level Class.

Could you please explain what exactly that error means? Thanks.

— Reply to this email directly, view it on GitHubhttps://github.com/gmteunisse/fantaxtic/issues/34, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHBWS3U42IWDMJBNGDPX7TTZF4GCLAVCNFSM6AAAAABI2WYZKGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTKOBZHAZDSNI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

lxsteiner commented 4 months ago

Sorry, here are features and taxonomy .qza files I used.

library(qiime2R)
library(phyloseq)
library(fantaxtic)

hpa4k <- qza_to_phyloseq(
  features = "dada2-table-grouped_decont-nocont-min2-noMitChl2-noUna_4462.qza",
  taxonomy = "dada2-silva138v3v4-taxonomy_decont-nocont-min2-noMitChl2-noUna_4462.qza"
)

top_asv <- top_taxa(hpa4k, n_taxa = 10)
plot_nested_bar(ps_obj = top_asv$ps_obj, asv_as_id = T,
                top_level = "Family", nested_level = "Genus") + 
  theme(legend.key.size = unit(10, "points")) + guides(fill = guide_legend(ncol = 1))

gives:

Error in nested_palette(data, group, subgroup, gradient_type, min_l, max_l,  : 
  Error: 9 values required in clr.pal, 8 provided.

Thanks.

gmteunisse commented 4 months ago

I found an issue with the code, I've now fixed it. Please reinstall the package and let me know whether that fixes your issue.

lxsteiner commented 3 months ago

Works now. Thanks!