removing taxa with missing names in heat_tree display

103 views
Skip to first unread message

brandily...@gmail.com

unread,
May 31, 2019, 12:29:45 PM5/31/19
to metacoder
Hi!
For better visualization of my heat tree (inserted below), I want to remove taxa that are missing names. I'm not so familiar with the nomenclature so please excuse my long-winded explanation. 
I want to remove these taxa from the tree display only (i.e. not removed from internal calculation of n_obs), and I want to keep each tree branch in the display up until it is missing a name. For example, if I have a taxa that has a name up until and including genus level, I only want to remove the species node that doesn't have a name, and keep the branch until genus. Or, if I have a taxa that has a name up until and including family level, I only want to remove the genus and species nodes with missing names, and keep the branch until family. I hope that makes sense!

I've tried using taxa::filter_taxa with various inputs but no success. Any advice? I'm happy to share my files via email for reproducibility. Thank you!!!

treephys2=parse_phyloseq(treephys7)
treephys2$data$otu_table <- calc_obs_props(treephys2,
                                    data = "otu_table",
                                   cols = treephys2$data$sample_data$SampleID)
treephys2$data$tax_table <- calc_taxon_abund(treephys2, 
                                       data = "otu_table", 
                                       cols = treephys2$data$sample_data$SampleID)
treephys2$data$diff_table <- compare_groups(treephys2,
                                      data = "tax_table",
                                      cols = treephys2$data$sample_data$SampleID, 
                                      groups = treephys2$data$sample_data$race4)
color_interval <- c(-.045, .045)
treephys2 %>%
  taxa::filter_taxa(taxon_names == "Bacteria", subtaxa = TRUE) %>%
  #taxa::filter_taxa(taxon_names!="",reassign_obs=TRUE) %>%    #something like this? but this does not work
  #taxa::filter_taxa(!is.na(taxon_names),reassign_obs=TRUE) %>%    #something like this? but this does not work
  heat_tree(node_size_axis_label = "Number of OTUs",
            node_size = n_obs,
            node_color_axis_label = "mean difference",
            node_color = mean_diff,
            node_color_range = diverging_palette(),
            node_color_trans = "linear",
           node_color_interval = color_interval,
           edge_color_interval = color_interval,
            node_label = taxon_names,
            node_label_max = 150)

metacoder_tree_ex.jpeg

Zachary Foster

unread,
May 31, 2019, 12:47:05 PM5/31/19
to metacoder
Hello,

It looks like you use filter_taxa right for this purpose. Do the taxa actually have missing names, or are the labels too small to be printed? If the labels are really small, they will not be printed. Try taxon_names(treephys2) to see a list of all the names to check for missing names if you have not already. If there are not missing names, you can increase the label size use the  node_label_size_range option to force the labels to be a specific size, in unites of proportion of total plot size.

You can also email me your data and I can take a look at it.

zacharyfoster1989 <at> gmail.com

Best,

Zach

brandily...@gmail.com

unread,
May 31, 2019, 1:18:50 PM5/31/19
to metacoder
Hi Zach,

Thanks for the quick response! This was exactly my problem. I'm still learning the package so I didn't know how to view the taxon_names nor realize they could be too small. Thanks, and thank you for metacoder! It is really great.

Brandi
Reply all
Reply to author
Forward
0 new messages