[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DNFPMZRV8P61D5DPPSPG6T":3,"skill-same:01M6DNFPMZRV8P61D5DPPSPG6T":70},{"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":23,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":45,"commitSha":46,"skillDirectory":5,"forksCount":14,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":49,"install":50,"resources":63},"01M6DNFPMZRV8P61D5DPPSPG6T","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.","huamu668\u002Fclawhub-openclaw-medical","huamu668","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F202473531?v=4","01M6DK1V7D7VP9PJ06Z1VXVK13","huamu","01M6DK1VBYG1BX5FT154AFZHAS",0,"LGPL-3.0","https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical\u002Fblob\u002Fmain\u002Fcbioportal-database\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37],"database","cbioportal database","validation","data","analysis","profiling","mutations","somatic","query","across","genomics","gene expression","essential","patient","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":43,"description":7},{"skill-author":44},"Kuan-lin Huang","main","d3998984163a67a891ee8397e35adf79b14e872d","https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical","https:\u002F\u002Fgithub.com\u002Fhuamu668","2026-03-12 11:49:42",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add huamu668\u002Fclawhub-openclaw-medical --skill cbioportal-database",{"tool":56,"command":57},"bunx","bunx skills add huamu668\u002Fclawhub-openclaw-medical --skill cbioportal-database",{"tool":59,"command":60},"pnpm","pnpm dlx skills add huamu668\u002Fclawhub-openclaw-medical --skill cbioportal-database","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical\u002Fblob\u002Fmain\u002Fcbioportal-database\u002FSKILL.md",true,[64],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"bmad-skill-manifest.yaml","REFERENCE","参考文档",1099,"https:\u002F\u002Fgithub.com\u002Fdelorenj\u002FyTm\u002Fblob\u002Fmain\u002F.crush\u002Fskills\u002Fbmad-agent-pm\u002Fbmad-skill-manifest.yaml",[71,92,121,141,153,182],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":38},"01M6DR3JGAEX5G5FR7TK3D8NS8","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.","MIT","https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical\u002Fblob\u002Fmain\u002Fzarr-python\u002FSKILL.md",[],[79,80,81,82,83,84,85,86,87,88,89,90,91],"python","zarr python","storage","scientific computing","numpy","arrays","pipelines","parallel","dask","cloud","gcs","s3","integration",{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":101,"publishedAt":38},"01M6DR101MEDE5XT2ZZ5VBEAA5","vaex","Use this skill for processing and analyzing large tabular datasets (billions of rows) that exceed available RAM. Vaex excels at out-of-core DataFrame operations, lazy evaluation, fast aggregations, efficient visualization of big data, and machine learning on large datasets. Apply when users need to work with large CSV\u002FHDF5\u002FArrow\u002FParquet files, perform fast statistics on massive datasets, create visualizations of big data, or build ML pipelines that do not fit in memory.","https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical\u002Fblob\u002Fmain\u002Fvaex\u002FSKILL.md",[98],{"categoryNo":99,"categoryName":100,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000013","分析与可视化",[94,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120],"machine learning","in memory","learning","csv","visualization","create","core","ml","big data","memory","visualizations","fit","statistics","do","build","files","use","operations","work",{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":38},"01M6DQVMB0GBKF2W44FKXVD1P7","torch-geometric","Graph Neural Networks (PyG). Node\u002Fgraph classification, link prediction, GCN, GAT, GraphSAGE, heterogeneous graphs, molecular property prediction, for geometric deep learning.","https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical\u002Fblob\u002Fmain\u002Ftorch-geometric\u002FSKILL.md",[],[128,104,129,130,131,132,133,134,135,136,137,138,139,140],"torch geometric","node","Neural","link","gat","molecular","graphs","deep","networks","graph","neural networks","deep learning","classification",{"skillNo":142,"name":143,"nameZh":6,"description":144,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":145,"categories":146,"keywords":147,"publishedAt":38},"01M6DQH2GZPZKEQ140GRCJ9746","tiledbvcf","Efficient storage and retrieval of genomic variant data using TileDB. Scalable VCF\u002FBCF ingestion, incremental sample addition, compressed storage, parallel queries, and export capabilities for population genomics.","https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical\u002Fblob\u002Fmain\u002Ftiledbvcf\u002FSKILL.md",[],[143,27,34,148,149,150,151,86,152,81],"sample","queries","ingestion","export","capabilities",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":167,"publishedAt":38},"01M6DQD9G958EM6NHJ994D0SK1","solublempnn","Solubility-optimized protein sequence design using SolubleMPNN. Use this skill when: (1) Designing for E. coli expression, (2) Optimizing solubility of designed proteins, (3) Reducing aggregation propensity, (4) Need high-yield expression, (5) Avoiding inclusion body formation.\nFor standard design, use proteinmpnn. For ligand-aware design, use ligandmpnn.","https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical\u002Fblob\u002Fmain\u002Fsolublempnn\u002FSKILL.md",[159,162],{"categoryNo":160,"categoryName":161,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":163,"categoryName":164,"taxonomyType":165,"taxonomyTypeDesc":166},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[155,168,169,118,170,171,172,173,174,175,176,177,178,179,180,181],"inclusion","yield","modal","Tools","aggregation","design","proteins","solubility","proteinmpnn","ligandmpnn","ligand-aware","inverse-folding","expression","sequence-design",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":186,"licenseFileUrl":6,"sourceHtmlUrl":187,"categories":188,"keywords":189,"publishedAt":38},"01M6DQ8W91A93MGGCEEW949HBC","scvelo","RNA velocity analysis with scVelo. Estimate cell state transitions from unspliced\u002Fspliced mRNA dynamics, infer trajectory directions, compute latent time, and identify driver genes in single-cell RNA-seq data. Complements Scanpy\u002FscVI-tools for trajectory inference.","BSD-3-Clause","https:\u002F\u002Fgithub.com\u002Fhuamu668\u002Fclawhub-openclaw-medical\u002Fblob\u002Fmain\u002Fscvelo\u002FSKILL.md",[],[184,190,191,192,193,194,195,196,197,198,28,171,27,199,200],"RNA","single-cell","infer","cell","transitions","time","compute","velocity","scanpy","state","inference"]