-
Notifications
You must be signed in to change notification settings - Fork 4
Create data validation report for animal parentage #534
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
Open
jryurkanin
wants to merge
7
commits into
release22.11-SNAPSHOT
Choose a base branch
from
22.11_fb_animal_data_validation
base: release22.11-SNAPSHOT
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
05d5e8b
Create parentDifferentSpecies.sql
jryurkanin f1a271d
Create parentsWrongGender.sql
jryurkanin 3e35ccb
Create parentsYoungerThanOffspring.sql
jryurkanin fc456d7
Rename parentDifferentSpecies.sql to parentsDifferentSpecies.sql
jryurkanin c59a448
create parentsBothDamAndSire.sql
jryurkanin 005f83b
create dataValidationReport page
jryurkanin e4f9256
add dataValidationReport to nav menu
jryurkanin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,30 @@ | ||
| SELECT t.Id as Parent, GROUP_CONCAT(t.DamChildren, ',') as DamChildren, GROUP_CONCAT(t.SireChildren, ',') as SireChildren FROM | ||
| ( | ||
|
|
||
| SELECT d.Id, d.DamChildren, s.SireChildren FROM ( | ||
|
|
||
| SELECT Id as DamChildren, | ||
| dam as Id | ||
| FROM demographics | ||
| WHERE dam IN ( | ||
| SELECT Distinct dam as Id | ||
| FROM demographics | ||
| WHERE dam IN (SELECT Distinct sire FROM demographics)) | ||
| ) d | ||
|
|
||
| JOIN | ||
|
|
||
| (SELECT * FROM ( | ||
|
|
||
| SELECT Id as SireChildren, | ||
| sire as Id | ||
| FROM demographics | ||
| WHERE sire IN ( | ||
| SELECT Distinct dam as Id | ||
| FROM demographics | ||
| WHERE dam IN (SELECT Distinct sire FROM demographics)) | ||
| ) si ) s | ||
|
|
||
| ON s.Id = d.Id | ||
| ) t | ||
| GROUP BY t.Id |
This file contains hidden or 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,15 @@ | ||
| SELECT * FROM ( | ||
| SELECT d1.Id, | ||
| d1.Dataset.Demographics.gender, | ||
| d1.Dataset.Demographics.species, | ||
| d1.Parents.dam, | ||
| d1.Parents.dam.Demographics.species as damSpecies, | ||
| d1.Parents.sire, | ||
| d1.Parents.sire.Demographics.species as sireSpecies, | ||
| CASE WHEN (d1.Parents.dam.Demographics.species IS NOT NULL AND d1.Parents.dam.Demographics.species != d1.Dataset.Demographics.species) OR (d1.Parents.sire.Demographics.species IS NOT NULL AND d1.Parents.sire.Demographics.species != d1.Dataset.Demographics.species) | ||
| THEN TRUE | ||
| ELSE FALSE | ||
| END as parentSpeciesMismatch | ||
| FROM study.Animal d1 | ||
| ) d2 | ||
| WHERE d2.parentSpeciesMismatch = TRUE |
This file contains hidden or 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,15 @@ | ||
| SELECT * FROM ( | ||
| SELECT d1.Id, | ||
| d1.Dataset.Demographics.gender, | ||
| d1.Dataset.Demographics.species, | ||
| d1.Parents.dam, | ||
| d1.Parents.dam.Demographics.gender as damSex, | ||
| d1.Parents.sire, | ||
| d1.Parents.sire.Demographics.gender as sireSex, | ||
| CASE WHEN (d1.Parents.dam.Demographics.gender.code IS NOT NULL AND d1.Parents.dam.Demographics.gender.code != 'f') OR (d1.Parents.sire.Demographics.gender.code IS NOT NULL AND d1.Parents.sire.Demographics.gender.code != 'm') | ||
| THEN TRUE | ||
| ELSE FALSE | ||
| END as parentSexMismatch | ||
| FROM study.Animal d1 | ||
| ) d2 | ||
| WHERE d2.parentSexMismatch = TRUE | ||
15 changes: 15 additions & 0 deletions
15
ehr/resources/queries/study/parentsYoungerThanOffspring.sql
This file contains hidden or 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,15 @@ | ||
| SELECT * FROM ( | ||
| SELECT | ||
| dem.Id, | ||
| dem.gender, | ||
| dem.species, | ||
| dem.birth, | ||
| dem.dam, | ||
| damDem.birth as damBirth, | ||
| dem.sire, | ||
| sireDem.birth as sireBirth | ||
| FROM demographics dem | ||
| LEFT JOIN demographics damDem ON dem.dam = damDem.Id | ||
| LEFT JOIN demographics sireDem ON dem.sire = sireDem.Id | ||
| ) t | ||
| WHERE (t.birth <= t.damBirth OR t.birth <= t.sireBirth) |
This file contains hidden or 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
This file contains hidden or 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,71 @@ | ||
| <p> | ||
| Each of the below data grids identifies issues present in the animal colony data that would prevent the pedigree plots from working correctly.<br> | ||
| To correct any data consistency issues, use this report as a reference for identifying the data issues, and then correct them on the demographics dataset, which can be access with the below button.<br> | ||
| </p> | ||
| <button onclick = "linkBrowseData()"> | ||
| Correct Data | ||
| </button> | ||
| <p><br></p> | ||
| <table> | ||
| <tr> | ||
| <td> | ||
| <div name="webpart" id='parentsDifferentSpeciesReport' /> | ||
| </td> | ||
| <td> | ||
| <div name="webpart" id='parentsBothDamAndSireReport' /> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td> | ||
| <div name="webpart" id='parentsWrongGenderReport' /> | ||
| </td> | ||
| <td> | ||
| <div name="webpart" id='parentsYoungerThanOffspringReport' /> | ||
| </td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| <script> | ||
|
|
||
| function linkBrowseData() { | ||
| window.location = LABKEY.ActionURL.buildURL( | ||
| "ehr", | ||
| "updateQuery", | ||
| LABKEY.ActionURL.getContainer(), | ||
| { | ||
| schemaName: "study", | ||
| queryName: "demographics", | ||
| returnUrl: window.location | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| new LABKEY.QueryWebPart({ | ||
| renderTo: 'parentsDifferentSpeciesReport', | ||
| title: 'Parents that are wrong species', | ||
| schemaName: 'study', | ||
| queryName: 'parentsDifferentSpecies' | ||
| }); | ||
|
|
||
| new LABKEY.QueryWebPart({ | ||
| renderTo: 'parentsBothDamAndSireReport', | ||
| title: 'Parents that are listed as both dam and sire', | ||
| schemaName: 'study', | ||
| queryName: 'parentsBothDamAndSire' | ||
| }); | ||
|
|
||
| new LABKEY.QueryWebPart({ | ||
| renderTo: 'parentsWrongGenderReport', | ||
| title: 'Parents that are listed as both dam and sire', | ||
| schemaName: 'study', | ||
| queryName: 'parentsWrongGender' | ||
| }); | ||
|
|
||
| new LABKEY.QueryWebPart({ | ||
| renderTo: 'parentsYoungerThanOffspringReport', | ||
| title: 'Parents that are listed as both dam and sire', | ||
| schemaName: 'study', | ||
| queryName: 'parentsYoungerThanOffspring' | ||
| }); | ||
|
|
||
| </script> |
This file contains hidden or 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,5 @@ | ||
| <view xmlns="http://labkey.org/data/xml/view" frame="none" title="Data Validation Report"> | ||
| <dependencies> | ||
| <dependency path="ehr.context" /> | ||
| </dependencies> | ||
| </view> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine, but wouldnt it be a little better to just base this on study.demographicsParents rather than animal? you're filtering anything not present in animal, arent you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, yes it would be better, but not all centers have study.demographicsParents working. I'm honestly just trying to keep things simple. we can always improve on it later if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was my suggestion to use Animal. Only one center doesn't have demographicsParents, but this won't work for them anyway. We should probably look into bringing demographicsParents into core EHR and setting up the Parents column in DefaultEHRCustomizer. @jryurkanin we can sync on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like it might be useful to create a demographicsPedigree.sql in core EHR, and have this SQL select from study.demographics, and then merge in ehr.supplemental_pedigree. That would make columns consistent across EHR instances, and by default support supplemental_pedigree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have something along those lines for the base demographicsParents in this PR. Most centers already have it overwritten, but we can use whatever version of demographicsParents is active for these queries.
#541