Q (sonnet): Do patients with PIK3CA mutations have different overall survival outcomes compared to PIK3CA wild-type patients in breast cancer from the MSK-CHORD Study? ▶ read_guide { "uri": "cbioportal://statistical-tests-guide" } ▶ list_studies { "search": "MSK CHORD" } ◀ 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":"msk_chord_2024","name":"MSK-CHORD (MSK, Nature 2024)","type_of_cancer_id":"mixed","sample_count":25040,"has_guide":true,"url":"https://www.cbioportal.org/study/summary?id=msk_chord_2024"}]} ▶ get_study_guide { "study_id": "msk_chord_2024" } ◀ result # MSK-CHORD (MSK, Nature 2024) **Study ID:** `msk_chord_2024` ## Overview Targeted sequencing via MSK-IMPACT panels. Clinical annotations include some derived from natural language processing (denoted NLP). **Exactly five cancer types** (`CANCER_TYPE`, patients): Non-Small Cell Lung Cancer 7,809, Colorectal Cancer 5,543, Breast Cancer 5,368, Prostate Cancer 3,211, Pancreatic Cancer 3,109. There is **no melanoma** or any other cancer type; say so up front if asked, instead of substituting another type. **No therapy-response variable.** There is no RECIST, objective response, or best-response attribute or event. For treatment-outcome questions (e.g. immunotherapy response), say this first; the only proxies are `OS_MONTHS`/`OS_STATUS`, or NLP radiology progression events (`Diagnosis` events with `SUBTYPE = 'Progression'`, key `PROGRESSION` = Y/N/Indeterminate), in patients with `Treatment` events of the relevant `SUBTYPE` (e.g. `Immuno`: 3,341 patients). Hand off the comparison to cBioPortal group comparison / survival. **Nearly one sample per patient: 24,950 patients / 25,040 samples.** Only 90 patients have more than one sample, and all 90 have samples from two different cancer types (second primaries); only 26 have both a `Primary` and a `Metastasis` sample. There is no meaningful same-patient (paired) primary-vs-metastasis cohort. For "same patient" / paired questions, say this up front, then offer the **unpaired** comparison of all `Primary` vs `Metastasis` samples (`SAMPLE_TYPE`), labelled as unpaired. ```sql SELECT countIf(n > 1) AS multi_sample_patients, -- 90 countIf(has_p AND has_m) AS primary_and_met -- 26 FROM (SELECT patient_unique_id, count() AS n, has(groupArray(attribute_value), 'Primary') AS has_p, has(groupArray(attribute_value), 'Metastasis') AS has_m FROM clinical_data_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND attribute_name = 'SAMPLE_TYPE' GROUP BY patient_unique_id); ``` ## Gene Panels This study uses multiple MSK-IMPACT panel versions: - **IMPACT341**: Earlier version, 341 genes - **IMPACT410**: 410 genes - **IMPACT468**: 468 genes - **IMPACT505**: Latest version, 505 genes **Important:** Different samples may have different gene coverage. Always use gene-specific denominators when calculating mutation frequencies. ## Clinical Attributes - Semantic Guide ### Cancer Classification | Attribute | Description | Values | |-----------|-------------|--------| | `CANCER_TYPE` | Broad cancer category | e.g., "Non-Small Cell Lung Cancer", "Breast Cancer" | | `CANCER_TYPE_DETAILED` | Specific subtype | e.g., "Lung Adenocarcinoma", "Invasive Ductal Carcinoma" | | `ONCOTREE_CODE` | OncoTree classification code | Standardized cancer type codes | ### Sample Information | Attribute | Description | Values | |-----------|-------------|--------| | `SAMPLE_TYPE` | Sample origin | Primary, Metastasis, Local Recurrence, Unknown | | `SAMPLE_CLASS` | Sample … (5439 more chars) ▶ read_guide { "uri": "cbioportal://clinical-data-guide" } ▶ search_oncotree { "search_term": "breast cancer" } ◀ result # Clinical Data Query Guide ## Overview Clinical data in cBioPortal is stored at both patient and sample levels. Understanding the distinction is crucial for accurate analysis. ## Data Organization ### Patient-Level vs Sample-Level Data - **Patient-level**: Demographics, overall survival, disease stage (stored once per patient) - **Sample-level**: Sample type, sequencing platform, purity (can have multiple per patient) ### Key Tables - `clinical_patient`: Patient-level clinical attributes - `clinical_sample`: Sample-level clinical attributes - `clinical_data_derived`: Pre-joined view combining both levels - `clinical_attribute_meta`: Metadata about available clinical attributes ## Recommended Approach: Use clinical_data_derived The `clinical_data_derived` table is pre-joined and optimized for most queries: ```sql -- Get clinical data for specific attributes SELECT sample_unique_id, patient_unique_id, attribute_name, attribute_value FROM clinical_data_derived WHERE cancer_study_identifier = 'your_study_id' AND attribute_name IN ('CANCER_TYPE', 'SAMPLE_TYPE', 'TMB_NONSYNONYMOUS'); ``` ## Clinical Attribute Discovery ### Use clinical_attribute_meta for Discovering Available Attributes **Always start here** to see what clinical attributes are available for a specific study: ```sql -- Discover available clinical attributes for a study SELECT attr_id, description, patient_attribute, cancer_study_id FROM clinical_attribute_meta WHERE cancer_study_id = ( SELECT cancer_study_id FROM cancer_study WHERE cancer_study_identifier = 'your_study_id' ) ORDER BY patient_attribute, attr_id; ``` **Key Fields:** - **attr_id**: matches attr_id in clinical_sample/clinical_patient tables - **description**: human-readable description of the attribute - **patient_attribute**: true = patient attribute, false = sample attribute - **cancer_study_id**: links to cancer_study table (filter by study) ## Attribute Semantics and Matching ### Case-Insensitive Matching for Attribute Values Clinical values are free text across studies and may differ only by case. For example, a controlled-looking value such as germline mutation status may appear as `GERMLINE`, `Germline`, or another case variant. When filtering `clinical_data_derived.attribute_value`, use case-insensitive matching unless you have already profiled the exact values in the target study: ```sql -- Correct: case-insensitive clinical value filter SELECT DISTINCT sample_unique_id, patient_unique_id FROM clinical_data_derived WHERE cancer_study_identifier = 'your_study_id' AND attribute_name = 'MUTATION_STATUS' AND upper(attribute_value) = 'GERMLINE'; ``` Do not write `attribute_value = 'GERMLINE'` without first checking all distinct values for that attribute in the study. ### Query the Requested Attribute, Not a Proxy Do not infer one clinical attribute from a related subtype or marker. Query the actual requested attribute when it … (17073 more chars) ◀ result {"result":[{"code":"ACBC","name":"Adenoid Cystic Breast Cancer","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > ACBC"},{"code":"BNNOS","name":"Breast Neoplasm, NOS","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BNNOS"},{"code":"BRAME","name":"Adenomyoepithelioma of the Breast","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRAME"},{"code":"BRCA","name":"Invasive Breast Carcinoma","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA"},{"code":"BRCANOS","name":"Breast Invasive Cancer, NOS","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > BRCANOS"},{"code":"BRCNOS","name":"Breast Invasive Carcinoma, NOS","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > BRCNOS"},{"code":"BREAST","name":"Breast","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST"},{"code":"BRSRCC","name":"Breast Carcinoma with Signet Ring","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > BRSRCC"},{"code":"CCHM","name":"Carcinoma with Chondroid Metaplasia","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > MBC > MMBC > CCHM"},{"code":"COM","name":"Carcinoma with Osseous Metaplasia","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > MBC > MMBC > COM"},{"code":"CSNOS","name":"Breast Invasive Carcinosarcoma, NOS","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > CSNOS"},{"code":"DCIS","name":"Breast Ductal Carcinoma In Situ","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > DCIS"},{"code":"EMBC","name":"Epithelial Type Metaplastic Breast Cancer","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > MBC > EMBC"},{"code":"IBC","name":"Inflammatory Breast Cancer","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > IBC"},{"code":"IDC","name":"Breast Invasive Ductal Carcinoma","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > IDC"},{"code":"ILC","name":"Breast Invasive Lobular Carcinoma","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > ILC"},{"code":"IMMC","name":"Breast Invasive Mixed Mucinous Carcinoma","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > IMMC"},{"code":"JSCB","name":"Juvenile Secretory Carcinoma of the Breast","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > JSCB"},{"code":"LCIS","name":"Breast Lobular Carcinoma In Situ","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > LCIS"},{"code":"MASC","name":"Metaplastic Adenosquamous Carcinoma","score":65,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > MBC > EMBC > MASC"},{"code":"MASCC","name":"Metaplastic Adenocarcinoma with Spindle … (712 more chars) ▶ clickhouse_run_select_query { "query": " WITH breast_patients AS ( SELECT DISTINCT patient_unique_id FROM clinical_data_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND attribute_name = 'CANCER_TYPE' AND attribute_value = 'Breast Cancer' ), mut AS ( SELECT DISTINCT patient_unique_id FROM genomic_event_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND hugo_gene_symbol = 'PIK3CA' AND variant_type = 'mutation' AND patient_unique_id IN (SELECT patient_unique_id FROM breast_patients) ), profiled AS ( SELECT DISTINCT patient_unique_id FROM genomic_event_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND off_panel = FALSE AND patient_unique_id IN (SELECT patient_unique_id FROM breast_patients) ), os AS ( SELECT patient_unique_id, maxIf(toFloat64OrNull(attribute_value), attribute_name = 'OS_MONTHS') AS os_months, maxIf(attribute_value, attribute_name = 'OS_STATUS') AS os_status FROM clinical_data_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND attribute_name IN ('OS_MONTHS', 'OS_STATUS') AND patient_unique_id IN (SELECT patient_unique_id FROM breast_patients) GROUP BY patient_unique_id ) SELECT if(os.patient_unique_id IN (SELECT patient_unique_id FROM mut), 'PIK3CA-Mutant', 'PIK3CA-Wild-type') AS group_name, count() AS n_patients, countIf(startsWith(os_status, '1')) AS n_events, countIf(startsWith(os_status, '0')) AS n_censored, round(min(os_months),1) AS min_followup_months, round(max(os_months),1) AS max_followup_months FROM os WHERE os_months IS NOT NULL AND os_status != '' AND os.patient_unique_id IN (SELECT patient_unique_id FROM profiled) GROUP BY group_name " } ◀ result {"rows":[{"group_name":"PIK3CA-Mutant","n_patients":1908,"n_events":718,"n_censored":1190,"min_followup_months":0,"max_followup_months":113.1},{"group_name":"PIK3CA-Wild-type","n_patients":3329,"n_events":1237,"n_censored":2092,"min_followup_months":0,"max_followup_months":118.5}]} ▶ resolve_and_route { "studyIds": [ "msk_chord_2024" ] } ◀ result {"success":true,"message":"Found 1 study. Use the metadata to call the appropriate navigation tool(s).","data":{"totalCount":1,"studiesWithMetadata":[{"studyId":"msk_chord_2024","name":"MSK-CHORD (MSK, Nature 2024)","sampleCount":25040,"studyViewUrl":"https://www.cbioportal.org/study?id=msk_chord_2024","metadata":{"clinicalAttributeIds":["ADRENAL_GLANDS","BONE","CANCER_TYPE","CANCER_TYPE_DETAILED","CLINICAL_GROUP","CLINICAL_SUMMARY","CNS_BRAIN","CURRENT_AGE_DEID","DIAGNOSIS_DESCRIPTION","ETHNICITY","FRACTION_GENOME_ALTERED","GENDER","GENE_PANEL","GLEASON_FIRST_REPORTED","GLEASON_HIGHEST_REPORTED","GLEASON_SAMPLE_LEVEL","HER2","HISTORY_OF_PDL1","HR","ICD_O_HISTOLOGY_DESCRIPTION","INTRA_ABDOMINAL","LIVER","LUNG","LYMPH_NODES","METASTATIC_SITE","MSI_COMMENT","MSI_SCORE","MSI_TYPE","MUTATION_COUNT","NUM_ICDO_DX","ONCOTREE_CODE","OS_MONTHS","OS_STATUS","OTHER","PATHOLOGICAL_GROUP","PDL1_POSITIVE","PLEURA","PRIMARY_SITE","PRIOR_MED_TO_MSK","RACE","REPRODUCTIVE_ORGANS","SAMPLE_CLASS","SAMPLE_COUNT","SAMPLE_COVERAGE","SAMPLE_TYPE","SMOKING_PREDICTIONS_3_CLASSES","SOMATIC_STATUS","STAGE_HIGHEST_RECORDED","TMB_NONSYNONYMOUS","TUMOR_PURITY"],"molecularProfileIds":["msk_chord_2024_cna","msk_chord_2024_mutations","msk_chord_2024_structural_variants"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations"]}}]}} ▶ navigate_to_results_view { "studyIds": [ "msk_chord_2024" ], "genes": [ "PIK3CA: MUT" ], "tab": "comparison/survival", "studyViewFilter": { "clinicalDataFilters": [ { "attributeId": "CANCER_TYPE", "values": [ { "value": "Breast Cancer" } ] } ] } } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/results/comparison/survival?session_id=6ab49ef5c2115c492d884a5f","url":"https://www.cbioportal.org/results/comparison/survival?session_id=6ab49ef5c2115c492d884a5f","data":{"studyIds":["msk_chord_2024"],"studies":[{"studyId":"msk_chord_2024","name":"MSK-CHORD (MSK, Nature 2024)","sampleCount":25040}],"genes":["PIK3CA"],"filteredSampleCount":5368,"caseSetId":"-1","sessionId":"6ab49ef5c2115c492d884a5f","studyViewUrl":"https://www.cbioportal.org/study?id=msk_chord_2024#filterJson=%7B%22clinicalDataFilters%22%3A%5B%7B%22attributeId%22%3A%22CANCER_TYPE%22%2C%22values%22%3A%5B%7B%22value%22%3A%22Breast%20Cancer%22%7D%5D%7D%5D%7D","pageDescription":"Kaplan-Meier survival analysis comparing groups defined by query genes."}} ═ answer (success) I can't compute a Kaplan-Meier survival estimate or a log-rank p-value directly — survival comparisons require handling censoring, which a simple database query cannot do correctly. Here's what I can report from the MSK-CHORD breast cancer cohort (patients with genomic profiling and overall survival data): | Group | N patients | Events (deceased) | Censored (living) | Follow-up range (months) | |---|---|---|---|---| | **PIK3CA-mutant** | 1,908 | 718 | 1,190 | 0 – 113.1 | | **PIK3CA-wild-type** | 3,329 | 1,237 | 2,092 | 0 – 118.5 | In both groups, fewer than half of patients have experienced an event (death), so the Kaplan-Meier median OS is likely **not reached** in either group at current follow-up — a naive average/median of the survival times would not be a valid estimate. To get the actual Kaplan-Meier curves and a log-rank p-value for this comparison, use cBioPortal's built-in Survival tab, which runs this analysis correctly: [PIK3CA-mutant vs. wild-type overall survival — MSK-CHORD Breast Cancer](https://www.cbioportal.org/results/comparison/survival?session_id=6ab49ef5c2115c492d884a5f) This link pre-filters the cohort to the 5,368 breast cancer patients in MSK-CHORD and sets up the Altered (PIK3CA-mutant) vs. Unaltered (PIK3CA wild-type) comparison groups on the Survival tab, where you can view the KM plot and its log-rank p-value directly. If you'd like, you can also run the same comparison yourself in R (`survival::survfit(Surv(OS_MONTHS, OS_STATUS=="1:DECEASED") ~ group)`) or Python (`lifelines.KaplanMeierFitter`) using the raw patient-level data.