forked from cBioPortal/cbioportal
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fc6800
commit c2019ad
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- This is example code to get Clinical Event counts using pure SQL | ||
-- Could replace JAVA code tied to the /api/clinical-event-type-counts/fetch endpoint | ||
-- Authors: Robert Sheridan, Matthijs Pon | ||
|
||
WITH select_all_events_from_studies AS -- Keeps this table IN memory, saves overhead? | ||
( | ||
SELECT | ||
sample.stable_id AS stableId, | ||
clinical_event.event_type AS eventType, | ||
patient.stable_id AS patientId, | ||
cancer_study.cancer_study_identifier AS cancerStudyId | ||
FROM | ||
sample | ||
Inner Join patient ON sample.patient_id = patient.internal_id | ||
Inner join clinical_event ON clinical_event.patient_id = patient.internal_id | ||
Inner Join cancer_study ON cancer_study.cancer_study_id = patient.cancer_study_id | ||
WHERE cancer_study.cancer_study_identifier IN ('brca_akt1_genie_2019','erbb2_genie_public','crc_public_genie_bpc', | ||
'nsclc_public_genie_bpc','mbc_genie_2020') | ||
), | ||
studyViewFilter AS -- TEMP representation of full studyviewfilter, this is only the clinical event part | ||
( | ||
SELECT | ||
DISTINCT stableId AS uniqueSampleKey, | ||
patientId AS uniquePatientKey | ||
FROM | ||
select_all_events_from_studies WHERE eventType IN ('Treatment', 'LAB_TEST') -- OR | ||
INTERSECT -- AND | ||
SELECT | ||
DISTINCT stableId AS UniqueSampleKey, | ||
patientId AS uniquePatientKey | ||
FROM | ||
select_all_events_from_studies WHERE eventType IN ('Pathology') -- OR | ||
) | ||
SELECT | ||
eventType, | ||
count(DISTINCT patientId) AS count -- Counts are on patient level | ||
FROM | ||
select_all_events_from_studies | ||
WHERE | ||
stableId IN (SELECT uniqueSampleKey FROM studyViewFilter) | ||
GROUP BY eventType | ||
ORDER BY count DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- This is example code to filter a sample list using clinical event filters | ||
-- Should become part of a bigger 'StudyViewFilter' SQL statement, which performs the full filtering. | ||
-- Authors: Robert Sheridan, Matthijs Pon | ||
|
||
WITH select_all_events_from_study as -- Keeps this table in memory, saves overhead? | ||
( | ||
SELECT | ||
sample.stable_id as stableId, | ||
clinical_event.event_type as eventType, | ||
patient.stable_id as patientId, | ||
cancer_study.cancer_study_identifier as cancerStudyId | ||
FROM | ||
sample | ||
Inner Join patient on sample.patient_id = patient.internal_id | ||
Inner join clinical_event on clinical_event.patient_id = patient.internal_id | ||
Inner Join cancer_study on cancer_study.cancer_study_id = patient.cancer_study_id | ||
WHERE cancer_study.cancer_study_identifier in ('brca_akt1_genie_2019','erbb2_genie_public','crc_public_genie_bpc', | ||
'nsclc_public_genie_bpc','mbc_genie_2020') | ||
) | ||
SELECT | ||
DISTINCT stableId as uniqueSampleKey, | ||
patientId as uniquePatientKey, | ||
cancerStudyId | ||
FROM | ||
select_all_events_from_study WHERE eventType in ('Treatment', 'LAB_TEST') -- OR filter | ||
INTERSECT -- AND filter | ||
SELECT | ||
DISTINCT stableId as UniqueSampleKey, | ||
patientId as uniquePatientKey, | ||
cancerStudyId | ||
FROM | ||
select_all_events_from_study WHERE eventType in ('Pathology'); -- OR filter |