cBioFormatter v0.1.0
First public release of cbioformatter, a Python package for assembling cBioPortal-compatible studies from pandas DataFrames, with offline validation against cBioPortal's official validator.
Installation
pip install cbioformatteror with uv:
uv add cbioformatterRequires Python 3.10 or newer.
Highlights
ClinicalStudyAPI: feed in sample and patient DataFrames, get a validated, cBioPortal-compatible study directory. Auto-generates patient data andPATIENT_IDs when not supplied.- Clinical data handling: column name cleaning, data type inference (
NUMBER/BOOLEAN/STRING), uniqueness and referential-integrity checks, and OncoTree cancer-type validation against a bundled code snapshot (no runtime API dependency). - File generation:
ClinicalStudy.write_files()producesmeta_study.txt, patient/sample meta and data files with the 4-line cBioPortal header, and acase_lists/cases_all.txtcase list. - Local validation:
ClinicalStudy.validate()wraps the official cBioPortalvalidateData.pywith--no_portal_checksfor fully offline validation. The validator is cloned and cached on first use;CBIOFORMATTER_VALIDATOR_PATHoverrides the location for air-gapped or CI environments.
Quick start
import pandas as pd
from cbioformatter import ClinicalStudy
study = ClinicalStudy(
study_id="my_study",
name="My Study",
description="A short description",
cancer_type="brca",
sample_data=sample_df,
patient_data=patient_df,
)
result = study.validate()
study.write_files(output_dir="./studies")See the README for a fuller walkthrough.
What's next
- v0.2: cBioPortal study upload to a running local instance (#42).
- v0.3: mutation data processing via vcf2maf (#19).
- See the open issues for the full backlog.
Full changelog
See CHANGELOG.md for the complete list of changes.
Feedback
Please file an issue if you hit problems or have feature requests.