0

I am working to attach metadata to a phylo4d tree. I will start by saying I can attach my objects as a dropbox file, but if I am just misunderstanding the logic I'll save myself and everyone's time.

I start with a phyloseq object then extract the phylo tree. I remove the node labels because some overlap with the tip labels.

library(phylobase)
library(phylosignal)

#get the tree out of the phyloseq object 'physeq'
tree <- phy_tree(physeq)

#remove the node labels to correct non-unique tip label error
tree$node.label <- NULL

#remove appropriate metadata from the phyloseq object 'physeq'
otu_table <- otu_table(physeq) #sample ID x ASV ID
tax_table <- tax_table(physeq) #taxonomy x ASV ID
sample_data <- as.list(sample_data(physeq)) #list of relevant metadata (chemistry, location, etc)

#merge the tree and metadata and create a phylo4d object
tree_4d <- phylo4d(tree,metadata = list(sample_data))

#create a phylo correlogram of the phylo4d object
pc <- phyloCorrelogram(tree_4d, ci.bs = 1000, ci.conf = 0.95)

My occurring error is as follows, which I received my answer to earlier. I understand I must attach the metadata (which is sample_data) above, yet I am struggling.

Any help is greatly appreciated!

Geomicro
  • 303
  • 3
  • 13
  • 1
    Without the minimal, reproducible example, the problem is not replicable. My guess is that the code needs this change: `tree_4d <- phylo4d(tree,metadata = sample_data)`, because `sample_data` is already a list. – nya Jan 25 '22 at 11:49
  • Major, major face palm. Thank you so much, @nya – Geomicro Jan 25 '22 at 19:04

0 Answers0