Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CNA query #11265

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@
<sql id="categoricalGenomicDataFilterForCNA">
<!-- filter on study to reduce query size in preparation of the following LEFT JOIN -->
WITH cna_query AS (
SELECT sample_unique_id, alteration_value
SELECT sample_unique_id as sampleUniqueId, alteration_value
FROM genetic_alteration_derived
WHERE profile_type = #{genomicDataFilter.profileType}
AND hugo_gene_symbol = #{genomicDataFilter.hugoGeneSymbol}
Expand All @@ -714,7 +714,7 @@
SELECT DISTINCT sd.sample_unique_id
<!-- join with sample table to get all 'NA' samples -->
FROM sample_derived sd
LEFT JOIN cna_query ON sd.sample_unique_id = cna_query.sample_unique_id
LEFT JOIN cna_query ON sd.sample_unique_id = cna_query.sampleUniqueId
WHERE cancer_study_identifier IN
<foreach item="studyId" collection="studyViewFilterHelper.studyViewFilter.studyIds" open="(" separator="," close=")">
#{studyId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
<select id="getCNACounts" resultMap="GenomicDataCountItemResultMap">
<bind name="profileType" value="genomicDataFilters[0].profileType" />
<!-- get all non-NA value samples. A caveat here is that if user select only 'NA', this query will return empty (null) thus we need the 2 coalesce() below to handle this case -->
WITH cna_query as (
WITH cna_count_query as (
SELECT
hugo_gene_symbol as hugoGeneSymbol,
#{profileType} as profileType,
Expand Down Expand Up @@ -288,10 +288,10 @@
SELECT
hugoGeneSymbol,
sum(count) as cna_count
FROM cna_query
FROM cna_count_query
GROUP BY hugoGeneSymbol
)
SELECT * FROM cna_query
SELECT * FROM cna_count_query
UNION ALL
<!-- The NA count is specially caculated using total sample count minus non-NA count, therefore
these 2 coalesces are here in case the non-NA subquery returned empty results and we need to provide properties needed to construct the target object -->
Expand Down
Loading