Q (haiku): What are the top 5 most frequently altered genes in a structural variant in the Osteosarcoma study from TARGET? ▶ read_guide { "uri": "cbioportal://mutation-frequency-guide" } ▶ list_studies { "search": "TARGET osteosarcoma" } ◀ 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 {"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"}]} ▶ get_study_guide { "study_id": "os_target_gdc" } ▶ clickhouse_list_table_columns { "table": "genomic_event_derived" } ◀ 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) ◀ 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 hugo_gene_symbol, COUNT(DISTINCT sample_unique_id) AS altered_samples, total_sv_events FROM genomic_event_derived WHERE cancer_study_identifier = 'os_target_gdc' AND variant_type = 'structural_variant' GROUP BY hugo_gene_symbol ORDER BY altered_samples DESC LIMIT 5 ", "max_rows": 100 } ◀ 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 identifier `total_sv_events` in scope SELECT hugo_gene_symbol, COUNTDistinct(sample_unique_id) AS altered_samples, total_sv_events FROM genomic_event_derived WHERE (cancer_study_identifier = 'os_target_gdc') AND (variant_type = 'structural_variant') GROUP BY hugo_gene_symbol ORDER BY altered_samples DESC LIMIT 5. (UNKNOWN_IDENTIFIER) (version 26.4.1.2359 (official build))\n"} ▶ clickhouse_run_select_query { "query": " SELECT * FROM top_sv_genes_in_study(study = 'os_target_gdc', top_n = 5) ", "max_rows": 100 } ◀ result {"rows":[]} ▶ clickhouse_run_select_query { "query": " SELECT DISTINCT variant_type, COUNT(*) as event_count FROM genomic_event_derived WHERE cancer_study_identifier = 'os_target_gdc' GROUP BY variant_type ORDER BY event_count DESC ", "max_rows": 100 } ◀ result {"rows":[{"variant_type":"cna","event_count":99668},{"variant_type":"mutation","event_count":2627}]} ▶ clickhouse_run_select_query { "query": " SELECT genetic_profile_id, genetic_alteration_type, datatype, name, description FROM genetic_profile WHERE cancer_study_identifier = 'os_target_gdc' ORDER BY genetic_alteration_type ", "max_rows": 100 } ◀ 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 genetic_profile_id, genetic_alteration_type, datatype, name, description FROM genetic_profile WHERE cancer_study_identifier = 'os_target_gdc' ORDER BY genetic_alteration_type ASC. (UNKNOWN_IDENTIFIER) (version 26.4.1.2359 (official build))\n"} ▶ clickhouse_list_table_columns { "table": "genetic_profile" } ◀ result {"columns":[{"name":"genetic_profile_id","type":"Int64"},{"name":"stable_id","type":"String"},{"name":"cancer_study_id","type":"Int64"},{"name":"genetic_alteration_type","type":"String"},{"name":"generic_assay_type","type":"Nullable(String)"},{"name":"datatype","type":"String"},{"name":"name","type":"String"},{"name":"description","type":"Nullable(String)"},{"name":"show_profile_in_analysis_tab","type":"Int32"},{"name":"pivot_threshold","type":"Nullable(Float64)"},{"name":"sort_order","type":"Nullable(String)"},{"name":"patient_level","type":"Nullable(Int32)"}]} ▶ clickhouse_run_select_query { "query": " SELECT gp.stable_id, gp.genetic_alteration_type, gp.datatype, gp.name FROM genetic_profile gp JOIN cancer_study cs ON gp.cancer_study_id = cs.cancer_study_id WHERE cs.cancer_study_identifier = 'os_target_gdc' ORDER BY gp.genetic_alteration_type ", "max_rows": 100 } ◀ result {"rows":[{"stable_id":"os_target_gdc_cna","genetic_alteration_type":"COPY_NUMBER_ALTERATION","datatype":"DISCRETE","name":"Putative copy-number alterations from GISTIC"},{"stable_id":"os_target_gdc_mrna_seq_tpm","genetic_alteration_type":"MRNA_EXPRESSION","datatype":"CONTINUOUS","name":"mRNA Expression (TPM)"},{"stable_id":"os_target_gdc_mrna_seq_tpm_Zscores","genetic_alteration_type":"MRNA_EXPRESSION","datatype":"Z-SCORE","name":"mRNA Expression TPM z-scores"},{"stable_id":"os_target_gdc_mrna_seq_fpkm","genetic_alteration_type":"MRNA_EXPRESSION","datatype":"CONTINUOUS","name":"mRNA Expression (FPKM)"},{"stable_id":"os_target_gdc_mrna_seq_fpkm_Zscores","genetic_alteration_type":"MRNA_EXPRESSION","datatype":"Z-SCORE","name":"mRNA Expression FPKM z-scores"},{"stable_id":"os_target_gdc_rna_seq_mrna","genetic_alteration_type":"MRNA_EXPRESSION","datatype":"CONTINUOUS","name":"mRNA Expression"},{"stable_id":"os_target_gdc_mrna_seq_read_counts_Zscores","genetic_alteration_type":"MRNA_EXPRESSION","datatype":"Z-SCORE","name":"mRNA Expression z-scores"},{"stable_id":"os_target_gdc_mutations","genetic_alteration_type":"MUTATION_EXTENDED","datatype":"MAF","name":"Mutations"}]} ═ answer (success) ## Result The **Osteosarcoma (TARGET GDC, 2025) study does not have structural variant data**. Based on the available molecular profiles, this study (`os_target_gdc`) contains: - **Mutations** (from whole exome sequencing) - **Copy number alterations** (GISTIC discrete CNA) - **mRNA expression** (multiple data types) There is **no structural variant profile** (`STRUCTURAL_VARIANT` alteration type) in this study. The data availability is limited to point mutations and copy-number events. If you're interested in the most frequently altered genes in a different alteration type, I can help you find: - **Top genes with copy number alterations (amplifications/deep deletions)** - **Top mutated genes** Would either of those alternatives be helpful?