Q (sonnet): 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://gene-expression-guide" } ▶ read_guide { "uri": "cbioportal://statistical-tests-guide" } ◀ 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 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) ▶ clickhouse_list_table_columns { "table": "genetic_alteration_derived" } ▶ list_studies { "search": "glioblastoma TCGA PanCancer" } ◀ result {"columns":[{"name":"sample_unique_id","type":"String"},{"name":"cancer_study_identifier","type":"LowCardinality(String)"},{"name":"hugo_gene_symbol","type":"String"},{"name":"profile_type","type":"LowCardinality(String)"},{"name":"alteration_value","type":"Nullable(String)"}]} ◀ 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": "SELECT DISTINCT profile_type FROM genetic_alteration_derived WHERE cancer_study_identifier = 'gbm_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'CDK4' ORDER BY profile_type" } ◀ 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"}]} ▶ clickhouse_run_select_query { "query": " WITH cna AS ( SELECT sample_unique_id, toFloat64OrNull(alteration_value) AS cna_val 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 NOT IN ('', 'NA') AND toFloat64OrNull(alteration_value) IS NOT NULL ), expr AS ( SELECT sample_unique_id, toFloat64OrNull(alteration_value) AS expr_val 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 alteration_value NOT IN ('', 'NA') AND toFloat64OrNull(alteration_value) IS NOT NULL ) SELECT cna.cna_val AS gistic_value, count() AS n_samples, round(avg(log2(expr.expr_val + 1)), 3) AS mean_log2_rsem, round(quantile(0.5)(log2(expr.expr_val + 1)), 3) AS median_log2_rsem, round(min(log2(expr.expr_val + 1)), 3) AS min_log2_rsem, round(max(log2(expr.expr_val + 1)), 3) AS max_log2_rsem FROM cna INNER JOIN expr USING (sample_unique_id) GROUP BY gistic_value ORDER BY gistic_value " } ◀ result {"rows":[{"gistic_value":-1,"n_samples":11,"mean_log2_rsem":11.464,"median_log2_rsem":11.364,"min_log2_rsem":10.945,"max_log2_rsem":12.567},{"gistic_value":0,"n_samples":95,"mean_log2_rsem":11.744,"median_log2_rsem":11.607,"min_log2_rsem":10.422,"max_log2_rsem":16.556},{"gistic_value":1,"n_samples":15,"mean_log2_rsem":12.133,"median_log2_rsem":12.099,"min_log2_rsem":11.407,"max_log2_rsem":13.367},{"gistic_value":2,"n_samples":27,"mean_log2_rsem":15.527,"median_log2_rsem":15.82,"min_log2_rsem":11.655,"max_log2_rsem":18.808}]} ▶ clickhouse_run_select_query { "query": " WITH cna AS ( SELECT sample_unique_id, toFloat64OrNull(alteration_value) AS cna_val 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 NOT IN ('', 'NA') AND toFloat64OrNull(alteration_value) IS NOT NULL ), expr AS ( SELECT sample_unique_id, toFloat64OrNull(alteration_value) AS expr_val 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 alteration_value NOT IN ('', 'NA') AND toFloat64OrNull(alteration_value) IS NOT NULL ) SELECT CASE WHEN cna.cna_val = 2 THEN 'AMP' WHEN cna.cna_val = 0 THEN 'DIPLOID' END AS grp, round(stddevPop(log2(expr.expr_val + 1)), 3) AS sd_log2_rsem, round(quantile(0.25)(log2(expr.expr_val + 1)), 3) AS q1, round(quantile(0.75)(log2(expr.expr_val + 1)), 3) AS q3 FROM cna INNER JOIN expr USING (sample_unique_id) WHERE cna.cna_val IN (0, 2) GROUP BY grp " } ◀ result {"rows":[{"grp":"AMP","sd_log2_rsem":1.691,"q1":15.215,"q3":16.589},{"grp":"DIPLOID","sd_log2_rsem":0.698,"q1":11.35,"q3":12.018}]} ▶ resolve_and_route { "studyIds": [ "gbm_tcga_pan_can_atlas_2018" ] } ◀ result {"success":true,"message":"Found 1 study. Use the metadata to call the appropriate navigation tool(s).","data":{"totalCount":1,"studiesWithMetadata":[{"studyId":"gbm_tcga_pan_can_atlas_2018","name":"Glioblastoma Multiforme (TCGA, PanCancer Atlas)","sampleCount":592,"studyViewUrl":"https://www.cbioportal.org/study?id=gbm_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":["gbm_tcga_pan_can_atlas_2018_gistic","gbm_tcga_pan_can_atlas_2018_log2CNA","gbm_tcga_pan_can_atlas_2018_mutations","gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna","gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_Zscores","gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_Zscores","gbm_tcga_pan_can_atlas_2018_rppa","gbm_tcga_pan_can_atlas_2018_rppa_Zscores","gbm_tcga_pan_can_atlas_2018_structural_variants"],"genericAssayProfiles":["gbm_tcga_pan_can_atlas_2018_armlevel_cna","gbm_tcga_pan_can_atlas_2018_genetic_ancestry","gbm_tcga_pan_can_atlas_2018_methylation_hm27_hm450_merge","gbm_tcga_pan_can_atlas_2018_methylation_hm450"],"heatmapProfileIds":["gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_Zscores","gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_Zscores","gbm_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"]}}]}} ▶ 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", "selectedGeneOption": "CDK4", "selectedDataSourceOption": "gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna" } } ◀ 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%22%2C%22selectedDataSourceOption%22%3A%22gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna%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%22%2C%22selectedDataSourceOption%22%3A%22gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna%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 (y-axis) by CDK4 CNA (x-axis)."}} ▶ navigate_to_group_comparison { "studyIds": [ "gbm_tcga_pan_can_atlas_2018" ], "tab": "mrna", "selectedGene": "CDK4", "groups": [ { "name": "CDK4 Amplified", "studyViewFilter": { "genomicDataFilters": [ { "hugoGeneSymbol": "CDK4", "profileType": "gistic", "values": [ { "value": "2" } ] } ] } }, { "name": "CDK4 Diploid", "studyViewFilter": { "genomicDataFilters": [ { "hugoGeneSymbol": "CDK4", "profileType": "gistic", "values": [ { "value": "0" } ] } ] } } ] } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/comparison/mrna?comparisonId=6ab7f4cbe497aad53593c5a5&selectedGene=CDK4","url":"https://www.cbioportal.org/comparison/mrna?comparisonId=6ab7f4cbe497aad53593c5a5&selectedGene=CDK4","data":{"description":"Group comparison (2 custom groups)","studies":["gbm_tcga_pan_can_atlas_2018"],"totalGroups":2,"groups":[{"name":"CDK4 Amplified","sampleCount":82},{"name":"CDK4 Diploid","sampleCount":396}],"studyViewUrl":"https://www.cbioportal.org/study?id=gbm_tcga_pan_can_atlas_2018","groupUrls":[{"groupName":"CDK4 Amplified","url":"https://www.cbioportal.org/study?id=gbm_tcga_pan_can_atlas_2018#filterJson=%7B%22genomicDataFilters%22%3A%5B%7B%22hugoGeneSymbol%22%3A%22CDK4%22%2C%22profileType%22%3A%22gistic%22%2C%22values%22%3A%5B%7B%22value%22%3A%222%22%7D%5D%7D%5D%7D"},{"groupName":"CDK4 Diploid","url":"https://www.cbioportal.org/study?id=gbm_tcga_pan_can_atlas_2018#filterJson=%7B%22genomicDataFilters%22%3A%5B%7B%22hugoGeneSymbol%22%3A%22CDK4%22%2C%22profileType%22%3A%22gistic%22%2C%22values%22%3A%5B%7B%22value%22%3A%220%22%7D%5D%7D%5D%7D"}],"pageDescription":"mRNA expression for all genes compared across CDK4 Amplified (82) vs CDK4 Diploid (396)."}} ═ answer (success) Here are the two direct links to explore/confirm this in the portal: - **[Scatter plot: CDK4 mRNA vs. CDK4 copy-number status](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%22%2C%22selectedDataSourceOption%22%3A%22gbm_tcga_pan_can_atlas_2018_rna_seq_v2_mrna%22%7D)** — full sample-level distribution, box plots per CNA category. - **[Group Comparison: CDK4 Amplified vs. CDK4 Diploid — mRNA tab](https://www.cbioportal.org/comparison/mrna?comparisonId=6ab7f4cbe497aad53593c5a5&selectedGene=CDK4)** — CDK4 Amplified (82 samples) vs. CDK4 Diploid (396 samples) across the whole PanCancer Atlas GBM cohort (note: this comparison view uses all profiled samples with valid GISTIC calls, a larger denominator than my query above, which required samples to also have paired RSEM expression). This tab runs the built-in significance test (Student's t-test on log2 expression) and will show you the actual p-value/q-value directly. **Summary:** Descriptively, CDK4 amplified GBM samples show substantially higher CDK4 mRNA expression than diploid samples (mean log2(RSEM+1) 15.53 vs. 11.74, non-overlapping interquartile ranges), consistent with a gene-dosage effect. I can't generate the p-value myself, but the effect size here is large enough that the Group Comparison link above should confirm significance almost immediately.