Skip to main content

flatiron-cleaner

flatiron-cleaner is a Python package that cleans Flatiron Health cancer datasets into analysis-ready formats, specifically designed with predictive modeling and survival analysis in mind. By automating complex and tedious data processing workflows, it helps researchers extract meaningful insights and ensure reproducible results while reducing preparation time.

Key features of the package include:

  • Providing a modular architecture that allows researchers to select which Flatiron files to process
  • Converting long-format dataframes into wide-format dataframes with unique PatientIDs per row
  • Ensuring appropriate data types for predictive modeling and statistical analysis
  • Standardizing data cleaning around a user-specified index date, such as metastatic diagnosis or treatment initiation
  • Engineering clinically relevant variables for analysis

Note: This package is under active development and serves as a starting framework for cleaning Flatiron Health datasets. Flatiron data structures may vary across different datacuts, including changes in column names, coding conventions, or unexpected values. While the package attempts to handle common variations, users should review the processing logic and adapt it as needed for their specific datacut and research question.

Installation

Built and tested in python 3.13.

pip install flatiron-cleaner 

Available Processors

Cancer-Specific Processors

The following cancers have their own dedicated data processor class:

Cancer Type Processor Name
Advanced Urothelial Cancer DataProcessorUrothelial
Advanced NSCLC DataProcessorNSCLC
Metastatic Colorectal Cancer DataProcessorColorectal
Metastatic Breast Cancer DataProcessorBreast
Metastatic Prostate Cancer DataProcessorProstate
Metastatic Renal Cell Cancer DataProcessorRenal
Advanced Melanoma DataProcessorMelanoma
Advanced Head and Neck DataProcessorHeadNeck

General Processor

For cancer types without a dedicated processor, DataProcessorGeneral is available with standard methods.

Processing Methods

Standard Methods

The following methods are available across all processor classes, including the general processor:

Method Description File Processed
process_demographics() Processes patient demographic information Demographics.csv
process_mortality() Processes mortality data Enhanced_Mortality_V2.csv
process_ecog() Processes performance status data ECOG.csv
process_medications() Processes medication administration records MedicationAdministration.csv
process_diagnosis() Processes ICD coding information Diagnosis.csv
process_labs() Processes laboratory test results Lab.csv
process_vitals() Processes vital signs data Vitals.csv
process_insurance() Processes insurance information Insurance.csv
process_practice() Processes practice type data Practice.csv

Cancer-Specific Methods

Cancer-specific classes contain additional methods (e.g., process_enhanced() and process_biomarkers()). For a complete list of available methods for each cancer type, refer to the source code or use Python's built-in help functionality:

from flatiron_cleaner import DataProcessorUrothelial

Usage Example

from flatiron_cleaner import DataProcessorUrothelial
from flatiron_cleaner import merge_dataframes

# Initialize class
processor = DataProcessorUrothelial()

# Import dataframe with PatientIDs and index date of interest
df = pd.read_csv('path/to/your/data')

# Load and clean data
cleaned_ecog_df = processor.process_ecog('path/to/your/ECOG.csv',
                                         index_date_df=df,
                                         index_date_column='AdvancedDiagnosisDate',
                                         days_before=30,
                                         days_after=0)                  

cleaned_medication_df = processor.process_medications('path/to/your/MedicationAdmninistration.csv',
                                                      index_date_df=df,
                                                      index_date_column='AdvancedDiagnosisDate',
                                                      days_before=180,
                                                      days_after=0)

# Merge dataframes 
merged_data = merge_dataframes(cleaned_ecog_df, cleaned_medication_df)

For a more detailed usage demonstration, see the notebook titled "tutorial" in the example/ directory.

Contact

Contributions and feedback are welcome. Contact: xavierorcutt@gmail.com

Metadata

Release files for flatiron-cleaner 0.1.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flatiron-cleaner 0.1.17
File Size Uploaded Provenance
flatiron_cleaner-0.1.17.tar.gz 118.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for flatiron-cleaner 0.1.17
File Interpreter ABI Platform
flatiron_cleaner-0.1.17-py3-none-any.whl Python 3 none any Details

Total release size: 250.5 kB

Release files / flatiron_cleaner-0.1.17.tar.gz

Download URL flatiron_cleaner-0.1.17.tar.gz
Size 118.8 kB
Tags Source
SHA-256 checksum
How to use checksums
09922fe8d3b85ff5e6920f8510c37bf2c4483b5aeead4ff0462d93d56c8dc58a
BLAKE2b-256 checksum
How to use checksums
a7f7183f4e5a173fc33ff96db08034b7b23fdf010700d1e711158de8caa5596a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / flatiron_cleaner-0.1.17-py3-none-any.whl

Download URL flatiron_cleaner-0.1.17-py3-none-any.whl
Size 131.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8babf3db60bf40fe4d9564f516356eafddda2eea845a40815dd208e563056c55
BLAKE2b-256 checksum
How to use checksums
f4395770544e32e828923aca9491ae7b0c95d26bd737e1fc3d71212aa86de329
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Security for flatiron-cleaner 0.1.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page