Open zachary-foster opened 5 years ago
Hello, thanks!
You can use counts_to_presence
to convert the output of calc_taxon_abund
and then specify colours manually using the result of that in heat_tree
. See example below and let me know f you have questions .
library(metacoder)
#> Loading required package: taxa
#> This is metacoder verison 0.3.4 (stable)
x = parse_tax_data(hmp_otus, class_cols = "lineage", class_sep = ";",
class_key = c(tax_rank = "taxon_rank", tax_name = "taxon_name"),
class_regex = "^(.+)__(.+)$")
x$data$tax_abund <- calc_taxon_abund(x, "tax_data", groups = hmp_samples$body_site, cols = hmp_samples$sample_id)
#> Summing per-taxon counts from 50 columns in 5 groups for 174 taxa
x$data$tax_abund <- counts_to_presence(x, "tax_abund")
#> No `cols` specified, so using all numeric columns:
#> Nose, Saliva, Skin, Stool, Throat
heat_tree(x, node_label = taxon_names, node_size = n_obs, node_color = ifelse(Saliva, "red", "grey"))
Created on 2020-07-16 by the reprex package (v0.3.0)
Hi @zachary-foster, Thanks for the above example. I tried above steps on my data and it worked. But I like to understand, is it required to use calc_taxon_abund for converting to presence absence matrix. As my data is not abundance data, its purely presence/absence data, so still do i need to follow it. How it is working? kindly make me to understand.
Thank you
If you data is TRUE
/FALSE
, its counting the number of TRUE
s, since in R, TRUE
is the same as 1
and FALSE
is 0
. I am about to leave for camping for a few days, but I can help more after.
Hi @zachary-foster, I like to thank for developing metacoder package. Its really awesome. I am presently working with presence/absence data to plot heat tree. I used calc_taxon_abund for presence/absence data to generate tax_table for further calculating difference between groups w.r.t presence/absence. Is this approach is correct? Or is there any other way to plot presence/absence data directly using heat_tree (I don't want to use heat_tree_matrix). Also i like to understand when using counts_to_presence, data is arranging in TRUE/FALSE (logical class) w.r.t presence/absence, so with this data can we generate heat tree? as it is taking only numerical data to plot. Please help me in understanding this.
Thanks in advance.