Q (sonnet-5.5):
How many samples in the TCGA PanCancer Atlas breast cancer study have PIK3CA mutations?
In Breast Invasive Carcinoma (TCGA, PanCancer Atlas), 347 of 1,066 profiled samples (32.6%) have a PIK3CA mutation.
Continue this conversation: reply to the user's new message.
break that down by PAM50 subtype please
▶ read_guide
{
"uri": "cbioportal://clinical-data-guide"
}
▶ read_guide
{
"uri": "cbioportal://mutation-frequency-guide"
}
▶ get_study_guide
{
"study_id": "brca_tcga_pan_can_atlas_2018"
}
◀ result
# Clinical Data Query Guide
## Overview
Clinical data in cBioPortal is stored at both patient and sample levels. Understanding the distinction is crucial for accurate analysis.
## Data Organization
### Patient-Level vs Sample-Level Data
- **Patient-level**: Demographics, overall survival, disease stage (stored once per patient)
- **Sample-level**: Sample type, sequencing platform, purity (can have multiple per patient)
### Key Tables
- `clinical_patient`: Patient-level clinical attributes
- `clinical_sample`: Sample-level clinical attributes
- `clinical_data_derived`: Pre-joined view combining both levels
- `clinical_attribute_meta`: Metadata about available clinical attributes
## Recommended Approach: Use clinical_data_derived
The `clinical_data_derived` table is pre-joined and optimized for most queries:
```sql
-- Get clinical data for specific attributes
SELECT
sample_unique_id,
patient_unique_id,
attribute_name,
attribute_value
FROM clinical_data_derived
WHERE
cancer_study_identifier = 'your_study_id'
AND attribute_name IN ('CANCER_TYPE', 'SAMPLE_TYPE', 'TMB_NONSYNONYMOUS');
```
## Clinical Attribute Discovery
### Use clinical_attribute_meta for Discovering Available Attributes
**Always start here** to see what clinical attributes are available for a specific study:
```sql
-- Discover available clinical attributes for a study
SELECT
attr_id,
description,
patient_attribute,
cancer_study_id
FROM clinical_attribute_meta
WHERE
cancer_study_id = (
SELECT cancer_study_id
FROM cancer_study
WHERE cancer_study_identifier = 'your_study_id'
)
ORDER BY patient_attribute, attr_id;
```
**Key Fields:**
- **attr_id**: matches attr_id in clinical_sample/clinical_patient tables
- **description**: human-readable description of the attribute
- **patient_attribute**: true = patient attribute, false = sample attribute
- **cancer_study_id**: links to cancer_study table (filter by study)
## Attribute Semantics and Matching
### Case-Insensitive Matching for Attribute Values
Clinical values are free text across studies and may differ only by case. For example, a controlled-looking value such as germline mutation status may appear as `GERMLINE`, `Germline`, or another case variant.
When filtering `clinical_data_derived.attribute_value`, use case-insensitive matching unless you have already profiled the exact values in the target study:
```sql
-- Correct: case-insensitive clinical value filter
SELECT DISTINCT sample_unique_id, patient_unique_id
FROM clinical_data_derived
WHERE cancer_study_identifier = 'your_study_id'
AND attribute_name = 'MUTATION_STATUS'
AND upper(attribute_value) = 'GERMLINE';
```
Do not write `attribute_value = 'GERMLINE'` without first checking all distinct values for that attribute in the study.
### Query the Requested Attribute, Not a Proxy
Do not infer one clinical attribute from a related subtype or marker. Query the actual requested attribute when it … (17073 more chars)
◀ 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)
◀ result
# Breast Invasive Carcinoma (TCGA, PanCancer Atlas)
**Study ID:** `brca_tcga_pan_can_atlas_2018`
See `_tcga_pancan_template.md` for common TCGA clinical attributes.
## Study-Specific Attributes
### Molecular Subtypes
| Attribute | Description | Values (patients) |
|-----------|-------------|--------|
| `SUBTYPE` | PAM50 molecular subtype | `BRCA_LumA` 499, `BRCA_LumB` 197, `BRCA_Basal` 171, `BRCA_Her2` 78, `BRCA_Normal` 36, blank 103 |
### Histology
| Attribute | Description | Values (samples) |
|-----------|-------------|--------|
| `CANCER_TYPE_DETAILED` | Histological type | Breast Invasive Ductal Carcinoma 780, Breast Invasive Lobular Carcinoma 201, Breast Invasive Carcinoma (NOS) 77, Breast Invasive Mixed Mucinous Carcinoma 17, Metaplastic Breast Cancer 8, Invasive Breast Carcinoma 1 |
### Not available in this study
- **ER / PR / HER2 receptor status and triple-negative status**: no clinical attribute; say it is not available here. Do not infer receptor status from `SUBTYPE`: PAM50 is an expression-based classification, not IHC/FISH. If the user accepts an expression-based proxy, `BRCA_Basal` (≈ triple-negative) or `BRCA_Her2` can be offered, labelled as PAM50. ERBB2 amplification is available from CNA data.
- `GRADE` is blank for all samples.
## Key Genes
- **TP53**: Most frequently mutated (~30%)
- **PIK3CA**: Common in ER+ tumors (~35%)
- **CDH1**: Enriched in lobular carcinoma
- **GATA3**: Luminal marker
- **ERBB2**: HER2 amplification target
## Notes
- Molecular subtypes (PAM50) correlate strongly with clinical behavior
- Lobular vs ductal distinction has different mutation profiles
▶ clickhouse_run_select_query
{
"query": "WITH sub AS (
SELECT sample_unique_id, any(attribute_value) AS subtype
FROM clinical_data_derived
WHERE cancer_study_identifier='brca_tcga_pan_can_atlas_2018' AND attribute_name='SUBTYPE'
GROUP BY sample_unique_id
),
prof AS (
SELECT DISTINCT sample_unique_id FROM sample_to_gene_panel_derived
WHERE cancer_study_identifier='brca_tcga_pan_can_atlas_2018' AND alteration_type='MUTATION_EXTENDED'
),
alt AS (
SELECT DISTINCT sample_unique_id FROM genomic_event_derived
WHERE cancer_study_identifier='brca_tcga_pan_can_atlas_2018' AND variant_type='mutation'
AND mutation_status!='UNCALLED' AND off_panel=0 AND hugo_gene_symbol='PIK3CA'
)
SELECT if(s.subtype IS NULL OR s.subtype='','No subtype assigned',s.subtype) AS subtype,
count() AS profiled,
countIf(p.sample_unique_id IN (SELECT sample_unique_id FROM alt)) AS pik3ca_mut,
round(pik3ca_mut*100/profiled,1) AS pct
FROM prof p LEFT JOIN sub s ON p.sample_unique_id=s.sample_unique_id
GROUP BY subtype ORDER BY profiled DESC"
}
◀ result
{"rows":[{"subtype":"No subtype assigned","profiled":1066,"pik3ca_mut":347,"pct":32.6}]}
▶ clickhouse_run_select_query
{
"query": "WITH pmap AS (
SELECT DISTINCT sample_unique_id, patient_unique_id FROM clinical_data_derived
WHERE cancer_study_identifier='brca_tcga_pan_can_atlas_2018' AND sample_unique_id!=''
),
sub AS (
SELECT patient_unique_id, any(attribute_value) AS subtype FROM clinical_data_derived
WHERE cancer_study_identifier='brca_tcga_pan_can_atlas_2018' AND attribute_name='SUBTYPE'
GROUP BY patient_unique_id
)
SELECT if(s.subtype='','No subtype assigned',s.subtype) AS subtype, count() AS profiled,
countIf(m.sample_unique_id IN (SELECT sample_unique_id FROM genomic_event_derived
WHERE cancer_study_identifier='brca_tcga_pan_can_atlas_2018' AND variant_type='mutation'
AND mutation_status!='UNCALLED' AND off_panel=0 AND hugo_gene_symbol='PIK3CA')) AS pik3ca_mut,
round(pik3ca_mut*100/profiled,1) AS pct
FROM (SELECT DISTINCT sample_unique_id FROM sample_to_gene_panel_derived
WHERE cancer_study_identifier='brca_tcga_pan_can_atlas_2018' AND alteration_type='MUTATION_EXTENDED') m
JOIN pmap USING sample_unique_id
LEFT JOIN sub s ON s.patient_unique_id=pmap.patient_unique_id
GROUP BY subtype ORDER BY profiled DESC"
}
▶ get_studyviewfilter_options
{
"studyId": "brca_tcga_pan_can_atlas_2018",
"attributeIds": [
"SUBTYPE"
]
}
◀ result
{"rows":[{"subtype":"BRCA_LumA","profiled":499,"pik3ca_mut":237,"pct":47.5},{"subtype":"BRCA_LumB","profiled":197,"pik3ca_mut":59,"pct":29.9},{"subtype":"BRCA_Basal","profiled":171,"pik3ca_mut":12,"pct":7},{"subtype":"No subtype assigned","profiled":85,"pik3ca_mut":5,"pct":5.9},{"subtype":"BRCA_Her2","profiled":78,"pik3ca_mut":26,"pct":33.3},{"subtype":"BRCA_Normal","profiled":36,"pik3ca_mut":8,"pct":22.2}]}
◀ result
{"success":true,"message":"Successfully retrieved StudyView filter options","data":{"studyId":"brca_tcga_pan_can_atlas_2018","attributes":[{"attributeId":"SUBTYPE","displayName":"Subtype","description":"Subtype","datatype":"STRING","values":["BRCA_Her2","NA","BRCA_Basal","BRCA_Normal","BRCA_LumA","BRCA_LumB"]}]}}
▶ navigate_to_results_view
{
"studyIds": [
"brca_tcga_pan_can_atlas_2018"
],
"genes": [
"PIK3CA: MUT"
],
"tab": "oncoprint",
"oncoprintClinicalTracks": [
"SUBTYPE"
],
"profileFilter": "mutations"
}
◀ result
{"success":true,"message":"Navigating to https://www.cbioportal.org/results/oncoprint?cancer_study_list=brca_tcga_pan_can_atlas_2018&gene_list=PIK3CA%3A+MUT&case_set_id=brca_tcga_pan_can_atlas_2018_all&profileFilter=mutations&clinicallist=SUBTYPE","url":"https://www.cbioportal.org/results/oncoprint?cancer_study_list=brca_tcga_pan_can_atlas_2018&gene_list=PIK3CA%3A+MUT&case_set_id=brca_tcga_pan_can_atlas_2018_all&profileFilter=mutations&clinicallist=SUBTYPE","data":{"studyIds":["brca_tcga_pan_can_atlas_2018"],"studies":[{"studyId":"brca_tcga_pan_can_atlas_2018","name":"Breast Invasive Carcinoma (TCGA, PanCancer Atlas)","sampleCount":1084}],"genes":["PIK3CA"],"caseSetId":"brca_tcga_pan_can_atlas_2018_all","pageDescription":"Visual summary of alterations in queried genes across samples."}}
═ answer (success)
PIK3CA mutation by PAM50 subtype in Breast Invasive Carcinoma (TCGA, PanCancer Atlas). Counts are samples, and the denominator is samples profiled for mutations (1,066).
| PAM50 subtype | PIK3CA-mutated | Profiled | % |
|---|---|---|---|
| Luminal A | 237 | 499 | 47.5% |
| Luminal B | 59 | 197 | 29.9% |
| HER2-enriched | 26 | 78 | 33.3% |
| Normal-like | 8 | 36 | 22.2% |
| Basal-like | 12 | 171 | 7.0% |
| No subtype assigned | 5 | 85 | 5.9% |
| **Total** | **347** | **1,066** | **32.6%** |
The subtype rows add up to the 347 of 1,066 (32.6%) from before.
- **Luminal A:** it has the highest rate, and it accounts for 237 of the 347 mutated samples (about 68%).
- **Basal-like:** it has the lowest rate of the assigned subtypes.
- **No subtype assigned:** 85 samples have no PAM50 call in the study.
- **Statistics:** these are descriptive counts only. I haven't run a test for differences between subtypes.
[View PIK3CA mutations in the OncoPrint with the PAM50 subtype track](https://www.cbioportal.org/results/oncoprint?cancer_study_list=brca_tcga_pan_can_atlas_2018&gene_list=PIK3CA%3A+MUT&case_set_id=brca_tcga_pan_can_atlas_2018_all&profileFilter=mutations&clinicallist=SUBTYPE)