[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EZ9JCXD77YNARF80MEF1T0":3,"skill-same:01M6EZ9JCXD77YNARF80MEF1T0":80},{"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":26,"publishedAt":45,"linkOnly":46,"markdownContent":47,"markdownBody":48,"frontMatter":49,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":14,"repositoryHtmlUrl":55,"repositoryHomepageUrl":56,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M6EZ9JCXD77YNARF80MEF1T0","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.","henriquescastilho\u002Fmy-claude","henriquescastilho","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F153296945?v=4","01M6ESH7EXPXTH9CVQ4K16SRG8","Henrique Scheer","01M6ESH7JHEK2PTNNH4HEH787Z",0,"LGPL-3.0","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fcbioportal-database\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],"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,"---\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,"license":15,"metadata":50,"description":7},{"skill-author":51},"Kuan-lin Huang","main","7925716f065257435fdb12e97f7e52842147d5ad",".codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fcbioportal-database","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude","https:\u002F\u002Fclaude.com\u002Fclaude-code","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho","Software · Applied AI · Quantitative Modeling · Building with Claude.","2026-06-10 12:24:46",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add henriquescastilho\u002Fmy-claude --skill cbioportal-database",{"tool":66,"command":67},"bunx","bunx skills add henriquescastilho\u002Fmy-claude --skill cbioportal-database",{"tool":69,"command":70},"pnpm","pnpm dlx skills add henriquescastilho\u002Fmy-claude --skill cbioportal-database","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fcbioportal-database\u002FSKILL.md",true,[74],{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"references\u002Fstudy_exploration.md","REFERENCE","参考文档",4411,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fcbioportal-database\u002Freferences\u002Fstudy_exploration.md",[81,122,131,140,162,187],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":102,"publishedAt":45},"01M6F0B6XPQ65AX2X0DWK8KT3E","markitdown","Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.","MIT","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[88,91,94,97],{"categoryNo":89,"categoryName":90,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":92,"categoryName":93,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":95,"categoryName":96,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000004","电子表格",{"categoryNo":98,"categoryName":99,"taxonomyType":100,"taxonomyTypeDesc":101},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[83,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121],"docx","PDF","pptx","xlsx","documents","csv","ocr","Audio","Bash","markdown","convert","read","write","edit","html","images","files","youtube","with",{"skillNo":123,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":130,"publishedAt":45},"01M6F06SBHR9F0SDWE282Y8075","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fscientific_writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[126,127,128,129],{"categoryNo":89,"categoryName":90,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":92,"categoryName":93,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":95,"categoryName":96,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":98,"categoryName":99,"taxonomyType":100,"taxonomyTypeDesc":101},[83,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121],{"skillNo":132,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":139,"publishedAt":45},"01M6F02D4R14EJAPBWVDF9J9VQ","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[135,136,137,138],{"categoryNo":89,"categoryName":90,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":92,"categoryName":93,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":95,"categoryName":96,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":98,"categoryName":99,"taxonomyType":100,"taxonomyTypeDesc":101},[83,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121],{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":45},"01M6F000KS6YB4MKS774G4R8ND","zarr-python","Chunked N-D arrays for cloud storage. Compressed arrays, parallel I\u002FO, S3\u002FGCS integration, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fzarr-python\u002FSKILL.md",[],[147,148,149,150,151,152,153,154,155,156,157,158,159,160,161],"python","zarr python","storage","integration","s3","gcs","cloud","dask","parallel","pipelines","arrays","numpy","scientific computing","scale","scientific",{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":169,"publishedAt":45},"01M6EZZJWFXM1GR78KTW6J0DN8","what-if-oracle","Run structured What-If scenario analysis with multi-branch possibility exploration. Use this skill when the user asks speculative questions like \"what if...\", \"what would happen if...\", \"what are the possibilities\", \"explore scenarios\", \"scenario analysis\", \"possibility space\", \"what could go wrong\", \"best case \u002F worst case\", \"risk analysis\", \"contingency planning\", \"strategic options\", or any question about uncertain futures. Also trigger when the user faces a fork-in-the-road decision, wants to stress-test an idea, or needs to think through consequences before committing.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fwhat-if-oracle\u002FSKILL.md",[168],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[170,171,172,173,174,175,43,176,177,178,179,114,115,180,181,182,183,184,185,186],"oracle","what if oracle","go","run","ux","futures","explore","decision","branch","question","idea","exploration","options","stress-test","strategies","scenario","stress",{"skillNo":188,"name":189,"nameZh":6,"description":190,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":191,"categories":192,"keywords":203,"publishedAt":45},"01M6EZZCXAEB49RXGQCJX5E8GB","venue-templates","Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fvenue-templates\u002FSKILL.md",[193,196,199,200],{"categoryNo":194,"categoryName":195,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":197,"categoryName":198,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":201,"categoryName":202,"taxonomyType":100,"taxonomyTypeDesc":101},"01JBSEEDCAT000000000000036","内容创作者",[204,205,206,207,208,209,210,211,111,212,114,115,116,213,214,215,216,217,161,218],"templates","venue templates","research","guidelines","NeurIPS","ICML","LaTeX","science","access","proposals","Academic","requirements","formatting","journal","chi"]