Skip to content

Commit

Permalink
Generate new generic assay table with NA values represented
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed Sep 3, 2024
1 parent 030e7f1 commit 6b4d625
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
25 changes: 25 additions & 0 deletions src/main/resources/db-scripts/clickhouse/clickhouse.sql
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ FROM
) AS subquery
JOIN sample_derived sd ON sd.internal_id = subquery.sample_id;

-- defunct
CREATE TABLE IF NOT EXISTS generic_assay_data_derived
(
sample_unique_id String,
Expand All @@ -380,6 +381,30 @@ CREATE TABLE IF NOT EXISTS generic_assay_data_derived
ENGINE = MergeTree()
ORDER BY (profile_type, entity_stable_id, sample_unique_id);

-- this handles NAs
INSERT INTO TABLE generic_assay_data_derivedNEW
SELECT sd.sample_unique_id as sample_unique_id,
ga.genetic_entity_id as genetic_entity_id,
multiIf(gadd.value='', 'NA', gadd.value=NULL, 'NA', gadd.value) as value,
gp.generic_assay_type as generic_assay_type,
gp.stable_id as profile_stable_id,
ge.stable_id as entity_stable_id,
gp.datatype as datatype,
gp.patient_level as patient_level,
replaceOne(gp.stable_id, concat(cs.cancer_study_identifier, '_'), '') as profile_type
FROM genetic_alteration ga
LEFT JOIN genetic_profile gp on ga.genetic_profile_id = gp.genetic_profile_id
LEFT JOIN genetic_entity ge on ga.genetic_entity_id = ge.id
LEFT JOIN cancer_study cs on cs.cancer_study_id = gp.cancer_study_id
RIGHT JOIN sample_derived sd on cs.cancer_study_identifier = sd.cancer_study_identifier
LEFT JOIN generic_assay_data_derivedAA gadd ON
gadd.sample_unique_id=sd.sample_unique_id
AND gadd.entity_stable_id = ge.stable_id
AND gadd.profile_stable_id = gp.stable_id

WHERE cs.cancer_study_identifier='prad_tcga_pan_can_atlas_2018'


INSERT INTO TABLE generic_assay_data_derived
SELECT
sd.sample_unique_id as sample_unique_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@
<foreach item="genericAssayDataFilter" collection="studyViewFilterHelper.categorizedGenericAssayDataCountFilter.getSampleNumericalGenericAssayDataFilters()" open="INTERSECT" separator="INTERSECT">
<include refid="numericalGenericAssayDataCountFilter">
<property name="unique_id" value="sample_unique_id"/>
<property name="table_name" value="generic_assay_data_derived"/>
<property name="table_name" value="generic_assay_data_derivedNEW"/>
</include>
</foreach>
</if>
<if test="studyViewFilterHelper.categorizedGenericAssayDataCountFilter.getSampleCategoricalGenericAssayDataFilters() != null and !studyViewFilterHelper.categorizedGenericAssayDataCountFilter.getSampleCategoricalGenericAssayDataFilters().isEmpty()">
<foreach item="genericAssayDataFilter" collection="studyViewFilterHelper.categorizedGenericAssayDataCountFilter.getSampleCategoricalGenericAssayDataFilters()" open="INTERSECT" separator="INTERSECT">
<include refid="categoricalGenericAssayDataCountFilter">
<property name="unique_id" value="sample_unique_id"/>
<property name="table_name" value="generic_assay_data_derived"/>
<property name="table_name" value="generic_assay_data_derivedNEW"/>
</include>
</foreach>
</if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@
<property name="attribute_value" value="value"/>
</include> AS value,
count(value) AS count
FROM generic_assay_data_derived
FROM generic_assay_data_derivedNEW
<where>
<include refid="applyStudyViewFilter">
<property name="filter_type" value="'SAMPLE_ID_ONLY'"/>
Expand Down

0 comments on commit 6b4d625

Please sign in to comment.