1 year ago

#207737

test-img

Geomicro

phyloCorrelogram() issues

I've been struggling with phyCorrelogram() from the package phylobase. I have received a myriad of errors this past month, and I have come full circle with the first error again. (yay) I am enormously grateful for any help.

The phyloseq object physeq is available here: https://www.dropbox.com/s/6o0kbvnbq632v9j/physeq.rds?dl=0 for a reproducible example.

I begin with a phylo object from the package phyloseq and my first goal is to ensure my tree does not contain NAs, and that the format is numeric with no missing values.

library(phylobase) 
#access tree from phyloseq object    
    tree <- phy_tree(physeq)

#confirm phlyo format
#should be numeric with no missing values (should all be "true")
num.check <- as.data.frame(check.numeric(tree$edge.length))

#find any NAs (would print "missing")
for(i in 1:length(tree$edge)) {
  
  if (is.na(tree$edge[i])) {
    print('Missing')
  }
}

My second goal is to organize associated metadata. The following code addresses previous errors by converting the taxonomic information (tax_table) to a matrix.

#access taxonomic information from phyloseq object
tax_table <- (as.data.frame(tax_table(physeq)))
tax_table <- tax_table[-c(5:7)]
tax_table <- lapply(tax_table, as.numeric)
tax_table <- model.matrix(~ Kingdom + Phylum +
                            Class + Order, data=tax_table)

#access metadata from phyloseq object
sample_data <- as.list(sample_data(physeq))
sample_data <- lapply(sample_data, as.numeric)

My third goal is to convert my phylo tree to a phylo4d object then add my metadata and taxonomic information.

#convert phylo tree to phylo4d
g1_try <- as(tree, "phylo4")

#add metadata
g2_try <- phylo4d(g1_try, tax_table, missing.data="warn", metadata = sample_data)

Finally, I attempt phyloCorrelogram()

#stats
pc_try <- phyloCorrelogram(g2_try)

This yields me the error:

Error in if (const(t, min(1e-08, mean(t, na.rm = TRUE)/1e+06))) { : 
  missing value where TRUE/FALSE needed

Which was the first error I received when I began work a month ago. Supposedly my code above addresses all previous errors, but it's clear I'm fundamentally misunderstanding this process. TIA.

r

phylogeny

phyloseq

0 Answers

Your Answer

Accepted video resources