DSEP is a command-line tool written in Rust for analyzing causal graphs using d-separation — a graphical criterion for determining conditional independence in Directed Acyclic Graphs (DAGs). It is aimed at researchers, epidemiologists, and statisticians who work with causal diagrams and need to identify confounding paths, validate adjustment sets, or find minimal separating sets between variables.
Given a causal DAG specification (e.g., a->b->c or
exposure<-confounder->outcome), DSEP can:
- Parse and construct a causal DAG from a concise arrow notation (
->,<-) - Classify nodes as Exposure (input), Outcome, Adjustment, or Unknown
- Validate adjustment sets: check whether a given set of conditioning variables d-separates the exposure from the outcome
- Find minimal d-separating sets: identify the smallest set of variables that blocks all paths between two nodes
- Visualize the DAG as a color-coded SVG diagram
- Read DAG definitions from command-line arguments, files, or standard input
# Check if adjusting for {Z} identifies the effect of X on Y in X -> Z -> Y
# (it does not for the total effect, since Z is a mediator; it does for the direct effect)
dsep "X->Z->Y" -e X -o Y -a Z --check-adjustment
dsep "X->Z->Y" -e X -o Y -a Z --check-adjustment --effect direct
# Find a minimal adjustment set for the total effect (the default)
dsep "X<-U->Y;X->M->Y" -e X -o Y --min-adjustment
# ...or for the direct effect, which also blocks paths through mediators
dsep "X<-U->Y;X->M->Y" -e X -o Y --min-adjustment --effect direct
# Generate an SVG visualization
dsep "X->Z->Y" --svg-file-name diagram.svgClone the repository and cd into it:
git clone https://github.com/wilswer/dsep.git && cd dsepInstall using cargo:
cargo install --path .