Skip to content

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

@Transmystical

Description

@Transmystical

Hi,

R-studio version: 1.3.1093
MetacodeR version: 0.3.4

First I want to complement you on this package - it is absolutely beautiful and we have published a paper already using your beautiful heat trees. I am now analyzing a different data-set and I keep running into the same error when trying to run the heat_tree_matrix command.

I have ran the following code in R:
parsed <- parse_tax_data(Genus2_summed, class_cols = c("Root", "Phylum", "Class", "Order", "Family", "Genus"))
parsed$data$otu_props <- calc_obs_props(parsed, data = "tax_data", cols = sample_data$Sample)
parsed_raw$data$tax_abund <- calc_taxon_abund(parsed, data = "otu_props", cols = sample_data$Sample)

Where sample_data is a df with:
sample_data$Sample = names of my samples (column names of my Genus2_summed after the Genus column)
sample_data$CO2_factor = a blend of words 'Bottom' and Top' - like - rep("Bottom", 34) and rep("Top", 34).

#Making the diff_table
parsed_raw$data$diff_table <- compare_groups(parsed, data = "tax_abund", cols = sample_ids, groups = sample_data$CO2_factor)

Note: This makes diff_table w/out issue and I am able to access it via:

parsed$data$diff_table - and it has column names of: taxon_id, treatment_1, treatment_2, log2_median_ratio, median_diff, mean_diff, and wilcox_p_value

However, when I try to graph it, it wont graph no matter how many times I re-run the code or try different things:

#Graphing
parsed_raw %>% filter_taxa(taxon_names != "NA", supertaxa = TRUE) %>% heat_tree_matrix(data = "diff_table", node_size = n_obs, node_label = taxon_names, node_color = log2_median_ratio)

It gives me the following error:

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

I have tried to graph this way as well:
`parsed_raw %>%
filter_taxa(taxon_names != "NA", supertaxa = TRUE) %>%
mutate_obs("diff_table", log2_median_ratio = ifelse(wilcox_p_value <= 0.05,
log2_median_ratio, 0)) %>%
heat_tree_matrix(data = "diff_table",

It still gives me the same error:

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

Note: If i run this code, it runs w/out issue at all and I get a nice heat tree
parsed %>% filter_taxa(taxon_names != "NA", supertaxa = TRUE) %>% heat_tree(node_size = n_obs, node_color = n_obs, node_label = taxon_names, node_label_max = 500, layout = "da", initial_layout = "re")

I am at a complete loss - any idea what could be causing this error?

Thank you very much for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions