Q (sonnet-5.5): In the TCGA PanCancer Atlas glioblastoma study, is CDK4 mRNA expression significantly higher in samples with CDK4 amplification compared to diploid samples? ▶ read_guide { "uri": "cbioportal://statistical-tests-guide" } ▶ read_guide { "uri": "cbioportal://gene-expression-guide" } ◀ 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) ▶ list_studies { "search": "glioblastoma pan_can_atlas" } ◀ result # Gene Expression Analysis Guide This guide covers continuous-value genomic data: gene **expression**, **copy number** values, **methylation**, and related profile types. Mutation/CNA/SV *frequency* analysis lives in `cbioportal://mutation-frequency-guide`. ## Where this data lives Continuous per-sample-per-gene values are stored in `genetic_alteration_derived`: | Column | Description | |---|---| | `sample_unique_id` | `_` | | `cancer_study_identifier` | study scope | | `hugo_gene_symbol` | gene | | `profile_type` | which assay/normalization (see below) | | `alteration_value` | the actual value — stored as Nullable(String); cast with `toFloat64OrNull` | `alteration_value` is a string because the same column hosts many different value scales. The `''` and `'NA'` sentinels mean "missing"; always filter them out and use `toFloat64OrNull(alteration_value) IS NOT NULL` for downstream math. ## Discovering profile types for a study Different studies expose different profile types depending on what assays were run and how the data was normalized. Always check what a specific study supports before picking one: ```sql SELECT DISTINCT profile_type FROM genetic_alteration_derived WHERE cancer_study_identifier = 'brca_metabric' ORDER BY profile_type; ``` Common values across the public portal: | Family | Profile types | |---|---| | mRNA expression | `rna_seq_v2_mrna`, `rna_seq_v2_mrna_median_Zscores`, `rna_seq_v2_mrna_median_all_sample_Zscores` (TCGA PanCancer Atlas), `mrna`, `mrna_median_Zscores`, `mrna_seq_v2_rsem`, `mrna_seq_v2_rsem_Zscores`, `mrna_seq_cpm`, `mrna_seq_fpkm`, `mrna_U133`, `mrna_outliers` | | Copy number (continuous) | `cna`, `linear_CNA`, `log2CNA`, `cna_consensus`, `cna_rae`, `gistic` | | Methylation | `methylation_hm27`, `methylation_hm450`, `methylation_epic`, `methylation_promoters_rrbs` | | miRNA | `mirna`, `mirna_median_Zscores` | | Protein | `protein_quantification`, `protein_level`, `RPPA` | **Z-score vs raw choice.** When the user asks "is X correlated with Y", either works for Spearman (rank-based) — Pearson would care. Default to the non-Z-score variant if both exist, and call out which one in the response. ## Canonical recipe — Spearman correlation between two genes ```sql SELECT * FROM gene_pair_coexpression( study = 'brca_metabric', gene_a = 'TP53', gene_b = 'MYC', profile_type = 'mrna' ); ``` Returns one row: `(gene_a, gene_b, profile_type, spearman_correlation, num_samples)`. - `spearman_correlation` in [−1, 1]; `NULL` when fewer than 3 valid paired samples. - Mirrors cbioportal-backend's `ClickhouseCoExpressionMapper.getCoExpressions`, simplified to a pair lookup (the backend computes one ref gene vs ALL other genes for the coexpression page; here the agent asks about a specific pair). ### Verified examples | Study | gene_a | gene_b | profile_type | spearman | n | |---|---|---|---|---|---| | `brca_metabric` | TP53 | MYC | `mrna` | 0.118 | 1980 | | … (4931 more chars) ◀ result {"result":[{"cancer_study_identifier":"gbm_tcga_pan_can_atlas_2018","name":"Glioblastoma Multiforme (TCGA, PanCancer Atlas)","type_of_cancer_id":"difg","sample_count":592,"has_guide":true,"url":"https://www.cbioportal.org/study/summary?id=gbm_tcga_pan_can_atlas_2018"}]} ▶ clickhouse_run_select_query { "query": "WITH cna AS (SELECT sample_unique_id, alteration_value AS c FROM genetic_alteration_derived WHERE cancer_study_identifier='gbm_tcga_pan_can_atlas_2018' AND hugo_gene_symbol='CDK4' AND profile_type='gistic' AND alteration_value IN ('2','0')), ex AS (SELECT sample_unique_id, log2(toFloat64OrNull(alteration_value)+1) AS v FROM genetic_alteration_derived WHERE cancer_study_identifier='gbm_tcga_pan_can_atlas_2018' AND hugo_gene_symbol='CDK4' AND profile_type='rna_seq_v2_mrna' AND toFloat64OrNull(alteration_value) IS NOT NULL) SELECT c, count() n, round(avg(v),2) mean_log2, round(median(v),2) med_log2, round(stddevSamp(v),2) sd FROM cna JOIN ex USING (sample_unique_id) GROUP BY c" } ▶ clickhouse_run_select_query { "query": "SELECT DISTINCT profile_type FROM genetic_alteration_derived WHERE cancer_study_identifier='gbm_tcga_pan_can_atlas_2018'" } ◀ result {"rows":[{"c":"2","n":27,"mean_log2":15.53,"med_log2":15.82,"sd":1.72},{"c":"0","n":95,"mean_log2":11.74,"med_log2":11.61,"sd":0.7}]} ◀ result {"rows":[{"profile_type":"gistic"},{"profile_type":"log2CNA"},{"profile_type":"rna_seq_v2_mrna"},{"profile_type":"rna_seq_v2_mrna_median_Zscores"},{"profile_type":"rna_seq_v2_mrna_median_all_sample_Zscores"},{"profile_type":"rppa"},{"profile_type":"rppa_Zscores"}]} ▶ navigate_to_results_view { "studyIds": [ "gbm_tcga_pan_can_atlas_2018" ], "genes": [ "CDK4" ], "tab": "plots", "plotsHorzSelection": { "dataType": "COPY_NUMBER_ALTERATION", "selectedGeneOption": "CDK4" }, "plotsVertSelection": { "dataType": "MRNA_EXPRESSION", "selectedGeneOption": "CDK4" } } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/results/plots?cancer_study_list=gbm_tcga_pan_can_atlas_2018&gene_list=CDK4&case_set_id=gbm_tcga_pan_can_atlas_2018_all&plots_horz_selection=%7B%22selectedGeneOption%22%3A%221019%22%2C%22dataType%22%3A%22COPY_NUMBER_ALTERATION%22%7D&plots_vert_selection=%7B%22selectedGeneOption%22%3A%221019%22%2C%22dataType%22%3A%22MRNA_EXPRESSION%22%7D","url":"https://www.cbioportal.org/results/plots?cancer_study_list=gbm_tcga_pan_can_atlas_2018&gene_list=CDK4&case_set_id=gbm_tcga_pan_can_atlas_2018_all&plots_horz_selection=%7B%22selectedGeneOption%22%3A%221019%22%2C%22dataType%22%3A%22COPY_NUMBER_ALTERATION%22%7D&plots_vert_selection=%7B%22selectedGeneOption%22%3A%221019%22%2C%22dataType%22%3A%22MRNA_EXPRESSION%22%7D","data":{"studyIds":["gbm_tcga_pan_can_atlas_2018"],"studies":[{"studyId":"gbm_tcga_pan_can_atlas_2018","name":"Glioblastoma Multiforme (TCGA, PanCancer Atlas)","sampleCount":592}],"genes":["CDK4"],"caseSetId":"gbm_tcga_pan_can_atlas_2018_all","pageDescription":"Scatter/box plots: CDK4 mRNA expression (y-axis) by CDK4 CNA (x-axis)."}} ═ answer (success) I can't give you a significance test, because the database I query can't run one. The data do show a large difference in the direction you expect. **CDK4 mRNA by copy-number status** (Glioblastoma Multiforme, TCGA PanCancer Atlas; samples with both copy-number and RNA-seq data; expression is log2(RSEM+1)): | CDK4 copy-number status | Samples | Mean | Median | SD | |---|---|---|---|---| | Amplified (GISTIC = 2) | 27 | 15.53 | 15.82 | 1.72 | | Diploid (GISTIC = 0) | 95 | 11.74 | 11.61 | 0.70 | - **Size of the difference:** Amplified samples have about 3.8 log2 units higher mean expression than diploid samples. The median difference is about 4.2 log2 units, which is roughly a 15-fold difference on the linear scale. - **Spread:** Amplified samples vary more (SD 1.72 versus 0.70). - **Group sizes:** Both groups have well over 3 samples, so a t-test is appropriate. That is the default test for expression data in the Group Comparison tab. - **Excluded samples:** I left out gain, shallow deletion and deep deletion samples, so this is amplified versus diploid only. **To get the p-value:** Open the plot below and read the statistics on the box plot. You can also run `t.test(expr ~ status)` in R, or `scipy.stats.ttest_ind` in Python, on the two groups. [CDK4 mRNA expression by CDK4 copy-number status (Plots tab)](https://www.cbioportal.org/results/plots?cancer_study_list=gbm_tcga_pan_can_atlas_2018&gene_list=CDK4&case_set_id=gbm_tcga_pan_can_atlas_2018_all&plots_horz_selection=%7B%22selectedGeneOption%22%3A%221019%22%2C%22dataType%22%3A%22COPY_NUMBER_ALTERATION%22%7D&plots_vert_selection=%7B%22selectedGeneOption%22%3A%221019%22%2C%22dataType%22%3A%22MRNA_EXPRESSION%22%7D) This shows CDK4 mRNA expression (y-axis) by CDK4 copy-number status (x-axis).