grunwaldlab / grunwaldlab/metacoder

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

Open
#301 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
148
Forks
30
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied parsed_raw pipeline and compare the working heat_tree call with heat_tree_matrix. Start at the heat_tree_matrix entry point and trace how diff_table produces layout_matrix before the apply error. Done means identifying why the matrix has no positive dimensions and confirming that the reported heat_tree_matrix example runs successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.