Skip to content

[Bug] get_tss_annotation_from_ensembl produces pyarrow.lib.ArrowTypeError when chromosome column contains mixed types #229

Description

@BDBGenomics

Describe the bug
The get_tss_annotation_from_ensembl function crashes with a pyarrow.lib.ArrowTypeError when BioMart returns chromosome identifiers as mixed types — some rows come back as strings, others as integers. The pyarrow conversion downstream doesn't handle this and throws before a TSS BED file is produced. This blocks the official human cerebellum tutorial at cell [17] on a clean install.
To Reproduce
Follow the official tutorial at pycistopic.readthedocs.io/en/latest/notebooks/human_cerebellum.html up to cell [17]:
pythontss_annotation = get_tss_annotation_from_ensembl(
biomart_name="hsapiens_gene_ensembl",
biomart_host="http://www.ensembl.org/",
transcript_type=["protein_coding"],
use_cache=True
)
Error output
/miniconda3/envs/scenicplus/lib/python3.11/site-packages/pybiomart/dataset.py:269: DtypeWarning: ...
pyarrow.lib.ArrowTypeError: Expected bytes, got a 'int' object
Expected behavior
TSS annotation BED file is produced and the tutorial proceeds to the next cell without error.
Screenshots
N/A — error is fully reproducible from the traceback above.
Version:

Python: 3.11
pycisTopic: v1.0.2
pybiomart: latest via scenicplus conda env
pyarrow: installed as scenicplus dependency

Additional context
The fix is likely a one-liner — explicitly casting the chromosome column to str before the pyarrow conversion step, since BioMart inconsistently returns chromosome names as mixed int/str types depending on the genome build. A similar type-casting issue was seen in create_cistopic_object_from_fragments (#201), suggesting this is a recurring pattern in the fragment-processing code worth auditing more broadly.
Happy to submit a PR with the fix if the maintainers can confirm the root cause location in the source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions