A comprehensive Python package for cancer clinical data analysis including data processing, statistical analysis, survival modeling, and visualization
Project description
Cancer Clinical Data Analysis
Project Description
This project provides a comprehensive command-line interface (CLI) tool for performing survival analysis on clinical cancer data. It is designed to fetch, clean, analyze, and visualize data obtained from [cBioPortal] (https://www.cbioportal.org) (a standard open-source data platform for clinical cancer datasets) with a focus on survival prediction and cohort characterization.
Survival analysis in cancer research helps assess how long patients survive after diagnosis or treatment and what factors influence those survival outcomes. Key variables used include:
-
os_months: Time to death or last follow-up (in months) -
os_event: Binary indicator (1 = death, 0 = censored/alive) -
Demographics:
age_at_diagnosis,gender,race,ethnicity -
Clinical/pathological features
For this project we specifically chose the TCGA-LUAD cohort (lung adenocarcinoma) with study ID (luad_tcga_gdc) but the pipeline is generic and can be reused for other studies from CBioPortal provided the required data columns are available. It supports data cleaning, statistical summaries, logistic regression survival analysis, Kaplan-Merier survival curves and visualizations of results.
The figure below illustrates the end-to-end workflow for data loading, preprocessing, modeling, and visualization of our project and sample results:
Installation
- Clone the repository:
git clone https://gitlab.com/your-username/cancer-clinical-data-analysis.git
cd group-10
- Create and activate a virtual environment:
python -m venv .venv
- On Unix/macOS:
source venv/bin/activate
- On Windows:
venv\Scripts\activate
- Install dependencies using uv:
uv pip install -r requirements.txt
or
pip install -e
- Make sure uv is installed and added to your PATH. If not:
pip install uv
- Verify installation:
python main.py --help
Usage
This project is run through the CLI via:
python main.py [COMMAND] [OPTIONS]
You can either run the full pipeline: process → summary → model → visualize or individual tasks from the project as follows:
1. Data Processing (process):
This step loads raw clinical data from cBioPortal, preprocesses and cleans the data to obtain required columns and reports missing data.
python main.py process [OPTIONS]
Options:
--source TEXT: Study ID to load from cBioPortal (default:luad_tcga_gdc)--output-dir TEXT: Directory to save results (default:results)
Example:
python main.py process --source luad_tcga_gdc --output-dir my_results
2. Statistical Summaries (statistical_summary):
This step generates a statistical summary including mean, standard deviation, frequencies, entropies for all the categorical and nummerical columns.
python main.py --statistical-summary
Options:
--data-file TEXT: Path to clinical data file (default:results/clinical_data.csv)--output-dir TEXT: Directory to save results (default:results)
Example:
python main.py statistical_summary --data-file results/clinical_data.csv --output-dir results
3. Survival Modeling (model)
This step trains and evaluates logistic regression and random forest models for for survival prediction (os_event) variable and generates classification results and plots:
- Feature importance bar plot
- Confusion matrix
python main.py model [OPTIONS]
Options:
--data-file TEXT: Path to clinical data file (default:results/clinical_data.csv)--output-dir TEXT: Directory to save model results (default:results)--target TEXT: Target variable for prediction (default:os_event)
Example:
python main.py model --data-file results/clinical_data.csv --target os_event --output-dir model_results
4. Data Visualization (visualize)
This step generates comprehensive visualizations of clinical data including demographics, age distribution, and Kaplan-Meier survival curves.
python main.py visualize [OPTIONS]
Options:
--data-file TEXT: Path to clinical data file (default:results/clinical_data.csv)--output-dir TEXT: Directory to save visualizations (default:results)
Example:
python main.py visualize --data-file results/clinical_data.csv --output-dir plots
5. Complete Analysis Pipeline (analyze)
TO run the complete analysis pipeline including data processing, statistics, visualization, and modeling.
python main.py analyze [OPTIONS]
Options:
--study-id TEXT: Specific study ID to analyze (uses default if not specified)--output-dir TEXT: Directory to save all results (default:results)
Example:
python main.py analyze --study-id luad_tcga_gdc --output-dir complete_analysis
Global Options
Available for all commands:
-v, --verbose: Increase output verbosity --v: Info level logging --vv: Debug level logging --vvv: Maximum verbosity
Example:
python main.py -vv process --source luad_tcga_gdc
Working with Different Studies
The toolkit works with any cBioPortal study ID. Common examples:
luad_tcga_gdc: Lung Adenocarcinoma (TCGA, Firehose Legacy)brca_tcga: Breast Invasive Carcinoma (TCGA, Firehose Legacy)prad_tcga: Prostate Adenocarcinoma (TCGA, Firehose Legacy)coadread_tcga: Colorectal Adenocarcinoma (TCGA, Firehose Legacy)
Visit cBioPortal to find more study IDs.
# Analyze breast cancer data
python main.py analyze --study-id brca_tcga --output-dir brca_analysis
# Process prostate cancer data
python main.py process --source prad_tcga --output-dir prostate_data
Output Files
The toolkit generates the following output files:
clinical_data.csv: Processed clinical datapathology_data.csv: Processed pathology datastatistical_summary.txt: Comprehensive statistical summaryfeature_importance.csv: Model feature importance rankings- Various visualization files (PNG format):
-
demographics.png: Patient demographics -age_distribution.png: Age distribution plots -kaplan_meier.png: Survival curves -confusion_matrix.png: Model performance -feature_importance.png: Feature importance plots
Project Structure
├── main.py # CLI entry point
├── cancer_analysis/ # Main package
│ ├── data/ # Data loading and preprocessing
│ ├── analysis/ # Statistical analysis and visualization
│ ├── models/ # Machine learning models
│ └── utils/ # Utility functions
├── results/ # Default output directory
├── tests/ # Test files
└── docs/ # Documentation
Contributing
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
Publication
Package on Test PyPI
You can install the package from the Test PyPI repository for testing purposes:
pip install --index-url https://test.pypi.org/simple/ cancer-clinical-data-analysis==0.1.1
Citation
You can cite the project using the following BibTeX:
@misc{cancer_clinical_data_analysis, author = {Zoha Rashid and Zaeem Asghar}, title = {Cancer Clinical Data Analysis}, month = jul, year = 2025, doi = {10.5072/zenodo.288798}, url = {https://handle.stage.datacite.org/10.5072/zenodo.288798} }
License
This project is licensed under the MIT License. You are free to use, modify, and distribute the code under the terms of the license.
Note: While this code interacts with data from cBioPortal and TCGA (e.g., LUAD cohort), the data itself is not redistributed with this repository. Users must adhere to cBioPortal and TCGA's respective data use policies when accessing or using any clinical datasets.
Data Use Disclaimer This project fetches clinical data from public repositories like cBioPortal and TCGA. The data is used for educational and non-commercial research purposes only. Please verify your own institutional and ethical guidelines before using the data.
Authors
- Zaeem Asghar - zaeem.asghar@mailbox.tu-dresden.de
- Zoha Rashid - zoha.rashid@mailbox.tu-dresden.de
Support
If you encounter any issues or have questions, please:
- Check the command help:
python main.py <command> --help - Run with verbose output:
python main.py -v <command> - Review the generated log files in your output directory
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cancer_clinical_data_analysis-0.1.1.tar.gz.
File metadata
- Download URL: cancer_clinical_data_analysis-0.1.1.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c1afeb2599016a3b9c1e0b316189fa93dc9da7f5cb5fbb2dc50e1654d1aea7c
|
|
| MD5 |
02c24e608af473734d5800906dd0b0ef
|
|
| BLAKE2b-256 |
4189d38569002f5dcd432d403f3466ff5a1c58d3864f7a75e6720d35b82b6cb4
|
File details
Details for the file cancer_clinical_data_analysis-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cancer_clinical_data_analysis-0.1.1-py3-none-any.whl
- Upload date:
- Size: 27.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04576c0e2c1ce46a129104023bcd5ca786eb28838a61076b17f92fc2e249e82c
|
|
| MD5 |
ec98ec4a97cf258d8921859e28df89ba
|
|
| BLAKE2b-256 |
9846d74836c72c0337e4131b5fc228f78e124c0f59731512dfd5817c4d7e9113
|