-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERRROR in heat_tree_matrix - missing value where TRUE/FALSE needed #240
Comments
Hello @Gian77! Can you please send me the data to reproduce this error? You can send part of the raw data and the code to reproduce the error or just use the |
Hello @zachary-foster, I had my data subsetted and I still have the same error. Please find the Thanks a lot for troubleshooting this, Gian |
Hi @Gian77, no problem, I think I fixed it. It was caused by the treatment columns being factors instead of characters. It should work with both factors and characters now. Try reinstalling the dev version and let me know if it still happens. Thanks! devtools::install_github("ropensci/taxa")
devtools::install_github("grunwaldlab/metacoder") |
Hi @zachary-foster, using the latest dev version I'm also seeing this or a similar issue when attempting to make a heat tree matrix from the attached
|
Hello @zachary-foster, I downloaded the dev version you have corrected and it worked. Thanks a lot for fixing it and for the great package. The only thing are a series of warnings that I think are not compromising the results of the analysis, what do you think?
Gian |
Hi Gian, Thanks! Im glad to hear its working. You can ignore those warnings. They will not cause any problems and they should be fixed in the most recent development version. |
Hi @zachary-foster, My issue is the following: I wanted to use DESeq2 instead of "compare_groups" for my 16S data, since I already use microbiomeSeq for the rest. I have 5 SampleType groups I want to compare in between (note: normal compare_means and heat_tree_matrix work). taxmap object:
testM represents concatenated output of DESeq2 as following:
Of the record, the same obj plots a heat_tree (of course not grouped). I continued to read other issues and I saw #195, changed the name "testM" to "diff_table", still no change. Thank you very much! |
Being on the matter, I have an additional question considering the filtering of the obj before passing it to heat_tree, that does not work if either node_size or node_color is not set to n_obs. My "obj" has 5 samples within.
I want to visualise taxons up until order, only for BAL with corresponding number of non-zero samples and average abundance
this gives a normal tree, but if I want to add filter until order, I have the following error message
This disappears if I change node_size to n_obs. Thank you very much in advance! |
Hello @Mirin1357, thanks for the kind words. DESeq issueYou seem to be doing it the right way. Its hard for me to say what exactly the problem is without being able to reproduce the error. Perhaps you don't have every combination of treatments or I noticed you used x = c('a', NA, 'NA')
x == 'NA'
#> [1] FALSE NA TRUE
is.na(x)
#> [1] FALSE TRUE FALSE Created on 2019-07-09 by the reprex package (v0.3.0) If you can email me the result of Filter obs issueYou probably want
You should be able to use the same code for |
Hi @zachary-foster, thank you very much for your reactivity! DESeqConsidering NA, I have accidentally omitted the lines where I check for NA before merging with obj, so here they are and their output. for being more logic, I replaced testM with deseq.tbl
I tried only a), only b) or both before adding to obj but did not work for the plot.
I tried also to do no modification on the deseq.tbl, add it to the obj as it is and pass the log2fold "filter" before plotting, did not work either.
I will send you the requested right away, and thank you for your help! Filter obsThank you for the suggestion, I have tried but I still have the same error. a) no filter -> works
b) filter -> does not work
c) filter + n_obs for node_size & node_color -> works
d) filter + 1 n_obs & obj$data$tax_occ$BAL (but obj$data$mean_perc$BAL defined in the obj -> not working
e) filter + 1 n_obs & obj$data$tax_occ$BAL (other not defined in the obj) -> works
However, I have managed to surpass the problem by creating individual obj for each sample from the beginning. Also, I renamed one "BAL" call to other word, so no need to use the longer expression for precision. |
Thanks for the data, I will look at it today. In regards to the filtering problem: I think it is because filtered_obj <- taxa::filter_taxa(taxon_ranks == "o", supertaxa = TRUE)
heat_tree(filtered_obj,
node_size = filtered_obj$data$tax_occ$BAL,
node_color = filtered_obj$data$mean_perc$BAL,
node_label = taxon_names,
node_size_axis_label = "Samples with reads",
node_color_axis_label = "Average percentage",
layout = "davidson-harel",
initial_layout = "reingold-tilford") If that does not work, make sure that |
Hi @Mirin1357, I found out what the problem was. The 'LUNG.T vs LUNG.DP' comparison has twice the number of values per taxon and there is no data for the 'LUNG.PT vs. LUNG.T' comparison. > table(paste(obj$data$diff_table$treatment_1, obj$data$diff_table$treatment_2))
BAL SALIVA LUNG.DP BAL LUNG.DP SALIVA LUNG.PT BAL LUNG.PT LUNG.DP LUNG.PT SALIVA LUNG.T BAL
354 354 354 354 354 354 354
LUNG.T LUNG.DP LUNG.T SALIVA
708 354 I have added a check to the
So that should be easier to figure out in the future. You can install the development version with that error message if you want: install.packages("devtools")
devtools::install_github("grunwaldlab/metacoder") |
Hello @zachary-foster, DESeqI rechecked the code for comparisons, and indeed, I have found one misspelled sample name, resulting in lack of 1 comparison and twice of the other. Then I used your suggestion to verify, and all was neet and the code ran without any further issues!!!! FilteringI tried your suggestion, but unfortunately, it did not work. passing taxon_ranks (filtered_obj) and taxon_ranks (obj) show good filtering, but proceeding to heat_tree gives following error:
however, both object appear exactly the same with print function (I do not know if this is normal), and the number of taxons is the same between tax_occ, mean_perc and tax_abund
I have also tried to filter before defining tax_occ or mean_perc, did not work. Only pure filtered_obj works. since this is however the subject of another issue, should I move the comments there? |
Ahh, I forgot, if you want to filter per-taxon data using filtered_obj <- taxa::filter_taxa(obj, taxon_ranks == "o", supertaxa = TRUE, reassign_obs = FALSE)
heat_tree(filtered_obj,
node_size = filtered_obj$data$tax_occ$BAL,
node_color = filtered_obj$data$mean_perc$BAL,
node_label = taxon_names,
node_size_axis_label = "Samples with reads",
node_color_axis_label = "Average percentage",
layout = "davidson-harel",
initial_layout = "reingold-tilford") However, this will also remove rows in the filtered_obj <- taxa::filter_taxa(obj, taxon_ranks == "o", supertaxa = TRUE,
reassign_obs = c(tax_abund = FALSE, tax_occ = FALSE, mean_perc = FALSE))
heat_tree(filtered_obj,
node_size = filtered_obj$data$tax_occ$BAL,
node_color = filtered_obj$data$mean_perc$BAL,
node_label = taxon_names,
node_size_axis_label = "Samples with reads",
node_color_axis_label = "Average percentage",
layout = "davidson-harel",
initial_layout = "reingold-tilford") |
Hello @zachary-foster , thank you for the solution! It works flawless for both examples! Of course, I would never thought of it... Thank you very much for your help in both problems, I hope it will also be useful to others. Best regards and great job for the package once again! |
Im glad it worked out. Thanks! |
Hello,
I am new with this package. I have tibble with a variable that contain 3 levels (treatments). I am trying to plot differential heat trees that shows differential abundances between the different treatments. However, I encountered the following error:
> obj$data$diff_table
# A tibble: 5,094 x 7taxon_id treatment_1 treatment_2 log2_median_ratio median_diff mean_diff wilcox_p_value
1 aab Picea Abies 0.0915 2165 2439. 0.0487
2 aac Picea Abies 0.268 3500. 3794. 0.02063 aad Picea Abies -0.112 -329 -594. 0.339
4 aae Picea Abies -0.00217 -9.5 -87.4 0.8675 aaf Picea Abies -0.367 -424. -365. 0.358
6 aag Picea Abies -0.774 -346. -337. 0.1737 aah Picea Abies 0 0 21.4 0.0853
8 aai Picea Abies 0 0 6.28 0.08629 aaj Picea Abies -0.205 -9 -5.69 0.697
10 aak Picea Abies -0.157 -54.5 -26.3 0.493# ... with 5,084 more rows
>> heat_tree_matrix(obj,
+ dataset = "diff_table",+ 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 OTUs",+ node_color_axis_label = "Log2 ratio median proportions")
Error in if (zero_range(as.numeric(limits))) { :missing value where TRUE/FALSE needed
In addition: There were 50 or more warnings (use warnings() to see the first 50)`>
Thank you for helping on this,
Gian
The text was updated successfully, but these errors were encountered: