Skip to content

Exclude labels of lowest taxon_rank  #367

Open
@fionnualabulman

Description

Hello and thanks for the great package.

I am producing a heat tree matrix of differential relative abundances in fungal taxa. I would like to display differences in taxa down to the order rank, however including the labels for this rank makes the figure unreadable. Is there a way to exclude all labels for this rank only (keeping labels for class, phyla & kingdom)?

I have read the FAQ "The labels are too small!" but hope there is another option instead of selectively suppressing them with "dont_print".

I have tried to filter "cleaned_names" for taxon_ranks = "o" but this produces an error as the vectors are no longer the same length:

obj %>%
+   metacoder::filter_taxa(taxon_ranks == "o", supertaxa = TRUE, reassign_obs = c(diff_table = FALSE)) %>%
+   mutate_obs("cleaned_names", 
+              gsub(taxon_names, pattern = "\\[|\\]", replacement = "")) %>%
+   filter_obs("cleaned_names", taxon_ranks != "o") %>%
+   metacoder::filter_taxa(grepl(cleaned_names, pattern = "^[a-zA-Z]+$"), reassign_obs = c(diff_table = FALSE)) %>%
+   heat_tree_matrix(data = "diff_table",
+                    node_label = cleaned_names,
+                    node_label_size = 7 * (n_obs / max(n_obs)),  # Adjust based on the number of OTUs
+                    node_size = n_obs,
+                    node_color = log2_median_ratio, # difference between groups
+                    node_color_trans = "linear",
+                    node_color_interval = c(-3, 3), # symmetric interval
+                    edge_color_interval = c(-3, 3), # symmetric interval
+                    node_color_range = c("cyan", "gray", "magenta"), # The color palette used
+                    node_color_axis_label = "Log 2 ratio of median counts",
+                    node_size_axis_label = "Number of OTUs",
+                    node_size_range = c(0.02, 0.04),
+                    node_label_size_range = c(0.02, 0.04),
+                    layout = "da", initial_layout = "re",
+                    key_size = 0.67,
+                    seed = 2)
Adding a new "character" vector of length 162.
Error: TRUE/FALSE vector (length = 57) must be the same length as the number of taxa (162)

Thanks for your help with this.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions