Q (sonnet): Can you please generate a survival curve for colorectal cancer patients based on the expression levels of IMPDH2? ▶ read_guide { "uri": "cbioportal://gene-expression-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 | `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 | | `brca_metabric` | ESR1 | PGR | `mrna` | 0.487 | 1980 | ESR1↔PGR is the textbook breast-cancer estrogen-receptor coregula … (2785 more chars) ▶ read_guide { "uri": "cbioportal://statistical-tests-guide" } ▶ list_studies { "search": "colorectal" } ◀ 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_met_2021","name":"MSK MetTropism (MSK, Cell 2021)","type_of_cancer_id":"mixed","sample_count":25775,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=msk_met_2021"},{"cancer_study_identifier":"crc_msk_2026","name":"Colorectal Adenocarcinoma (MSK, 2026)","type_of_cancer_id":"read","sample_count":7237,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=crc_msk_2026"},{"cancer_study_identifier":"crc_eo_2020","name":"Colorectal Cancer (MSK, JNCI 2021)","type_of_cancer_id":"bowel","sample_count":1516,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=crc_eo_2020"},{"cancer_study_identifier":"crc_msk_2017","name":"Metastatic Colorectal Cancer (MSK, Cancer Cell 2018)","type_of_cancer_id":"coadread","sample_count":1134,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=crc_msk_2017"},{"cancer_study_identifier":"crc_sysucc_2022","name":"Colorectal Cancer- ChangKang Project (SYSUCC, Nat Commun 2022)","type_of_cancer_id":"coadread","sample_count":1015,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=crc_sysucc_2022"},{"cancer_study_identifier":"coadread_tcga","name":"Colorectal Adenocarcinoma (TCGA, Firehose Legacy)","type_of_cancer_id":"coadread","sample_count":640,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=coadread_tcga"},{"cancer_study_identifier":"coadread_dfci_2016","name":"Colorectal Adenocarcinoma (DFCI, Cell Reports 2016)","type_of_cancer_id":"coadread","sample_count":619,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=coadread_dfci_2016"},{"cancer_study_identifier":"coadread_tcga_pan_can_atlas_2018","name":"Colorectal Adenocarcinoma (TCGA, PanCancer Atlas)","type_of_cancer_id":"coadread","sample_count":594,"has_guide":true,"url":"https://www.cbioportal.org/study/summary?id=coadread_tcga_pan_can_atlas_2018"},{"cancer_study_identifier":"crc_apc_impact_2020","name":"Colorectal Cancer (MSK, Gastroenterology 2020)","type_of_cancer_id":"coadread","sample_count":471,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=crc_apc_impact_2020"},{"cancer_study_identifier":"coadread_tcga_pub","name":"Colorectal Adenocarcinoma (TCGA, Nature 2012)","type_of_cancer_id":"coadread","sample_count":276,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=coadread_tcga_pub"},{"cancer_study_identifier":"bowel_colitis_msk_2022","name":"Colorectal Adenocarcinoma (MSK, Nat Commun 2022)","type_of_cancer_id":"bowel","sample_count":179,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=bowel_colitis_msk_2022"},{"cancer_study_identifier":"coadread_cass_2020","name":"Colorectal Cancer (CAS Shanghai, Cancer Cell 2020)","type_of_cancer_id":"coadread","sample_count":146,"has_guide":false,"url":"https://www.cbioportal.org/study/summary?id=coadread_cass_2020"},{"cancer_study_identifier":"coadread_mskcc","name":"Colorectal Adenocarcinoma Triplets (MSK, Geno … (1887 more chars) ▶ resolve_and_route { "studyIds": [ "coadread_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":"coadread_tcga_pan_can_atlas_2018","name":"Colorectal Adenocarcinoma (TCGA, PanCancer Atlas)","sampleCount":594,"studyViewUrl":"https://www.cbioportal.org/study?id=coadread_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":["coadread_tcga_pan_can_atlas_2018_gistic","coadread_tcga_pan_can_atlas_2018_log2CNA","coadread_tcga_pan_can_atlas_2018_mutations","coadread_tcga_pan_can_atlas_2018_protein_quantification","coadread_tcga_pan_can_atlas_2018_protein_quantification_zscores","coadread_tcga_pan_can_atlas_2018_rna_seq_v2_mrna","coadread_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_Zscores","coadread_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_Zscores","coadread_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_ref_normal_Zscores","coadread_tcga_pan_can_atlas_2018_rppa","coadread_tcga_pan_can_atlas_2018_rppa_Zscores","coadread_tcga_pan_can_atlas_2018_structural_variants"],"genericAssayProfiles":["coadread_tcga_pan_can_atlas_2018_armlevel_cna","coadread_tcga_pan_can_atlas_2018_genetic_ancestry","coadread_tcga_pan_can_atlas_2018_methylation_hm27_hm450_merge","coadread_tcga_pan_can_atlas_2018_methylation_hm450"],"heatmapProfileIds":["coadread_tcga_pan_can_atlas_2018_protein_quantification_zscores","coadread_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_Zscores","coadread_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_Zscores","coadread_tcga_pan_can_atlas_2018_rna_seq_v2_mrna_median_all_sample_ref_normal_Zscores","coadread_tcga_pan_can_atlas_2018_rppa_Zscores"],"availableComparisonTabs":["overlap","clinical","survival","alterations","mutations","mrna","protein","generic_assay_armlevel_c … (70 more chars) ▶ clickhouse_run_select_query { "query": "SELECT DISTINCT profile_type FROM genetic_alteration_derived WHERE cancer_study_identifier = 'coadread_tcga_pan_can_atlas_2018' AND profile_type LIKE '%mrna%' ORDER BY profile_type" } ◀ result {"rows":[{"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":"rna_seq_v2_mrna_median_all_sample_ref_normal_Zscores"}]} ▶ clickhouse_run_select_query { "query": " SELECT count() AS n, min(v) AS min_v, quantile(0.25)(v) AS q25, quantile(0.5)(v) AS median_v, quantile(0.75)(v) AS q75, max(v) AS max_v FROM ( SELECT toFloat64OrNull(alteration_value) AS v FROM genetic_alteration_derived WHERE cancer_study_identifier = 'coadread_tcga_pan_can_atlas_2018' AND profile_type = 'rna_seq_v2_mrna_median_Zscores' AND hugo_gene_symbol = 'IMPDH2' AND alteration_value NOT IN ('', 'NA') ) WHERE v IS NOT NULL " } ◀ result {"rows":[{"n":592,"min_v":-2.041,"q25":-0.7661,"median_v":-0.26385000000000003,"q75":0.48105000000000003,"max_v":8.0313}]} ▶ navigate_to_group_comparison { "studyIds": [ "coadread_tcga_pan_can_atlas_2018" ], "tab": "survival", "groups": [ { "name": "IMPDH2-High", "studyViewFilter": { "genomicDataFilters": [ { "hugoGeneSymbol": "IMPDH2", "profileType": "rna_seq_v2_mrna_median_Zscores", "values": [ { "start": -0.26385000000000003 } ] } ] } }, { "name": "IMPDH2-Low", "studyViewFilter": { "genomicDataFilters": [ { "hugoGeneSymbol": "IMPDH2", "profileType": "rna_seq_v2_mrna_median_Zscores", "values": [ { "end": -0.26385000000000003 } ] } ] } } ] } ◀ result {"success":true,"message":"Navigating to https://www.cbioportal.org/comparison/survival?comparisonId=6ab5d15ae497aad53593c290","url":"https://www.cbioportal.org/comparison/survival?comparisonId=6ab5d15ae497aad53593c290","data":{"description":"Group comparison (2 custom groups)","studies":["coadread_tcga_pan_can_atlas_2018"],"totalGroups":2,"groups":[{"name":"IMPDH2-High","sampleCount":296},{"name":"IMPDH2-Low","sampleCount":296}],"studyViewUrl":"https://www.cbioportal.org/study?id=coadread_tcga_pan_can_atlas_2018","groupUrls":[{"groupName":"IMPDH2-High","url":"https://www.cbioportal.org/study?id=coadread_tcga_pan_can_atlas_2018#filterJson=%7B%22genomicDataFilters%22%3A%5B%7B%22hugoGeneSymbol%22%3A%22IMPDH2%22%2C%22profileType%22%3A%22rna_seq_v2_mrna_median_Zscores%22%2C%22values%22%3A%5B%7B%22start%22%3A-0.26385000000000003%7D%5D%7D%5D%7D"},{"groupName":"IMPDH2-Low","url":"https://www.cbioportal.org/study?id=coadread_tcga_pan_can_atlas_2018#filterJson=%7B%22genomicDataFilters%22%3A%5B%7B%22hugoGeneSymbol%22%3A%22IMPDH2%22%2C%22profileType%22%3A%22rna_seq_v2_mrna_median_Zscores%22%2C%22values%22%3A%5B%7B%22end%22%3A-0.26385000000000003%7D%5D%7D%5D%7D"}],"pageDescription":"Kaplan-Meier survival analysis comparing IMPDH2-High (296) vs IMPDH2-Low (296)."}} ═ answer (success) ## Cohort: Colorectal Adenocarcinoma (TCGA, PanCancer Atlas) I split the cohort at the median IMPDH2 mRNA z-score (RNA-Seq V2, RSEM; median = −0.264, n = 592 profiled samples of 594 total) into high vs. low expression groups: | Group | Samples | |---|---| | IMPDH2-High (above median) | 296 | | IMPDH2-Low (at/below median) | 296 | **[View IMPDH2-High vs. IMPDH2-Low Survival Comparison](https://www.cbioportal.org/comparison/survival?comparisonId=6ab5d15ae497aad53593c290)** This opens directly on the Survival tab, where cBioPortal will render the Kaplan-Meier curves (overall survival by default, with options for disease-free/progression-free survival) and run the log-rank test — I can't compute Kaplan-Meier estimates or p-values myself, so the curve itself needs to be generated and interpreted on that page. A couple of notes: - **Study choice:** several colorectal cohorts matched your query (e.g., MSK metastatic CRC series, DFCI, various regional cohorts). I used the TCGA PanCancer Atlas colorectal cohort since it's the standard reference set with full expression + survival annotation. If you had a different cohort in mind (larger sample size, metastatic-specific, or a particular institution's series), let me know and I'll rebuild this for that study. - **Grouping choice:** I used a median split (z-score) since you didn't specify high/low thresholds — you can adjust the cutoff or use tertiles/quartiles directly in the Group Comparison tool if you'd like a different split.