Difference between revisions of "Manual Phenotyping Database"

From Poland Lab Wiki
Jump to: navigation, search
m
Line 11: Line 11:
  
 
The query below is an example of how to generate a monthly report of the PCTHEAD (percent heading) trait.
 
The query below is an example of how to generate a monthly report of the PCTHEAD (percent heading) trait.
 +
 +
<syntaxhighlight lang ="SQL" line>
  
 
SET SESSION group_concat_max_len = 10000;
 
SET SESSION group_concat_max_len = 10000;
Line 25: Line 27:
 
EXECUTE stmt;
 
EXECUTE stmt;
 
DEALLOCATE PREPARE stmt;
 
DEALLOCATE PREPARE stmt;
 +
 +
</syntaxhighlight>

Revision as of 08:47, 5 October 2016

The manual phenotyping database contains phenotypic field data that was collected by hand.

The main tables in the manual phenotyping database are shown in the figure below.


Phenotyping.png

Example Queries

Row-to-Column Query

The query below is an example of how to generate a monthly report of the PCTHEAD (percent heading) trait.

  1. SET SESSION group_concat_max_len = 10000;
  2. SET @SQL = NULL;
  3. SELECT
  4.   GROUP_CONCAT(DISTINCT
  5.     CONCAT(
  6.       'MAX(IF(phenotype_date = ''', `phenotype_date`, ''',phenotype_value,NULL)) AS ''', `phenotype_date`,'''')
  7.   ) INTO @SQL FROM phenotype WHERE YEAR(phenotype_date) = 2016;
  8. SET @SQL = CONCAT('SELECT  entity_id, ', @SQL, ' 
  9.                   FROM    phenotype WHERE phenotype.entity_id LIKE ''%16ASH0%'' AND phenotype.trait_id LIKE ''%PCTHEAD%''
  10.                   GROUP   BY entity_id');
  11. PREPARE stmt FROM @SQL;
  12. EXECUTE stmt;
  13. DEALLOCATE PREPARE stmt;