grunwaldlab / metacoder

Parsing, Manipulation, and Visualization of Metabarcoding/Taxonomic data
http://grunwaldlab.github.io/metacoder_documentation
Other
135 stars 28 forks source link

Set any differences to 0 that were not significant in metacoder #241

Closed laracp closed 6 years ago

laracp commented 6 years ago

Hi @zachary-foster I am currently running through the metacoder tutorial. At the end of the compare two groups section, there is a comment right after we test for significant differences between two groups:

"... but if there still were some significant differences, we could set any difference that is not significant to zero and repeat the last heat_tree command."

I can't seem to figure out how to set any differences to 0 that were not significant. I apologize if the code/answer is in a very obvious place.

To add to this, for the heat_tree_matrix, comparing multiple groups, do we also need to set non-significant differences to 0 in order to only visualize significant differences in the heat trees or will the heat_tree_matrix command already take this into account.

Many thanks for this wonderful R package!

-Lara

zachary-foster commented 6 years ago

Hi Lara,

Thanks for you kind words

I can't seem to figure out how to set any differences to 0 that were not significant. I apologize if the code/answer is in a very obvious place.

No problem. It be done like so:

obj$data$diff_table$wilcox_p_value[obj$data$diff_table$wilcox_p_value > 0.05] <- 0

To add to this, for the heat_tree_matrix, comparing multiple groups, do we also need to set non-significant differences to 0 in order to only visualize significant differences in the heat trees or will the heat_tree_matrix command already take this into account.

You need to do this yourself, since the heat_tree and heat_tree_matrix functions make no assumptions about what you are plotting, since they might be used for many different things.

laracp commented 6 years ago

Hi @zachary-foster,

Thank you for your reply and help!

I just ran the code and it appears to have set all of the p-values > 0.05 to 0 rather than the differences that were not significant to zero.

When I re-run the heat tree, it looks identical to the previous one before adjusting. I'm assuming we need to set non-significant log-2 ratio of median proportions to zero so they will not be plotted?

Would this be correct?

obj$data$diff_table$log2_median_ratio[obj$data$diff_table$wilcox_p_value > 0.05] <- 0

zachary-foster commented 6 years ago

Oh yea, sorry about that. Yes, I meant:

obj$data$diff_table$log2_median_ratio[obj$data$diff_table$wilcox_p_value > 0.05] <- 0
laracp commented 6 years ago

Wonderful! Thanks again for your fast replies and help. It is very much appreciated on this end.

-Lara

zachary-foster commented 6 years ago

No problem!