Python and R Bindings
Tetrad includes an extensive Java implementation of causal discovery algorithms, scores, tests, data structures, and utilities.
To make this functionality easier to use from other programming environments, we provide official Python and R bindings that directly interface with the Java core.
These bindings allow researchers to access the full power of the Java Tetrad engine while working in Python or R.
py-tetrad (Python Binding)
Repository:
👉 https://github.com/cmu-phil/py-tetrad
py-tetrad is the official Python interface to the Tetrad Java codebase. It exposes:
Full access to Tetrad causal discovery algorithms (PC, FCI, GFCI, BOSS, GRaSP, etc.)
Scores, independence tests, and utilities
Graph objects and graph manipulation APIs
Dense and sparse matrix tools
Simulation modules
Seamless conversion between Python data structures (NumPy arrays, pandas DataFrames) and Tetrad
DataSets
py-tetrad is ideal when you want to:
Use Tetrad’s Java algorithms from Python
Access algorithms not included in native-Python packages
Ensure feature parity with Tetrad GUI / Java library
Run algorithms at Java-level performance, especially for large datasets
rpy-tetrad (R Binding)
Repository:
👉 https://github.com/cmu-phil/py-tetrad/tree/main/pytetrad/R
rpy-tetrad provides an R interface built on the py-tetrad infrastructure. It lets R users:
Call Tetrad Java search algorithms directly from R
Pass R data frames into the Java Tetrad backend
Retrieve graphs, adjustment sets, statistics, and scores into R
Script large-scale analyses using familiar R workflows
rpy-tetrad is recommended if you:
Work primarily in R but want direct access to Tetrad’s Java engine
Need methods not implemented in R packages such as
pcalg,dagitty, orbnlearnWant consistent results across GUI, Java, Python, and R contexts
When to Use These Bindings
Use py-tetrad or rpy-tetrad when:
You need exact behavior from Tetrad’s Java implementation
(e.g., FGES, FCI variants, BOSS, GRaSP, FCIT, BF-BIC, BF-LRT, O-sets, RA, etc.)You want algorithms or features not implemented natively in Python or R
You want to call Tetrad from another language but retain:
Same parameters
Same scoring behavior
Same PAG/CPDAG semantics
Same orientation rules
Same simulation procedures
In short:
If your work depends on the Tetrad Java engine, these bindings are the intended way to access it.