grunwaldlab / metacoder

Parsing, Manipulation, and Visualization of Metabarcoding/Taxonomic data
http://grunwaldlab.github.io/metacoder_documentation
Other
134 stars 28 forks source link

How to increase the text size for lineage names in heat_tree #315

Open biosciences opened 2 years ago

biosciences commented 2 years ago

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

zachary-foster commented 2 years ago

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

mcddna commented 5 months ago

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!

zachary-foster commented 5 months ago

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

mcddna commented 5 months ago

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". :)