0
votes

I'm getting an error when running make_work from the "vegan" R package:

net <- make_network(ps)

Error in .C("veg_distance", x = as.double(x), nr = N, nc = ncol(x), d = double(N *  : 
"veg_distance" not available for .C() for package "vegan"

Here is my sesion info:

R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] vegan_2.5-1             lattice_0.20-35         permute_0.9-4          
[4] phyloseqGraphTest_0.0.1 ggplot2_2.2.1           phyloseq_1.22.3 

I've seen the other cases related to this error, which advised to uninstall and re-install vegan, which I did (hence the recent update to the package), to no avail.

4
Firstly, there is no command make_work() or make_network() in vegan: you must be using some other package. Secondly, veg_distance() cannot be called like that in vegan_2.5-1 (it needs .Call() instead of .C()). Thirdly, you should not call the compiled code from your package, but you should call the R function vegan::vegdist(). You seem to have a problem with some external package or script. Both CRAN and we checked the vegan 2.5-1 does not break dependent packages, but check the package from which your found make_network() command.Jari Oksanen
@JariOksanen I'm pretty sure this (calling C code from outside a pkg) is not allowed by CRAN and hasn't been for a very long time.Gavin Simpson
@GavinSimpson I was thinking the same, but it happened... and I was baffled. The error message had a call .C("veg_distance", ...) although there was no such a line in vegan 2.5-1. I assumed it was in some other function. However, the situation seems to be that when vegan was upgraded to 2.5-1, phyloseq kept R functions of older vegan (2.4-x) and did not upgrade them. The compiled library was still upgraded and there is a mismatch between compiled library and phyloseq copies of vegan functions. I don't know if this copy was made in build, install or load time.Jari Oksanen
@GavinSimpson it seems that when you make a S4 generic from a function in another package, the original function is made as the default method for that new S4 generic. When you build a binary or install that new package with the S4 generic, the original function is copied to the new package. So there was a copy of 2.4-6 version of vegan::vegdist in phyloseq, and when vegan was upgraded to 2.5-1 the compiled library changed to 2.5-1 interface, and the old phyloseq version failed.Jari Oksanen

4 Answers

1
votes

This is most likely an issue with phyloseq interacting with vegan internals -- at least a similar issue has been reported both in vegan and in phyloseq in github. The alternatives seem to be:

  1. You can try if re-installing phyloseq (to the same version) after vegan 2.5-1 update will help: it seems that phyloseq saves the vegan function when it is installed or built (either, I don't know), and it will use that private version even when vegan changes.
  2. Downgrade vegan to 2.4-6 which is the newest version with the old internals (that were also used in phyloseq).
  3. Wait till the issue is fixed in phyloseq.
  4. If possible, try to find a way to go around the problem.
0
votes

I had the same problem (with another function from phyloseq, ordinate()), and think I got it to work. People discussed it in great detail: https://github.com/joey711/phyloseq/issues/921. I'll leave here what has worked for me, after reading cjfields's advice on the page linked above.

# First get stringi straight
install.packages("stringi", configure.args="--disable-pkg-config")
library(stringi)
packageVersion("stringi")
# Vegan
install.packages("vegan")
library(vegan)
packageVersion('vegan') #should be 2.5-1 (or more recent, if someone reads this later)
# Phyloseq. Install the latest version from github (the version on other repos may still have the bug)
library("devtools")
install_github("joey711/phyloseq")
library(phyloseq)
packageVersion('phyloseq')

Before this, I tried downgrading vegan and installing phyloseq again, with no success.

0
votes

Install phyloseq from github. It fixes the issue.

library("devtools")

install_github("joey711/phyloseq")

packageVersion('phyloseq')

[1] ‘1.23.1’

0
votes

I don't know about that R version, but for R 3.3.3, I downgraded to vegan 2.4.2 and this solved it. I also needed to downgrade to ape 4.0 for an ape incompatibility with older phyloseq. I was unable to upgrade phyloseq with devtools due to biocgenerics 0.22 being required.