[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EAFEY3DKNDEYAT67VNP3CG":3,"skill-same:01M6EAFEY3DKNDEYAT67VNP3CG":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M6EAFEY3DKNDEYAT67VNP3CG","cbioportal-database",null,"Query cBioPortal for cancer genomics data including somatic mutations, copy number alterations, gene expression, and survival data across hundreds of cancer studies. Essential for cancer target validation, oncogene\u002Ftumor suppressor analysis, and patient-level genomic profiling.","luokai0\u002Fai-agent-skills-by-luo-kai","luokai0","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266954973?v=4","01M6E16VNT42JB8B3X3254QWJ7","luo kai","01M6E16VTFVP6S5XJF1V1MPV90",14,"LGPL-3.0","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fcbioportal-database\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"database","cbioportal database","copy","validation","tumor","survival","expression","patient","essential","gene expression","genomics","across","query","somatic","mutations","profiling","analysis","data","2026-11-10 10:12:30",false,"---\nauthor: luo-kai\nname: cbioportal-database\ndescription: Query cBioPortal for cancer genomics data including somatic mutations, copy number alterations, gene expression, and survival data across hundreds of cancer studies. Essential for cancer target validation, oncogene\u002Ftumor suppressor analysis, and patient-level genomic profiling.\nlicense: LGPL-3.0\nmetadata:\n    skill-author: Kuan-lin Huang\n---\n\n# cBioPortal Database\n\n## Overview\n\ncBioPortal for Cancer Genomics (https:\u002F\u002Fwww.cbioportal.org\u002F) is an open-access resource for exploring, visualizing, and analyzing multidimensional cancer genomics data. It hosts data from The Cancer Genome Atlas (TCGA), AACR Project GENIE, MSK-IMPACT, and hundreds of other cancer studies — covering mutations, copy number alterations (CNA), structural variants, mRNA\u002Fprotein expression, methylation, and clinical data for thousands of cancer samples.\n\n**Key resources:**\n- cBioPortal website: https:\u002F\u002Fwww.cbioportal.org\u002F\n- REST API: https:\u002F\u002Fwww.cbioportal.org\u002Fapi\u002F\n- API docs (Swagger): https:\u002F\u002Fwww.cbioportal.org\u002Fapi\u002Fswagger-ui\u002Findex.html\n- Python client: `bravado` or `requests`\n- GitHub: https:\u002F\u002Fgithub.com\u002FcBioPortal\u002Fcbioportal\n\n## When to Use This Skill\n\nUse cBioPortal when:\n\n- **Mutation landscape**: What fraction of a cancer type has mutations in a specific gene?\n- **Oncogene\u002FTSG validation**: Is a gene frequently mutated, amplified, or deleted in cancer?\n- **Co-mutation patterns**: Are mutations in gene A and gene B mutually exclusive or co-occurring?\n- **Survival analysis**: Do mutations in a gene associate with better or worse patient outcomes?\n- **Alteration profiles**: What types of alterations (missense, truncating, amplification, deletion) affect a gene?\n- **Pan-cancer analysis**: Compare alteration frequencies across cancer types\n- **Clinical associations**: Link genomic alterations to clinical variables (stage, grade, treatment response)\n- **TCGA\u002FGENIE exploration**: Systematic access to TCGA and clinical sequencing datasets\n\n## Core Capabilities\n\n### 1. cBioPortal REST API\n\nBase URL: `https:\u002F\u002Fwww.cbioportal.org\u002Fapi`\n\nThe API is RESTful, returns JSON, and requires no API key for public data.\n\n```python\nimport requests\n\nBASE_URL = \"https:\u002F\u002Fwww.cbioportal.org\u002Fapi\"\nHEADERS = {\"Accept\": \"application\u002Fjson\", \"Content-Type\": \"application\u002Fjson\"}\n\ndef cbioportal_get(endpoint, params=None):\n    url = f\"{BASE_URL}\u002F{endpoint}\"\n    response = requests.get(url, params=params, headers=HEADERS)\n    response.raise_for_status()\n    return response.json()\n\ndef cbioportal_post(endpoint, body):\n    url = f\"{BASE_URL}\u002F{endpoint}\"\n    response = requests.post(url, json=body, headers=HEADERS)\n    response.raise_for_status()\n    return response.json()\n```\n\n### 2. Browse Studies\n\n```python\ndef get_all_studies():\n    \"\"\"List all available cancer studies.\"\"\"\n    return cbioportal_get(\"studies\", {\"pageSize\": 500})\n\n# Each study has:\n# studyId: unique identifier (e.g., \"brca_tcga\")\n# name: human-readable name\n# description: dataset description\n# cancerTypeId: cancer type abbreviation\n# referenceGenome: GRCh37 or GRCh38\n# pmid: associated publication\n\nstudies = get_all_studies()\nprint(f\"Total studies: {len(studies)}\")\n\n# Common TCGA study IDs:\n# brca_tcga, luad_tcga, coadread_tcga, gbm_tcga, prad_tcga,\n# skcm_tcga, blca_tcga, hnsc_tcga, lihc_tcga, stad_tcga\n\n# Filter for TCGA studies\ntcga_studies = [s for s in studies if \"tcga\" in s[\"studyId\"]]\nprint([s[\"studyId\"] for s in tcga_studies[:10]])\n```\n\n### 3. Molecular Profiles\n\nEach study has multiple molecular profiles (mutation, CNA, expression, etc.):\n\n```python\ndef get_molecular_profiles(study_id):\n    \"\"\"Get all molecular profiles for a study.\"\"\"\n    return cbioportal_get(f\"studies\u002F{study_id}\u002Fmolecular-profiles\")\n\nprofiles = get_molecular_profiles(\"brca_tcga\")\nfor p in profiles:\n    print(f\"  {p['molecularProfileId']}: {p['name']} ({p['molecularAlterationType']})\")\n\n# Alteration types:\n# MUTATION_EXTENDED — somatic mutations\n# COPY_NUMBER_ALTERATION — CNA (GISTIC)\n# MRNA_EXPRESSION — mRNA expression\n# PROTEIN_LEVEL — RPPA protein expression\n# STRUCTURAL_VARIANT — fusions\u002Frearrangements\n```\n\n### 4. Mutation Data\n\n```python\ndef get_mutations(molecular_profile_id, entrez_gene_ids, sample_list_id=None):\n    \"\"\"Get mutations for specified genes in a molecular profile.\"\"\"\n    body = {\n        \"entrezGeneIds\": entrez_gene_ids,\n        \"sampleListId\": sample_list_id or molecular_profile_id.replace(\"_mutations\", \"_all\")\n    }\n    return cbioportal_post(\n        f\"molecular-profiles\u002F{molecular_profile_id}\u002Fmutations\u002Ffetch\",\n        body\n    )\n\n# BRCA1 Entrez ID is 672, TP53 is 7157, PTEN is 5728\nmutations = get_mutations(\"brca_tcga_mutations\", entrez_gene_ids=[7157])  # TP53\n\n# Each mutation record contains:\n# patientId, sampleId, entrezGeneId, gene.hugoGeneSymbol\n# mutationType (Missense_Mutation, Nonsense_Mutation, Frame_Shift_Del, etc.)\n# proteinChange (e.g., \"R175H\")\n# variantClassification, variantType\n# ncbiBuild, chr, startPosition, endPosition, referenceAllele, variantAllele\n# mutationStatus (Somatic\u002FGermline)\n# alleleFreqT (tumor VAF)\n\nimport pandas as pd\ndf = pd.DataFrame(mutations)\nprint(df[[\"patientId\", \"mutationType\", \"proteinChange\", \"alleleFreqT\"]].head())\nprint(f\"\\nMutation types:\\n{df['mutationType'].value_counts()}\")\n```\n\n### 5. Copy Number Alteration Data\n\n```python\ndef get_cna(molecular_profile_id, entrez_gene_ids):\n    \"\"\"Get discrete CNA data (GISTIC: -2, -1, 0, 1, 2).\"\"\"\n    body = {\n        \"entrezGeneIds\": entrez_gene_ids,\n        \"sampleListId\": molecular_profile_id.replace(\"_gistic\", \"_all\").replace(\"_cna\", \"_all\")\n    }\n    return cbioportal_post(\n        f\"molecular-profiles\u002F{molecular_profile_id}\u002Fdiscrete-copy-number\u002Ffetch\",\n        body\n    )\n\n# GISTIC values:\n# -2 = Deep deletion (homozygous loss)\n# -1 = Shallow deletion (heterozygous loss)\n#  0 = Diploid (neutral)\n#  1 = Low-level gain\n#  2 = High-level amplification\n\ncna_data = get_cna(\"brca_tcga_gistic\", entrez_gene_ids=[1956])  # EGFR\ndf_cna = pd.DataFrame(cna_data)\nprint(df_cna[\"value\"].value_counts())\n```\n\n### 6. Alteration Frequency (OncoPrint-style)\n\n```python\ndef get_alteration_frequency(study_id, gene_symbols, alteration_types=None):\n    \"\"\"Compute alteration frequencies for genes across a cancer study.\"\"\"\n    import requests, pandas as pd\n\n    # Get sample list\n    samples = requests.get(\n        f\"{BASE_URL}\u002Fstudies\u002F{study_id}\u002Fsample-lists\",\n        headers=HEADERS\n    ).json()\n    all_samples_id = next(\n        (s[\"sampleListId\"] for s in samples if s[\"category\"] == \"all_cases_in_study\"), None\n    )\n    total_samples = len(requests.get(\n        f\"{BASE_URL}\u002Fsample-lists\u002F{all_samples_id}\u002Fsample-ids\",\n        headers=HEADERS\n    ).json())\n\n    # Get gene Entrez IDs\n    gene_data = requests.post(\n        f\"{BASE_URL}\u002Fgenes\u002Ffetch\",\n        json=[{\"hugoGeneSymbol\": g} for g in gene_symbols],\n        headers=HEADERS\n    ).json()\n    entrez_ids = [g[\"entrezGeneId\"] for g in gene_data]\n\n    # Get mutations\n    mutation_profile = f\"{study_id}_mutations\"\n    mutations = get_mutations(mutation_profile, entrez_ids, all_samples_id)\n\n    freq = {}\n    for g_symbol, e_id in zip(gene_symbols, entrez_ids):\n        mutated = len(set(m[\"patientId\"] for m in mutations if m[\"entrezGeneId\"] == e_id))\n        freq[g_symbol] = mutated \u002F total_samples * 100\n\n    return freq\n\n# Example\nfreq = get_alteration_frequency(\"brca_tcga\", [\"TP53\", \"PIK3CA\", \"BRCA1\", \"BRCA2\"])\nfor gene, pct in sorted(freq.items(), key=lambda x: -x[1]):\n    print(f\"  {gene}: {pct:.1f}%\")\n```\n\n### 7. Clinical Data\n\n```python\ndef get_clinical_data(study_id, attribute_ids=None):\n    \"\"\"Get patient-level clinical data.\"\"\"\n    params = {\"studyId\": study_id}\n    all_clinical = cbioportal_get(\n        \"clinical-data\u002Ffetch\",\n        params\n    )\n    # Returns list of {patientId, studyId, clinicalAttributeId, value}\n\n# Clinical attributes include:\n# OS_STATUS, OS_MONTHS, DFS_STATUS, DFS_MONTHS (survival)\n# TUMOR_STAGE, GRADE, AGE, SEX, RACE\n# Study-specific attributes vary\n\ndef get_clinical_attributes(study_id):\n    \"\"\"List all available clinical attributes for a study.\"\"\"\n    return cbioportal_get(f\"studies\u002F{study_id}\u002Fclinical-attributes\")\n```\n\n## Query Workflows\n\n### Workflow 1: Gene Alteration Profile in a Cancer Type\n\n```python\nimport requests, pandas as pd\n\ndef alteration_profile(study_id, gene_symbol):\n    \"\"\"Full alteration profile for a gene in a cancer study.\"\"\"\n\n    # 1. Get gene Entrez ID\n    gene_info = requests.post(\n        f\"{BASE_URL}\u002Fgenes\u002Ffetch\",\n        json=[{\"hugoGeneSymbol\": gene_symbol}],\n        headers=HEADERS\n    ).json()[0]\n    entrez_id = gene_info[\"entrezGeneId\"]\n\n    # 2. Get mutations\n    mutations = get_mutations(f\"{study_id}_mutations\", [entrez_id])\n    mut_df = pd.DataFrame(mutations) if mutations else pd.DataFrame()\n\n    # 3. Get CNAs\n    cna = get_cna(f\"{study_id}_gistic\", [entrez_id])\n    cna_df = pd.DataFrame(cna) if cna else pd.DataFrame()\n\n    # 4. Summary\n    n_mut = len(set(mut_df[\"patientId\"])) if not mut_df.empty else 0\n    n_amp = len(cna_df[cna_df[\"value\"] == 2]) if not cna_df.empty else 0\n    n_del = len(cna_df[cna_df[\"value\"] == -2]) if not cna_df.empty else 0\n\n    return {\"mutations\": n_mut, \"amplifications\": n_amp, \"deep_deletions\": n_del}\n\nresult = alteration_profile(\"brca_tcga\", \"PIK3CA\")\nprint(result)\n```\n\n### Workflow 2: Pan-Cancer Gene Mutation Frequency\n\n```python\nimport requests, pandas as pd\n\ndef pan_cancer_mutation_freq(gene_symbol, cancer_study_ids=None):\n    \"\"\"Mutation frequency of a gene across multiple cancer types.\"\"\"\n    studies = get_all_studies()\n    if cancer_study_ids:\n        studies = [s for s in studies if s[\"studyId\"] in cancer_study_ids]\n\n    results = []\n    for study in studies[:20]:  # Limit for demo\n        try:\n            freq = get_alteration_frequency(study[\"studyId\"], [gene_symbol])\n            results.append({\n                \"study\": study[\"studyId\"],\n                \"cancer\": study.get(\"cancerTypeId\", \"\"),\n                \"mutation_pct\": freq.get(gene_symbol, 0)\n            })\n        except Exception:\n            pass\n\n    df = pd.DataFrame(results).sort_values(\"mutation_pct\", ascending=False)\n    return df\n```\n\n### Workflow 3: Survival Analysis by Mutation Status\n\n```python\nimport requests, pandas as pd\n\ndef survival_by_mutation(study_id, gene_symbol):\n    \"\"\"Get survival data split by mutation status.\"\"\"\n    # This workflow fetches clinical and mutation data for downstream analysis\n\n    gene_info = requests.post(\n        f\"{BASE_URL}\u002Fgenes\u002Ffetch\",\n        json=[{\"hugoGeneSymbol\": gene_symbol}],\n        headers=HEADERS\n    ).json()[0]\n    entrez_id = gene_info[\"entrezGeneId\"]\n\n    mutations = get_mutations(f\"{study_id}_mutations\", [entrez_id])\n    mutated_patients = set(m[\"patientId\"] for m in mutations)\n\n    clinical = cbioportal_get(\"clinical-data\u002Ffetch\", {\"studyId\": study_id})\n    clinical_df = pd.DataFrame(clinical)\n\n    os_data = clinical_df[clinical_df[\"clinicalAttributeId\"].isin([\"OS_MONTHS\", \"OS_STATUS\"])]\n    os_wide = os_data.pivot(index=\"patientId\", columns=\"clinicalAttributeId\", values=\"value\")\n    os_wide[\"mutated\"] = os_wide.index.isin(mutated_patients)\n\n    return os_wide\n```\n\n## Key API Endpoints Summary\n\n| Endpoint | Description |\n|----------|-------------|\n| `GET \u002Fstudies` | List all studies |\n| `GET \u002Fstudies\u002F{studyId}\u002Fmolecular-profiles` | Molecular profiles for a study |\n| `POST \u002Fmolecular-profiles\u002F{profileId}\u002Fmutations\u002Ffetch` | Get mutation data |\n| `POST \u002Fmolecular-profiles\u002F{profileId}\u002Fdiscrete-copy-number\u002Ffetch` | Get CNA data |\n| `POST \u002Fmolecular-profiles\u002F{profileId}\u002Fmolecular-data\u002Ffetch` | Get expression data |\n| `GET \u002Fstudies\u002F{studyId}\u002Fclinical-attributes` | Available clinical variables |\n| `GET \u002Fclinical-data\u002Ffetch` | Clinical data |\n| `POST \u002Fgenes\u002Ffetch` | Gene metadata by symbol or Entrez ID |\n| `GET \u002Fstudies\u002F{studyId}\u002Fsample-lists` | Sample lists |\n\n## Best Practices\n\n- **Know your study IDs**: Use the Swagger UI or `GET \u002Fstudies` to find the correct study ID\n- **Use sample lists**: Each study has an `all` sample list and subsets; always specify the appropriate one\n- **TCGA vs. GENIE**: TCGA data is comprehensive but older; GENIE has more recent clinical sequencing data\n- **Entrez gene IDs**: The API uses Entrez IDs — use `\u002Fgenes\u002Ffetch` to convert from symbols\n- **Handle 404s**: Some molecular profiles may not exist for all studies\n- **Rate limiting**: Add delays for bulk queries; consider downloading data files for large-scale analyses\n\n## Data Downloads\n\nFor large-scale analyses, download study data directly:\n```bash\n# Download TCGA BRCA data\nwget https:\u002F\u002Fcbioportal-datahub.s3.amazonaws.com\u002Fbrca_tcga.tar.gz\n```\n\n## Additional Resources\n\n- **cBioPortal website**: https:\u002F\u002Fwww.cbioportal.org\u002F\n- **API Swagger UI**: https:\u002F\u002Fwww.cbioportal.org\u002Fapi\u002Fswagger-ui\u002Findex.html\n- **Documentation**: https:\u002F\u002Fdocs.cbioportal.org\u002F\n- **GitHub**: https:\u002F\u002Fgithub.com\u002FcBioPortal\u002Fcbioportal\n- **Data hub**: https:\u002F\u002Fdatahub.cbioportal.org\u002F\n- **Citation**: Cerami E et al. (2012) Cancer Discovery. PMID: 22588877\n- **API clients**: https:\u002F\u002Fdocs.cbioportal.org\u002Fweb-api-and-clients\u002F\n","# cBioPortal Database\n\n## Overview\n\ncBioPortal for Cancer Genomics (https:\u002F\u002Fwww.cbioportal.org\u002F) is an open-access resource for exploring, visualizing, and analyzing multidimensional cancer genomics data. It hosts data from The Cancer Genome Atlas (TCGA), AACR Project GENIE, MSK-IMPACT, and hundreds of other cancer studies — covering mutations, copy number alterations (CNA), structural variants, mRNA\u002Fprotein expression, methylation, and clinical data for thousands of cancer samples.\n\n**Key resources:**\n- cBioPortal website: https:\u002F\u002Fwww.cbioportal.org\u002F\n- REST API: https:\u002F\u002Fwww.cbioportal.org\u002Fapi\u002F\n- API docs (Swagger): https:\u002F\u002Fwww.cbioportal.org\u002Fapi\u002Fswagger-ui\u002Findex.html\n- Python client: `bravado` or `requests`\n- GitHub: https:\u002F\u002Fgithub.com\u002FcBioPortal\u002Fcbioportal\n\n## When to Use This Skill\n\nUse cBioPortal when:\n\n- **Mutation landscape**: What fraction of a cancer type has mutations in a specific gene?\n- **Oncogene\u002FTSG validation**: Is a gene frequently mutated, amplified, or deleted in cancer?\n- **Co-mutation patterns**: Are mutations in gene A and gene B mutually exclusive or co-occurring?\n- **Survival analysis**: Do mutations in a gene associate with better or worse patient outcomes?\n- **Alteration profiles**: What types of alterations (missense, truncating, amplification, deletion) affect a gene?\n- **Pan-cancer analysis**: Compare alteration frequencies across cancer types\n- **Clinical associations**: Link genomic alterations to clinical variables (stage, grade, treatment response)\n- **TCGA\u002FGENIE exploration**: Systematic access to TCGA and clinical sequencing datasets\n\n## Core Capabilities\n\n### 1. cBioPortal REST API\n\nBase URL: `https:\u002F\u002Fwww.cbioportal.org\u002Fapi`\n\nThe API is RESTful, returns JSON, and requires no API key for public data.\n\n```python\nimport requests\n\nBASE_URL = \"https:\u002F\u002Fwww.cbioportal.org\u002Fapi\"\nHEADERS = {\"Accept\": \"application\u002Fjson\", \"Content-Type\": \"application\u002Fjson\"}\n\ndef cbioportal_get(endpoint, params=None):\n    url = f\"{BASE_URL}\u002F{endpoint}\"\n    response = requests.get(url, params=params, headers=HEADERS)\n    response.raise_for_status()\n    return response.json()\n\ndef cbioportal_post(endpoint, body):\n    url = f\"{BASE_URL}\u002F{endpoint}\"\n    response = requests.post(url, json=body, headers=HEADERS)\n    response.raise_for_status()\n    return response.json()\n```\n\n### 2. Browse Studies\n\n```python\ndef get_all_studies():\n    \"\"\"List all available cancer studies.\"\"\"\n    return cbioportal_get(\"studies\", {\"pageSize\": 500})\n\n# Each study has:\n# studyId: unique identifier (e.g., \"brca_tcga\")\n# name: human-readable name\n# description: dataset description\n# cancerTypeId: cancer type abbreviation\n# referenceGenome: GRCh37 or GRCh38\n# pmid: associated publication\n\nstudies = get_all_studies()\nprint(f\"Total studies: {len(studies)}\")\n\n# Common TCGA study IDs:\n# brca_tcga, luad_tcga, coadread_tcga, gbm_tcga, prad_tcga,\n# skcm_tcga, blca_tcga, hnsc_tcga, lihc_tcga, stad_tcga\n\n# Filter for TCGA studies\ntcga_studies = [s for s in studies if \"tcga\" in s[\"studyId\"]]\nprint([s[\"studyId\"] for s in tcga_studies[:10]])\n```\n\n### 3. Molecular Profiles\n\nEach study has multiple molecular profiles (mutation, CNA, expression, etc.):\n\n```python\ndef get_molecular_profiles(study_id):\n    \"\"\"Get all molecular profiles for a study.\"\"\"\n    return cbioportal_get(f\"studies\u002F{study_id}\u002Fmolecular-profiles\")\n\nprofiles = get_molecular_profiles(\"brca_tcga\")\nfor p in profiles:\n    print(f\"  {p['molecularProfileId']}: {p['name']} ({p['molecularAlterationType']})\")\n\n# Alteration types:\n# MUTATION_EXTENDED — somatic mutations\n# COPY_NUMBER_ALTERATION — CNA (GISTIC)\n# MRNA_EXPRESSION — mRNA expression\n# PROTEIN_LEVEL — RPPA protein expression\n# STRUCTURAL_VARIANT — fusions\u002Frearrangements\n```\n\n### 4. Mutation Data\n\n```python\ndef get_mutations(molecular_profile_id, entrez_gene_ids, sample_list_id=None):\n    \"\"\"Get mutations for specified genes in a molecular profile.\"\"\"\n    body = {\n        \"entrezGeneIds\": entrez_gene_ids,\n        \"sampleListId\": sample_list_id or molecular_profile_id.replace(\"_mutations\", \"_all\")\n    }\n    return cbioportal_post(\n        f\"molecular-profiles\u002F{molecular_profile_id}\u002Fmutations\u002Ffetch\",\n        body\n    )\n\n# BRCA1 Entrez ID is 672, TP53 is 7157, PTEN is 5728\nmutations = get_mutations(\"brca_tcga_mutations\", entrez_gene_ids=[7157])  # TP53\n\n# Each mutation record contains:\n# patientId, sampleId, entrezGeneId, gene.hugoGeneSymbol\n# mutationType (Missense_Mutation, Nonsense_Mutation, Frame_Shift_Del, etc.)\n# proteinChange (e.g., \"R175H\")\n# variantClassification, variantType\n# ncbiBuild, chr, startPosition, endPosition, referenceAllele, variantAllele\n# mutationStatus (Somatic\u002FGermline)\n# alleleFreqT (tumor VAF)\n\nimport pandas as pd\ndf = pd.DataFrame(mutations)\nprint(df[[\"patientId\", \"mutationType\", \"proteinChange\", \"alleleFreqT\"]].head())\nprint(f\"\\nMutation types:\\n{df['mutationType'].value_counts()}\")\n```\n\n### 5. Copy Number Alteration Data\n\n```python\ndef get_cna(molecular_profile_id, entrez_gene_ids):\n    \"\"\"Get discrete CNA data (GISTIC: -2, -1, 0, 1, 2).\"\"\"\n    body = {\n        \"entrezGeneIds\": entrez_gene_ids,\n        \"sampleListId\": molecular_profile_id.replace(\"_gistic\", \"_all\").replace(\"_cna\", \"_all\")\n    }\n    return cbioportal_post(\n        f\"molecular-profiles\u002F{molecular_profile_id}\u002Fdiscrete-copy-number\u002Ffetch\",\n        body\n    )\n\n# GISTIC values:\n# -2 = Deep deletion (homozygous loss)\n# -1 = Shallow deletion (heterozygous loss)\n#  0 = Diploid (neutral)\n#  1 = Low-level gain\n#  2 = High-level amplification\n\ncna_data = get_cna(\"brca_tcga_gistic\", entrez_gene_ids=[1956])  # EGFR\ndf_cna = pd.DataFrame(cna_data)\nprint(df_cna[\"value\"].value_counts())\n```\n\n### 6. Alteration Frequency (OncoPrint-style)\n\n```python\ndef get_alteration_frequency(study_id, gene_symbols, alteration_types=None):\n    \"\"\"Compute alteration frequencies for genes across a cancer study.\"\"\"\n    import requests, pandas as pd\n\n    # Get sample list\n    samples = requests.get(\n        f\"{BASE_URL}\u002Fstudies\u002F{study_id}\u002Fsample-lists\",\n        headers=HEADERS\n    ).json()\n    all_samples_id = next(\n        (s[\"sampleListId\"] for s in samples if s[\"category\"] == \"all_cases_in_study\"), None\n    )\n    total_samples = len(requests.get(\n        f\"{BASE_URL}\u002Fsample-lists\u002F{all_samples_id}\u002Fsample-ids\",\n        headers=HEADERS\n    ).json())\n\n    # Get gene Entrez IDs\n    gene_data = requests.post(\n        f\"{BASE_URL}\u002Fgenes\u002Ffetch\",\n        json=[{\"hugoGeneSymbol\": g} for g in gene_symbols],\n        headers=HEADERS\n    ).json()\n    entrez_ids = [g[\"entrezGeneId\"] for g in gene_data]\n\n    # Get mutations\n    mutation_profile = f\"{study_id}_mutations\"\n    mutations = get_mutations(mutation_profile, entrez_ids, all_samples_id)\n\n    freq = {}\n    for g_symbol, e_id in zip(gene_symbols, entrez_ids):\n        mutated = len(set(m[\"patientId\"] for m in mutations if m[\"entrezGeneId\"] == e_id))\n        freq[g_symbol] = mutated \u002F total_samples * 100\n\n    return freq\n\n# Example\nfreq = get_alteration_frequency(\"brca_tcga\", [\"TP53\", \"PIK3CA\", \"BRCA1\", \"BRCA2\"])\nfor gene, pct in sorted(freq.items(), key=lambda x: -x[1]):\n    print(f\"  {gene}: {pct:.1f}%\")\n```\n\n### 7. Clinical Data\n\n```python\ndef get_clinical_data(study_id, attribute_ids=None):\n    \"\"\"Get patient-level clinical data.\"\"\"\n    params = {\"studyId\": study_id}\n    all_clinical = cbioportal_get(\n        \"clinical-data\u002Ffetch\",\n        params\n    )\n    # Returns list of {patientId, studyId, clinicalAttributeId, value}\n\n# Clinical attributes include:\n# OS_STATUS, OS_MONTHS, DFS_STATUS, DFS_MONTHS (survival)\n# TUMOR_STAGE, GRADE, AGE, SEX, RACE\n# Study-specific attributes vary\n\ndef get_clinical_attributes(study_id):\n    \"\"\"List all available clinical attributes for a study.\"\"\"\n    return cbioportal_get(f\"studies\u002F{study_id}\u002Fclinical-attributes\")\n```\n\n## Query Workflows\n\n### Workflow 1: Gene Alteration Profile in a Cancer Type\n\n```python\nimport requests, pandas as pd\n\ndef alteration_profile(study_id, gene_symbol):\n    \"\"\"Full alteration profile for a gene in a cancer study.\"\"\"\n\n    # 1. Get gene Entrez ID\n    gene_info = requests.post(\n        f\"{BASE_URL}\u002Fgenes\u002Ffetch\",\n        json=[{\"hugoGeneSymbol\": gene_symbol}],\n        headers=HEADERS\n    ).json()[0]\n    entrez_id = gene_info[\"entrezGeneId\"]\n\n    # 2. Get mutations\n    mutations = get_mutations(f\"{study_id}_mutations\", [entrez_id])\n    mut_df = pd.DataFrame(mutations) if mutations else pd.DataFrame()\n\n    # 3. Get CNAs\n    cna = get_cna(f\"{study_id}_gistic\", [entrez_id])\n    cna_df = pd.DataFrame(cna) if cna else pd.DataFrame()\n\n    # 4. Summary\n    n_mut = len(set(mut_df[\"patientId\"])) if not mut_df.empty else 0\n    n_amp = len(cna_df[cna_df[\"value\"] == 2]) if not cna_df.empty else 0\n    n_del = len(cna_df[cna_df[\"value\"] == -2]) if not cna_df.empty else 0\n\n    return {\"mutations\": n_mut, \"amplifications\": n_amp, \"deep_deletions\": n_del}\n\nresult = alteration_profile(\"brca_tcga\", \"PIK3CA\")\nprint(result)\n```\n\n### Workflow 2: Pan-Cancer Gene Mutation Frequency\n\n```python\nimport requests, pandas as pd\n\ndef pan_cancer_mutation_freq(gene_symbol, cancer_study_ids=None):\n    \"\"\"Mutation frequency of a gene across multiple cancer types.\"\"\"\n    studies = get_all_studies()\n    if cancer_study_ids:\n        studies = [s for s in studies if s[\"studyId\"] in cancer_study_ids]\n\n    results = []\n    for study in studies[:20]:  # Limit for demo\n        try:\n            freq = get_alteration_frequency(study[\"studyId\"], [gene_symbol])\n            results.append({\n                \"study\": study[\"studyId\"],\n                \"cancer\": study.get(\"cancerTypeId\", \"\"),\n                \"mutation_pct\": freq.get(gene_symbol, 0)\n            })\n        except Exception:\n            pass\n\n    df = pd.DataFrame(results).sort_values(\"mutation_pct\", ascending=False)\n    return df\n```\n\n### Workflow 3: Survival Analysis by Mutation Status\n\n```python\nimport requests, pandas as pd\n\ndef survival_by_mutation(study_id, gene_symbol):\n    \"\"\"Get survival data split by mutation status.\"\"\"\n    # This workflow fetches clinical and mutation data for downstream analysis\n\n    gene_info = requests.post(\n        f\"{BASE_URL}\u002Fgenes\u002Ffetch\",\n        json=[{\"hugoGeneSymbol\": gene_symbol}],\n        headers=HEADERS\n    ).json()[0]\n    entrez_id = gene_info[\"entrezGeneId\"]\n\n    mutations = get_mutations(f\"{study_id}_mutations\", [entrez_id])\n    mutated_patients = set(m[\"patientId\"] for m in mutations)\n\n    clinical = cbioportal_get(\"clinical-data\u002Ffetch\", {\"studyId\": study_id})\n    clinical_df = pd.DataFrame(clinical)\n\n    os_data = clinical_df[clinical_df[\"clinicalAttributeId\"].isin([\"OS_MONTHS\", \"OS_STATUS\"])]\n    os_wide = os_data.pivot(index=\"patientId\", columns=\"clinicalAttributeId\", values=\"value\")\n    os_wide[\"mutated\"] = os_wide.index.isin(mutated_patients)\n\n    return os_wide\n```\n\n## Key API Endpoints Summary\n\n| Endpoint | Description |\n|----------|-------------|\n| `GET \u002Fstudies` | List all studies |\n| `GET \u002Fstudies\u002F{studyId}\u002Fmolecular-profiles` | Molecular profiles for a study |\n| `POST \u002Fmolecular-profiles\u002F{profileId}\u002Fmutations\u002Ffetch` | Get mutation data |\n| `POST \u002Fmolecular-profiles\u002F{profileId}\u002Fdiscrete-copy-number\u002Ffetch` | Get CNA data |\n| `POST \u002Fmolecular-profiles\u002F{profileId}\u002Fmolecular-data\u002Ffetch` | Get expression data |\n| `GET \u002Fstudies\u002F{studyId}\u002Fclinical-attributes` | Available clinical variables |\n| `GET \u002Fclinical-data\u002Ffetch` | Clinical data |\n| `POST \u002Fgenes\u002Ffetch` | Gene metadata by symbol or Entrez ID |\n| `GET \u002Fstudies\u002F{studyId}\u002Fsample-lists` | Sample lists |\n\n## Best Practices\n\n- **Know your study IDs**: Use the Swagger UI or `GET \u002Fstudies` to find the correct study ID\n- **Use sample lists**: Each study has an `all` sample list and subsets; always specify the appropriate one\n- **TCGA vs. GENIE**: TCGA data is comprehensive but older; GENIE has more recent clinical sequencing data\n- **Entrez gene IDs**: The API uses Entrez IDs — use `\u002Fgenes\u002Ffetch` to convert from symbols\n- **Handle 404s**: Some molecular profiles may not exist for all studies\n- **Rate limiting**: Add delays for bulk queries; consider downloading data files for large-scale analyses\n\n## Data Downloads\n\nFor large-scale analyses, download study data directly:\n```bash\n# Download TCGA BRCA data\nwget https:\u002F\u002Fcbioportal-datahub.s3.amazonaws.com\u002Fbrca_tcga.tar.gz\n```\n\n## Additional Resources\n\n- **cBioPortal website**: https:\u002F\u002Fwww.cbioportal.org\u002F\n- **API Swagger UI**: https:\u002F\u002Fwww.cbioportal.org\u002Fapi\u002Fswagger-ui\u002Findex.html\n- **Documentation**: https:\u002F\u002Fdocs.cbioportal.org\u002F\n- **GitHub**: https:\u002F\u002Fgithub.com\u002FcBioPortal\u002Fcbioportal\n- **Data hub**: https:\u002F\u002Fdatahub.cbioportal.org\u002F\n- **Citation**: Cerami E et al. (2012) Cancer Discovery. PMID: 22588877\n- **API clients**: https:\u002F\u002Fdocs.cbioportal.org\u002Fweb-api-and-clients\u002F\n",{"name":5,"author":42,"license":15,"metadata":43,"description":7},"luo-kai",{"skill-author":44},"Kuan-lin Huang","main","4d2fb89cdfb75f3f6fd3c6c5ec9ad90ea129eb3c","ai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fcbioportal-database",2,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai","https:\u002F\u002Fgithub.com\u002Fluokai0","a solo builder.","2026-05-06 04:29:04",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill cbioportal-database",{"tool":59,"command":60},"bunx","bunx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill cbioportal-database",{"tool":62,"command":63},"pnpm","pnpm dlx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill cbioportal-database","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fcbioportal-database\u002FSKILL.md",true,[67,73],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"reference\u002Fdrift-classification.md","REFERENCE","参考文档",1235,"https:\u002F\u002Fgithub.com\u002FBoloBoloMe\u002Fskills\u002Fblob\u002Fmain\u002Fworkflow\u002Fmaintain-verification-skill\u002Freference\u002Fdrift-classification.md",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Fstudy_exploration.md",4411,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fcbioportal-database\u002Freferences\u002Fstudy_exploration.md",[78,106,123,147,174,199],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":82,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":37},"01M6F2SKTE208174C7S7JJCZC7","write-contracts","Generates secure Aptos Move V2 smart contracts with Object model, Digital Asset integration, security patterns, and storage type guidance. Includes comprehensive storage decision framework for optimal data structure selection. Triggers on: 'write contract', 'create NFT collection', 'build marketplace', 'implement minting', 'generate Move module', 'create token contract', 'build DAO', 'implement staking'. Ask storage questions when: 'store', 'track', 'registry', 'mapping', 'list', 'collection'.","MIT","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fwrite-contracts\u002FSKILL.md",[],[86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105],"write","contracts","write contracts","storage","secure","create","generate","collection","model","decision","ask","smart-contracts","selection","objects","structure","nft","token","aptos","critical","move",{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":82,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":37},"01M6F2RFXJ6T9MKW0A7N7GM45B","web-search","通用网络搜索技能，支持多引擎搜索（百度、必应、DuckDuckGo），无需API密钥即可获取实时信息","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fweb-search-ex-skill\u002FSKILL.md",[],[113,114,115,116,117,118,119,120,121,122],"web","search","web search","搜索","baidu","bing","duckduckgo","百度","多引擎","internet",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":82,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":37},"01M6F2K968G1FZEZFPW2E6B222","solo-build","Execute implementation plan tasks with TDD workflow, auto-commit, and phase gates. Use when user says \"build it\", \"start building\", \"execute plan\", \"implement tasks\", \"ship it\", or references a track ID. Do NOT use for planning (use \u002Fplan) or scaffolding (use \u002Fscaffold).","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fsolo-build\u002FSKILL.md",[],[130,131,132,133,134,135,136,137,114,138,139,140,86,141,142,143,31,144,145,146],"build","solo","solo build","MCP","workflow","commit","tasks","code","Bash","plan","read","auto","references","context7","scaffolding","ship it","project",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":82,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":37},"01M6F2GKN39SGHSPWYB3662YC8","react-email","Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Freact-email-skills\u002FSKILL.md",[],[154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173],"react","email","react email","github","editor","components","react components","component","welcome","https","notifications","password","node","use","html","resend","visual","emails","rendering","with",{"skillNo":175,"name":176,"nameZh":6,"description":177,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":82,"licenseFileUrl":6,"sourceHtmlUrl":178,"categories":179,"keywords":180,"publishedAt":37},"01M6F2FBVGVDFSG8SSFJGXA40C","APITester Agent-Driven API Testing","Test API endpoints and document responses. Define tests in plain English, run them, get formatted results. Agent-driven Postman alternative.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fopenclaw-api-tester\u002FSKILL.md",[],[181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198],"testing","api","api testing","driven","APITester Agent Driven API Testing","test","run","postman","results","plain english","tester","endpoints","document","get","define","tests","english","api-tester",{"skillNo":200,"name":201,"nameZh":6,"description":202,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":82,"licenseFileUrl":6,"sourceHtmlUrl":203,"categories":204,"keywords":205,"publishedAt":37},"01M6F273Y3NGAPVJZ608BC0G9G","hubspot-implementation-plan","Generate a phased implementation plan from a HubSpot audit report. Creates prioritized, sequenced cleanup processes with effort estimates, dependencies, and automation feasibility. Use after running \u002Fhubspot-audit.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fhubspot-implementation-plan\u002FSKILL.md",[],[139,206,207,208,209,210,211,92,212,213,214,215,216,167,217,218,173,219],"implementation","hubspot","hubspot implementation plan","automation","feasibility","cleanup","planning","report","audit","audit report","phased implementation","dependencies","processes","hubspot audit"]