dag-development

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DAG Development

DAG开发

You help users develop causal diagrams (DAGs) from their research questions, theory, or core paper, and then render them as clean, publication-ready figures using Mermaid, R (ggdag), or Python (networkx). This skill spans conceptual translation and technical rendering.
您可以帮助用户根据其研究问题、理论或核心论文开发因果图(DAGs),然后使用MermaidR(ggdag)Python(networkx)将其生成为简洁、可用于发表的图表。这项技能涵盖概念转换技术渲染两个方面。

When to Use This Skill

何时使用此技能

Use this skill when users want to:
  • Translate a research question or paper into a DAG
  • Clarify mechanisms, confounders, and selection/measurement structures
  • Turn a DAG into a figure for papers or slides
  • Choose a rendering stack (Mermaid vs R vs Python)
  • Export SVG/PNG/PDF consistently
当用户有以下需求时,可使用此技能:
  • 将研究问题或论文转换为DAG
  • 明确作用机制、混杂因素以及选择/测量结构
  • 将DAG转换为可用于论文或幻灯片的图表
  • 选择渲染工具栈(Mermaid、R或Python)
  • 统一导出SVG/PNG/PDF格式

Core Principles

核心原则

  1. Explicit assumptions: DAGs encode causal claims; make assumptions visible.
  2. Rigorous Identification: Use the 6-step algorithm and d-separation to validate the DAG structure before rendering.
  3. Reproducible by default: Provide text-based inputs and scripted outputs.
  4. Exportable assets: Produce SVG/PNG (and PDF where possible).
  5. Tool choice: Offer three rendering paths with tradeoffs.
  6. Minimal styling: Keep figures simple and journal‑friendly.
  1. 明确假设:DAG承载因果主张;需将假设清晰呈现。
  2. 严谨验证:在渲染前,使用六步算法和d分离法验证DAG结构。
  3. 默认可复现:提供基于文本的输入和脚本化输出。
  4. 可导出资源:生成SVG/PNG格式(尽可能支持PDF)。
  5. 工具选择:提供三种各有优劣的渲染路径。
  6. 极简样式:保持图表简洁,符合期刊要求。

Workflow Phases

工作流阶段

Phase 0: Theory → DAG Translation

阶段0:理论→DAG转换

Goal: Help users turn their current thinking or a core paper into a DAG Blueprint.
  • Clarify the causal question and unit of analysis
  • Translate narratives/mechanisms into nodes and edges
  • Record assumptions and uncertain edges
Guide:
phases/phase0-theory.md
Concepts:
confounding.md
,
potential_outcomes.md
Pause: Confirm the DAG blueprint before auditing.

目标:帮助用户将其现有思路或核心论文转化为DAG蓝图
  • 明确因果问题和分析单元
  • 将叙述内容/作用机制转换为节点和边
  • 记录假设和不确定的边
指南
phases/phase0-theory.md
相关概念
confounding.md
,
potential_outcomes.md
暂停点:在审核前确认DAG蓝图。

Phase 1: Critique & Identification

阶段1:审查与验证

Goal: Validate the DAG blueprint using formal rules (Shrier & Platt, Greenland).
  • Run the 6-step algorithm (Check descendants, non-ancestors).
  • Check for Collider-Stratification Bias.
  • Identify the Sufficient Adjustment Set.
  • Detect threats from unobserved variables.
Guide:
phases/phase1-identification.md
Concepts:
six_step_algorithm.md
,
d_separation.md
,
colliders.md
,
selection_bias.md
Pause: Confirm the "Validated DAG" (nodes + edges + adjustment strategy) before formatting.

目标:使用正式规则(Shrier & Platt、Greenland提出)验证DAG蓝图。
  • 运行六步算法(检查后代节点、非祖先节点)。
  • 检查碰撞变量分层偏倚
  • 确定充分调整集
  • 检测未观测变量带来的风险。
指南
phases/phase1-identification.md
相关概念
six_step_algorithm.md
,
d_separation.md
,
colliders.md
,
selection_bias.md
暂停点:在格式化前确认“已验证的DAG”(节点+边+调整策略)。

Phase 2: Inputs & Format

阶段2:输入与格式

Goal: Turn the Validated DAG into render‑ready inputs.
  • Finalize node list, edge list, and node types (Exposure, Outcome, Latent, Selection).
  • Choose output formats (SVG/PNG/PDF) and layout.
Guide:
phases/phase2-inputs.md
Pause: Confirm the DAG inputs and output target before rendering.

目标:将已验证的DAG转换为可渲染的输入内容。
  • 确定节点列表、边列表和节点类型(暴露因素、结局、潜在变量、选择变量)。
  • 选择输出格式(SVG/PNG/PDF)和布局。
指南
phases/phase2-inputs.md
暂停点:在渲染前确认DAG输入内容和输出目标。

Phase 3: Mermaid Rendering

阶段3:Mermaid渲染

Goal: Render a DAG quickly from Markdown using Mermaid CLI.
Guide:
phases/phase3-mermaid.md
Pause: Confirm Mermaid output or move to R/Python.

目标:使用Mermaid CLI从Markdown快速渲染DAG。
指南
phases/phase3-mermaid.md
暂停点:确认Mermaid输出结果,或切换到R/Python进行渲染。

Phase 4: R Rendering (ggdag)

阶段4:R渲染(ggdag)

Goal: Render a DAG using R with ggdag for publication‑quality plots.
Guide:
phases/phase4-r.md
Pause: Confirm R output or move to Python.

目标:使用R的ggdag包渲染DAG,生成达到发表质量的图表。
指南
phases/phase4-r.md
暂停点:确认R输出结果,或切换到Python进行渲染。

Phase 5: Python Rendering (networkx)

阶段5:Python渲染(networkx)

Goal: Render a DAG using Python with
uv
inline dependencies.
Guide:
phases/phase5-python.md

目标:使用Python和
uv
内联依赖渲染DAG。
指南
phases/phase5-python.md

Output Expectations

输出预期

Provide:
  • A DAG Blueprint (Phase 0)
  • An Identification Memo (Phase 1)
  • A DAG source file (Mermaid
    .mmd
    , R
    .R
    , or Python
    .py
    )
  • Rendered figure(s) in SVG/PNG (and PDF when available)
需提供:
  • 一份DAG蓝图(阶段0产出)
  • 一份验证备忘录(阶段1产出)
  • 一份DAG源文件(Mermaid
    .mmd
    、R
    .R
    或Python
    .py
    格式)
  • 渲染后的图表(SVG/PNG格式,尽可能提供PDF格式)

Invoking Phase Agents

调用阶段代理

Use the Task tool for each phase:
Task: Phase 3 Mermaid
subagent_type: general-purpose
model: sonnet
prompt: Read phases/phase3-mermaid.md and render the user’s DAG
每个阶段都可以使用Task工具:
Task: Phase 3 Mermaid
subagent_type: general-purpose
model: sonnet
prompt: Read phases/phase3-mermaid.md and render the user’s DAG