I'm exploring some bioinformatics data and I like to use R notebooks (i.e. Rmarkdown) when I can. Right now, I need to use a command line tool to analyze a VCF file and I would like to do it through a Bash code chunk in the Rmarkdown notebook.
The problem is that the command I want to use was installed with conda
into my conda environment. The tool is bcftools
. When I try to access this command, I get this error (code chunk commented out to show rmarkdown code chunk format):
#```{bash}
bcftools view -H test.vcf.gz
#```
/var/folders/9l/phf62p1s0cxgnzp4hgl7hy8h0000gn/T/RtmplzEvEh/chunk-code-6869322acde0.txt: line 3: bcftools: command not found
Whereas if I run from Terminal, I get output (using conda environment called "binfo"):
> bcftools view -H test.vcf.gz | head -n 3
chr10 78484538 . A C . PASS DP=57;SOMATIC;SS=2;SSC=16;GPV=1;SPV=0.024109 GT:GQ:DP:RD:AD:FREQ:DP4 0/0:.:34:33:0:0%:0,33,0,0 0/1:.:23:19:4:17.39%:1,18,0,4
chr12 4333138 . G T . PASS DP=119;SOMATIC;SS=2;SSC=14;GPV=1;SPV=0.034921 GT:GQ:DP:RD:AD:FREQ:DP4 0/0:.:72:71:1:1.39%:71,0,1,0 0/1:.:47:42:5:10.64%:42,0,5,0
chr15 75086860 . C T . PASS DP=28;SOMATIC;SS=2;SSC=18;GPV=1;SPV=0.013095 GT:GQ:DP:RD:AD:FREQ:DP4 0/0:.:15:15:0:0%:4,11,0,0 0/1:.:13:8:5:38.46%:5,3,1,4
(binfo)
So, how do I access tools installed with conda/in my conda env from an R notebook/Rmarkdown bash code chunk? I searched for quite a while and could not find anyone talking about running conda
commands in a shell chunk in Rmarkdown. Any help would be appreciated because I like the R notebook format for exploratory analysis.