gtonkinhill / fastbaps

A fast approximation to a Dirichlet Process Mixture model (DPM) for clustering genetic data
MIT License
58 stars 8 forks source link

Index out of bounds #22

Closed pedrosenna closed 2 years ago

pedrosenna commented 2 years ago

Hi,

I was testing fastbaps with mitochondrial DNA sequences and these errors popped out when running some functions. Here's an example:

library(ape)
library(fastbaps)

data("woodmouse")

wood.sparse <- import_fasta_sparse_nt(woodmouse)
wood.sparse.optim <- optimise_prior(wood.sparse, type="optimise.baps")

Error in tree_llk(temp.sparse.data, temp.h$merge) : Mat::operator(): index out of bounds

baps.res <- fast_baps(wood.sparse)

[1] "Calculating initial clustering..." [1] "Calculating initial dk values..." [1] "Clustering using hierarchical Bayesian clustering..." Error in bhier_parallel(sparse.data, initial.partition, dk.initial, n.cores) : Mat::operator(): index out of bounds

What can i do?

gtonkinhill commented 2 years ago

Hi Pedro,

Thanks very much for pointing this out. This turned out to be due to inconsistencies in the way fastbaps handles data loaded directly using the import_fasta_sparse_nt function and indirectly using ape. In the latter case, if the alignment included gaps or Ns the subsequent functions would crash.

I have now pushed an update that should hopefully fix this issue.

gtonkinhill commented 2 years ago

These updates are now available in the latest release (v1.0.8)