Skip to content
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

Using MetacodeR with Sourmash LCA output #246

Closed
shigdon opened this issue Aug 19, 2018 · 3 comments
Closed

Using MetacodeR with Sourmash LCA output #246

shigdon opened this issue Aug 19, 2018 · 3 comments

Comments

@shigdon
Copy link

shigdon commented Aug 19, 2018

Hello @zachary-foster,

I have microbial classification data that was generated using Sourmash, and now I would like to visualize with metacoder. I am struggling to read in the taxmap object file based on the input csv file format. The data I am trying to read in as a taxmap object has the following format (sample_id, superkingdom, phylum, class, order, family, genus, species).

Here are two example lines within my output file:

172,Bacteria,Proteobacteria,Gammaproteobacteria,Enterobacterales,Enterobacteriaceae,,
173,Bacteria,Proteobacteria,Gammaproteobacteria,Enterobacterales,Enterobacteriaceae,,

What I wish to do is count the number of observations for each level of taxonomic classification across all of my samples and visualize the number of observations for each classification level within my population of sequenced microbial isolates.

I have been trying to learn by following your https://cran.r-project.org/web/packages/metacoder/vignettes/introduction.html, but my data does not seem to be in the same format as the hmp_otus file.

Is there a way to use metacoder and taxa to parse the sourmash classification data I have described to generate counts that can be visualized as a heat tree, or do I need to somehow generate counts first?

@zachary-foster
Copy link
Contributor

HEllo @shigdon,

Try this:

library(metacoder)
library(readr)
 
raw_data <- read_csv(file = "my/file/path")

obj <- parse_tax_data(raw_data, class_cols = 2:8)

n_obs(obj, "tax_data") # Count number of rows in table for each taxon

heat_tree(obj,
          node_label = taxon_names,
          node_size = n_obs,
          node_color = n_obs)

Let me know if you have problems

@shigdon
Copy link
Author

shigdon commented Aug 20, 2018

Thank you very much @zachary-foster ! I now have a beautiful starting point for the plot. I will continue to use and explore the features of this package!

@zachary-foster
Copy link
Contributor

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants