Closed mr2raccoon closed 3 years ago
Greetings Mr. Raccoon II,
The node_label
option for heat_tree
must take a character vector of length equal to the number of taxa in exobj
. exobj
probably already has the taxon names if it was produced correctly, and these can be accessed in the heat_tree
function using taxon_names
. Does this work?
heat_tree(exobj, node_label=taxon_names, node_size= reads, node_color= reads)
You might also want to look at the examples in the function documentation by typing ?heat_tree
Thanks for getting back to me. I tried parsing my data from a phyloseq object now. I am still having trouble. I think it did not create the taxon names correctly. My taxmap object looks like this: `> metaphy
@zachary-foster Nevermind my last post I managed to draw the heat_tree now. I simply had to change "NA" to chr-value "unclassified". I managed to filter to show only "Fungi" even.
Two questions remian
How can I draw one heat tree per sample? I assume now it plots a heat tree for both samples together?
The n_obs does not seem to take the reads stored in the OTU-table but count the rows for observation. How can I assign n_obs correctly ?
metaobj <- parse_phyloseq(physeq_nano) metaobj%>% filter_taxa(taxon_names == "Fungi", subtaxa = TRUE) %>% heat_tree( node_label = taxon_names, node_size = n_obs, node_color = n_obs)
`
2 data sets:
otu_table:
# A tibble: 336 x 4
taxon_id otu_id MB5_2020_nano MB6_2020_nano
<chr> <chr> <dbl> <dbl>
1 bcg 1873960 178089 49468
2 bch 574774 41123 12172
3 bci 5606 34803 8956
# … with 333 more rows
tax_data:
# A tibble: 336 x 10
taxon_id otu_id superkingdom kingdom phylum class order family genus species
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 bcg 1873960 Eukaryota Fungi Ascomycota Dothideomycetes Capnodiales Mycosphaerellaceae Pseudocercospora Pseudocercospora fijiensis
2 bch 574774 Eukaryota Fungi Ascomycota Dothideomycetes unclassified Gloniaceae Glonium Glonium stellatum
3 bci 5606 Eukaryota Fungi Ascomycota unclassified unclassified unclassified Saitoella Saitoella complicata
# … with 333 more rows
0 functions:`
Hey, I followed the workshop (https://grunwaldlab.github.io/metacoder_documentation) and then tried to replicate what was done with my own data. Please note: I am still very much a beginner to programming and R in general.
I tried to create a heat tree and I receive the following error message:
library(metacoder) heat_tree(exobj, node_label=7:13, node_size= reads, node_color= reads)
Error in check_element_length(c("node_size", "edge_size", "node_label_size", : Length of argument'node_size' must be a factor of the length of 'taxon_id'
For note labels I used columns 7:13 stored in the object, from superkingdom to species. The column "reads" stores the number of reads from Illumina-sequencing for this one sample.
Creating "exobj" I did as follows:
`otu_data <- read.csv("mb5_2020_ill_OTU_counts.csv") tax_data <- read.csv("mb5_2020_ill_tax.csv")
com_data <- left_join(otu_data,tax_data, by=c("taxon_id"="taxon_id"))
exobj <- parse_tax_data(com_data, class_cols=7:13)`
Thank you in advance!