Q (sonnet-5.5): are lung carcinosarcomas associated with BRIP1 mutations? ▶ read_guide { "uri": "cbioportal://mutation-frequency-guide" } ▶ read_guide { "uri": "cbioportal://statistical-tests-guide" } ◀ 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) ▶ search_oncotree { "search_term": "lung carcinosarcoma" } ◀ 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":[]} ▶ search_oncotree { "search_term": "sarcomatoid" } ▶ search_oncotree { "search_term": "carcinosarcoma" } ◀ result {"result":[{"code":"SARCL","name":"Sarcomatoid Carcinoma of the Lung","score":60,"mainType":"Non-Small Cell Lung Cancer","tissue":"Lung","hierarchy":"LUNG > SARCL"},{"code":"SCB","name":"Sarcomatoid Carcinoma of the Urinary Bladder","score":60,"mainType":"Bladder Cancer","tissue":"Bladder/Urinary Tract","hierarchy":"BLADDER > SCB"},{"code":"SRCC","name":"Sarcomatoid Renal Cell Carcinoma","score":60,"mainType":"Renal Cell Carcinoma","tissue":"Kidney","hierarchy":"KIDNEY > RCC > NCCRCC > SRCC"},{"code":"PLSMESO","name":"Pleural Mesothelioma, Sarcomatoid Type","score":50,"mainType":"Mesothelioma","tissue":"Pleura","hierarchy":"PLEURA > PLMESO > PLSMESO"},{"code":"SCCRCC","name":"Renal Clear Cell Carcinoma with Sarcomatoid Features","score":50,"mainType":"Renal Cell Carcinoma","tissue":"Kidney","hierarchy":"KIDNEY > RCC > CCRCC > SCCRCC"}]} ◀ result {"result":[{"code":"CSNOS","name":"Breast Invasive Carcinosarcoma, NOS","score":50,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > BRCA > CSNOS"},{"code":"MCS","name":"Metaplastic Carcinosarcoma","score":50,"mainType":"Breast Cancer","tissue":"Breast","hierarchy":"BREAST > MBC > MMBC > MCS"},{"code":"OCS","name":"Ovarian Carcinosarcoma/Malignant Mixed Mesodermal Tumor","score":50,"mainType":"Ovarian Cancer","tissue":"Ovary/Fallopian Tube","hierarchy":"OVARY > OVT > OCS"},{"code":"UCS","name":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","score":50,"mainType":"Endometrial Cancer","tissue":"Uterus","hierarchy":"UTERUS > UCEC > UCS"}]} ▶ clickhouse_list_table_columns { "table": "clinical_data_derived" } ◀ 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": "SELECT cancer_study_identifier, attribute_name, attribute_value, uniqExact(sample_unique_id) n FROM clinical_data_derived WHERE attribute_name IN ('CANCER_TYPE_DETAILED','ONCOTREE_CODE') AND (attribute_value = 'SARCL' OR lower(attribute_value) LIKE '%carcinosarcoma%' OR lower(attribute_value) LIKE '%sarcomatoid carcinoma of the lung%' OR lower(attribute_value) LIKE '%pleomorphic carcinoma%') GROUP BY 1,2,3 ORDER BY n DESC LIMIT 50" } ◀ result {"rows":[{"cancer_study_identifier":"msk_impact_50k_2026","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":293},{"cancer_study_identifier":"ucec_ancestry_cds_msk_2023","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":225},{"cancer_study_identifier":"msk_met_2021","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":192},{"cancer_study_identifier":"pancan_mimsi_msk_2024","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":136},{"cancer_study_identifier":"pancan_pdmr_2025","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":105},{"cancer_study_identifier":"msk_impact_50k_2026","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Ovarian Carcinosarcoma/Malignant Mixed Mesodermal Tumor","n":81},{"cancer_study_identifier":"msk_impact_50k_2026","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Pleomorphic Carcinoma of the Lung","n":61},{"cancer_study_identifier":"ucs_tcga_gdc","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":57},{"cancer_study_identifier":"ucs_tcga","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":57},{"cancer_study_identifier":"ucs_tcga_pan_can_atlas_2018","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":57},{"cancer_study_identifier":"cellline_ccle_broad","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Ovarian Carcinosarcoma/Malignant Mixed Mesodermal Tumor","n":47},{"cancer_study_identifier":"msk_chord_2024","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Pleomorphic Carcinoma of the Lung","n":45},{"cancer_study_identifier":"mycf_msk_2026","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":40},{"cancer_study_identifier":"msk_impact_2017","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":38},{"cancer_study_identifier":"ucec_msk_2018","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Uterine Carcinosarcoma/Uterine Malignant Mixed Mullerian Tumor","n":37},{"cancer_study_identifier":"msk_impact_50k_2026","attribute_name":"CANCER_TYPE_DETAILED","attribute_value":"Sarcomatoid Carcinoma of the Lung","n":30},{"cancer_study_identifier":"msk_impact_50k_2026","attribute_name":"ONCOTREE_CODE","attribute_value":"SARCL","n":30},{"cancer_study_identifier":"msk_ch_2023","attribute_name":"ONCOTREE_CODE","attribute_value":"SARCL","n":22},{"cancer_study_ … (4775 more chars) ▶ clickhouse_run_select_query { "query": "WITH st AS (SELECT sample_unique_id, anyIf(attribute_value, attribute_name='CANCER_TYPE') ct, anyIf(attribute_value, attribute_name='CANCER_TYPE_DETAILED') ctd FROM clinical_data_derived WHERE cancer_study_identifier='msk_impact_50k_2026' AND attribute_name IN ('CANCER_TYPE','CANCER_TYPE_DETAILED') AND sample_unique_id!='' GROUP BY sample_unique_id), grp AS (SELECT sample_unique_id, multiIf(ctd='Sarcomatoid Carcinoma of the Lung','Sarcomatoid carcinoma of lung (SARCL)', ctd='Pleomorphic Carcinoma of the Lung','Pleomorphic carcinoma of lung', ct='Non-Small Cell Lung Cancer','Other NSCLC','') g FROM st), prof AS (SELECT sample_unique_id FROM mutation_panel_gene_coverage WHERE hugo_gene_symbol='BRIP1' AND cancer_study_identifier='msk_impact_50k_2026' UNION ALL SELECT sample_unique_id FROM mutation_wes_coverage WHERE cancer_study_identifier='msk_impact_50k_2026'), alt AS (SELECT DISTINCT sample_unique_id FROM genomic_event_derived WHERE cancer_study_identifier='msk_impact_50k_2026' AND variant_type='mutation' AND mutation_status!='UNCALLED' AND off_panel=0 AND hugo_gene_symbol='BRIP1') SELECT g, uniqExact(sample_unique_id) profiled, uniqExactIf(sample_unique_id, sample_unique_id IN (SELECT sample_unique_id FROM alt)) altered, round(altered*100/profiled,2) pct FROM grp WHERE g!='' AND sample_unique_id IN (SELECT sample_unique_id FROM prof) GROUP BY g" } ▶ resolve_and_route { "studyIds": [ "msk_impact_50k_2026" ] } ◀ result {"rows":[{"g":"Other NSCLC","profiled":7776,"altered":147,"pct":1.89},{"g":"Sarcomatoid carcinoma of lung (SARCL)","profiled":30,"altered":0,"pct":0},{"g":"Pleomorphic carcinoma of lung","profiled":61,"altered":1,"pct":1.64}]} ◀ result {"success":true,"message":"Found 1 study. Use the metadata to call the appropriate navigation tool(s).","data":{"totalCount":1,"studiesWithMetadata":[{"studyId":"msk_impact_50k_2026","name":"MSK-IMPACT 50K Clinical Sequencing Cohort (MSK, Cancer Cell 2026)","sampleCount":54331,"studyViewUrl":"https://www.cbioportal.org/study?id=msk_impact_50k_2026","metadata":{"clinicalAttributeIds":["AGE_AT_DX","ANCESTRY_LABEL","CANCER_TYPE","CANCER_TYPE_DETAILED","DISEASE_STATUS","FACETS_PLOIDY","FACETS_PURITY","FACETS_QC","FACETS_SUITE_VERSION","FACETS_WGD","FRACTION_GENOME_ALTERED","GENE_PANEL","HLA-A1","HLA-A2","HLA-B1","HLA-B2","HLA-C1","HLA-C2","HLA_A1_LOH","HLA_A2_LOH","HLA_B1_LOH","HLA_B2_LOH","HLA_C1_LOH","HLA_C2_LOH","HLA_GENOTYPE_AVAILABLE","METASTATIC_SITE","MSI_SCORE","MSI_TYPE","MUTATION_COUNT","N_OTHER_CANCER_TYPES","ONCOTREE_CODE","OS_MONTHS","OS_STATUS","PRIMARY_SITE","PURITY_ESTIMATE_FROM_MUTATIONS","SAMPLE_COUNT","SAMPLE_COVERAGE","SAMPLE_TYPE","SEX","SOMATIC_STATUS","TMB_SCORE","TUMOR_PURITY"],"molecularProfileIds":["msk_impact_50k_2026_gistic","msk_impact_50k_2026_mutations","msk_impact_50k_2026_structural_variants"],"genericAssayProfiles":["msk_impact_50k_2026_armlevel_cna","msk_impact_50k_2026_loh_hla","msk_impact_50k_2026_mutational_signatures_contribution_v2"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations","generic_assay_armlevel_cna","generic_assay_loh_hla","generic_assay_mutational_signature"]}}]}} ▶ navigate_to_group_comparison { "studyIds": [ "msk_impact_50k_2026" ], "groups": [ { "name": "Sarcomatoid carcinoma of lung", "studyViewFilter": { "clinicalDataFilters": [ { "attributeId": "CANCER_TYPE_DETAILED", "values": [ { "value": "Sarcomatoid Carcinoma of the Lung" }, { "value": "Pleomorphic Carcinoma of the Lung" } ] } ] } }, { "name": "Other NSCLC", "studyViewFilter": { "clinicalDataFilters": [ { "attributeId": "CANCER_TYPE", "values": [ { "value": "Non-Small Cell Lung Cancer" } ] } ] } } ], "tab": "alterations" } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/comparison/alterations?comparisonId=6abb42d2c2115c492d8855ce","url":"https://www.cbioportal.org/comparison/alterations?comparisonId=6abb42d2c2115c492d8855ce","data":{"description":"Group comparison (2 custom groups)","studies":["msk_impact_50k_2026"],"totalGroups":2,"groups":[{"name":"Sarcomatoid carcinoma of lung","sampleCount":91},{"name":"Other NSCLC","sampleCount":7867}],"studyViewUrl":"https://www.cbioportal.org/study?id=msk_impact_50k_2026","groupUrls":[{"groupName":"Sarcomatoid carcinoma of lung","url":"https://www.cbioportal.org/study?id=msk_impact_50k_2026#filterJson=%7B%22clinicalDataFilters%22%3A%5B%7B%22attributeId%22%3A%22CANCER_TYPE_DETAILED%22%2C%22values%22%3A%5B%7B%22value%22%3A%22Sarcomatoid%20Carcinoma%20of%20the%20Lung%22%7D%2C%7B%22value%22%3A%22Pleomorphic%20Carcinoma%20of%20the%20Lung%22%7D%5D%7D%5D%7D"},{"groupName":"Other NSCLC","url":"https://www.cbioportal.org/study?id=msk_impact_50k_2026#filterJson=%7B%22clinicalDataFilters%22%3A%5B%7B%22attributeId%22%3A%22CANCER_TYPE%22%2C%22values%22%3A%5B%7B%22value%22%3A%22Non-Small%20Cell%20Lung%20Cancer%22%7D%5D%7D%5D%7D"}],"pageDescription":"Comparison of genomic alteration rates across Sarcomatoid carcinoma of lung (91) vs Other NSCLC (7867)."}} ═ answer (success) **I found no evidence that lung carcinosarcoma is associated with BRIP1 mutations. The cohort is very small, though, so this can't rule one out.** cBioPortal has no separate "lung carcinosarcoma" category. The closest categories are **Sarcomatoid Carcinoma of the Lung** (OncoTree code SARCL) and **Pleomorphic Carcinoma of the Lung**. I used the largest cohort that contains them, the MSK-IMPACT 50K Clinical Sequencing Cohort (`msk_impact_50k_2026`). Counts are samples that were sequenced for BRIP1, with somatic and unknown-status mutations included. | Group | Samples with a BRIP1 mutation / sequenced for BRIP1 | % | |---|---|---| | Sarcomatoid carcinoma of the lung | 0 / 30 | 0% | | Pleomorphic carcinoma of the lung | 1 / 61 | 1.6% | | Other NSCLC (comparison group) | 147 / 7,776 | 1.9% | - **Mutation rate:** The sarcomatoid and pleomorphic groups (91 samples combined) have a BRIP1 mutation rate similar to other NSCLC. In these counts, sarcomatoid carcinoma shows none and pleomorphic carcinoma is close to the background rate. - **Statistical test:** I didn't run a significance test. With 1 mutated sample in 91, the comparison has little power to detect an association. Fisher's exact test is the appropriate test, and the comparison link below will compute it. - **Not a diagnosis:** A BRIP1 mutation here is a mutation record only. It doesn't tell you whether the variant is pathogenic or functional. - **Comparison group:** The "Other NSCLC" group in the link includes the 91 sarcomatoid and pleomorphic samples, because the portal's "Non-Small Cell Lung Cancer" category contains them. The two groups therefore overlap slightly. The figures in my table exclude them from "Other NSCLC". - **Labeling:** Some cases that pathologists would call carcinosarcoma may be labeled differently in other MSK cohorts. Other studies have only a handful of sarcomatoid lung cases. [Group comparison: sarcomatoid/pleomorphic lung carcinoma vs other NSCLC (alteration enrichment)](https://www.cbioportal.org/comparison/alterations?comparisonId=6abb42d2c2115c492d8855ce) [MSK-IMPACT 50K study overview](https://www.cbioportal.org/study?id=msk_impact_50k_2026)