cbioportal-database
Cancer genomics (TCGA et al.) via cBioPortal REST API. Retrieve somatic mutations, CNAs, expression, clinical data (survival/stage/treatment) across thousands of studies. Use for TMB, oncoprints, survival analysis. For population frequencies use gnomad-database; for drug-gene interactions use dgidb-database.
npx skills add BioTender-max/awesome-bio-agent-skills --skill cbioportal-database --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
The skill provides concrete steps and code snippets to access cBioPortal data via REST API for cancer genomics. It covers querying cancer types, studies, samples, mutations, copy number alterations, clinical data, gene expression, and gene metadata. It includes example workflows for assembling mutation and CNA data, retrieving clinical attributes, and obtaining expression values, with explicit endpoints, parameters, and data handling patterns. It also demonstrates how to map gene symbols to Entrez IDs and how to fetch per-study mutation frequencies for visualization.
How it works
- Uses base URL https://www.cbioportal.org/api for all API requests.
- Defines helper functions cbio_get and cbio_post for GET and POST requests, including headers for JSON communication and timeouts.
- Query 1 (Cancer Types and Studies): fetches cancer-types, then studies by keyword, and retrieves study metadata and molecular profiles.
- Query 2 (Somatic Mutations): obtains all samples for a study, constructs a mutation fetch body with sampleIds and entrezGeneIds, and requests mutations from the mutations fetch endpoint; summarizes mutation types.
- Query 3 (Copy Number Alterations): uses a discrete CNA profile (gistic) and fetches CNA data for specified genes; decodes numerical values to labels like AMP, GAIN, DIPLOID, LOSS, HOMDEL.
- Query 4 (Clinical Data): lists clinical attributes for a study, filters for survival-related attributes, fetches patient-level clinical data, pivots to a patient × attribute matrix, and reports OS counts.
- Query 5 (Gene Expression Data): retrieves RNA-seq expression from rna_seq_v2_mrna_median_normed_log2 and builds a gene-by-sample matrix for selected genes.
- Query 6 (Gene Details and Batch Lookup): fetches single-gene metadata, resolves multiple genes from Hugo symbols via a fetch endpoint, and displays Entrez IDs and types.
- Query 7 (Visualization — Mutation Frequency Barplot): loops over several TCGA PanCancer Atlas studies, computes TP53 mutation frequency by fetching samples and mutations, and renders a horizontal bar plot with counts and percentages; saves an image and prints a summary table.
- The skill emphasizes concrete file names, endpoints, gene identifiers, and example data flows; it requires the claude-code tool as declared.
When to use it
- When you need somatic mutation, CNA, expression, and clinical data for TCGA or other cBioPortal studies.
- When you want to identify which studies have data for a given cancer type or gene and to prepare data for downstream analyses like survival or differential expression.
- When you need gene-symbol to Entrez-ID mapping for query construction.
What it can touch
- Tools: claude-code
- Endpoints used include: https://www.cbioportal.org/api, with endpoints such as cancer-types, studies, studies/{study_id}, molecular-profiles, samples, mutations/fetch, studies/{study_id}/clinical-data, genes/TP53, genes/fetch, etc.
- Data touches genes by Entrez IDs (e.g., 7157 for TP53) and Hugo symbols (e.g., BRCA1). It handles sample IDs and molecular profile IDs constructed from study IDs.
Caveats
- License declared: AGPL-3.0 for the skill; runtime license in the code is NOASSERTION in the repository metadata.
- Requires internet access; no API key is required for cBioPortal REST API.
- Rate limits described: no strict rate limits; implements a polite sleep between batch requests (time.sleep(0.2)).
- Results depend on the availability of data in cBioPortal for each study and gene; some queries may skip with errors and print a message.
# cBioPortal Database ## Overview cBioPortal for Cancer Genomics is a public repository of cancer genomics data including TCGA, ICGC, and hundreds of curated studies spanning 100+ cancer types. It provides somatic mutation profiles, copy number alterations (CNA), gene expression, clinical data (survival, stage, treatment history), and methylation data for tens of thousands of patient samples. Data is accessible via a REST API at `https://www.cbioportal.org/api/` with no authentication required. ## When to Use - Retrieving somatic mutation profiles (variant type, amino acid change) for a gene across TCGA studies - Querying copy number alteration data (amplification, deep deletion) for candidate cancer driver genes - Accessing clinical data — overall survival, disease-free survival, tumor stage — for survival curve analysis - Identifying which cancer studies have molecular profiling data for a specific cancer type (e.g., breast, lung) - Downloading gene expression (RNA-seq FPKM/RSEM) data from specific TCGA cohorts for differential expression analysis - Correlating genomic alterations with clinical outcomes in a specific study - Use `gnomad-database` instead when you need population-
- Overview
- When to Use
- Prerequisites
- Quick Start
- Core API
- Query 1: Cancer Types and Studies
- Query 2: Somatic Mutations
- Query 3: Copy Number Alterations
- Query 4: Clinical Data
- Query 5: Gene Expression Data
- Query 6: Gene Details and Batch Lookup
- Query 7: Visualization — Mutation Frequency Barplot
- Key Concepts
- cBioPortal Data Model
pip install requests pandas matplotlib
What does the cbioportal-database skill do?
Cancer genomics (TCGA et al.) via cBioPortal REST API. Retrieve somatic mutations, CNAs, expression, clinical data (survival/stage/treatment) across thousands of studies. Use for TMB, oncoprints, survival analysis. For population frequencies use gnomad-database; for drug-gene interactions use dgidb-database.
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill cbioportal-database --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From BioTender-max/awesome-bio-agent-skills, a repository with 135 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
