Q (sonnet): How many patients have a shallow deletion for SMARCA4 in the POG study? ▶ list_guides {} ▶ list_studies { "search": "POG" } ◀ result {"result":[{"uri":"cbioportal://mutation-frequency-guide","description":"Comprehensive guide for calculating gene mutation frequencies with gene-specific profiling denominators"},{"uri":"cbioportal://clinical-data-guide","description":"Guide for querying clinical data including patient vs sample level considerations"},{"uri":"cbioportal://sample-filtering-guide","description":"Guide for filtering samples and studies in cBioPortal queries"},{"uri":"cbioportal://common-pitfalls","description":"Guide to avoid common mistakes when querying cBioPortal data. If you already know which numbered pitfall applies, fetch just that section via read_guide(\"cbioportal://common-pitfalls#\") (e.g. #16) instead of the full guide"},{"uri":"cbioportal://treatment-guide","description":"Guide for querying treatment/clinical event data including drug agents, timelines, and linking to genomic data"},{"uri":"cbioportal://faq-guide","description":"General cBioPortal FAQ: history, how to cite, data types, reference genome, abbreviations, GISTIC thresholds, API access"},{"uri":"cbioportal://statistical-tests-guide","description":"Statistical test selection guide — decision matrix for choosing Fisher's exact, Wilcoxon, chi-squared, t-test, ANOVA, etc. based on data type and group count"},{"uri":"cbioportal://gene-expression-guide","description":"Gene expression / copy-number / methylation analysis. Covers genetic_alteration_derived, profile_type discovery, and the gene_pair_coexpression view for Spearman correlation between two genes"},{"uri":"cbioportal://external-resources-guide","description":"Guide for finding external linked resources such as imaging, pathology, Minerva, HTAN, or other resource_* table links before declaring data unavailable"},{"uri":"cbioportal://gene-resolution-guide","description":"Guide for resolving ambiguous gene symbols, aliases, gene families, and shorthand such as CD3 before querying expression or alteration data"},{"uri":"cbioportal://study-resolution-guide","description":"Guide for resolving requested studies, avoiding silent substitute cohorts, and redirecting to known external cBioPortal instances when data is not in this deployment"},{"uri":"cbioportal://germline-guide","description":"Guide for querying germline variant data — storage columns, study discovery, query patterns, and somatic vs germline considerations"},{"uri":"cbioportal://study-guide/{study_id}","description":"Dynamic study-specific guide - use get_study_guide(study_id) tool to generate"}]} ◀ result {"result":[{"cancer_study_identifier":"pog570_bcgsc_2020","name":"Pan-cancer Analysis of Advanced and Metastatic Tumors (BCGSC, Nature Cancer 2020)","type_of_cancer_id":"mixed","sample_count":570,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=pog570_bcgsc_2020"}]} ▶ read_guide { "uri": "cbioportal://mutation-frequency-guide" } ▶ clickhouse_list_table_columns { "table": "genomic_event_derived" } ◀ 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) ◀ 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 count() AS sample_rows, uniqExact(sample_unique_id) AS shallow_del_samples, uniqExact(patient_unique_id) AS shallow_del_patients FROM genetic_alteration_derived WHERE cancer_study_identifier = 'pog570_bcgsc_2020' AND hugo_gene_symbol = 'SMARCA4' AND profile_type = 'gistic' AND alteration_value = '-1'" } ◀ result {"error_message":"Query execution failed: HTTPDriver for https://dl96orhu96.us-east-1.aws.clickhouse.cloud:8443 received ClickHouse error code 47\n Code: 47. DB::Exception: Unknown expression or function identifier `patient_unique_id` in scope SELECT count() AS sample_rows, uniqExact(sample_unique_id) AS shallow_del_samples, uniqExact(patient_unique_id) AS shallow_del_patients FROM genetic_alteration_derived WHERE (cancer_study_identifier = 'pog570_bcgsc_2020') AND (hugo_gene_symbol = 'SMARCA4') AND (profile_type = 'gistic') AND (alteration_value = '-1'). Maybe you meant: ['sample_unique_id']. (UNKNOWN_IDENTIFIER) (version 26.4.1.2359 (official build))\n"} ▶ clickhouse_run_select_query { "query": "SELECT uniqExact(c.patient_unique_id) AS shallow_del_patients, uniqExact(g.sample_unique_id) AS shallow_del_samples FROM genetic_alteration_derived g JOIN ( SELECT DISTINCT sample_unique_id, patient_unique_id FROM clinical_data_derived WHERE cancer_study_identifier = 'pog570_bcgsc_2020' ) c USING (sample_unique_id) WHERE g.cancer_study_identifier = 'pog570_bcgsc_2020' AND g.hugo_gene_symbol = 'SMARCA4' AND g.profile_type = 'gistic' AND g.alteration_value = '-1'" } ◀ result {"rows":[{"shallow_del_patients":111,"shallow_del_samples":111}]} ▶ clickhouse_run_select_query { "query": "SELECT count() AS profiled_samples FROM genetic_alteration_derived WHERE cancer_study_identifier = 'pog570_bcgsc_2020' AND hugo_gene_symbol = 'SMARCA4' AND profile_type = 'gistic' AND alteration_value NOT IN ('', 'NA')" } ◀ result {"rows":[{"profiled_samples":570}]} ▶ resolve_and_route { "studyIds": [ "pog570_bcgsc_2020" ] } ◀ result {"success":true,"message":"Found 1 study. Use the metadata to call the appropriate navigation tool(s).","data":{"totalCount":1,"studiesWithMetadata":[{"studyId":"pog570_bcgsc_2020","name":"Pan-cancer Analysis of Advanced and Metastatic Tumors (BCGSC, Nature Cancer 2020)","sampleCount":570,"studyViewUrl":"https://www.cbioportal.org/study?id=pog570_bcgsc_2020","metadata":{"clinicalAttributeIds":["AGE","ANALYSIS_COHORT","BIOPSY_COHORT","BIOPSY_SITE","CANCER_TYPE","CANCER_TYPE_DETAILED","GENDER","HRD_SCORE","ICI","ICI_BEST_RESPONSE","ICI_DURABLE_CLINICAL_BENEFIT","ICI_MUTATION_CATEGORY","MSI_SCORE","MUTATION_COUNT","ONCOTREE_CODE","OS_MONTHS","OS_STATUS","PRIMARY_SITE","SAMPLE_COUNT","SAMPLE_TYPE","SOMATIC_STATUS","TMB_NONSYNONYMOUS","TREATED_WITH_ICI","TREATMENT_CATEGORY","TUMOR_CONTENT","T_CELLS_CD4_MEMORY_ACTIVATED","T_CELLS_CD4_MEMORY_RESTING","T_CELLS_CD4_NAIVE","T_CELLS_CD8","T_CELLS_FOLLICULAR_HELPER","T_CELLS_GAMMA_DELTA","T_CELLS_REGULATORY_TREGS"],"molecularProfileIds":["pog570_bcgsc_2020_gistic","pog570_bcgsc_2020_mutations","pog570_bcgsc_2020_rna_seq_mrna","pog570_bcgsc_2020_rna_seq_mrna_median_all_sample_Zscores","pog570_bcgsc_2020_structural_variants"],"genericAssayProfiles":["pog570_bcgsc_2020_immune_cell_signature"],"heatmapProfileIds":["pog570_bcgsc_2020_rna_seq_mrna_median_all_sample_Zscores"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations","mrna","generic_assay_immune_cell_signature"]}}]}} ▶ navigate_to_study_view { "studyIds": [ "pog570_bcgsc_2020" ], "filterJson": { "genomicDataFilters": [ { "hugoGeneSymbol": "SMARCA4", "profileType": "gistic", "values": [ { "value": "-1" } ] } ] } } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/study/summary?id=pog570_bcgsc_2020#filterJson=%7B%22genomicDataFilters%22%3A%5B%7B%22hugoGeneSymbol%22%3A%22SMARCA4%22%2C%22profileType%22%3A%22gistic%22%2C%22values%22%3A%5B%7B%22value%22%3A%22-1%22%7D%5D%7D%5D%7D","url":"https://www.cbioportal.org/study/summary?id=pog570_bcgsc_2020#filterJson=%7B%22genomicDataFilters%22%3A%5B%7B%22hugoGeneSymbol%22%3A%22SMARCA4%22%2C%22profileType%22%3A%22gistic%22%2C%22values%22%3A%5B%7B%22value%22%3A%22-1%22%7D%5D%7D%5D%7D","data":{"studyIds":["pog570_bcgsc_2020"],"studies":[{"studyId":"pog570_bcgsc_2020","name":"Pan-cancer Analysis of Advanced and Metastatic Tumors (BCGSC, Nature Cancer 2020)","sampleCount":570}],"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."}} ═ answer (success) ## Results **Study:** POG570 (Pan-cancer Analysis of Advanced and Metastatic Tumors, BCGSC, *Nature Cancer* 2020) — `pog570_bcgsc_2020` **SMARCA4 shallow deletions (GISTIC discrete CNA, value = -1):** - **111 patients** (111 samples; one sample per patient in this cohort) have a SMARCA4 shallow deletion - Denominator: 570 samples profiled for discrete CNA - Frequency: 111 / 570 = **19.5%** [View SMARCA4 shallow-deletion cohort in POG570 StudyView](https://www.cbioportal.org/study/summary?id=pog570_bcgsc_2020#filterJson=%7B%22genomicDataFilters%22%3A%5B%7B%22hugoGeneSymbol%22%3A%22SMARCA4%22%2C%22profileType%22%3A%22gistic%22%2C%22values%22%3A%5B%7B%22value%22%3A%22-1%22%7D%5D%7D%5D%7D) 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.