Rhtslib is an R package that provides the C
library for high-throughput sequence data analysis. The library
provides APIs for creating, indexing, manipulating, and analyzing data
in SAM/BAM/CRAM sequence files and VCF/BCF2 variant files. See the
HTSlib website for complete details and
The Rhtslib package is primarily useful to developers of other R packages who want to use the HTSlib facilities in the C code of their own packages.
The version of the included HTSlib is displayed at package load time,
but a user can also query the HTSlib version directly by calling
Rhtslib:::htsVersion() in an R session. The current version of the
package is 1.15.1.
Effort is made to update the included version of HTSlib with minor version releases from the HTSlib authors. If you notice the included HTSlib is older than the current minor release of HTSlib, please contact the Rhtslib maintainer.
There are several advantages to using
Rhtslib, rather than requiring
an explicit user system dependency on
Rhtslibmeans that your users (who are not always sophisticated system administrators) do not need to manually install their own library.
htslib, so that you as a developer can rely on presence of specific features (and bugs!) rather than writing code to manage different library versions.
for an example of a package that compiles and links against
In order for the C/C++ compiler to find HTSlib headers (and zlib
headers on Windows) during installation of your package, you must
zlibbioc to the
LinkingTo field of its
DESCRIPTION file, e.g.,
LinkingTo: Rhtslib, zlibbioc
Note that as of R 3.0.2
LinkingTo values can include version
LinkingTo: Rhtslib (>= 0.99.10).
In C or C++ code files, use standard techniques, e.g.,
#include "htslib/hts.h". Header files are available for perusal at (enter
in an R session)
##  "/tmp/Rtmp8vI6qu/Rinst24e26411715845/Rhtslib/include"
Rhtslib provides both static and dynamic library versions of HTSlib
on Linux and Mac OS X platforms, but only the static version on
Windows. The procedure above will link against the static library
version of HTSlib on all platforms.