【问题标题】:unable to find an inherited method for function ‘UniFrac’ for signature ‘"phylo"’无法为签名“phylo”找到函数“UniFrac”的继承方法
【发布时间】:2020-04-10 12:46:39
【问题描述】:
library(tidyverse)
library(ape)
library(phyloseq)

unifrac_unweighted <- UniFrac(tree, weighted = F)

Fehler in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘UniFrac’ for signature ‘"phylo"’
3.
stop(gettextf("unable to find an inherited method for function %s for signature %s", sQuote(fdef@generic), sQuote(cnames)), domain = NA)
2.
(function (classes, fdef, mtable) { methods <- .findInheritedMethods(classes, fdef, mtable) if (length(methods) == 1L) ...
1.
UniFrac(tree_BLS, weighted = T)

tree 是一棵系统发育树(用class(tree) 证明)。 我已经尝试重新安装 phyloseq,但它没有帮助。如何避免这个错误?

【问题讨论】:

    标签: r ape-phylo


    【解决方案1】:

    UniFrac 函数需要一个phyloseq 对象:

    physeq: (Required). ‘phyloseq-class’, containing at minimum a
              phylogenetic tree (‘phylo-class’) and contingency table
              (‘otu_table-class’). See examples below for coercions that
              might be necessary
    

    不太确定这对您是否有意义,但不妨考虑以下示例。关键是要正确构造phyloseq对象,我不确定的部分是如何构造otu_table,我设置了taxa_are_row=FALSE

    #you get a tree
    sample_tree = rtree(20,tip.label=letters[1:20])
    
    # there are counts associated with each sample in tree
    sample_counts = matrix(rnbinom(100*20,mu=20,size=1),
    ncol=20,dimnames=list(1:100,letters[1:20]))
    
    x1 = phyloseq(
    otu_table(sample_counts,taxa_are_row=FALSE), 
    sample_tree)
    
    UniFrac(x1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多