R integration

Two ways to use rsx from R: the in-process rsxr package (preferred), or subprocess calls to the rsx CLI for existing RADSex-style pipelines.

1 Preferred: rsxr (in-process C API)

Install from the monorepo subdirectory (needs cargo; see rsx-r/README.md):

pak::pak("HaoZeke/rsx-rs/rsx-r")
# or: remotes::install_github("HaoZeke/rsx-rs", subdir = "rsx-r")
library(rsxr)
rsx_version()

High-level workflow returns tibbles:

mt <- marker_table("markers.tsv")
triaged <- triage(mt, popmap = "popmap.tsv", min_depth = 10L)
sig     <- signif_markers(mt, popmap = "popmap.tsv", test = "fisher")

Full install notes, vignette, and CI badges: rsx-r/README.md. Language matrix and Python comparison:

Language bindings

2 RADSex output compatibility

rsx produces byte-identical TSV to C++ RADSex when groups are specified explicitly (-G M,F / group1 / group2). Existing R helpers that read RADSex marker tables, distributions, or alignments keep working without changes.

3 Subprocess CLI (legacy / orchestration)

Build the binary once (pixi or cargo), then call it from R:

system2("rsx", c(
  "distrib",
  "-t", "data/markers_table.tsv",
  "-p", "data/popmap.tsv",
  "-o", "data/distribution.tsv",
  "-d", "5", "-G", "M,F"
))

Example pixi task that ensures rsx is on PATH:

build-rsx = """bash -c 'if ! command -v rsx >/dev/null 2>&1; then \
  cargo install --path /path/to/rsx-rs/rsx-cli; fi'"""

Prefer rsxr when you want tibbles and no intermediate process; prefer the CLI when a scheduler or Snakemake rule already shells out to rsx.