Skip to content

Convert: pycistopic CistopicObject pickles #28

Closed

Description

@Claptar

Part of #20. Depends on #21.

Constraints

  • A CistopicObject is a Python pickle of pycisTopic.cistopic_class.CistopicObject. Unpickling needs pycistopic installed (and its scipy/pandas stack) and executes arbitrary code from the file.
  • Put it behind an optional extra (pyadata-cli[pycistopic]), import lazily with a clear error when missing, require an explicit --from pycistopic, and document the security caveat.
  • Alternative to evaluate: run the unpickling in a subprocess via uv run --with pycisTopic so the core install stays clean and heavy deps never land in the main environment.

Mapping

CistopicObject AnnData
fragment_matrix (scipy sparse, regions × cells) X as cells × regions CSR
binary_matrix layers["binary"]
cell_names, cell_data obs_names, obs
region_names, region_data var_names, var
selected_model.cell_topic obsm["X_topic"]
selected_model.topic_region varm["topic_region"]
selected_model metrics / parameters uns["pycistopic"]["model"]
projections obsm["X_<name>"]
project, path_to_fragments uns["pycistopic"]

Plan

Unpickle → write through the elements.write helpers. This path is necessarily in memory (the pickle is); document that clearly.

Tests

Fixture pickled in a uv run --with pycisTopic subprocess under the integration marker; check shapes, names and topic matrices.

Activity

  1. added a commit that references this issue on Oct 21, 2026
  2. Claptar commented on Oct 21, 2026

    @Claptar
    ContributorAuthor

    Done in #67, released in 0.14.0. adata convert cistopic_obj.pkl -o atac.h5ad reads a CistopicObject (fragment and binary matrices, cell and region data, the selected model's topics, projections, and the rest in uns["pycistopic"]) and a CistopicImputedFeatures, without pycisTopic: an allowlisted unpickler refuses any global such an object never holds, so nothing in the file runs. pandas and scipy come with pip install 'pyadata-cli[pickle]'; the Docker image has them. Checked against GEO GSE292438's pickle (pycisTopic's pandas 1.5), converted under pandas 2.2 and 3 in CI.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions