QuantGen / BEDMatrix

A matrix-like wrapper around PLINK .bed files
Other
18 stars 2 forks source link

error message on convertIndex #19

Closed rosieli5 closed 5 years ago

rosieli5 commented 5 years ago

Hi there,

When I typed

mat <- BEDMatrix("test.bed")
mat[1:2,1:2]

I received the following error message:

Error in convertIndex(x, i, "i", allowDoubles = allowDoubles) :
  could not find function "convertIndex"

Any suggestions? Thanks!

Best, Rosie

agrueneberg commented 5 years ago

Hi Rosie,

could you please let me know what versions of the BEDMatrix package and its dependency, the crochet package (which contains the convertIndex function), you are using? You can copy and paste the following two lines into an R session:

packageVersion("BEDMatrix")
packageVersion("crochet")

Thanks, Alex

rosieli5 commented 5 years ago

Hi Alex, here are the package versions below. Thank you!

Best, Rosie

> packageVersion("BEDMatrix",lib.loc=pkgpath)
[1] ‘1.4.1’
> packageVersion("crochet",lib.loc=pkgpath)
[1] ‘2.1.0’
agrueneberg commented 5 years ago

Weird, crochet 2.1.0 should definitely contain the convertIndex function--it's even exported. What happens if you load the crochet package before the BEDMatrix package and run your example again?

library("crochet", lib.loc = pkgpath)
library("BEDMatrix", lib.loc = pkgpath)
mat <- BEDMatrix("test.bed")
mat[1:2,1:2]
rosieli5 commented 5 years ago

Aha, it worked. Thanks Alex!

Best, Rosie

agrueneberg commented 5 years ago

You shouldn't have to load the crochet package manually, though... What version of R are you using? You can figure that out by copy and pasting version$version.string into your R session.

rosieli5 commented 5 years ago

True, not having to load it each time would be better. I have R version 3.5.1 (2018-07-02).

agrueneberg commented 5 years ago

Sorry, I cannot reproduce the problem on my end. Can you reproduce the problem on your end if you run the following code in a new R session?

pkgpath <- "please_fill_in"
library("BEDMatrix", lib.loc = pkgpath)
mat <- BEDMatrix("test.bed")
mat[1:2,1:2]
rosieli5 commented 5 years ago

I got the following message. Hmm it may be an issue with my environment?

Warning: namespace ‘crochet’ is not available and has been replaced
by .GlobalEnv when processing object ‘’
Error in convertIndex(x, i, "i", allowDoubles = allowDoubles) :
  could not find function "convertIndex"
agrueneberg commented 5 years ago

Sounds like there is a workspace image (a hidden file called .RData) in the directory from which you start your R session. You can either delete or rename the file before starting R, start R with the --no-restore option, run rm(list = ls()) after starting R, or start R from a different directory to get a clean environment.

rosieli5 commented 5 years ago

I tried rm(list=ls()), but it didn't seem to have worked. Thanks still!