grunwaldlab / metacoder

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

calc_obs_prop returns Nan when whole column is 0. #278

Open zachary-foster opened 4 years ago

zachary-foster commented 4 years ago

Would be more convenient to return 0 for the whole column, even if 0/0 = Nan

zachary-foster commented 4 years ago

Hello Johnny,

Yes, you can either convert the result to percentages (example below) or convert them when you plot (node_color = value * 100).

Make example data

x = parse_tax_data(hmp_otus, class_cols = "lineage", class_sep = ";", class_key = c(tax_rank = "taxon_rank", tax_name = "taxon_name"), class_regex = "^(.+)__(.+)$") props <- calc_obs_props(x, "tax_data", groups = hmp_samples$sex)

Convert proportions to %

props[, -1] <- props[, -1] * 100

Best,

Zach

On Sat, Sep 12, 2020 at 5:03 AM Johnny Konjarla notifications@github.com wrote:

Hi @zachary-foster https://github.com/zachary-foster Hope you are doing well. I have small doubt. Is it possible to convert result of calc_obs_props in percentage?. To represent(node_color) species composition under each family in percentage.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grunwaldlab/metacoder/issues/278#issuecomment-691477702, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOO6O5GSFHWVFMVN2H3CSTSFNPSVANCNFSM4JU4VCMQ .

-- Zachary S.L. Foster, PhD USDA Agricultural Research Service Corvallis, Oregon, USA