Q (haiku): TCGA PanCancer Atlas の乳がんで TP53 変異の頻度を教えてください。 Breast Invasive Carcinoma (TCGA, PanCancer Atlas) では、TP53 変異はプロファイルされた 1,066 サンプル中 347 サンプル(32.6%)に見られます。 Continue this conversation: reply to the user's new message. 変異だけでなく、ホモ接合性欠失(deep deletion)も含めて計算してください。 ▶ read_guide { "uri": "cbioportal://mutation-frequency-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) ▶ clickhouse_run_select_query { "query": " SELECT cancer_study_identifier, name, sample_count, mutation_sample_count, cna_sample_count FROM cancer_study WHERE type_of_cancer IN (SELECT oncotree_code FROM type_of_cancer WHERE name ILIKE '%breast%invasive%') AND name ILIKE '%tcga%' AND name ILIKE '%pan%cancer%atlas%' LIMIT 10 ", "max_rows": 20 } ◀ result {"error_message":"Query execution failed: HTTPDriver for https://dl96orhu96.us-east-1.aws.clickhouse.cloud:8443 received ClickHouse error code 47\n Code: 47. DB::Exception: Unknown expression identifier `oncotree_code` in scope (SELECT oncotree_code FROM type_of_cancer WHERE name ILIKE '%breast%invasive%'). (UNKNOWN_IDENTIFIER) (version 26.4.1.2359 (official build))\n"} ▶ clickhouse_list_table_columns { "table": "type_of_cancer" } ◀ result {"columns":[{"name":"type_of_cancer_id","type":"String"},{"name":"name","type":"String"},{"name":"dedicated_color","type":"String"},{"name":"short_name","type":"Nullable(String)"},{"name":"parent","type":"Nullable(String)"},{"name":"main_type","type":"String","comment":"Broad OncoTree grouping (e.g. Non-Small Cell Lung Cancer, Glioma). Useful for grouping related subtypes."},{"name":"tissue","type":"String","comment":"Tissue of origin (e.g. Lung, CNS/Brain, Breast). Top-level anatomical grouping."},{"name":"level","type":"UInt8","comment":"Depth in OncoTree hierarchy: 1 = tissue, 2-6 = increasingly specific subtypes. Lower = broader."},{"name":"revocations","type":"Array(String)","comment":"Deprecated OncoTree codes that this code replaces (e.g. BLL replaces ALL, GB replaces GBM). Search here when a user code is not found."},{"name":"precursors","type":"Array(String)","comment":"Previous codes merged into this code (e.g. CLLSLL merges CLL and SLL). Similar to revocations but for code merges."}]} ▶ clickhouse_run_select_query { "query": " SELECT cancer_study_identifier, name, sample_count, mutation_sample_count, cna_sample_count FROM cancer_study WHERE type_of_cancer LIKE 'BRCA' AND name ILIKE '%tcga%pan%cancer%atlas%' LIMIT 10 ", "max_rows": 20 } ◀ result {"error_message":"Query execution failed: HTTPDriver for https://dl96orhu96.us-east-1.aws.clickhouse.cloud:8443 received ClickHouse error code 47\n Code: 47. DB::Exception: Unknown expression or function identifier `type_of_cancer` in scope SELECT cancer_study_identifier, name, sample_count, mutation_sample_count, cna_sample_count FROM cancer_study WHERE (type_of_cancer LIKE 'BRCA') AND (name ILIKE '%tcga%pan%cancer%atlas%') LIMIT 10. Maybe you meant: ['type_of_cancer_id']. (UNKNOWN_IDENTIFIER) (version 26.4.1.2359 (official build))\n"} ▶ clickhouse_list_table_columns { "table": "cancer_study" } ◀ result {"columns":[{"name":"cancer_study_id","type":"Int64","comment":"Internal numeric ID. Prefer cancer_study_identifier for queries as it is more readable and stable."},{"name":"cancer_study_identifier","type":"Nullable(String)","comment":"Stable string identifier for the study (e.g., \"msk_chord_2024\", \"brca_tcga\"). Use this for filtering, not cancer_study_id."},{"name":"type_of_cancer_id","type":"String"},{"name":"name","type":"String","comment":"Full descriptive name of the study (e.g., \"MSK-CHORD (MSK, Nature 2024)\")."},{"name":"description","type":"String"},{"name":"public","type":"Int32"},{"name":"pmid","type":"Nullable(String)"},{"name":"citation","type":"Nullable(String)"},{"name":"groups","type":"Nullable(String)"},{"name":"status","type":"Nullable(Int64)"},{"name":"import_date","type":"Nullable(DateTime64(6))"},{"name":"reference_genome_id","type":"Nullable(Int64)"},{"name":"sample_count","type":"UInt32","comment":"Samples in the study (members of _all), as shown in the portal study list. Precomputed daily at LLM-prep time."},{"name":"mutation_sample_count","type":"UInt32","comment":"Samples profiled for mutations (_sequenced) — portal \"Data type\" filter: \"Mutations\". 0 = no mutation data."},{"name":"cna_sample_count","type":"UInt32","comment":"Samples profiled for copy-number alterations (_cna) — \"CNA\". 0 = no CNA data."},{"name":"structural_variant_sample_count","type":"UInt32","comment":"Distinct samples with at least one structural variant (fusions etc.). 0 = none."},{"name":"rna_seq_sample_count","type":"UInt32","comment":"Samples with RNA-Seq expression (_rna_seq_v2_mrna) — \"RNA-Seq\"."},{"name":"mrna_microarray_sample_count","type":"UInt32","comment":"Samples with microarray mRNA expression (_mrna) — \"RNA (microarray)\"."},{"name":"mirna_sample_count","type":"UInt32","comment":"Samples with microRNA expression (_microrna) — \"miRNA\"."},{"name":"rppa_sample_count","type":"UInt32","comment":"Samples with RPPA protein levels (_rppa) — \"RPPA\"."},{"name":"mass_spectrometry_sample_count","type":"UInt32","comment":"Samples with mass-spectrometry protein quantification (_protein_quantification) — \"Protein Mass-Spectrometry\"."},{"name":"treatment_patient_count","type":"UInt32","comment":"PATIENTS (not samples) with treatment clinical events — \"Treatment\". 0 = no treatment data."},{"name":"resource_sample_counts","type":"Map(String, UInt32)","comment":"Samples with each linked resource, keyed by display name: imaging and pathology such as 'Slide Microscopy', 'Computed Tomography', 'Magnetic Resonance', 'H&E Slide', 'MxIF Image'. Query with mapKeys(resource_sample_counts) or resource_sample_counts['Slide Microscopy'] > 0."},{"name":"mrna_expression_sample_count","type":"UInt32","comment":"Samples in any mRNA expression profile (RNA-Seq, microarray, TPM, z-scores; from sample_profile). Use this for \"does the study have expression data\" — rna_seq_sample_count and mrna_m … (136 more chars) ▶ clickhouse_run_select_query { "query": " SELECT cancer_study_identifier, name, sample_count, mutation_sample_count, cna_sample_count FROM cancer_study WHERE type_of_cancer_id = 'BRCA' AND name ILIKE '%tcga%pan%cancer%atlas%' ", "max_rows": 10 } ◀ result {"rows":[]} ▶ list_studies { "search": "breast TCGA PanCancer", "limit": 10 } ◀ result {"result":[{"cancer_study_identifier":"brca_tcga_pan_can_atlas_2018","name":"Breast Invasive Carcinoma (TCGA, PanCancer Atlas)","type_of_cancer_id":"brca","sample_count":1084,"has_guide":true,"url":"https://www.cbioportal.org/study/summary?id=brca_tcga_pan_can_atlas_2018"}]} ▶ clickhouse_run_select_query { "query": " -- TP53 変異 + ホモ接合性欠失の頻度計算 -- Study: brca_tcga_pan_can_atlas_2018 WITH mutations AS ( -- TP53 の変異 SELECT COUNT(DISTINCT sample_unique_id) AS tp53_mutated FROM genomic_event_derived WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'TP53' AND variant_type = 'mutation' AND mutation_status != 'UNCALLED' AND off_panel = 0 ), deep_deletions AS ( -- TP53 のホモ接合性欠失 (HOMDEL = -2) SELECT COUNT(DISTINCT sample_unique_id) AS tp53_homodel FROM genomic_event_derived WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'TP53' AND variant_type = 'cna' AND cna_alteration = -2 ), combined_altered AS ( -- 変異またはホモ接合性欠失のいずれかを持つサンプル SELECT COUNT(DISTINCT sample_unique_id) AS tp53_altered FROM genomic_event_derived WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'TP53' AND ( (variant_type = 'mutation' AND mutation_status != 'UNCALLED' AND off_panel = 0) OR (variant_type = 'cna' AND cna_alteration = -2) ) ), profiled_for_mutation AS ( -- 変異がプロファイルされたサンプル数 SELECT COUNT(DISTINCT sample_unique_id) AS mutation_profiled FROM sample_to_gene_panel_derived WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'TP53' AND alteration_type = 'MUTATION_EXTENDED' ), profiled_for_cna AS ( -- CNA がプロファイルされたサンプル数 SELECT COUNT(DISTINCT sample_unique_id) AS cna_profiled FROM sample_to_gene_panel_derived WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'TP53' AND alteration_type = 'COPY_NUMBER_ALTERATION' ) SELECT m.tp53_mutated AS mutations_altered_samples, d.tp53_homodel AS deep_deletion_altered_samples, c.tp53_altered AS total_altered_samples, pm.mutation_profiled AS mutation_profiled_samples, pc.cna_profiled AS cna_profiled_samples, ROUND(m.tp53_mutated * 100.0 / pm.mutation_profiled, 1) AS mutation_frequency_pct, ROUND(d.tp53_homodel * 100.0 / pc.cna_profiled, 1) AS deep_deletion_frequency_pct, ROUND(c.tp53_altered * 100.0 / LEAST(pm.mutation_profiled, pc.cna_profiled), 1) AS combined_frequency_pct FROM mutations m, deep_deletions d, combined_altered c, profiled_for_mutation pm, profiled_for_cna pc ", "max_rows": 10 } ◀ result {"error_message":"Query execution failed: HTTPDriver for https://dl96orhu96.us-east-1.aws.clickhouse.cloud:8443 received ClickHouse error code 47\n Code: 47. DB::Exception: Unknown expression or function identifier `hugo_gene_symbol` in scope profiled_for_mutation AS pm. (UNKNOWN_IDENTIFIER) (version 26.4.1.2359 (official build))\n"} ▶ clickhouse_list_table_columns { "table": "sample_to_gene_panel_derived" } ◀ result {"columns":[{"name":"sample_unique_id","type":"String"},{"name":"alteration_type","type":"LowCardinality(String)"},{"name":"gene_panel_id","type":"LowCardinality(String)"},{"name":"cancer_study_identifier","type":"LowCardinality(String)"},{"name":"genetic_profile_id","type":"LowCardinality(String)"}]} ▶ clickhouse_run_select_query { "query": " -- TP53 変異のみ SELECT * FROM gene_alteration_frequency_by_cancer_type( preference = 'pan_cancer_tcga', gene = 'TP53', alteration = 'mutation' ) WHERE cancer_type ILIKE '%breast%' ", "max_rows": 10 } ◀ result {"rows":[{"cancer_type":"Breast Cancer","altered_samples":347,"profiled_samples":1066,"frequency_pct":32.6}]} ▶ clickhouse_run_select_query { "query": " -- TP53 ホモ接合性欠失(deep deletion) SELECT * FROM gene_alteration_frequency_by_cancer_type( preference = 'pan_cancer_tcga', gene = 'TP53', alteration = 'deep_deletion' ) WHERE cancer_type ILIKE '%breast%' ", "max_rows": 10 } ◀ result {"rows":[{"cancer_type":"Breast Cancer","altered_samples":9,"profiled_samples":1070,"frequency_pct":0.8}]} ▶ clickhouse_run_select_query { "query": " -- TP53 変異とホモ接合性欠失を統合的に計算 WITH mutations_data AS ( SELECT COUNT(DISTINCT sample_unique_id) AS tp53_mutated FROM genomic_event_derived WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'TP53' AND variant_type = 'mutation' AND mutation_status != 'UNCALLED' AND off_panel = 0 ), deep_deletions_data AS ( SELECT COUNT(DISTINCT sample_unique_id) AS tp53_deleted FROM genomic_event_derived WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'TP53' AND variant_type = 'cna' AND cna_alteration = -2 ), combined_altered_data AS ( SELECT COUNT(DISTINCT sample_unique_id) AS tp53_altered_total FROM genomic_event_derived WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol = 'TP53' AND ( (variant_type = 'mutation' AND mutation_status != 'UNCALLED' AND off_panel = 0) OR (variant_type = 'cna' AND cna_alteration = -2) ) ) SELECT m.tp53_mutated, d.tp53_deleted, c.tp53_altered_total, 1066 AS profiled_samples, ROUND(m.tp53_mutated * 100.0 / 1066, 1) AS mutation_pct, ROUND(d.tp53_deleted * 100.0 / 1066, 1) AS deletion_pct, ROUND(c.tp53_altered_total * 100.0 / 1066, 1) AS combined_pct FROM mutations_data m, deep_deletions_data d, combined_altered_data c ", "max_rows": 10 } ◀ result {"rows":[{"tp53_mutated":347,"tp53_deleted":9,"tp53_altered_total":354,"profiled_samples":1066,"mutation_pct":32.6,"deletion_pct":0.8,"combined_pct":33.2}]} ═ answer (success) 完璧です。では results を表示します。 --- ## TCGA PanCancer Atlas 乳がん(Breast Invasive Carcinoma)における TP53 の変異と deep deletion の頻度 **Study:** Breast Invasive Carcinoma (TCGA, PanCancer Atlas) **プロファイルサンプル数:** 1,066 サンプル | 変異型 | 変異サンプル数 | 頻度 | |-------|-------------|------| | **TP53 変異(point mutation)** | 347/1,066 | **32.6%** | | **TP53 ホモ接合性欠失(deep deletion)** | 9/1,066 | **0.8%** | | **合計(変異 + deep deletion)** | 354/1,066 | **33.2%** | ### 解釈 - **TP53 変異単体:** 32.6%(前回のお答えと同一) - **ホモ接合性欠失(HOMDEL):** わずか 0.8%(9サンプル) - **両者を合わせた頻度:** **33.2%** TP53 のホモ接合性欠失は乳がんではごく稀で、全体の TP53 異常の大半(347/354 = 98%)は point mutation です。