samtools loading in R
1
1
Entering edit mode
rbronste ▴ 60
@rbronste-12189
Last seen 5.4 years ago

Hi

Using a package that requires samtools and only finding Rsamtools from Bioconductor, have that loaded and getting the following error:

sh: samtools: command not found
Error in readBAMIndex(bamFile, refgenome = refgenome) : 
  Cannot run "samtools".  Install "samtools" first!

Is there a regular samtools package? Having trouble locating it. Thank you.

 

samtools rsamtools • 2.9k views
ADD COMMENT
0
Entering edit mode

I realize that this is a long shot, but did you ever find a fix to this? I'm getting the same error but samtools seems to be installed correctly. I can run it in terminal but R can't find it.

Cheers

ADD REPLY
0
Entering edit mode

The original answer still applies. If the package you are trying to use -- which package? -- requires the samtools application to be installed (and discoverable, so somewhere in specified by the PATH environment variable) then you'll need to install samtools independently of R. If you need help doing that, then probably you need to ask somewhere (biostars?) where there is more likely to be relevant expertise.

Alternatively, if you're trying to access or manipulate BAM files from within R, you might try the Rsamtools or GenomicAlignments (or VariantAnnotation, for VCF) packages.

ADD REPLY
0
Entering edit mode

This is obviously a very late answer but I had a similar error:

sh: samtools: command not found

sh: samtools: command not found

Warning message: In FUN(X[[i]], ...) : error in running command

And here is how I fixed it (in case someone ends up here years later like me):

For a bit of context, samtools was correctly installed via conda and I have been using it by itself. So I tried installing samtools again but this time using the installation described on the manual on the official website directly and it was working fine on my terminal; but still not with RStudio for a package that requires samtools.

So here is how you can make sure R is looking in the right directories where your tools are installed (type this in R):

Sys.getenv("PATH")

I noticed it did not contain any of the paths where samtools was installed. So using the following command you can add a directory to your PATH:

Sys.setenv(PATH = paste("/path/to/samtools", Sys.getenv("PATH"), sep=":"))

And that's as easy as that (but not obvious if you're not familiar with R like me)!

ADD REPLY
2
Entering edit mode
@martin-morgan-1513
Last seen 12 weeks ago
United States

samtools isn't R software, so you would have to install it independently of R. This might be 'hard' on Windows. But maybe the task that you want to accomplish doesn't require the package with the unfriendly dependency on samtools?

ADD COMMENT
0
Entering edit mode

I am using Mac OS, unfortunately no way around the R package I am using for this task so need to fix this error.

ADD REPLY

Login before adding your answer.

Traffic: 527 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6