Q (sonnet): Which patients have a TP53 G199V mutation? Which are somatic vs germline? ▶ read_guide { "uri": "cbioportal://mutation-frequency-guide" } ▶ read_guide { "uri": "cbioportal://germline-guide" } ◀ result # Mutation Frequency Analysis Guide ## IMPORTANT: Reporting Mutation Frequencies - **ALWAYS report frequencies as percentages**, not raw counts: `frequency = (altered_samples / total_profiled_samples) × 100` - For quick frequency lookups, **prefer the TCGA Pan-Cancer Atlas study first**, then offer to expand to other studies - When reporting across multiple studies, show **ranges** (e.g., "TP53 is mutated in 30–60% of samples") rather than a single average - **NEVER** sum mutation events across studies to compute an aggregate frequency — this can exceed 100% due to double-counting - Warn users that samples may overlap across cohorts (e.g., MSK studies may share patients) - **Choose and state the counting unit**: use patient-level frequencies for prevalence/rate questions unless the user explicitly asks for samples; use sample-level frequencies when the user asks about samples. - **For "across cancer types" questions**, jump to the [Cross-Cancer-Type Mutation Frequency](#cross-cancer-type-mutation-frequency) section below — there is one correct recipe and several common wrong ones. ## Counting Unit: Samples vs Patients Before answering any mutation count or frequency question, decide whether the unit is samples or patients and state that choice in the answer. | User wording | Counting unit | |--------------|---------------| | "prevalence", "rate", "fraction of patients", "patients with", "how common is" | Patient-level: `COUNT(DISTINCT patient_unique_id)` | | "samples", "specimens", "biopsies", sample-level cohort composition | Sample-level: `COUNT(DISTINCT sample_unique_id)` | | Ambiguous | Ask, or default to patient-level for prevalence/rate language and say so | ### Cross-study sample-count caveat When an answer touches more than one study and reports a sample count, prepend a one-line caveat: > Sample IDs are unique within cBioPortal study prefixes, not guaranteed biological-sample identifiers across studies; overlapping cohorts can count the same patient/sample more than once. Prefer one of these safer approaches: - Use a shipped `cancer_study_query_preferences` cohort such as `pan_cancer_tcga` or `all_studies_non_redundant`. - Restrict to one named study. - Aggregate by `patient_unique_id` when the biological question is patient prevalence. ## STOP rule: a frequency above 100% means your query is wrong If your query returns a frequency over 100%, **do not try to debug or explain the data inconsistency to the user**. The cause is always one of these query bugs: - Summing mutation events instead of `COUNT(DISTINCT sample_unique_id)` for the numerator - Using a study-wide sample count as the denominator instead of the gene-specific profiled count - Cross-study aggregation where the same biological sample appears under multiple `sample_unique_id` values (e.g., MSK-IMPACT and MSK-CHORD share patients) - **Joining the profiled CTE through `gene_panel` / `gene_panel_list` without a WES branch.** `gene_panel_id = 'WES'` is *not* a row in … (36467 more chars) ◀ result Germline Variant Guide ====================== Overview -------- cBioPortal stores both somatic AND germline variant data. Many cBioPortal features work identically for both variant types. This guide explains how to query germline variants and what to be aware of. How Germline Data is Stored --------------------------- ### mutation_status is free text — always compare case-insensitively Each study loads its own spelling. Germline calls appear as `'Germline'`, `'GERMLINE'` and `'germline'`; somatic calls as `'Somatic'`, `'SOMATIC'` and `'somatic'`; unannotated mutations as `'NA'`, `'.'`, `'Unknown'`, `'UNKNOWN'`, `'__UNKNOWN__'` and others. Matching one spelling silently drops whole studies (`mutation_status = 'Germline'` misses `all_stjude_2013`, `aml_stjude_2024` and `pog570_bcgsc_2020`). - **Germline:** `upper(mutation_status) = 'GERMLINE'` - **Somatic:** `upper(mutation_status) = 'SOMATIC'` — but only when the user asks for somatic-only. Many studies label their somatic calls `'NA'` or `'UNKNOWN'`, so for ordinary mutation questions follow common-pitfalls #3 and exclude only `'UNCALLED'`. - When unsure, list the values first: `SELECT mutation_status, count() FROM genomic_event_derived WHERE cancer_study_identifier = '{study_id}' AND variant_type = 'mutation' GROUP BY mutation_status` ### Where the column lives - `genomic_event_derived.mutation_status` (preferred): mutations, and structural variants (from `sv_status`: `'SOMATIC'`, `'Somatic'`, `'GERMLINE'`) - `mutation_derived.mutationStatus`: the same values for mutations Identifying Studies with Germline Data -------------------------------------- Not all studies include germline data. Always check before querying: ```sql -- Find studies containing germline mutations SELECT cancer_study_identifier, COUNT(*) as germline_count FROM genomic_event_derived WHERE variant_type = 'mutation' AND upper(mutation_status) = 'GERMLINE' GROUP BY cancer_study_identifier ORDER BY germline_count DESC ``` Common Query Patterns --------------------- ### Count germline vs somatic mutations per gene in a study ```sql SELECT hugo_gene_symbol, upper(mutation_status) AS status, COUNT(*) as count FROM genomic_event_derived WHERE cancer_study_identifier = '{study_id}' AND variant_type = 'mutation' AND upper(mutation_status) IN ('GERMLINE', 'SOMATIC') GROUP BY hugo_gene_symbol, status ORDER BY count DESC LIMIT 20 ``` ### Find patients with germline mutations in a specific gene ```sql SELECT DISTINCT patient_unique_id, sample_unique_id, mutation_variant, mutation_type FROM genomic_event_derived WHERE hugo_gene_symbol = '{GENE}' AND upper(mutation_status) = 'GERMLINE' AND cancer_study_identifier = '{study_id}' AND variant_type = 'mutation' ``` ### Germline mutation frequency The numerator is samples with a germline mutation in the gene; the denominator is samples **profiled** for the gene — not samples that happen to have a mutation in it. Take the denominator from mutation-frequency-guide Step 2 (or … (2222 more chars) ▶ clickhouse_run_select_query { "query": " SELECT cancer_study_identifier, patient_unique_id, sample_unique_id, mutation_variant, mutation_type, mutation_status FROM genomic_event_derived WHERE hugo_gene_symbol = 'TP53' AND variant_type = 'mutation' AND mutation_variant = 'G199V' ORDER BY cancer_study_identifier, patient_unique_id ", "max_rows": 200 } ◀ result {"rows":[{"cancer_study_identifier":"alk_msk_2026","patient_unique_id":"alk_msk_2026_C-RPRH27","sample_unique_id":"alk_msk_2026_s_C_RPRH27_X001_d01","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"NA"},{"cancer_study_identifier":"blca_tcga_gdc","patient_unique_id":"blca_tcga_gdc_TCGA-XF-A9ST","sample_unique_id":"blca_tcga_gdc_TCGA-XF-A9ST-01","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"Somatic"},{"cancer_study_identifier":"blca_tcga_pan_can_atlas_2018","patient_unique_id":"blca_tcga_pan_can_atlas_2018_TCGA-XF-A9ST","sample_unique_id":"blca_tcga_pan_can_atlas_2018_TCGA-XF-A9ST-01","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"."},{"cancer_study_identifier":"blca_tcga_pub_2017","patient_unique_id":"blca_tcga_pub_2017_TCGA-XF-A9ST","sample_unique_id":"blca_tcga_pub_2017_TCGA-XF-A9ST-01","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"Somatic"},{"cancer_study_identifier":"bm_nsclc_mskcc_2023","patient_unique_id":"bm_nsclc_mskcc_2023_P-0049559","sample_unique_id":"bm_nsclc_mskcc_2023_P-0049559-T01-IM6","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"SOMATIC"},{"cancer_study_identifier":"bowel_colitis_msk_2022","patient_unique_id":"bowel_colitis_msk_2022_TRF117586","sample_unique_id":"bowel_colitis_msk_2022_TRF117586","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"NA"},{"cancer_study_identifier":"braf_msk_impact_2024","patient_unique_id":"braf_msk_impact_2024_P-0046745","sample_unique_id":"braf_msk_impact_2024_P-0046745-T01-IM6","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"SOMATIC"},{"cancer_study_identifier":"brca_metabric","patient_unique_id":"brca_metabric_MB-2632","sample_unique_id":"brca_metabric_MB-2632","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"NA"},{"cancer_study_identifier":"brca_tcga","patient_unique_id":"brca_tcga_TCGA-A2-A0SX","sample_unique_id":"brca_tcga_TCGA-A2-A0SX-01","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"Somatic"},{"cancer_study_identifier":"brca_tcga","patient_unique_id":"brca_tcga_TCGA-C8-A27A","sample_unique_id":"brca_tcga_TCGA-C8-A27A-01","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"Somatic"},{"cancer_study_identifier":"brca_tcga_gdc","patient_unique_id":"brca_tcga_gdc_TCGA-A2-A0SX","sample_unique_id":"brca_tcga_gdc_TCGA-A2-A0SX-01","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"Somatic"},{"cancer_study_identifier":"brca_tcga_gdc","patient_unique_id":"brca_tcga_gdc_TCGA-C8-A27A","sample_unique_id":"brca_tcga_gdc_TCGA-C8-A27A-01","mutation_variant":"G199V","mutation_type":"Missense_Mutation","mutation_status":"Somatic"},{"cancer_study_identifier":"brca_tcga_pan_can_atlas_2018","patient_unique_id":"brca_tcga_pan_can_atlas_2018_TCGA-A2-A … (44379 more chars) ▶ clickhouse_run_select_query { "query": " SELECT cancer_study_identifier, patient_unique_id, upper(mutation_status) AS status FROM genomic_event_derived WHERE hugo_gene_symbol = 'TP53' AND variant_type = 'mutation' AND mutation_variant = 'G199V' AND upper(mutation_status) = 'GERMLINE' " } ◀ result {"rows":[{"cancer_study_identifier":"brca_tcga_pub","patient_unique_id":"brca_tcga_pub_TCGA-A2-A0SX","status":"GERMLINE"}]} ═ answer (success) Now I have the key facts. Let me summarize clearly, since this variant appears across an enormous number of overlapping cBioPortal studies (the same patients re-loaded under many different MSK and TCGA cohort versions). ## TP53 G199V — Summary The **TP53 p.G199V** missense mutation is recurrent and appears in dozens of cBioPortal studies, but almost all of these "hits" are the **same small set of underlying patients**, re-loaded under multiple overlapping cohorts (e.g., a single MSK-IMPACT patient shows up separately in `msk_impact_2017`, `msk_impact_50k_2026`, `msk_chord_2024`, `msk_met_2021`, and various disease-specific MSK sub-cohorts; a single TCGA patient shows up in `brca_tcga`, `brca_tcga_gdc`, `brca_tcga_pan_can_atlas_2018`, `brca_tcga_pub`, and `brca_tcga_pub2015`). **Do not read the ~180 rows as 180 distinct patients** — the true number of biologically distinct patients is far smaller (roughly two to three dozen), since study prefixes multiply the count of every real person. ### Somatic vs. Germline - **Germline:** Exactly **one** record is explicitly annotated `GERMLINE` — patient **TCGA-A2-A0SX** (breast cancer), in the [`brca_tcga_pub`](https://www.cbioportal.org/study/summary?id=brca_tcga_pub) study only. - **Somatic:** The great majority of records are explicitly labeled `SOMATIC`/`Somatic` (MSK-IMPACT-derived cohorts and most TCGA GDC re-processings). - **Unlabeled (`NA`, `.`, `UNKNOWN`):** A substantial fraction of records — including **that same patient TCGA-A2-A0SX** in the parallel studies `brca_tcga`, `brca_tcga_gdc`, and `brca_tcga_pan_can_atlas_2018` — carry no mutation-status annotation at all (`Somatic`/`.`/`NA` depending on the study's own loading conventions). This means **the same physical patient is labeled germline in one TCGA study version and somatic (or unlabeled) in others** — a data-provenance inconsistency between reprocessed versions of the same cohort, not necessarily two different biological events. I cannot resolve which label is authoritative from the database alone. Because of the scale and redundancy here, rather than list every one of the ~150+ study-prefixed rows, I recommend viewing this directly in the portal, filtered to the mutation of interest. The MSK-CHORD cohort (`msk_chord_2024`) is the largest **non-redundant** MSK cohort containing this variant (17 distinct patients, all labeled SOMATIC), and is a good single-cohort view; TCGA PanCancer studies are the standard reference for the germline-flagged case. **Note:** Only somatic driver/OncoKB annotations exist for mutations in this database when the study supplies them — I have not verified oncogenicity here, only the somatic/germline status field as loaded per study. Would you like me to open a filtered view? I can generate direct links to browse all patients carrying this variant in the OncoPrint/Mutations tab, or specifically to the germline-flagged TCGA-A2-A0SX patient page — let me know which you'd prefer, or if you'd like me to restrict this to one specific study rather than the full cross-database list.