Trying my hand on a heat_tree_matrix but getting an error

39 views
Skip to first unread message

swa...@gmail.com

unread,
Apr 2, 2020, 4:25:08 PM4/2/20
to metacoder
I'm currently using a simple parse_phyloseq
to see if I can make some heat trees.
Following a script by Marieag, I've managed to generate a heat tree comparing treatments.
But as soon as I try to move on to a heat-tree_matrix, Im getting a

Error in apply(layout_matrix, MARGIN = 2, function(x) all(is.na(x))) :
  dim
(X) must have a positive length

Any help would be much appreciated.

Zachary Foster

unread,
Apr 2, 2020, 4:41:51 PM4/2/20
to metacoder
Hi,

Can you send me the object your are giving to heat_tree_matrix using saveRDS? Your code would be useful too.

Best,

Zach

swa...@gmail.com

unread,
Apr 2, 2020, 4:51:14 PM4/2/20
to metacoder
 
 Here's the rds file and im trying out the following:

heat_tree(obj$filter_taxa(taxon_names == "Bacteria", subtaxa = TRUE),
          node_label = taxon_names,
          node_size = n_obs,
          node_color = log2_median_ratio, 
          node_color_range = c("purple", "grey95", "orange"),
          node_size_axis_label = "species count",
          node_color_axis_label = "Log 2 ratio of median proportions",
          layout = "davidson-harel",
          initial_layout = "reingold-tilford",
          title = "Orange = Higher Abundance in control\n Purple = Higher Abundance in marinas",
          title_size = 0.05,
          edge_label_size_range = c(1,5))

which gives me a decent (albeit overly wordy) heat tree
But moving to 
heat_tree_matrix(obj$filter_taxa(taxon_names == "Bacteria", subtaxa = TRUE),
                 data = "diff_table",
                 node_size = n_obs,
                 node_label = taxon_names,
                 node_color = log2_median_ratio,
                 #                node_color_range = set_3_rb,
                 node_color_range = c("purple", "gray95", "orange"),
                 node_size_axis_label = "species count",
                 layout = "davidson-harel",
                 initial_layout = "reingold-tilford",
                 node_color_axis_label = "Log2 ratio median proportions")

results in the mentioned error. Im assuming my data is just not properly formatted, which Ive worked around earlier but now Im not sure how to interpret the error.

swa...@gmail.com

unread,
Apr 6, 2020, 4:48:42 AM4/6/20
to metacoder
Hey Zachary,

Assuming you've figured it out. Something just worked at the end after a quick reboot and update of the package.
Perhaps something I just missed.

There's another thing though. I fear my ps to taxmap wasn't entirely elegant, and Im trying to have the heat_tree_matrix to compare different groups using my obj$data$sample_data
I've been searching around but I keep bumping into the problem of not having these columns in sample_data in my $otu_table, but even adding those then did not make it work.

The heatmatrixtree, after obj$data$diff_table <- compare_groups(obj, data = "tax_abund", cols = obj$data$sample_data$sample_id, groups = BAY), gave me a nice matrix that compared every BAY with eachother.
The next thing i'm trying to accomplish is to have it compare every CONTROL BAY against MARINA BAY, instead of simply every BAY.

I'm quite new to this so please excuse my rookie questions.

Zachary Foster

unread,
Apr 7, 2020, 6:03:44 PM4/7/20
to metacoder
Hi,

Sorry for the delay. So your original problem went away? So I still need to look into that?

heat_tree_matrix only plots all pair wise plot currently, so I am not sure how you would plot only specific comparisons. I would probably make a simple function to plot a single tree with a comparsion of a matina bay vs a control bay and loop over that and combine the plots with a pacakge like cowplot or gridExtra. Does that sound reasonable?

Best,

Zach

swa...@gmail.com

unread,
Apr 7, 2020, 11:38:10 PM4/7/20
to metacoder
Yeah the original problem was just in trying to plot a tree matrix when my data only had two variables (control vs marina) where all individual samples lost their identifiers.

The error code was just a bit cryptic to me.

On the new topic: there isn't a way to use the "combinations" to indicate different sets.
It'd already be great if i could get the tree matrix to only compare control vs marina samples..

Zachary Foster

unread,
Apr 9, 2020, 10:34:07 PM4/9/20
to metacoder
Hi Sven,

Here is an example of basically making your own plot like heat_tree_matrix, but this method will allow you more control over what it is plotted and how it is formatted. See attached Rmd and its output. Let me know if you have questions.

Best,

Zach
example.pdf
example.Rmd

swa...@gmail.com

unread,
Apr 13, 2020, 10:04:19 AM4/13/20
to metacoder
Hi Zachary,

Sorry for the late response. Thanks a lot this! I'll get on it after Easter!
Reply all
Reply to author
Forward
0 new messages