Skip to content

Check how gaia is using tskit/C++/R #141

Description

Activity

  1. gregorgorjanc commented on Aug 20, 2026

    @gregorgorjanc
    MemberAuthor

    gaia implements almost exactly the infrastructure RcppTskit is meant to centralise:

    • It vendors and compiles its own copy of tskit.

    • Its S4 treeseq object stores external pointers to both a tsk_treeseq_t and a current tsk_tree_t: treeseq_class.R.

    • It manually allocates, wraps, finalises, and frees those structures: tsk_treeseq_load.c.

    • It writes separate C wrappers that copy tskit tables into R data frames: tsk_table_nodes.c, tsk_table_edges.c.

    • Its application algorithms extract the native pointer and work directly with the tskit C API.

    • It currently carries tskit 1.1.2 in-tree, so it owns the ongoing upgrade and security burden.

    This validates RcppTskit’s basic design: downstream packages should be able to receive a TreeSequence$xptr, safely access tsk_treeseq_t in compiled code, and avoid implementing their own loader, finalisers, vendoring workflow, and routine wrappers.

    Concrete lessons for RcppTskit

    The largest missing downstream-oriented capability is tree iteration. gaia keeps a tsk_tree_t next to its tree sequence because its algorithms repeatedly traverse local trees. RcppTskit should eventually offer either:

    • a safe public C++ example for constructing and iterating tsk_tree_t from TreeSequence$xptr; or

    • an owned tree-iterator wrapper that preserves its parent tree sequence for its entire lifetime.

    The lifetime requirement matters: a child tree or iterator must not outlive the tree sequence it references.

    gaia also demonstrates the value of bulk table access. Returning nodes or edges as R data frames is useful for inspection and analysis.

  2. gregorgorjanc commented on Aug 20, 2026

    @gregorgorjanc
    MemberAuthor

    @LynxJinyangii implemented iterator in #132 so that would then cover the suggestions and I logged data.frame export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions