Q (sonnet-5.5): I receive a report with the PIK3CA p.*1069Wext*3 mutation. Can you provide details of it ▶ read_guide { "uri": "cbioportal://mutation-frequency-guide" } ▶ read_guide { "uri": "cbioportal://common-pitfalls" } ◀ 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 # Common Query Pitfalls Guide ## Overview This guide highlights frequent mistakes when analyzing cBioPortal data and provides solutions to avoid them. ## Critical Pitfalls ### 1. 🚨 CRITICAL MUTATION FREQUENCY ERRORS #### ❌ WRONG: Using study-wide totals for gene frequencies ```sql -- INCORRECT - This gives wrong frequencies! SELECT hugo_gene_symbol, COUNT(DISTINCT sample_unique_id) as altered_samples, (SELECT COUNT(DISTINCT sample_unique_id) FROM genomic_event_derived WHERE cancer_study_identifier = 'your_study_id') as total_samples FROM genomic_event_derived WHERE variant_type = 'mutation' AND cancer_study_identifier = 'your_study_id' GROUP BY hugo_gene_symbol; ``` **Problem**: Different genes have different profiling coverage - you can't use study-wide totals! #### ❌ WRONG: Not using gene-specific profiling denominators ```sql -- INCORRECT - Missing gene-specific denominators SELECT hugo_gene_symbol, COUNT(DISTINCT sample_unique_id) as altered_samples FROM genomic_event_derived WHERE variant_type = 'mutation' GROUP BY hugo_gene_symbol; -- Missing: WHERE ARE THE DENOMINATORS FOR EACH GENE? ``` #### ❌ WRONG: Skipping individual gene profiling queries **Problem**: Failing to run separate profiling queries for EACH gene in results. **Each gene has different coverage**: TP53 might be profiled in 25,040 samples, MUC16 in 23,000, etc. #### ✅ CORRECT: Complete gene-specific workflow ```sql -- STEP 1: Get altered counts per gene SELECT hugo_gene_symbol, entrez_gene_id, COUNT(DISTINCT CASE WHEN off_panel = 0 THEN sample_unique_id END) AS numberOfAlteredSamplesOnPanel, COUNT(*) AS totalMutationEvents FROM genomic_event_derived WHERE variant_type = 'mutation' AND mutation_status != 'UNCALLED' GROUP BY entrez_gene_id, hugo_gene_symbol ORDER BY numberOfAlteredSamplesOnPanel DESC; -- STEP 2: FOR EACH GENE, run this profiling query: SELECT COUNT(DISTINCT stgp.sample_unique_id) AS numberOfProfiledSamples FROM sample_to_gene_panel_derived stgp JOIN gene_panel gp ON stgp.gene_panel_id = gp.stable_id JOIN gene_panel_list gpl ON gp.internal_id = gpl.internal_id JOIN gene g ON gpl.gene_id = g.entrez_gene_id WHERE stgp.alteration_type = 'MUTATION_EXTENDED' AND g.hugo_gene_symbol = 'TP53' -- Replace with each gene from Step 1 AND stgp.cancer_study_identifier = 'your_study_id'; -- STEP 3: Calculate frequency = numberOfAlteredSamplesOnPanel / numberOfProfiledSamples * 100 ``` #### 🚨 WORKFLOW REQUIREMENTS VIOLATIONS: - **Missing denominator columns**: Must show gene-specific profiled samples per row - **Wrong table format**: Should be | Gene | # Mutations | # Samples | Profiled Samples | Sample % | - **Not replacing gene symbols**: Must replace 'TP53' with actual gene for each query - **Using study totals**: Never use genomic_event_derived for total sample counts ### 2. 🚨 OFF-PANEL MUTATION INCLUSION #### ❌ Wrong: Including off-panel mutations ```sql -- INCORRECT - Includes mutations outside gene panels SELEC … (38012 more chars) ▶ clickhouse_list_table_columns { "table": "genomic_event_derived" } ◀ result {"columns":[{"name":"sample_unique_id","type":"String"},{"name":"hugo_gene_symbol","type":"String","comment":"HUGO gene symbol (e.g., TP53, KRAS, BRAF). Use for gene-specific queries."},{"name":"entrez_gene_id","type":"Int32"},{"name":"gene_panel_stable_id","type":"LowCardinality(String)"},{"name":"cancer_study_identifier","type":"LowCardinality(String)"},{"name":"genetic_profile_stable_id","type":"LowCardinality(String)"},{"name":"variant_type","type":"LowCardinality(String)","comment":"Type of genomic event: \"mutation\" for SNVs/indels, \"cna\" for copy number alterations, \"structural_variant\" for SVs. Always filter by this."},{"name":"mutation_variant","type":"String","comment":"Protein change notation (e.g., p.V600E, p.R175H). Use for specific variant queries. \"NA\" for non-mutation events."},{"name":"mutation_type","type":"LowCardinality(String)"},{"name":"mutation_status","type":"LowCardinality(String)","comment":"For mutations: Somatic, Germline, UNKNOWN, or UNCALLED. Filter mutation_status != \"UNCALLED\" to exclude uncertain calls. Include all other statuses."},{"name":"driver_filter","type":"LowCardinality(String)"},{"name":"driver_filter_annotation","type":"String"},{"name":"driver_tiers_filter","type":"LowCardinality(String)"},{"name":"driver_tiers_filter_annotation","type":"String"},{"name":"cna_alteration","type":"Nullable(Int8)","comment":"Copy number alteration: only 2 = amplification (AMP) and -2 = deep deletion (HOMDEL) are stored. Shallow deletion (-1), diploid (0) and gain (1) are not in this table; query genetic_alteration_derived WHERE profile_type = 'gistic' (alteration_value is a String, e.g. '-1'). NULL for non-CNA events."},{"name":"cna_cytoband","type":"String"},{"name":"sv_event_info","type":"String"},{"name":"patient_unique_id","type":"String"},{"name":"off_panel","type":"Bool","comment":"Boolean: 1 = mutation outside gene panel coverage (off-panel), 0 = within panel (on-panel). Filter off_panel = 0 for reliable frequency calculations."}]} ▶ clickhouse_run_select_query { "query": "SELECT cancer_study_identifier, mutation_variant, mutation_type, mutation_status, driver_filter, count() AS events, uniqExact(sample_unique_id) AS samples, uniqExact(patient_unique_id) AS patients FROM genomic_event_derived WHERE hugo_gene_symbol='PIK3CA' AND variant_type='mutation' AND mutation_status!='UNCALLED' AND (mutation_variant LIKE '%1069%' OR mutation_type='Nonstop_Mutation') GROUP BY cancer_study_identifier, mutation_variant, mutation_type, mutation_status, driver_filter ORDER BY samples DESC" } ◀ result {"rows":[{"cancer_study_identifier":"msk_impact_2017","mutation_variant":"*1069Ffs*5","mutation_type":"Frame_Shift_Ins","mutation_status":"NA","events":3,"samples":3,"patients":3},{"cancer_study_identifier":"msk_impact_50k_2026","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":3,"samples":3,"patients":3},{"cancer_study_identifier":"msk_impact_50k_2026","mutation_variant":"*1069Ffs*5","mutation_type":"Frame_Shift_Ins","mutation_status":"SOMATIC","events":3,"samples":3,"patients":3},{"cancer_study_identifier":"msk_chord_2024","mutation_variant":"*1069Ffs*5","mutation_type":"Frame_Shift_Ins","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"msk_chord_2024","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"cellline_ccle_broad","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"NA","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"msk_impact_50k_2026","mutation_variant":"*1069*","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"pancan_mimsi_msk_2024","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"msk_met_2021","mutation_variant":"*1069Ffs*5","mutation_type":"Frame_Shift_Ins","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"msk_met_2021","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"msk_impact_50k_2026","mutation_variant":"*1068*","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"crc_msk_2026","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"ccle_broad_2019","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"NA","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"breast_msk_2026","mutation_variant":"*1069*","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"ccle_broad_2025","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"NA","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"ccle_genentech_2014","mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","mutation_status":"NA","events":2,"samples":2,"patients":2},{"cancer_study_identifier":"breast_msk_2026","mutation_variant":"*1064*","mutation_type":"Nonstop_Mutation","mutation_status":"SOMATIC","events":2,"samples":2,"patients":1} … (5754 more chars) ▶ clickhouse_run_select_query { "query": "SELECT * FROM gene_mutation_variants_in_study(study='msk_impact_50k_2026', gene='PIK3CA') WHERE mutation_variant LIKE '*1069%' OR mutation_type='Nonstop_Mutation'" } ▶ resolve_and_route { "studyIds": [ "msk_impact_50k_2026" ] } ◀ result {"rows":[{"mutation_variant":"*1069Ffs*5","mutation_type":"Frame_Shift_Ins","altered_samples":3,"profiled_samples":54331,"frequency_pct":0,"total_mutation_events":3},{"mutation_variant":"*1069Wext*4","mutation_type":"Nonstop_Mutation","altered_samples":3,"profiled_samples":54331,"frequency_pct":0,"total_mutation_events":3},{"mutation_variant":"*1068*","mutation_type":"Nonstop_Mutation","altered_samples":2,"profiled_samples":54331,"frequency_pct":0,"total_mutation_events":2},{"mutation_variant":"*1069*","mutation_type":"Nonstop_Mutation","altered_samples":2,"profiled_samples":54331,"frequency_pct":0,"total_mutation_events":2},{"mutation_variant":"*1069Lfs*4","mutation_type":"Frame_Shift_Ins","altered_samples":1,"profiled_samples":54331,"frequency_pct":0,"total_mutation_events":1}]} ◀ result {"success":true,"message":"Found 1 study. Use the metadata to call the appropriate navigation tool(s).","data":{"totalCount":1,"studiesWithMetadata":[{"studyId":"msk_impact_50k_2026","name":"MSK-IMPACT 50K Clinical Sequencing Cohort (MSK, Cancer Cell 2026)","sampleCount":54331,"studyViewUrl":"https://www.cbioportal.org/study?id=msk_impact_50k_2026","metadata":{"clinicalAttributeIds":["AGE_AT_DX","ANCESTRY_LABEL","CANCER_TYPE","CANCER_TYPE_DETAILED","DISEASE_STATUS","FACETS_PLOIDY","FACETS_PURITY","FACETS_QC","FACETS_SUITE_VERSION","FACETS_WGD","FRACTION_GENOME_ALTERED","GENE_PANEL","HLA-A1","HLA-A2","HLA-B1","HLA-B2","HLA-C1","HLA-C2","HLA_A1_LOH","HLA_A2_LOH","HLA_B1_LOH","HLA_B2_LOH","HLA_C1_LOH","HLA_C2_LOH","HLA_GENOTYPE_AVAILABLE","METASTATIC_SITE","MSI_SCORE","MSI_TYPE","MUTATION_COUNT","N_OTHER_CANCER_TYPES","ONCOTREE_CODE","OS_MONTHS","OS_STATUS","PRIMARY_SITE","PURITY_ESTIMATE_FROM_MUTATIONS","SAMPLE_COUNT","SAMPLE_COVERAGE","SAMPLE_TYPE","SEX","SOMATIC_STATUS","TMB_SCORE","TUMOR_PURITY"],"molecularProfileIds":["msk_impact_50k_2026_gistic","msk_impact_50k_2026_mutations","msk_impact_50k_2026_structural_variants"],"genericAssayProfiles":["msk_impact_50k_2026_armlevel_cna","msk_impact_50k_2026_loh_hla","msk_impact_50k_2026_mutational_signatures_contribution_v2"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations","generic_assay_armlevel_cna","generic_assay_loh_hla","generic_assay_mutational_signature"]}}]}} ▶ navigate_to_results_view { "studyIds": [ "msk_impact_50k_2026" ], "genes": [ "PIK3CA: MUT" ], "tab": "mutations" } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/results/mutations?cancer_study_list=msk_impact_50k_2026&gene_list=PIK3CA%3A+MUT&case_set_id=msk_impact_50k_2026_all","url":"https://www.cbioportal.org/results/mutations?cancer_study_list=msk_impact_50k_2026&gene_list=PIK3CA%3A+MUT&case_set_id=msk_impact_50k_2026_all","data":{"studyIds":["msk_impact_50k_2026"],"studies":[{"studyId":"msk_impact_50k_2026","name":"MSK-IMPACT 50K Clinical Sequencing Cohort (MSK, Cancer Cell 2026)","sampleCount":54331}],"genes":["PIK3CA"],"caseSetId":"msk_impact_50k_2026_all","pageDescription":"Detailed mutation table with lollipop plot showing mutation positions, types, and frequencies for queried genes."}} ═ answer (success) **I found no exact match for `PIK3CA p.*1069Wext*3` in cBioPortal, but the closely related `p.*1069Wext*4` is present.** **Possible discrepancy in your report.** The stop-loss variant recorded in the database at this position is `*1069Wext*4`. The extension length, `*3` versus `*4`, differs from your report. That may be a difference in transcript or annotation, or a typo in the report. Please check the transcript and the cDNA change (c.) in the report. I didn't treat the two as the same variant. **What the notation means.** The stop codon at position 1069 is changed to tryptophan (W). The protein then extends past its normal end, and a new stop codon follows after the stated number of extra amino acids. It is classified as a Nonstop (stop-loss) mutation. **Where `*1069Wext*4` appears in cBioPortal.** Each entry below is one sample from one patient unless a count is given. | Study | Samples | |---|---| | MSK-IMPACT 50K (`msk_impact_50k_2026`) | 3 of 54,331 profiled | | MSK-CHORD 2024 | 2 | | MSK-MET 2021 | 2 | | MSI pan-cancer MSK 2024 | 2 | | CRC MSK 2026 | 2 | | TCGA glioblastoma (`gbm_tcga`, `gbm_tcga_gdc`, `gbm_tcga_pan_can_atlas_2018`, `gbm_tcga_pub2013`, `lgggbm_tcga_pub`) | 1 each | | METABRIC breast | 1 | | CCLE and NCI-60 cell lines, and a colorectal study (`coadread_dfci_2016`) | 1–2 each | - **Frequency:** In the largest cohort, MSK-IMPACT 50K, the variant is in 3 of 54,331 samples (about 0.006%), so it is very rare. - **Somatic status:** Where somatic status is recorded, it is called somatic. Several studies leave it blank. - **Other stop-loss calls nearby:** Other stop-loss variants of PIK3CA at positions 1064–1069 appear in a few samples (for example `*1069*`, `*1068*` and `*1069Rext*4`). Frameshifts at the same codon (`*1069Ffs*5`) are also recorded. **Limits of this data.** - I checked whether the study data carries a custom driver annotation for these entries. It doesn't, so I can't say whether this variant is oncogenic, a driver or a passenger. - Occurrence counts alone don't show functional or clinical significance. For that you need an external curated source such as OncoKB, ClinVar or the primary literature. I did not consult any of these, and this is not clinical advice. **Explore it yourself.** [PIK3CA Mutations tab, MSK-IMPACT 50K](https://www.cbioportal.org/results/mutations?cancer_study_list=msk_impact_50k_2026&gene_list=PIK3CA%3A+MUT&case_set_id=msk_impact_50k_2026_all) has the lollipop plot and mutation table, where you can find the C-terminal stop-loss variants. If you send the c. notation and transcript ID from the report, I can look for a closer match.