metacoder icon indicating copy to clipboard operation
metacoder copied to clipboard

How to increase the text size for lineage names in heat_tree

Open taowis opened this issue 4 years ago • 4 comments

How to increase the text size for lineage names in heat_tree? The text is too small to recognize.

taowis avatar Jul 27 '21 07:07 taowis

Look at this and let me know if you still have questions about it.

https://grunwaldlab.github.io/metacoder_documentation/faq.html#the-labels-are-too-small

zachary-foster avatar Jul 27 '21 17:07 zachary-foster

I have related question. Is there a way to only print the labels on terminal nodes? Or maybe an arbitrary set of taxon levels, such as Genus, Family, and Order? Also, is there any way to change font for different taxon levels? Thanks!

mcddna avatar Feb 07 '24 18:02 mcddna

See the below sample for the first two questions. To change font, im not sure. It uses ggplot2 under the hood, so perhaps any way to encode font in strings that work for ggplot2 might work, but I have not tried.

library(metacoder)
#> This is metacoder version 0.3.6 (stable)

x = parse_tax_data(hmp_otus, class_cols = "lineage", class_sep = ";",
                   class_key = c(tax_rank = "taxon_rank", tax_name = "taxon_name"),
                   class_regex = "^(.+)__(.+)$")

heat_tree(x,
          node_label = ifelse(is_leaf, taxon_names, ""),
          node_size = n_obs,
          node_color = n_obs)



heat_tree(x,
          node_label =ifelse(taxon_ranks %in% c("g", "f", "o"), taxon_names, ""),
          node_size = n_obs,
          node_color = n_obs)

Created on 2024-02-07 with reprex v2.1.0

zachary-foster avatar Feb 07 '24 21:02 zachary-foster

Thanks so much zachary-foster! I used a clunky regular expression code, and it had some problems. This is perfect, for first question. I'll try playing with ggplot2, thanks for letting me know that is what is "under the hood". :)

mcddna avatar Feb 07 '24 23:02 mcddna