Q (sonnet): What cancer types in MSK-IMPACT have mutations in TP53? ▶ read_guide { "uri": "cbioportal://mutation-frequency-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 … (35166 more chars) ▶ list_studies { "search": "MSK-IMPACT" } ◀ result {"result":[{"cancer_study_identifier":"msk_impact_50k_2026","name":"MSK-IMPACT 50K Clinical Sequencing Cohort (MSK, Cancer Cell 2026)","type_of_cancer_id":"mixed","sample_count":54331,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=msk_impact_50k_2026"},{"cancer_study_identifier":"msk_ch_2023","name":"Cancer Therapy and Clonal Hematopoiesis (MSK, Blood Adv 2023)","type_of_cancer_id":"mixed","sample_count":42714,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=msk_ch_2023"},{"cancer_study_identifier":"msk_chord_2024","name":"MSK-CHORD (MSK, Nature 2024)","type_of_cancer_id":"mixed","sample_count":25040,"has_guide":true,"url":"https://www.cbioportal.org/study/summary?id=msk_chord_2024"},{"cancer_study_identifier":"msk_ch_2020","name":"Cancer Therapy and Clonal Hematopoiesis (MSK, Nat Genet 2020)","type_of_cancer_id":"mixed","sample_count":24146,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=msk_ch_2020"},{"cancer_study_identifier":"msk_impact_2017","name":"MSK-IMPACT Clinical Sequencing Cohort (MSK, Nat Med 2017)","type_of_cancer_id":"mixed","sample_count":10945,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=msk_impact_2017"},{"cancer_study_identifier":"crc_msk_2026","name":"Colorectal Adenocarcinoma (MSK, 2026)","type_of_cancer_id":"read","sample_count":7237,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=crc_msk_2026"},{"cancer_study_identifier":"breast_msk_2026","name":"CCNE1 Amplifications in Breast Cancer (MSK, 2026)","type_of_cancer_id":"breast","sample_count":6318,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=breast_msk_2026"},{"cancer_study_identifier":"pancan_mimsi_msk_2024","name":"Mixed Tumors - MiMSI Cohort (MSK, Nat Commun 2024)","type_of_cancer_id":"mixed","sample_count":5033,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=pancan_mimsi_msk_2024"},{"cancer_study_identifier":"breast_msk_2025","name":"Breast Cancer (MSK, Nat Genet 2025)","type_of_cancer_id":"brca","sample_count":3879,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=breast_msk_2025"},{"cancer_study_identifier":"mycf_msk_2026","name":"MYC Family Amplifications in MSK-IMPACT Solid Tumors (MSK, 2026)","type_of_cancer_id":"mixed","sample_count":3442,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=mycf_msk_2026"},{"cancer_study_identifier":"heme_msk_impact_2022","name":"MSK-IMPACT Heme Tumors (MSK, 2022)","type_of_cancer_id":"mixed","sample_count":2383,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=heme_msk_impact_2022"},{"cancer_study_identifier":"pdac_msk_2024","name":"Pancreatic Adenocarcinoma (MSK, Nat Med 2024)","type_of_cancer_id":"pancreas","sample_count":2336,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=pdac_msk_2024"},{"cancer_study_identifier":"prostate_msk_2024","name":"Prostate Cancer (MSK, Clin Cancer Res 2024)","type_of_cancer_id" … (1829 more chars) ▶ clickhouse_run_select_query { "query": "SELECT * FROM gene_mutation_frequency_in_study(study = 'msk_impact_2017', gene = 'TP53') ORDER BY frequency_pct DESC", "max_rows": 100 } ◀ result {"rows":[{"cancer_type":"Small Cell Lung Cancer","altered_samples":71,"profiled_samples":82,"frequency_pct":86.6},{"cancer_type":"Colorectal Cancer","altered_samples":724,"profiled_samples":1007,"frequency_pct":71.9},{"cancer_type":"Ovarian Cancer","altered_samples":159,"profiled_samples":224,"frequency_pct":71},{"cancer_type":"Esophagogastric Cancer","altered_samples":239,"profiled_samples":341,"frequency_pct":70.1},{"cancer_type":"Pancreatic Cancer","altered_samples":287,"profiled_samples":502,"frequency_pct":57.2},{"cancer_type":"Non-Small Cell Lung Cancer","altered_samples":917,"profiled_samples":1668,"frequency_pct":55},{"cancer_type":"Endometrial Cancer","altered_samples":116,"profiled_samples":218,"frequency_pct":53.2},{"cancer_type":"Skin Cancer, Non-Melanoma","altered_samples":76,"profiled_samples":148,"frequency_pct":51.4},{"cancer_type":"Cancer of Unknown Primary","altered_samples":84,"profiled_samples":186,"frequency_pct":45.2},{"cancer_type":"Head and Neck Cancer","altered_samples":82,"profiled_samples":186,"frequency_pct":44.1},{"cancer_type":"Breast Cancer","altered_samples":553,"profiled_samples":1337,"frequency_pct":41.4},{"cancer_type":"Glioma","altered_samples":219,"profiled_samples":553,"frequency_pct":39.6},{"cancer_type":"Bladder Cancer","altered_samples":167,"profiled_samples":423,"frequency_pct":39.5},{"cancer_type":"Uterine Sarcoma","altered_samples":34,"profiled_samples":93,"frequency_pct":36.6},{"cancer_type":"Appendiceal Cancer","altered_samples":28,"profiled_samples":79,"frequency_pct":35.4},{"cancer_type":"Prostate Cancer","altered_samples":217,"profiled_samples":717,"frequency_pct":30.3},{"cancer_type":"Hepatobiliary Cancer","altered_samples":95,"profiled_samples":355,"frequency_pct":26.8},{"cancer_type":"Mature B-Cell Neoplasms","altered_samples":31,"profiled_samples":134,"frequency_pct":23.1},{"cancer_type":"Salivary Gland Cancer","altered_samples":24,"profiled_samples":114,"frequency_pct":21.1},{"cancer_type":"Melanoma","altered_samples":75,"profiled_samples":365,"frequency_pct":20.5},{"cancer_type":"Cervical Cancer","altered_samples":10,"profiled_samples":50,"frequency_pct":20},{"cancer_type":"Soft Tissue Sarcoma","altered_samples":88,"profiled_samples":443,"frequency_pct":19.9},{"cancer_type":"Thyroid Cancer","altered_samples":40,"profiled_samples":231,"frequency_pct":17.3},{"cancer_type":"Renal Cell Carcinoma","altered_samples":54,"profiled_samples":361,"frequency_pct":15},{"cancer_type":"Bone Cancer","altered_samples":20,"profiled_samples":134,"frequency_pct":14.9},{"cancer_type":"Germ Cell Tumor","altered_samples":33,"profiled_samples":288,"frequency_pct":11.5},{"cancer_type":"Mesothelioma","altered_samples":11,"profiled_samples":107,"frequency_pct":10.3},{"cancer_type":"Gastrointestinal Stromal Tumor","altered_samples":9,"profiled_samples":137,"frequency_pct":6.6},{"cancer_type":"Peripheral Nervous System","altered_samples":1,"profiled_samples":80,"frequency_pct":1.2}]} ▶ resolve_and_route { "studyIds": [ "msk_impact_2017" ] } ◀ result {"success":true,"message":"Found 1 study. Use the metadata to call the appropriate navigation tool(s).","data":{"totalCount":1,"studiesWithMetadata":[{"studyId":"msk_impact_2017","name":"MSK-IMPACT Clinical Sequencing Cohort (MSK, Nat Med 2017)","sampleCount":10945,"studyViewUrl":"https://www.cbioportal.org/study?id=msk_impact_2017","metadata":{"clinicalAttributeIds":["CANCER_TYPE","CANCER_TYPE_DETAILED","DNA_INPUT","FRACTION_GENOME_ALTERED","MATCHED_STATUS","METASTATIC_SITE","MUTATION_COUNT","ONCOTREE_CODE","OS_MONTHS","OS_STATUS","PRIMARY_SITE","SAMPLE_CLASS","SAMPLE_COLLECTION_SOURCE","SAMPLE_COUNT","SAMPLE_COVERAGE","SAMPLE_TYPE","SEX","SMOKING_HISTORY","SOMATIC_STATUS","SPECIMEN_PRESERVATION_TYPE","SPECIMEN_TYPE","TMB_NONSYNONYMOUS","TUMOR_PURITY","VITAL_STATUS"],"molecularProfileIds":["msk_impact_2017_cna","msk_impact_2017_mutations","msk_impact_2017_structural_variants"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations"]}}]}} ▶ navigate_to_study_view { "studyIds": [ "msk_impact_2017" ], "filterJson": { "geneFilters": [ { "molecularProfileIds": [ "msk_impact_2017_mutations" ], "geneQueries": [ [ { "hugoGeneSymbol": "TP53" } ] ] } ] } } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/study/summary?id=msk_impact_2017#filterJson=%7B%22geneFilters%22%3A%5B%7B%22geneQueries%22%3A%5B%5B%7B%22hugoGeneSymbol%22%3A%22TP53%22%7D%5D%5D%2C%22molecularProfileIds%22%3A%5B%22msk_impact_2017_mutations%22%5D%7D%5D%7D","url":"https://www.cbioportal.org/study/summary?id=msk_impact_2017#filterJson=%7B%22geneFilters%22%3A%5B%7B%22geneQueries%22%3A%5B%5B%7B%22hugoGeneSymbol%22%3A%22TP53%22%7D%5D%5D%2C%22molecularProfileIds%22%3A%5B%22msk_impact_2017_mutations%22%5D%7D%5D%7D","data":{"studyIds":["msk_impact_2017"],"studies":[{"studyId":"msk_impact_2017","name":"MSK-IMPACT Clinical Sequencing Cohort (MSK, Nat Med 2017)","sampleCount":10945}],"tab":"summary","hasFilters":true,"hasPlotsConfig":false,"pageDescription":"Overview of all study data displayed as interactive charts summarizing available clinical and genomic data. Click within a chart to filter. Additional charts may be available in the Charts menu."}} ▶ navigate_to_results_view { "studyIds": [ "msk_impact_2017" ], "genes": [ "TP53" ], "tab": "cancerTypesSummary" } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/results/cancerTypesSummary?cancer_study_list=msk_impact_2017&gene_list=TP53&case_set_id=msk_impact_2017_all","url":"https://www.cbioportal.org/results/cancerTypesSummary?cancer_study_list=msk_impact_2017&gene_list=TP53&case_set_id=msk_impact_2017_all","data":{"studyIds":["msk_impact_2017"],"studies":[{"studyId":"msk_impact_2017","name":"MSK-IMPACT Clinical Sequencing Cohort (MSK, Nat Med 2017)","sampleCount":10945}],"genes":["TP53"],"caseSetId":"msk_impact_2017_all","pageDescription":"Alteration frequencies for queried genes by cancer type."}} ═ answer (success) **Navigate:** - [Cancer Types Summary — TP53 in MSK-IMPACT](https://www.cbioportal.org/results/cancerTypesSummary?cancer_study_list=msk_impact_2017&gene_list=TP53&case_set_id=msk_impact_2017_all) — Alteration frequencies for TP53 broken down by cancer type across the full cohort. - [Study View filtered to TP53-mutant samples](https://www.cbioportal.org/study/summary?id=msk_impact_2017#filterJson=%7B%22geneFilters%22%3A%5B%7B%22geneQueries%22%3A%5B%5B%7B%22hugoGeneSymbol%22%3A%22TP53%22%7D%5D%5D%2C%22molecularProfileIds%22%3A%5B%22msk_impact_2017_mutations%22%5D%7D%5D%7D) — Explore clinical/genomic distribution of the TP53-mutant subcohort (10,945-sample MSK-IMPACT study).