从比较系统发育学的两个数据帧在 R 中创建比较对象
Creating a compartive object in R from two dataframes for comparitive phylogenetics
我正在尝试将两个数据帧读入一个比较对象,以便我可以使用 pgls 绘制它们。
我不确定返回的错误是什么意思,以及如何摆脱它。
我的代码:
library(ape)
library(geiger)
library(caper)
taxatree <- read.nexus("taxonomyforzeldospecies.nex")
LWEVIYRcombodata <- read.csv("LWEVIYR.csv")
LWEVIYRcombodataPGLS <-data.frame(LWEVIYRcombodata$Sum.of.percentage,OGT=LWEVIYRcombodata$OGT, Species=LWEVIYRcombodata$Species)
comp.dat <- comparative.data(taxatree, LWEVIYRcombodataPGLS, "Species")
Returns 错误:
> comp.dat <- comparative.data(taxatree, LWEVIYRcombodataPGLS, 'Species')
Error in if (tabulate(phy$edge[, 1])[ntips + 1] > 2) FALSE else TRUE :
missing value where TRUE/FALSE needed
这可能来自您的数据集,并且您的系统发育存在一些 comparative.data
难以处理的差异(通过错误消息的外观)。
您可以尝试使用 dispRity::clean.data
:
清理数据集和树
library(dispRity)
## Reading the data
taxatree <- read.nexus("taxonomyforzeldospecies.nex")
LWEVIYRcombodata <- read.csv("LWEVIYR.csv")
LWEVIYRcombodataPGLS <- data.frame(LWEVIYRcombodata$Sum.of.percentage,OGT=LWEVIYRcombodata$OGT, Species=LWEVIYRcombodata$Species)
## Cleaning the data
cleaned_data <- clean.data(LWEVIYRcombodataPGLS, taxatree)
## Preparing the comparative data object
comp.dat <- comparative.data(cleaned_data$tree, cleaned_data$data, "Species")
但是,正如@MrFlick 所建议的,如果没有可重现的示例,很难知道这是否解决了问题。
这里的错误是我使用的是一个nexus文件,虽然?comparitive.data
没有指定它应该使用哪个phylo对象,newick树似乎工作正常,而nexus文件没有。
我正在尝试将两个数据帧读入一个比较对象,以便我可以使用 pgls 绘制它们。
我不确定返回的错误是什么意思,以及如何摆脱它。
我的代码:
library(ape)
library(geiger)
library(caper)
taxatree <- read.nexus("taxonomyforzeldospecies.nex")
LWEVIYRcombodata <- read.csv("LWEVIYR.csv")
LWEVIYRcombodataPGLS <-data.frame(LWEVIYRcombodata$Sum.of.percentage,OGT=LWEVIYRcombodata$OGT, Species=LWEVIYRcombodata$Species)
comp.dat <- comparative.data(taxatree, LWEVIYRcombodataPGLS, "Species")
Returns 错误:
> comp.dat <- comparative.data(taxatree, LWEVIYRcombodataPGLS, 'Species')
Error in if (tabulate(phy$edge[, 1])[ntips + 1] > 2) FALSE else TRUE :
missing value where TRUE/FALSE needed
这可能来自您的数据集,并且您的系统发育存在一些 comparative.data
难以处理的差异(通过错误消息的外观)。
您可以尝试使用 dispRity::clean.data
:
library(dispRity)
## Reading the data
taxatree <- read.nexus("taxonomyforzeldospecies.nex")
LWEVIYRcombodata <- read.csv("LWEVIYR.csv")
LWEVIYRcombodataPGLS <- data.frame(LWEVIYRcombodata$Sum.of.percentage,OGT=LWEVIYRcombodata$OGT, Species=LWEVIYRcombodata$Species)
## Cleaning the data
cleaned_data <- clean.data(LWEVIYRcombodataPGLS, taxatree)
## Preparing the comparative data object
comp.dat <- comparative.data(cleaned_data$tree, cleaned_data$data, "Species")
但是,正如@MrFlick 所建议的,如果没有可重现的示例,很难知道这是否解决了问题。
这里的错误是我使用的是一个nexus文件,虽然?comparitive.data
没有指定它应该使用哪个phylo对象,newick树似乎工作正常,而nexus文件没有。