skembel / picante

R tools for integrating phylogenies and ecology

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PD rooted/unrooted NULL error

damioresegun opened this issue · comments

Hi,
I'm trying to run pd within a command to set up a dataframe (see below) but I'm having issues with pd. A quick breakdown:

  1. My phylogenetic tree was generated using a R package called 'mia' and then added to my data object (with otu etc)
  2. The combined phylo data was then converted into a phyloseq object for analysis
  3. The phylogenetic tree was rooted using ape and a function to determine an outgroup

So when I run the command:

data.frame("Observed" = estimate_richness(AlphaCombRare, measures = "Observed"),
                  "Shannon" = estimate_richness(AlphaCombRare, measures = "Shannon"),
                  "PD" = pd(samp = data.frame(t(data.frame(otu_table(AlphaCombRare)))), 
                  tree = phy_tree(AlphaCombRare),include.root = TRUE)[,1],
                  "Region" = sample_data(AlphaCombRare)$REGION)

I get the error:
Error in UseMethod("is.rooted") : no applicable method for 'is.rooted' applied to an object of class "NULL"

I also tried with include.root = FALSE just in case that could help. The dataframe is made however, the pd calculation ends up being 0 for all my isolates:

       Observed  Shannon PD Region
P25307     4728 7.598848  0   Fife
P25708     4442 7.402825  0   Fife
P25825     4836 7.632431  0   Fife
P27584     4655 7.432215  0   Fife
P35790     4823 7.466226  0 London
P35791     5055 7.596144  0 London

However, I also get these warnings:

In drop.tip(tree, treeabsent) :
  drop all tips of the tree: returning NULL
4: In drop.tip(tree, treeabsent) :
  drop all tips of the tree: returning NULL
5: In drop.tip(tree, treeabsent) :
  drop all tips of the tree: returning NULL
6: In drop.tip(tree, treeabsent) :
  drop all tips of the tree: returning NULL
7: In drop.tip(tree, treeabsent) :
  drop all tips of the tree: returning NULL
8: In drop.tip(tree, treeabsent) :
  drop all tips of the tree: returning NULL

So I dont know what could be causing this. Any suggestions?

@damioresegun, did you ever get this sorted out? I just ran into the same error.

Hi, the error message seems to indicate that the phylo object is empty. Can you attach the data object to help with troubleshooting this issue?

Thanks for the quick response @skembel! Just sorted it out. Interestingly my phylo object was there (and rooted), and the error seemed to be due to passing an OTU table that was species x samples instead of samples x species.

Moving from

pd(samp = t(data.frame(ps@otu_table@.Data)),
   tree = ps@phy_tree)

to

pd(samp = data.frame(ps@otu_table@.Data),
   tree = ps@phy_tree)

resolved the error and returned a range of non-zero PD values.