tcga-downloader/examples
yunpeng.zhang a01a59b371
Some checks failed
CI / Lint (push) Failing after 9m32s
CI / Test (3.11) (push) Successful in 6m41s
CI / Test (3.12) (push) Successful in 4m21s
feat: add interactive cli
2026-02-09 13:13:39 +08:00
..
advanced_filtering.py feat: add interactive cli 2026-02-09 13:13:39 +08:00
basic_query_download.py feat: add interactive cli 2026-02-09 13:13:39 +08:00
batch_query.py feat: add interactive cli 2026-02-09 13:13:39 +08:00
interactive_example.py feat: add interactive cli 2026-02-09 13:13:39 +08:00
README.md feat: add interactive cli 2026-02-09 13:13:39 +08:00
using_config.py feat: add interactive cli 2026-02-09 13:13:39 +08:00
validate_downloads.py feat: add interactive cli 2026-02-09 13:13:39 +08:00

Examples

This directory contains example scripts demonstrating various use cases of TCGA Downloader.

Examples

1. Basic Query and Download

File: basic_query_download.py

Demonstrates:

  • Querying a single TCGA project
  • Creating a manifest file
  • Downloading files using the manifest
python examples/basic_query_download.py

2. Batch Query Multiple Projects

File: batch_query.py

Demonstrates:

  • Querying multiple TCGA projects in one command
  • Combining results from multiple queries
  • Statistics for combined results
python examples/batch_query.py

3. Advanced Filtering

File: advanced_filtering.py

Demonstrates:

  • Querying with sample type filter
  • Querying with platform filter
  • Multiple filter criteria at once
python examples/advanced_filtering.py

4. Using Configuration Files

File: using_config.py

Demonstrates:

  • Creating a default configuration file
  • Using configuration for other commands
python examples/using_config.py
tcga-downloader query --file config.json

5. Validate Downloads

File: validate_downloads.py

Demonstrates:

  • Loading a manifest file
  • Validating manifest structure
  • Checking downloaded files against manifest
  • Verifying MD5 checksums
python examples/validate_downloads.py

Running Examples

Make sure you have TCGA Downloader installed:

pip install -e .

Then run any example:

cd examples
python <example_name>.py

Common TCGA Projects

  • TCGA-BRCA: Breast invasive carcinoma
  • TCGA-LUAD: Lung adenocarcinoma
  • TCGA-COAD: Colon adenocarcinoma
  • TCGA-PRAD: Prostate adenocarcinoma
  • TCGA-SKCM: Skin cutaneous melanoma
  • TCGA-KIRC: Kidney renal clear cell carcinoma
  • TCGA-GBM: Glioblastoma multiforme

Common Data Types

  • Gene Expression
  • Copy Number Variation
  • DNA Methylation
  • miRNA Expression
  • Protein Expression
  • Somatic Mutation

Interactive Mode

File: interactive_example.py

Demonstrates:

  • Dynamic project selection from API
  • Dynamic data type selection based on selected project
  • Interactive menu-driven workflow

Usage:

tcga-downloader interactive --out manifest.tsv --out-dir ./data

The interactive mode provides a user-friendly menu-driven workflow:

  1. Dynamic Project List: Fetches available TCGA projects from GDC API
  2. Project Selection: Interactive menu to select a project
  3. Dynamic Data Types: Fetches available data types for selected project
  4. Data Type Selection: Interactive menu to select data type
  5. Manifest Generation: Creates manifest based on selections
  6. Download: Downloads files using gdc-client

Usage:

tcga-downloader interactive --out manifest.tsv --out-dir ./data

This mode requires questionary library, which is included in the main package dependencies.