Q (sonnet): "What are the top 5 frequently altered genes in the Osteosarcoma study from TARGET for mutations, copy numbers and SVs combined?" ▶ list_studies { "search": "Osteosarcoma TARGET" } ▶ read_guide { "uri": "cbioportal://mutation-frequency-guide" } ◀ result {"result":[{"cancer_study_identifier":"os_target_gdc","name":"Osteosarcoma (TARGET GDC, 2025)","type_of_cancer_id":"os","sample_count":159,"has_guide":true,"url":"https://www.cbioportal.org/study/summary?id=os_target_gdc"}]} ◀ 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) ▶ clickhouse_run_select_query { "query": " SELECT hugo_gene_symbol, COUNT(DISTINCT CASE WHEN variant_type = 'mutation' AND mutation_status != 'UNCALLED' THEN sample_unique_id END) AS mut_samples, COUNT(DISTINCT CASE WHEN variant_type = 'cna' AND cna_alteration IN (2,-2) THEN sample_unique_id END) AS cna_samples, COUNT(DISTINCT CASE WHEN variant_type = 'structural_variant' THEN sample_unique_id END) AS sv_samples, COUNT(DISTINCT CASE WHEN (variant_type = 'mutation' AND mutation_status != 'UNCALLED') OR (variant_type = 'cna' AND cna_alteration IN (2,-2)) OR (variant_type = 'structural_variant') THEN sample_unique_id END) AS altered_samples FROM genomic_event_derived WHERE cancer_study_identifier = 'os_target_gdc' GROUP BY hugo_gene_symbol ORDER BY altered_samples DESC LIMIT 15 " } ▶ clickhouse_run_select_query { "query": "SELECT cancer_study_identifier, sample_count, mutation_sample_count, cna_sample_count, resource_sample_counts FROM cancer_study WHERE cancer_study_identifier = 'os_target_gdc'" } ◀ result {"rows":[{"hugo_gene_symbol":"TP53","mut_samples":32,"cna_samples":6,"sv_samples":0,"altered_samples":38},{"hugo_gene_symbol":"LINC00901","mut_samples":0,"cna_samples":32,"sv_samples":0,"altered_samples":32},{"hugo_gene_symbol":"CSMD3","mut_samples":6,"cna_samples":26,"sv_samples":0,"altered_samples":31},{"hugo_gene_symbol":"MYO15A","mut_samples":2,"cna_samples":30,"sv_samples":0,"altered_samples":31},{"hugo_gene_symbol":"RN7SL442P","mut_samples":0,"cna_samples":31,"sv_samples":0,"altered_samples":31},{"hugo_gene_symbol":"TRIM16","mut_samples":1,"cna_samples":30,"sv_samples":0,"altered_samples":31},{"hugo_gene_symbol":"FLII","mut_samples":1,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"RNA5SP436","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"DRC3","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"ZNF286A","mut_samples":1,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"ZSWIM5P1","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"MEIS3P1","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"UBE2SP1","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"ZNF29P","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"RNU6-862P","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30}]} ◀ result {"rows":[{"cancer_study_identifier":"os_target_gdc","sample_count":159,"mutation_sample_count":143,"cna_sample_count":81,"resource_sample_counts":{}}]} ▶ get_study_guide { "study_id": "os_target_gdc" } ◀ result # Osteosarcoma (TARGET GDC, 2025) **Study ID:** `os_target_gdc` ## Overview Pediatric osteosarcoma study from the TARGET (Therapeutically Applicable Research to Generate Effective Treatments) initiative. Whole exome sequencing data. ## Gene Panel - **WES** (Whole Exome Sequencing): all coding genes profiled - **143 of the 160 samples are profiled for mutations.** Use 143 as the mutation-frequency denominator (`sample_to_gene_panel_derived`, `alteration_type = 'MUTATION_EXTENDED'`), not the study's sample count — e.g. TP53 is mutated in 32/143 = 22.4%. ## Patients vs Samples 383 patients have clinical data, but only 153 of them have a sample (159 samples). Patient-level questions (age, sex, survival) use all patients with a value; genomic questions use the 143 mutation-profiled samples. ## Clinical Attributes - Semantic Guide ### Patient Demographics | Attribute | Description | Notes | |-----------|-------------|-------| | `AGE` | Age at diagnosis, **floored at 18** | Every patient younger than 18 is recorded as 18 (241 of 293). **Don't use it for age statistics** — use `DAYS_TO_BIRTH` | | `DAYS_TO_BIRTH` | Days from birth to diagnosis, negative | Age at diagnosis in years = `-DAYS_TO_BIRTH / 365.25`. 293 patients have a value; 90 are empty | | `SEX` | Patient sex | Male 172, Female 133, 78 empty | | `RACE`, `ETHNICITY` | Race, ethnicity | | ### Disease Characteristics | Attribute | Description | Notes | |-----------|-------------|-------| | `CANCER_TYPE_DETAILED` | Cancer type | Osteosarcoma for every sample | | `PRIMARY_SITE_PATIENT` | Primary site | "Appendicular Skeleton" for every patient with a value — no finer location (femur, tibia) | No histological subtype, tumor necrosis / chemotherapy response, or event-free survival attributes exist in this study. ### Clinical Outcomes | Attribute | Description | Notes | |-----------|-------------|-------| | `OS_MONTHS` | Overall survival in months | Time from diagnosis | | `OS_STATUS` | Overall survival status | 0:LIVING 171, 1:DECEASED 105, 107 empty | ## Age at Diagnosis Compute age from `DAYS_TO_BIRTH`, not `AGE`. A median from `AGE` comes out as 18 because every child is recorded as 18; the real median is about 15 years. ```sql SELECT count() AS patients, round(median(-toFloat64OrNull(attribute_value) / 365.25), 1) AS median_age_years, round(min(-toFloat64OrNull(attribute_value) / 365.25), 1) AS min_age_years, round(max(-toFloat64OrNull(attribute_value) / 365.25), 1) AS max_age_years FROM clinical_data_derived WHERE cancer_study_identifier = 'os_target_gdc' AND attribute_name = 'DAYS_TO_BIRTH' AND toFloat64OrNull(attribute_value) IS NOT NULL; -- 293 patients, median 15.2, range 3.6-87.1 ``` When reporting, say the age comes from `DAYS_TO_BIRTH` and that `AGE` is floored at 18. ## Notes & Caveats - This is a pediatric cancer cohort; age distribution is younger than adult studies - WES coverage means no gene panel filtering needed for frequency calculations - Part … (66 more chars) ▶ clickhouse_run_select_query { "query": " SELECT hugo_gene_symbol, COUNT(DISTINCT CASE WHEN variant_type = 'mutation' AND mutation_status != 'UNCALLED' THEN sample_unique_id END) AS mut_samples, COUNT(DISTINCT CASE WHEN variant_type = 'cna' AND cna_alteration IN (2,-2) THEN sample_unique_id END) AS cna_samples, COUNT(DISTINCT CASE WHEN variant_type = 'structural_variant' THEN sample_unique_id END) AS sv_samples, COUNT(DISTINCT CASE WHEN (variant_type = 'mutation' AND mutation_status != 'UNCALLED') OR (variant_type = 'cna' AND cna_alteration IN (2,-2)) OR (variant_type = 'structural_variant') THEN sample_unique_id END) AS altered_samples FROM genomic_event_derived WHERE cancer_study_identifier = 'os_target_gdc' AND hugo_gene_symbol NOT LIKE '%P' AND hugo_gene_symbol NOT LIKE '%P1' AND hugo_gene_symbol NOT LIKE 'LINC%' AND hugo_gene_symbol NOT LIKE 'RN%' AND hugo_gene_symbol NOT LIKE 'MIR%' GROUP BY hugo_gene_symbol ORDER BY altered_samples DESC LIMIT 20 " } ◀ result {"rows":[{"hugo_gene_symbol":"TP53","mut_samples":32,"cna_samples":6,"sv_samples":0,"altered_samples":38},{"hugo_gene_symbol":"TRIM16","mut_samples":1,"cna_samples":30,"sv_samples":0,"altered_samples":31},{"hugo_gene_symbol":"MYO15A","mut_samples":2,"cna_samples":30,"sv_samples":0,"altered_samples":31},{"hugo_gene_symbol":"CSMD3","mut_samples":6,"cna_samples":26,"sv_samples":0,"altered_samples":31},{"hugo_gene_symbol":"FLII","mut_samples":1,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"CDRT15P2","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"DRC3","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"BRI3P3","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"RAI1","mut_samples":1,"cna_samples":29,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"ALKBH5","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"TBC1D26-AS1","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"DRG2","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"MIEF2","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"NCOR1","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"UBB","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"TVP23C","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"TRPS1-AS1","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"ATPAF2","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"RPLP1P11","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30},{"hugo_gene_symbol":"FBXW10B","mut_samples":0,"cna_samples":30,"sv_samples":0,"altered_samples":30}]} ▶ clickhouse_run_select_query { "query": "SELECT * FROM top_cna_genes_in_study(study = 'os_target_gdc', top_n = 10)" } ◀ result {"rows":[{"hugo_gene_symbol":"LINC00901","cytoband":"3q13.31","cna_type":"HOMDEL","altered_samples":32,"profiled_samples":81,"frequency_pct":39.5},{"hugo_gene_symbol":"RN7SL442P","cytoband":"17p11.2","cna_type":"AMP","altered_samples":31,"profiled_samples":81,"frequency_pct":38.3},{"hugo_gene_symbol":"ALKBH5","cytoband":"17p11.2","cna_type":"AMP","altered_samples":30,"profiled_samples":81,"frequency_pct":37},{"hugo_gene_symbol":"ATPAF2","cytoband":"17p11.2","cna_type":"AMP","altered_samples":30,"profiled_samples":81,"frequency_pct":37},{"hugo_gene_symbol":"BRI3P3","cytoband":"17p11.2","cna_type":"AMP","altered_samples":30,"profiled_samples":81,"frequency_pct":37},{"hugo_gene_symbol":"CARS1P2","cytoband":"8q23.3","cna_type":"AMP","altered_samples":30,"profiled_samples":81,"frequency_pct":37},{"hugo_gene_symbol":"DRC3","cytoband":"17p11.2","cna_type":"AMP","altered_samples":30,"profiled_samples":81,"frequency_pct":37},{"hugo_gene_symbol":"DRG2","cytoband":"17p11.2","cna_type":"AMP","altered_samples":30,"profiled_samples":81,"frequency_pct":37},{"hugo_gene_symbol":"FLII","cytoband":"17p11.2","cna_type":"AMP","altered_samples":30,"profiled_samples":81,"frequency_pct":37},{"hugo_gene_symbol":"GID4","cytoband":"17p11.2","cna_type":"AMP","altered_samples":30,"profiled_samples":81,"frequency_pct":37}]} ▶ clickhouse_run_select_query { "query": "SELECT DISTINCT genetic_alteration_type, datatype, name, genetic_profile_id FROM genetic_profile WHERE cancer_study_identifier = 'os_target_gdc'" } ◀ 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 `cancer_study_identifier` in scope SELECT DISTINCT genetic_alteration_type, datatype, name, genetic_profile_id FROM genetic_profile WHERE cancer_study_identifier = 'os_target_gdc'. (UNKNOWN_IDENTIFIER) (version 26.4.1.2359 (official build))\n"} ▶ clickhouse_run_select_query { "query": " SELECT COUNT(DISTINCT stgp.sample_unique_id) AS profiled_samples FROM sample_to_gene_panel_derived stgp WHERE stgp.alteration_type = 'MUTATION_EXTENDED' AND stgp.cancer_study_identifier = 'os_target_gdc' " } ◀ result {"rows":[{"profiled_samples":143}]} ▶ resolve_and_route { "studyIds": [ "os_target_gdc" ] } ◀ result {"success":true,"message":"Found 1 study. Use the metadata to call the appropriate navigation tool(s).","data":{"totalCount":1,"studiesWithMetadata":[{"studyId":"os_target_gdc","name":"Osteosarcoma (TARGET GDC, 2025)","sampleCount":159,"studyViewUrl":"https://www.cbioportal.org/study?id=os_target_gdc","metadata":{"clinicalAttributeIds":["AGE","CANCER_TYPE","CANCER_TYPE_DETAILED","DAYS_TO_BIRTH","DAYS_TO_DEATH","DISEASE_TYPE","ETHNICITY","MUTATION_COUNT","ONCOTREE_CODE","OS_MONTHS","OS_STATUS","PRIMARY_DIAGNOSIS","PRIMARY_SITE_PATIENT","PROJECT_ID","RACE","SAMPLE_COUNT","SEX","SPECIMEN_TYPE","TMB_NONSYNONYMOUS","VITAL_STATUS"],"molecularProfileIds":["os_target_gdc_cna","os_target_gdc_mrna_seq_fpkm","os_target_gdc_mrna_seq_fpkm_Zscores","os_target_gdc_mrna_seq_read_counts_Zscores","os_target_gdc_mrna_seq_tpm","os_target_gdc_mrna_seq_tpm_Zscores","os_target_gdc_mutations","os_target_gdc_rna_seq_mrna"],"heatmapProfileIds":["os_target_gdc_mrna_seq_fpkm_Zscores","os_target_gdc_mrna_seq_read_counts_Zscores","os_target_gdc_mrna_seq_tpm_Zscores"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations","mrna"]}}]}} ▶ navigate_to_results_view { "studyIds": [ "os_target_gdc" ], "genes": [ "TP53", "LINC00901", "CSMD3", "MYO15A", "TRIM16" ], "tab": "oncoprint" } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/results/oncoprint?cancer_study_list=os_target_gdc&gene_list=TP53%0ALINC00901%0ACSMD3%0AMYO15A%0ATRIM16&case_set_id=os_target_gdc_all","url":"https://www.cbioportal.org/results/oncoprint?cancer_study_list=os_target_gdc&gene_list=TP53%0ALINC00901%0ACSMD3%0AMYO15A%0ATRIM16&case_set_id=os_target_gdc_all","data":{"studyIds":["os_target_gdc"],"studies":[{"studyId":"os_target_gdc","name":"Osteosarcoma (TARGET GDC, 2025)","sampleCount":159}],"genes":["TP53","LINC00901","CSMD3","MYO15A","TRIM16"],"caseSetId":"os_target_gdc_all","pageDescription":"Visual summary of alterations in queried genes across samples."}} ═ answer (success) ## Osteosarcoma (TARGET GDC, 2025) — 159 samples, 143 mutation-profiled, 81 CNA-profiled, **no structural variant data** A straightforward "top 5 by combined altered-sample count" turns out to be misleading for this cohort, so I want to flag that before giving numbers. **Why:** Osteosarcoma is characterized by massive chromosomal instability, and this study's copy-number data reflects that — instead of focal, gene-specific amplifications/deletions, the CNA calls consist of a handful of very large, recurrent chromosomal segments (e.g., most of 17p11.2, a block on 3q13.31, a block on 8q23.3). Every gene sitting inside those segments — regardless of biological relevance — gets counted as "altered" in ~30 of the 81 CNA-profiled samples. Ranking by raw altered-sample count surfaces mostly pseudogenes and non-coding RNAs (`LINC00901`, `RN7SL442P`, `TRIM16`, `MYO15A`, `CSMD3`, etc.) that happen to fall in these segments — not genes under selective pressure. There is also no structural variant profile in this study at all, so the "SV" component contributes zero to every gene. **The one gene with a real, non-artifactual combined signal:** | Gene | Mutations | CNA (AMP/HOMDEL) | SV | Combined altered samples | Denominator | Frequency | |---|---|---|---|---|---|---| | **TP53** | 32 | 6 | 0 | 38 | 143 mutation-profiled / 81 CNA-profiled (samples counted once) | ~24–27%* | *TP53 mutation frequency alone is 32/143 = 22.4%; combined with its 6 CNA events (some samples may overlap), the true unique count is 38 altered samples, but the two data types have different profiled denominators (143 vs. 81), so a single clean combined percentage isn't well-defined here — I'd recommend citing the two rates separately (22.4% mutated of 143 profiled; CNA rate of 6/81 = 7.4%). For genes #2–5, the raw counts (30–32 "altered" samples each) are essentially tied and driven entirely by segment membership rather than gene-specific alteration — reporting them as a ranked "top 5" would misrepresent recurrent CNA-segment membership as gene-level significance. **Recommendation:** For a biologically meaningful combined view, use the OncoPrint below, which lets you inspect mutation vs. CNA events per sample directly, or restrict analysis to genes with documented relevance in osteosarcoma (e.g., TP53, RB1, ATRX, MDM2) rather than an unfiltered gene-wide ranking. [View TP53 + top CNA-segment genes in OncoPrint](https://www.cbioportal.org/results/oncoprint?cancer_study_list=os_target_gdc&gene_list=TP53%0ALINC00901%0ACSMD3%0AMYO15A%0ATRIM16&case_set_id=os_target_gdc_all) — visual summary of mutation/CNA overlap across the queried genes. [Browse full cohort in Study View](https://www.cbioportal.org/study?id=os_target_gdc) — explore the CNA Genes and Mutated Genes charts directly, which show the same cytoband clustering. Would you like me to instead restrict the ranking to a specific candidate gene list (e.g., known osteosarcoma drivers), or report mutation-only and CNA-only top-5 lists separately so the segment artifact doesn't dominate?