grunwaldlab / metacoder

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

changes to tree size in heat tree matrix #271

Open maracashay opened 5 years ago

maracashay commented 5 years ago

Hi all,

I'm making heat tree matrices for ITS and 16S sequencing data. I like the matrix that was built for the ITS data but when using the same exact parameters for the 16S data, I get trees that are much smaller and more difficult to read. Is there a way to increase the size of the trees in the 16S matrix? Below is the code that I'm using for both matrices: heat_tree_matrix(ps.obj, data = "diff_table", key_size = 0.6, node_size = n_obs, node_label = taxon_names, node_color = log2_median_ratio, node_color_range = diverging_palette(), node_color_trans = "linear", node_color_interval = c(-3, 3), edge_color_interval = c(-3, 3), node_size_axis_label = "Number of ASVs", node_color_axis_label = "Log2 ratio median proportions", layout = "davidson-harel", # The primary layout algorithm initial_layout = "reingold-tilford", output_file = "differential_heat_tree-16s.pdf")

differential_heat_tree-ITS.pdf

differential_heat_tree-16S.pdf

zachary-foster commented 5 years ago

Hi @maracashay,

Yea, looks like you just have a lot of taxa, but there is a few things you can try. First off, check out the tips here:

https://grunwaldlab.github.io/metacoder_documentation/faq.html

Besides that, you can also manually specify the node size range with (e.g. node_size_range = c(0.01, 0.03) )

Your best bet will be to filter out taxa not relevant to the figure, such as those with low read counts or that have no significant differences between any treatments.

If this is for publication, you might consider filtering out any taxon with odd names (e.g. "IMCC26256", "Gitt−GS−136"), since these are not likely to be interesting to most readers. node_label = ifelse(grepl(taxon_names, '^[a-zA-Z ]+$'), taxon_names, NA) should do it. You could make an alternative version of the figure that includes those taxa and put it in the supplements for those who are interested.

I hope that helps!

maracashay commented 5 years ago

Zach,

Thanks for the input! I figured out what was causing the issue. My otu table included both bacteria and archaea and although the archaeal tree is small, it is splitting off to the side, causing my bacterial tree to show up small. So, I cut out the archaea and now have an appropriately sized network of bacteria.

I will also implement the suggested change regarding filtering out taxa with strange names. Great idea!

Cheers!

zachary-foster commented 5 years ago

Oh, nice, I did not notice the archea off to the side. Also, I realized the code I showed you:

node_label = ifelse(grepl(taxon_names, '^[a-zA-Z ]+$'), taxon_names, NA)

will not print those names, but the taxa will still be there. To remove the taxa (what I intended to suggest) you need something like:

ps.obj %>%
   filter_taxa(grepl(taxon_names, '^[a-zA-Z ]+$'), reassign_obs = c(diff_table
= FALSE) %>%
   heat_tree_matrix(...)