Q (sonnet): In the “Pan-cancer analysis of whole genomes” study what is the survival difference and the corresponding statistical significance between patients with mutations in both TP53 and KRAS versus patients with only a KRAS mutation? ▶ read_guide { "uri": "cbioportal://statistical-tests-guide" } ▶ list_studies { "search": "Pan-cancer analysis of whole genomes" } ◀ result Statistical Test Selection Guide ================================ Purpose ------- This guide ensures the correct statistical test is selected before performing any group comparison, matching cBioPortal's own Group Comparison defaults. HARD RULES — NEVER FABRICATE A STATISTIC ---------------------------------------- ClickHouse cannot run statistical tests. The agent therefore must NEVER produce a derived statistic that is not a literal column value from a SQL result. Specifically: 1. **Never invent a p-value.** Not "p < 0.001", not "p ≈ 0.05", not any p-value. If the user asks "what is the p-value?", the answer is *"I can't compute that — here is the 2x2 contingency table (or group statistics). Run it in cBioPortal's Group Comparison tab, in R with `fisher.test(...)` / `wilcox.test(...)`, or in Python with `scipy.stats.fisher_exact(...)` / `mannwhitneyu(...)`."* 2. **Never claim mutual exclusivity (or co-occurrence) from a contingency table alone.** A 2x2 table is not a test. The shape "altered/not altered × group A/group B" needs Fisher's exact + a defined direction (odds ratio < 1 with significant p). Without that test, the agent presents the table and stops. Descriptive phrasing is also a claim: "largely/mostly mutually exclusive", "rarely co-occur", "tend to co-occur" are forbidden without the test — point to cBioPortal's Mutual Exclusivity tab instead. 3. **Never report a "median" that came from `AVG(...)` or any non-median aggregate.** "Median" and "mean" are different statistics; for skewed clinical distributions (especially survival) they differ substantially. Use ClickHouse's `quantile(0.5)(...)` for actual median, and label arithmetic averages as "mean", never "median". 4. **Never report a hazard ratio, odds ratio, risk ratio, or relative risk** that wasn't computed by an external tool. These require regression / model fitting that ClickHouse does not do. 5. **Never report median overall survival from `AVG(OS_MONTHS)` or even `quantile(0.5)(OS_MONTHS)`.** Median OS requires Kaplan-Meier estimation, which handles censoring (`OS_STATUS = 0:LIVING` means the event hasn't happened yet). Naive medians/means over `OS_MONTHS` ignore censoring and are systematically wrong. The correct handoff: return the raw `(OS_MONTHS, OS_STATUS)` pairs (or descriptive counts: N events, N censored, follow-up range) and tell the user to run KM in R (`survival::survfit`) or Python (`lifelines.KaplanMeierFitter`), or use cBioPortal's Survival comparison. If asked to do any of (1)–(5), respond with the appropriate handoff template from the "Approved Response Templates" section below — do not produce the number. Ambiguous-Term Clarification (before any analysis) -------------------------------------------------- If the user's question uses an ambiguous term, ask before computing anything. Examples: - **"aggressive"** → could mean shorter overall survival, higher metastasis rate, higher grade/stage, higher TMB, or specific molecular features. Ask which definit … (9984 more chars) ◀ result {"result":[{"cancer_study_identifier":"pancan_pcawg_2020","name":"Pan-cancer analysis of whole genomes (ICGC/TCGA, Nature 2020)","type_of_cancer_id":"mixed","sample_count":2922,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=pancan_pcawg_2020"}]} ▶ clickhouse_list_table_columns { "table": "genomic_event_derived" } ▶ clickhouse_list_table_columns { "table": "clinical_data_derived" } ◀ 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."}]} ◀ result {"columns":[{"name":"internal_id","type":"Int32"},{"name":"sample_unique_id","type":"String","comment":"Globally unique sample ID: cancer_study_identifier + \"_\" + sample.stable_id. Empty for patient-level attributes. Use this for sample filtering and joins."},{"name":"patient_unique_id","type":"String","comment":"Globally unique patient ID: cancer_study_identifier + \"_\" + patient.stable_id. Present for both sample and patient-level attributes."},{"name":"attribute_name","type":"LowCardinality(String)","comment":"Clinical attribute name (e.g., SAMPLE_TYPE, CANCER_TYPE, AGE, OS_MONTHS). Use with attribute_value for filtering. AGE may be floored or capped for de-identification (e.g. all children recorded as 18, or everyone 89+ recorded as 89 or 90): before age statistics check for a pile-up at the min/max, and if present compute age from DAYS_TO_BIRTH (-days / 365.25)."},{"name":"attribute_value","type":"String","comment":"Value of the clinical attribute (String). For SAMPLE_TYPE: Primary, Metastasis, Local Recurrence, Unknown. Missing values are empty strings, so use toFloat64OrNull(attribute_value) for numeric comparisons — CAST fails on them."},{"name":"cancer_study_identifier","type":"LowCardinality(String)"},{"name":"type","type":"LowCardinality(String)","comment":"Data level: \"sample\" for sample-level attributes (e.g., SAMPLE_TYPE), \"patient\" for patient-level attributes (e.g., AGE, OS_MONTHS)."}]} ▶ clickhouse_run_select_query { "query": " WITH mutated_patients AS ( SELECT DISTINCT patient_unique_id, hugo_gene_symbol FROM genomic_event_derived WHERE cancer_study_identifier = 'pancan_pcawg_2020' AND variant_type = 'mutation' AND mutation_status != 'UNCALLED' AND hugo_gene_symbol IN ('TP53', 'KRAS') AND off_panel = 0 ), tp53_patients AS ( SELECT DISTINCT patient_unique_id FROM mutated_patients WHERE hugo_gene_symbol = 'TP53' ), kras_patients AS ( SELECT DISTINCT patient_unique_id FROM mutated_patients WHERE hugo_gene_symbol = 'KRAS' ), both_group AS ( SELECT patient_unique_id FROM kras_patients WHERE patient_unique_id IN (SELECT patient_unique_id FROM tp53_patients) ), kras_only_group AS ( SELECT patient_unique_id FROM kras_patients WHERE patient_unique_id NOT IN (SELECT patient_unique_id FROM tp53_patients) ) SELECT 'BOTH_TP53_KRAS' AS grp, count(*) AS n_patients FROM both_group UNION ALL SELECT 'KRAS_ONLY' AS grp, count(*) AS n_patients FROM kras_only_group " } ◀ result {"rows":[{"grp":"BOTH_TP53_KRAS","n_patients":187},{"grp":"KRAS_ONLY","n_patients":85}]} ▶ clickhouse_run_select_query { "query": " WITH mutated_patients AS ( SELECT DISTINCT patient_unique_id, hugo_gene_symbol FROM genomic_event_derived WHERE cancer_study_identifier = 'pancan_pcawg_2020' AND variant_type = 'mutation' AND mutation_status != 'UNCALLED' AND hugo_gene_symbol IN ('TP53', 'KRAS') AND off_panel = 0 ), tp53_patients AS ( SELECT DISTINCT patient_unique_id FROM mutated_patients WHERE hugo_gene_symbol = 'TP53' ), kras_patients AS ( SELECT DISTINCT patient_unique_id FROM mutated_patients WHERE hugo_gene_symbol = 'KRAS' ), both_group AS ( SELECT patient_unique_id, 'BOTH_TP53_KRAS' AS grp FROM kras_patients WHERE patient_unique_id IN (SELECT patient_unique_id FROM tp53_patients) ), kras_only_group AS ( SELECT patient_unique_id, 'KRAS_ONLY' AS grp FROM kras_patients WHERE patient_unique_id NOT IN (SELECT patient_unique_id FROM tp53_patients) ), all_groups AS ( SELECT * FROM both_group UNION ALL SELECT * FROM kras_only_group ), os_status AS ( SELECT patient_unique_id, attribute_value AS os_status FROM clinical_data_derived WHERE cancer_study_identifier = 'pancan_pcawg_2020' AND attribute_name = 'OS_STATUS' AND type = 'patient' ), os_months AS ( SELECT patient_unique_id, toFloat64OrNull(attribute_value) AS os_months FROM clinical_data_derived WHERE cancer_study_identifier = 'pancan_pcawg_2020' AND attribute_name = 'OS_MONTHS' AND type = 'patient' ) SELECT g.grp, count(*) AS n_patients, countIf(s.os_status = '1:DECEASED') AS n_events, countIf(s.os_status = '0:LIVING') AS n_censored, countIf(s.os_status = '' OR s.os_status IS NULL) AS n_missing_status, countIf(m.os_months IS NULL) AS n_missing_months, min(m.os_months) AS min_followup, max(m.os_months) AS max_followup FROM all_groups g LEFT JOIN os_status s ON g.patient_unique_id = s.patient_unique_id LEFT JOIN os_months m ON g.patient_unique_id = m.patient_unique_id GROUP BY g.grp " } ◀ result {"rows":[{"grp":"BOTH_TP53_KRAS","n_patients":187,"n_events":122,"n_censored":65,"n_missing_status":0,"n_missing_months":186,"min_followup":33.51973684,"max_followup":33.51973684},{"grp":"KRAS_ONLY","n_patients":85,"n_events":41,"n_censored":44,"n_missing_status":0,"n_missing_months":82,"min_followup":0,"max_followup":29.60526316}]} ▶ clickhouse_run_select_query { "query": " SELECT attribute_value, count(*) FROM clinical_data_derived WHERE cancer_study_identifier = 'pancan_pcawg_2020' AND attribute_name = 'OS_MONTHS' AND type = 'patient' GROUP BY attribute_value ORDER BY count(*) DESC LIMIT 10 " } ◀ result {"rows":[{"count()":2376},{"attribute_value":"0","count()":41},{"attribute_value":"29.60526316","count()":7},{"attribute_value":"19.73684211","count()":5},{"attribute_value":"22.69736842","count()":4},{"attribute_value":"23.68421053","count()":4},{"attribute_value":"26.64473684","count()":4},{"attribute_value":"25.65789474","count()":3},{"attribute_value":"28.61842105","count()":3},{"attribute_value":"20.72368421","count()":2}]} ▶ clickhouse_run_select_query { "query": " SELECT attribute_value, count(*) FROM clinical_data_derived WHERE cancer_study_identifier = 'pancan_pcawg_2020' AND attribute_name = 'OS_STATUS' AND type = 'patient' GROUP BY attribute_value ORDER BY count(*) DESC " } ◀ result {"rows":[{"attribute_value":"0:LIVING","count()":1734},{"attribute_value":"1:DECEASED","count()":724},{"count()":200}]} ▶ resolve_and_route { "studyIds": [ "pancan_pcawg_2020" ] } ◀ result {"success":true,"message":"Found 1 study. Use the metadata to call the appropriate navigation tool(s).","data":{"totalCount":1,"studiesWithMetadata":[{"studyId":"pancan_pcawg_2020","name":"Pan-cancer analysis of whole genomes (ICGC/TCGA, Nature 2020)","sampleCount":2922,"studyViewUrl":"https://www.cbioportal.org/study?id=pancan_pcawg_2020","metadata":{"clinicalAttributeIds":["AGE","ALCOHOL","ALCOHOL_HISTORY_INTENSITY","ANCESTRY_PRIMARY","CANCER_TYPE","CANCER_TYPE_DETAILED","CELLULARITY","FIRST THERAPY_RESPONSE","FIRST_THERAPY","GRADE","HISTOLOGY","HISTOLOGY_ABBREVIATION","HISTOLOGY_TIER1","HISTOLOGY_TIER2","HISTOLOGY_TIER3","HISTOLOGY_TIER4","ICD_10","ICGC_SAMPLE_ID","MUTATION_COUNT","ONCOTREE_CODE","ORGAN_SYSTEM","OS_MONTHS","OS_STATUS","PLOIDY","PROJECT_CODE","PURITY","PURITY_CONFUGURATION","SAMPLE_CLASS","SAMPLE_COUNT","SAMPLE_TYPE","SEQUENCING_TYPE","SEX","STAGE","TBL_SCORE","TMB_NONSYNONYMOUS","TOBACCO_SMOKING_HISTORY_INDICATOR","TOBACCO_SMOKING_INTENSITY","TUMOR_SAMPLE_HISTOLOGY_CODE","WGD"],"molecularProfileIds":["pancan_pcawg_2020_cna","pancan_pcawg_2020_mirna","pancan_pcawg_2020_mirna_median_Zscores","pancan_pcawg_2020_mrna_seq_fpkm_capture","pancan_pcawg_2020_mrna_seq_fpkm_capture_all_sample_Zscores","pancan_pcawg_2020_mutations"],"genericAssayProfiles":["pancan_pcawg_2020_mutational_signatures_contribution_DBS","pancan_pcawg_2020_mutational_signatures_contribution_ID","pancan_pcawg_2020_mutational_signatures_contribution_SBS","pancan_pcawg_2020_mutational_signatures_counts_DBS","pancan_pcawg_2020_mutational_signatures_counts_ID","pancan_pcawg_2020_mutational_signatures_counts_SBS"],"heatmapProfileIds":["pancan_pcawg_2020_mirna_median_Zscores","pancan_pcawg_2020_mrna_seq_fpkm_capture_all_sample_Zscores"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations","mrna","generic_assay_mutational_signature"]}}]}} ▶ navigate_to_group_comparison { "studyIds": [ "pancan_pcawg_2020" ], "tab": "survival", "groups": [ { "name": "TP53 & KRAS mutant", "studyViewFilter": { "geneFilters": [ { "molecularProfileIds": [ "pancan_pcawg_2020_mutations" ], "geneQueries": [ [ { "hugoGeneSymbol": "TP53" } ], [ { "hugoGeneSymbol": "KRAS" } ] ] } ] } }, { "name": "KRAS mutant only (TP53 WT)", "studyViewFilter": { "mutationDataFilters": [ { "hugoGeneSymbol": "KRAS", "profileType": "mutations", "categorization": "MUTATED", "values": [ [ { "value": "Mutated" } ] ] }, { "hugoGeneSymbol": "TP53", "profileType": "mutations", "categorization": "MUTATED", "values": [ [ { "value": "Not Mutated" } ] ] } ] } } ] } ◀ result {"success":false,"error":"Internal Server Error","details":{"status":500,"response":{"req":{"method":"POST","url":"https://www.cbioportal.org/api/filtered-samples/fetch","data":{"mutationDataFilters":[{"hugoGeneSymbol":"KRAS","profileType":"mutations","categorization":"MUTATED","values":[[{"value":"Mutated"}]]},{"hugoGeneSymbol":"TP53","profileType":"mutations","categorization":"MUTATED","values":[[{"value":"Not Mutated"}]]}],"studyIds":["pancan_pcawg_2020"]},"headers":{"user-agent":"node-superagent/3.8.3","accept":"application/json","content-type":"application/json"}},"header":{"cache-control":"no-cache, no-store, max-age=0, must-revalidate","content-encoding":"gzip","content-type":"application/json","date":"Fri, 25 Sep 2026 01:39:06 GMT","elapsed-time":"34","expires":"0","pragma":"no-cache","strict-transport-security":"max-age=31536000 ; includeSubDomains","vary":"origin,access-control-request-method,access-control-request-headers,accept-encoding","x-content-type-options":"nosniff","x-frame-options":"DENY","x-xss-protection":"0","connection":"close","transfer-encoding":"chunked"},"status":500,"text":"{\"message\":\"SQL exception. If you are a maintainer of this instance, see logs for details.\"}"}}} ▶ get_studyviewfilter_options { "studyId": "pancan_pcawg_2020", "geneSpecificQueries": [ { "hugoGeneSymbol": "KRAS", "profileType": "mutations" }, { "hugoGeneSymbol": "TP53", "profileType": "mutations" } ] } ◀ result {"success":true,"message":"Successfully retrieved StudyView filter options","data":{"studyId":"pancan_pcawg_2020","geneSpecificCounts":[{"hugoGeneSymbol":"KRAS","profileType":"mutations","counts":[{"value":"Missense_Mutation","label":"Missense Mutation","count":278}]},{"hugoGeneSymbol":"TP53","profileType":"mutations","counts":[{"value":"Missense_Mutation","label":"Missense Mutation","count":599},{"value":"Nonsense_Mutation","label":"Nonsense Mutation","count":117},{"value":"Frame_Shift_Del","label":"Frame Shift Del","count":87},{"value":"Splice_Site","label":"Splice Site","count":69},{"value":"In_Frame_Ins","label":"In Frame Ins","count":6},{"value":"Splice_Region","label":"Splice Region","count":5},{"value":"In_Frame_Del","label":"In Frame Del","count":19},{"value":"Frame_Shift_Ins","label":"Frame Shift Ins","count":36}]}]}} ▶ navigate_to_group_comparison { "studyIds": [ "pancan_pcawg_2020" ], "tab": "survival", "groups": [ { "name": "TP53 & KRAS mutant", "studyViewFilter": { "geneFilters": [ { "molecularProfileIds": [ "pancan_pcawg_2020_mutations" ], "geneQueries": [ [ { "hugoGeneSymbol": "TP53" } ], [ { "hugoGeneSymbol": "KRAS" } ] ] } ] } }, { "name": "KRAS mutant only (TP53 WT)", "studyViewFilter": { "mutationDataFilters": [ { "hugoGeneSymbol": "KRAS", "profileType": "mutations", "categorization": "MUTATED", "values": [ [ { "value": "MUTATED" } ] ] }, { "hugoGeneSymbol": "TP53", "profileType": "mutations", "categorization": "MUTATED", "values": [ [ { "value": "NOT_MUTATED" } ] ] } ] } } ] } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/comparison/survival?comparisonId=6ab5d0c6c2115c492d884e20","url":"https://www.cbioportal.org/comparison/survival?comparisonId=6ab5d0c6c2115c492d884e20","data":{"description":"Group comparison (2 custom groups)","studies":["pancan_pcawg_2020"],"totalGroups":2,"groups":[{"name":"TP53 & KRAS mutant","sampleCount":187},{"name":"KRAS mutant only (TP53 WT)","sampleCount":86}],"studyViewUrl":"https://www.cbioportal.org/study?id=pancan_pcawg_2020","groupUrls":[{"groupName":"TP53 & KRAS mutant","url":"https://www.cbioportal.org/study?id=pancan_pcawg_2020#filterJson=%7B%22geneFilters%22%3A%5B%7B%22molecularProfileIds%22%3A%5B%22pancan_pcawg_2020_mutations%22%5D%2C%22geneQueries%22%3A%5B%5B%7B%22hugoGeneSymbol%22%3A%22TP53%22%7D%5D%2C%5B%7B%22hugoGeneSymbol%22%3A%22KRAS%22%7D%5D%5D%7D%5D%7D"},{"groupName":"KRAS mutant only (TP53 WT)","url":"https://www.cbioportal.org/study?id=pancan_pcawg_2020#filterJson=%7B%22mutationDataFilters%22%3A%5B%7B%22hugoGeneSymbol%22%3A%22KRAS%22%2C%22profileType%22%3A%22mutations%22%2C%22categorization%22%3A%22MUTATED%22%2C%22values%22%3A%5B%5B%7B%22value%22%3A%22MUTATED%22%7D%5D%5D%7D%2C%7B%22hugoGeneSymbol%22%3A%22TP53%22%2C%22profileType%22%3A%22mutations%22%2C%22categorization%22%3A%22MUTATED%22%2C%22values%22%3A%5B%5B%7B%22value%22%3A%22NOT_MUTATED%22%7D%5D%5D%7D%5D%7D"}],"pageDescription":"Kaplan-Meier survival analysis comparing TP53 & KRAS mutant (187) vs KRAS mutant only (TP53 WT) (86)."}} ═ answer (success) This matches the group sizes from the database query (187 vs 85/86, off by one likely due to panel/profiling edge cases — negligible). ## Summary **Study:** [Pan-cancer analysis of whole genomes (ICGC/TCGA, Nature 2020)](https://www.cbioportal.org/study/summary?id=pancan_pcawg_2020) (`pancan_pcawg_2020`) **Cohorts (patient-level, mutation calls with off-panel excluded):** | Group | N patients | Events (deceased) | Censored (living) | |---|---|---|---| | TP53 + KRAS mutant | 187 | 122 | 65 | | KRAS mutant only (TP53 wild-type) | 85 | 41 | 44 | **Important data limitation:** I cannot report a survival difference or its statistical significance from the database directly. Kaplan-Meier estimation (which properly handles patients still alive/censored at last follow-up) requires paired follow-up time and status — but in this study, `OS_MONTHS` (the numeric follow-up time) is populated for only a small fraction of patients (roughly 200 of ~2,900 patients study-wide; essentially only 1 of 187 in the TP53+KRAS group and 3 of 85 in the KRAS-only group have a usable value). `OS_STATUS` (event/censoring) is available for most patients, but without matched follow-up times a survival curve cannot be constructed from this data, and I won't fabricate one. Given this sparsity, any median OS or log-rank p-value you might see quoted elsewhere for this cohort should be treated cautiously, and the same limitation will affect cBioPortal's own Kaplan-Meier tab. You can inspect this directly — the same two groups are pre-built here: **[View Kaplan-Meier survival comparison: TP53+KRAS mutant vs KRAS-only mutant](https://www.cbioportal.org/comparison/survival?comparisonId=6ab5d0c6c2115c492d884e20)** This will show you exactly how many patients have plottable follow-up data and, if the log-rank test can be computed, its p-value (which I cannot compute myself). If the tab shows "not enough follow-up data," that confirms the sparsity found above.