0

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.

  • 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 Apr 17 '18 at 18:54
  • @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 Apr 18 '18 at 03:53
  • @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 Apr 18 '18 at 06:11
  • @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 Apr 20 '18 at 07:55

4 Answers4

1

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.
Jari Oksanen
  • 3,287
  • 1
  • 11
  • 15
  • Thanks for the tips. I attempted to install and reinstall phyloseq, to no avail. I am going to attempt the downgrade next, and if not, try to find another work around. I appreciate the response! – Samantha Sevilla Apr 20 '18 at 04:36
  • You need to install **phyloseq** from the source files. If you cannot do, you must wait till a new build version of **phyloseq** is published in the Bioconductor. While waiting, you only choice is to downgrade **vegan** to version 2.4-6 that is compatible with your **phyloseq** – Jari Oksanen Apr 20 '18 at 05:51
0

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.

Melinda
  • 107
  • 1
  • 6
0

Install phyloseq from github. It fixes the issue.

library("devtools")

install_github("joey711/phyloseq")

packageVersion('phyloseq')

[1] ‘1.23.1’

pushkin
  • 9,575
  • 15
  • 51
  • 95
Carly MW
  • 21
  • 4
0

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.