-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
5 changed files
with
121 additions
and
106 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...ources/ManualTesting/MatchPredictionValidation/exercise4/SQL_Homework_1_HomeworkCheck.sql
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,10 @@ | ||
/* | ||
* CHECK THAT HOMEWORK SETS HAVE BEEN IMPORTED | ||
* Can also use this query to follow progress of the individual PDP processing. | ||
*/ | ||
|
||
SELECT * | ||
FROM HomeworkSets h | ||
JOIN PatientDonorPairs pdp | ||
ON h.Id = pdp.HomeworkSet_Id | ||
ORDER BY HomeworkSet_Id, PatientId, DonorId |
File renamed without changes.
111 changes: 111 additions & 0 deletions
111
...es/ManualTesting/MatchPredictionValidation/exercise4/SQL_Homework_3_ImputationResults.sql
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,111 @@ | ||
/* | ||
* SELECT INFO BY PATIENT AND DONOR ID | ||
*/ | ||
|
||
-- SET THE FOLLOWING VARS | ||
DECLARE @PatientId varchar(16) = 'P000820' | ||
DECLARE @DonorId varchar(16) = 'D908661' | ||
DECLARE @MatchCountDenominator int = 10 -- i.e., "10" for x/10 search, "8" for x/8 search, etc. | ||
|
||
|
||
/* | ||
* QUERIES | ||
*/ | ||
|
||
DECLARE @PatientImputationId int = (SELECT Id FROM ImputationSummaries WHERE ExternalSubjectId = @PatientId) | ||
DECLARE @DonorImputationId int = (SELECT Id FROM ImputationSummaries WHERE ExternalSubjectId = @DonorId) | ||
|
||
-- select imputation summaries for patient and donor | ||
SELECT si.*, i.* | ||
FROM ImputationSummaries i | ||
JOIN SubjectInfo si | ||
ON i.ExternalSubjectId = si.ExternalId | ||
WHERE i.Id = @PatientImputationId | ||
|
||
SELECT si.*, i.* | ||
FROM ImputationSummaries i | ||
JOIN SubjectInfo si | ||
ON i.ExternalSubjectId = si.ExternalId | ||
WHERE i.Id = @DonorImputationId | ||
|
||
-- select distinct genotypes for patient | ||
SELECT DISTINCT | ||
Patient_A_1, Patient_A_2, | ||
Patient_B_1, Patient_B_2, | ||
Patient_C_1, Patient_C_2, | ||
Patient_DQB1_1, Patient_DQB1_2, | ||
Patient_DRB1_1, Patient_DRB1_2, | ||
Patient_Likelihood | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries i | ||
ON mg.Patient_ImputationSummary_Id = i.Id | ||
WHERE i.Id = @PatientImputationId | ||
|
||
-- select distinct genotypes for donors | ||
SELECT DISTINCT | ||
Donor_A_1, Donor_A_2, | ||
Donor_B_1, Donor_B_2, | ||
Donor_C_1, Donor_C_2, | ||
Donor_DQB1_1, Donor_DQB1_2, | ||
Donor_DRB1_1, Donor_DRB1_2, | ||
Donor_Likelihood | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries i | ||
ON mg.Donor_ImputationSummary_Id = i.Id | ||
WHERE i.Id = @DonorImputationId | ||
|
||
-- select matching genotypes | ||
SELECT mg.* | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries p | ||
ON mg.Patient_ImputationSummary_Id = p.Id | ||
JOIN ImputationSummaries d | ||
ON mg.Donor_ImputationSummary_Id = d.Id | ||
WHERE p.Id = @PatientImputationId and d.Id = @DonorImputationId | ||
|
||
-- select match probabilities | ||
DECLARE @PatientLikelihoodSum decimal = (SELECT SumOfLikelihoods FROM ImputationSummaries WHERE Id = @PatientImputationId) | ||
DECLARE @DonorLikelihoodSum decimal = (SELECT SumOfLikelihoods FROM ImputationSummaries WHERE Id = @DonorImputationId) | ||
DECLARE @MatchProbabilityDenominator decimal = (@PatientLikelihoodSum * @DonorLikelihoodSum) | ||
|
||
SELECT | ||
@MatchCountDenominator - TotalCount AS MismatchCount_Total, | ||
100 * SUM(Patient_Likelihood * Donor_Likelihood) / @MatchProbabilityDenominator AS ProbabilityPercentage | ||
FROM MatchingGenotypes | ||
WHERE Patient_ImputationSummary_Id = @PatientImputationId and Donor_ImputationSummary_Id = @DonorImputationId | ||
GROUP BY TotalCount | ||
|
||
SELECT | ||
2 - A_Count AS MismatchCount_A, | ||
100 * SUM(Patient_Likelihood * Donor_Likelihood) / @MatchProbabilityDenominator AS ProbabilityPercentage | ||
FROM MatchingGenotypes | ||
WHERE Patient_ImputationSummary_Id = @PatientImputationId and Donor_ImputationSummary_Id = @DonorImputationId | ||
GROUP BY A_Count | ||
|
||
SELECT | ||
2 - B_Count AS MismatchCount_B, | ||
100 * SUM(Patient_Likelihood * Donor_Likelihood) / @MatchProbabilityDenominator AS ProbabilityPercentage | ||
FROM MatchingGenotypes | ||
WHERE Patient_ImputationSummary_Id = @PatientImputationId and Donor_ImputationSummary_Id = @DonorImputationId | ||
GROUP BY B_Count | ||
|
||
SELECT | ||
2 - C_Count AS MismatchCount_C, | ||
100 * SUM(Patient_Likelihood * Donor_Likelihood) / @MatchProbabilityDenominator AS ProbabilityPercentage | ||
FROM MatchingGenotypes | ||
WHERE Patient_ImputationSummary_Id = @PatientImputationId and Donor_ImputationSummary_Id = @DonorImputationId | ||
GROUP BY C_Count | ||
|
||
SELECT | ||
2 - DQB1_Count AS MismatchCount_DQB1, | ||
100 * SUM(Patient_Likelihood * Donor_Likelihood) / @MatchProbabilityDenominator AS ProbabilityPercentage | ||
FROM MatchingGenotypes | ||
WHERE Patient_ImputationSummary_Id = @PatientImputationId and Donor_ImputationSummary_Id = @DonorImputationId | ||
GROUP BY DQB1_Count | ||
|
||
SELECT | ||
2 - DRB1_Count AS MismatchCount_DRB1, | ||
100 * SUM(Patient_Likelihood * Donor_Likelihood) / @MatchProbabilityDenominator AS ProbabilityPercentage | ||
FROM MatchingGenotypes | ||
WHERE Patient_ImputationSummary_Id = @PatientImputationId and Donor_ImputationSummary_Id = @DonorImputationId | ||
GROUP BY DRB1_Count |
53 changes: 0 additions & 53 deletions
53
...rces/ManualTesting/MatchPredictionValidation/exercise4/SQL_Homework_ImputationResults.sql
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
...anualTesting/MatchPredictionValidation/exercise4/SQL_Homework_SelectMatchingGenotypes.sql
This file was deleted.
Oops, something went wrong.