Q (sonnet-5.5): Give me an OncoPrint for RTK genes in lung cancer, limited to driver events. ▶ read_guide { "uri": "cbioportal://common-pitfalls" } ▶ list_studies { "search": "lung", "limit": 50 } ◀ 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) ◀ result {"result":[{"cancer_study_identifier":"msk_met_2021","name":"MSK MetTropism (MSK, Cell 2021)","type_of_cancer_id":"mixed","sample_count":25775,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=msk_met_2021"},{"cancer_study_identifier":"luad_mskcc_2023_met_organotropism","name":"Lung Adenocarcinoma Met Organotropism (MSK, Cancer Cell 2023)","type_of_cancer_id":"luad","sample_count":2653,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=luad_mskcc_2023_met_organotropism"},{"cancer_study_identifier":"nsclc_ctdx_msk_2022","name":"Metastatic Non-Small Cell Lung Cancer (MSK, Nature Medicine 2022)","type_of_cancer_id":"nsclc","sample_count":2621,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=nsclc_ctdx_msk_2022"},{"cancer_study_identifier":"nsclc_tcga_broad_2016","name":"Pan-Lung Cancer (TCGA, Nat Genet 2016)","type_of_cancer_id":"nsclc","sample_count":1144,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=nsclc_tcga_broad_2016"},{"cancer_study_identifier":"lung_msk_2017","name":"Non-Small Cell Cancer (MSK, Cancer Discov 2017)","type_of_cancer_id":"luad","sample_count":915,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=lung_msk_2017"},{"cancer_study_identifier":"luad_mskcc_2020","name":"Lung Adenocarcinoma (MSK, J Thorac Oncol 2020)","type_of_cancer_id":"luad","sample_count":604,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=luad_mskcc_2020"},{"cancer_study_identifier":"luad_tcga","name":"Lung Adenocarcinoma (TCGA, Firehose Legacy)","type_of_cancer_id":"luad","sample_count":586,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=luad_tcga"},{"cancer_study_identifier":"luad_tcga_gdc","name":"Lung Adenocarcinoma (TCGA GDC, 2025)","type_of_cancer_id":"luad","sample_count":571,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=luad_tcga_gdc"},{"cancer_study_identifier":"luad_tcga_pan_can_atlas_2018","name":"Lung Adenocarcinoma (TCGA, PanCancer Atlas)","type_of_cancer_id":"luad","sample_count":566,"has_guide":true,"url":"https://www.cbioportal.org/study/summary?id=luad_tcga_pan_can_atlas_2018"},{"cancer_study_identifier":"lusc_tcga","name":"Lung Squamous Cell Carcinoma (TCGA, Firehose Legacy)","type_of_cancer_id":"lusc","sample_count":511,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=lusc_tcga"},{"cancer_study_identifier":"lusc_tcga_gdc","name":"Lung Squamous Cell Carcinoma (TCGA GDC, 2025)","type_of_cancer_id":"lusc","sample_count":503,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=lusc_tcga_gdc"},{"cancer_study_identifier":"lusc_tcga_pan_can_atlas_2018","name":"Lung Squamous Cell Carcinoma (TCGA, PanCancer Atlas)","type_of_cancer_id":"lusc","sample_count":487,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=lusc_tcga_pan_can_atlas_2018"},{"cancer_study_identifier":"nsclc_tracerx_2017","name":"Non-Small Cell Lung Cancer (TRACERx, NEJM & N … (7167 more chars) ▶ resolve_and_route { "studyIds": [ "luad_tcga_pan_can_atlas_2018", "lusc_tcga_pan_can_atlas_2018" ] } ◀ result {"success":true,"message":"Found 2 matching studies. Pick the best match (prefer TCGA → prefer PanCancer Atlas), use its metadata to call the appropriate navigation tool(s) and generate URLs immediately. Present other studies as alternatives.","data":{"totalCount":2,"studiesWithMetadata":[{"studyId":"luad_tcga_pan_can_atlas_2018","name":"Lung Adenocarcinoma (TCGA, PanCancer Atlas)","sampleCount":566,"studyViewUrl":"https://www.cbioportal.org/study?id=luad_tcga_pan_can_atlas_2018","metadata":{"clinicalAttributeIds":["AGE","AJCC_PATHOLOGIC_TUMOR_STAGE","AJCC_STAGING_EDITION","ANEUPLOIDY_SCORE","BUFFA_HYPOXIA_SCORE","CANCER_TYPE","CANCER_TYPE_ACRONYM","CANCER_TYPE_DETAILED","DAYS_LAST_FOLLOWUP","DAYS_TO_BIRTH","DAYS_TO_INITIAL_PATHOLOGIC_DIAGNOSIS","DFS_MONTHS","DFS_STATUS","DSS_MONTHS","DSS_STATUS","ETHNICITY","FORM_COMPLETION_DATE","FRACTION_GENOME_ALTERED","GENETIC_ANCESTRY_LABEL","GRADE","HISTORY_NEOADJUVANT_TRTYN","ICD_10","ICD_O_3_HISTOLOGY","ICD_O_3_SITE","INFORMED_CONSENT_VERIFIED","IN_PANCANPATHWAYS_FREEZE","MSI_SCORE_MANTIS","MSI_SENSOR_SCORE","MUTATION_COUNT","NEW_TUMOR_EVENT_AFTER_INITIAL_TREATMENT","ONCOTREE_CODE","OS_MONTHS","OS_STATUS","OTHER_PATIENT_ID","PATH_M_STAGE","PATH_N_STAGE","PATH_T_STAGE","PERSON_NEOPLASM_CANCER_STATUS","PFS_MONTHS","PFS_STATUS","PRIMARY_LYMPH_NODE_PRESENTATION_ASSESSMENT","PRIOR_DX","RACE","RADIATION_THERAPY","RAGNUM_HYPOXIA_SCORE","SAMPLE_COUNT","SAMPLE_TYPE","SEX","SOMATIC_STATUS","SUBTYPE","TBL_SCORE","TISSUE_PROSPECTIVE_COLLECTION_INDICATOR","TISSUE_RETROSPECTIVE_COLLECTION_INDICATOR","TISSUE_SOURCE_SITE","TISSUE_SOURCE_SITE_CODE","TMB_NONSYNONYMOUS","TUMOR_TISSUE_SITE","TUMOR_TYPE","WEIGHT","WINTER_HYPOXIA_SCORE"],"molecularProfileIds":["luad_tcga_pan_can_atlas_2018_gistic","luad_tcga_pan_can_atlas_2018_log2CNA","luad_tcga_pan_can_atlas_2018_mutations","luad_tcga_pan_can_atlas_2018_rna_seq_v2_mrna","luad_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_Zscores","luad_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_Zscores","luad_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_ref_normal_Zscores","luad_tcga_pan_can_atlas_2018_rppa","luad_tcga_pan_can_atlas_2018_rppa_Zscores","luad_tcga_pan_can_atlas_2018_structural_variants"],"genericAssayProfiles":["luad_tcga_pan_can_atlas_2018_armlevel_cna","luad_tcga_pan_can_atlas_2018_genetic_ancestry","luad_tcga_pan_can_atlas_2018_methylation_hm27_hm450_merge","luad_tcga_pan_can_atlas_2018_methylation_hm450"],"heatmapProfileIds":["luad_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_Zscores","luad_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_Zscores","luad_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_ref_normal_Zscores","luad_tcga_pan_can_atlas_2018_rppa_Zscores"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations","mrna","protein","generic_assay_armlevel_cna","generic_assay_genetic_ancestry","generic_assay_methylation"]}},{"studyId":"lusc_tcga_pan_can_atlas_2018","name":"Lung Squamous Cell … (2585 more chars) ▶ navigate_to_results_view { "studyIds": [ "luad_tcga_pan_can_atlas_2018", "lusc_tcga_pan_can_atlas_2018" ], "genes": [ "EGFR: DRIVER", "ERBB2: DRIVER", "ERBB3: DRIVER", "ERBB4: DRIVER", "MET: DRIVER", "ALK: DRIVER", "ROS1: DRIVER", "RET: DRIVER", "FGFR1: DRIVER", "FGFR2: DRIVER", "FGFR3: DRIVER", "FGFR4: DRIVER", "PDGFRA: DRIVER", "KIT: DRIVER", "IGF1R: DRIVER", "NTRK1: DRIVER", "NTRK2: DRIVER", "NTRK3: DRIVER" ], "tab": "oncoprint" } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/results/oncoprint?cancer_study_list=luad_tcga_pan_can_atlas_2018%2Clusc_tcga_pan_can_atlas_2018&gene_list=EGFR%3A+DRIVER%0AERBB2%3A+DRIVER%0AERBB3%3A+DRIVER%0AERBB4%3A+DRIVER%0AMET%3A+DRIVER%0AALK%3A+DRIVER%0AROS1%3A+DRIVER%0ARET%3A+DRIVER%0AFGFR1%3A+DRIVER%0AFGFR2%3A+DRIVER%0AFGFR3%3A+DRIVER%0AFGFR4%3A+DRIVER%0APDGFRA%3A+DRIVER%0AKIT%3A+DRIVER%0AIGF1R%3A+DRIVER%0ANTRK1%3A+DRIVER%0ANTRK2%3A+DRIVER%0ANTRK3%3A+DRIVER&case_set_id=all","url":"https://www.cbioportal.org/results/oncoprint?cancer_study_list=luad_tcga_pan_can_atlas_2018%2Clusc_tcga_pan_can_atlas_2018&gene_list=EGFR%3A+DRIVER%0AERBB2%3A+DRIVER%0AERBB3%3A+DRIVER%0AERBB4%3A+DRIVER%0AMET%3A+DRIVER%0AALK%3A+DRIVER%0AROS1%3A+DRIVER%0ARET%3A+DRIVER%0AFGFR1%3A+DRIVER%0AFGFR2%3A+DRIVER%0AFGFR3%3A+DRIVER%0AFGFR4%3A+DRIVER%0APDGFRA%3A+DRIVER%0AKIT%3A+DRIVER%0AIGF1R%3A+DRIVER%0ANTRK1%3A+DRIVER%0ANTRK2%3A+DRIVER%0ANTRK3%3A+DRIVER&case_set_id=all","data":{"studyIds":["luad_tcga_pan_can_atlas_2018","lusc_tcga_pan_can_atlas_2018"],"studies":[{"studyId":"luad_tcga_pan_can_atlas_2018","name":"Lung Adenocarcinoma (TCGA, PanCancer Atlas)","sampleCount":566},{"studyId":"lusc_tcga_pan_can_atlas_2018","name":"Lung Squamous Cell Carcinoma (TCGA, PanCancer Atlas)","sampleCount":487}],"genes":["EGFR","ERBB2","ERBB3","ERBB4","MET","ALK","ROS1","RET","FGFR1","FGFR2","FGFR3","FGFR4","PDGFRA","KIT","IGF1R","NTRK1","NTRK2","NTRK3"],"caseSetId":"all","pageDescription":"Visual summary of alterations in queried genes across samples."}} ═ answer (success) [View the RTK driver OncoPrint for lung cancer](https://www.cbioportal.org/results/oncoprint?cancer_study_list=luad_tcga_pan_can_atlas_2018%2Clusc_tcga_pan_can_atlas_2018&gene_list=EGFR%3A+DRIVER%0AERBB2%3A+DRIVER%0AERBB3%3A+DRIVER%0AERBB4%3A+DRIVER%0AMET%3A+DRIVER%0AALK%3A+DRIVER%0AROS1%3A+DRIVER%0ARET%3A+DRIVER%0AFGFR1%3A+DRIVER%0AFGFR2%3A+DRIVER%0AFGFR3%3A+DRIVER%0AFGFR4%3A+DRIVER%0APDGFRA%3A+DRIVER%0AKIT%3A+DRIVER%0AIGF1R%3A+DRIVER%0ANTRK1%3A+DRIVER%0ANTRK2%3A+DRIVER%0ANTRK3%3A+DRIVER&case_set_id=all) I made three choices to build this OncoPrint. Tell me if you want any of them changed. - **Cohort:** "Lung cancer" matches many studies, so I used the two TCGA PanCancer Atlas lung studies: - [Lung Adenocarcinoma (TCGA, PanCancer Atlas)](https://www.cbioportal.org/study/summary?id=luad_tcga_pan_can_atlas_2018): 566 samples - [Lung Squamous Cell Carcinoma (TCGA, PanCancer Atlas)](https://www.cbioportal.org/study/summary?id=lusc_tcga_pan_can_atlas_2018): 487 samples - Small cell, MSK-IMPACT and other NSCLC cohorts are not included. I can swap in a different study if you prefer. - **RTK gene set:** cBioPortal has no built-in "RTK" list, so I picked 18 receptor tyrosine kinases: EGFR, ERBB2, ERBB3, ERBB4, MET, ALK, ROS1, RET, FGFR1–4, PDGFRA, KIT, IGF1R and NTRK1–3. I can add genes such as AXL, DDR2 or VEGFR/KDR, or remove some. - **Driver filter:** Each gene uses the portal's `DRIVER` query, so only driver-annotated events appear. This covers mutations, fusions and copy-number changes. Events without a driver annotation are excluded. I haven't checked how many events that removes, so the OncoPrint may show fewer alterations than an unfiltered query. I haven't computed alteration frequencies here. The OncoPrint shows them per gene and per study.