richfitz / diversitree

diversitree: comparative phylogenetic analyses of diversification
http://www.zoology.ubc.ca/prog/diversitree
30 stars 9 forks source link

Multiple records with same name #11

Open mwpennell opened 9 years ago

mwpennell commented 9 years ago

When a vector contains multiple species with the same name, diversitree uses only the first observation. The correct behavior should be to throw an error. I just corrected this in geiger https://github.com/mwpennell/geiger-v2/commit/b7a7d458ccb798666401c3f592a55618c962277f

MWE

library(diversitree)

## simulate a continuous dataset
set.seed(1)
t <- tree.bd(c(1,0), max.taxa=10)
d <- sim.character(t,1)

## using the simulated dataset
lik <- make.bm(t,d)
lik(1)

## adding a species with same name to data
d2 <- c(d, "sp10"=1)
lik2 <- make.bm(t,d2)

## likelihood is the same
lik2(1)

## however, swapping order of species
d3 <- d2[c(1:9,11,10)]
lik3 <- make.bm(t,d3)

## different likelihood
lik3(1)
richfitz commented 9 years ago

Thanks Matt!

Possible fix following same type of bug in geiger: https://github.com/mwpennell/geiger-v2/commit/b7a7d458ccb798666401c3f592a55618c962277f