From f6a196535732e7b72b15e37736489b461c0934cc Mon Sep 17 00:00:00 2001 From: Vel Date: Tue, 27 Mar 2018 14:46:09 +1100 Subject: [PATCH] Adding capability to fetch PanelApp panel names and the number of genes for each confidence level from the DB. Displaying this as a filter option on the short variant and GBS query pages. --- actions/action_gbs_analysis.php | 12 +- config.ini | 2 + functions/gene_list_functions.php | 45 ++++++- functions/session_variable_functions.php | 3 +- gbs_query.php | 148 ++++++++++++++--------- query.php | 81 +++++++++++++ 6 files changed, 218 insertions(+), 73 deletions(-) diff --git a/actions/action_gbs_analysis.php b/actions/action_gbs_analysis.php index 248cf87..face52d 100644 --- a/actions/action_gbs_analysis.php +++ b/actions/action_gbs_analysis.php @@ -221,11 +221,11 @@ } elseif ($_SESSION["gbs_analysis_type"] == "svfusions") { // Store the lists selected in the multi-select box so they can be restored on the query page (only used for this) - if (isset($_POST["svfusions_gene_list_selection"])) { - $_SESSION["gbs_svfusions_gene_list_selection"] = $_POST["svfusions_gene_list_selection"]; + if (isset($_POST["gbs_gene_list_selection"])) { + $_SESSION["gbs_gbs_gene_list_selection"] = $_POST["gbs_gene_list_selection"]; // If no list was selected reset to nothing (in case some were selected before) } else { - $_SESSION["gbs_svfusions_gene_list_selection"] = ""; + $_SESSION["gbs_gbs_gene_list_selection"] = ""; } // Store the manual entry gene list submitted @@ -236,14 +236,14 @@ } // If no gene list was selected and no genes were typed into the manual entry box - if ($_SESSION["gbs_svfusions_gene_list_selection"] == "" && $_SESSION["gbs_svfusions_gene_list"] == "") { + if ($_SESSION["gbs_gbs_gene_list_selection"] == "" && $_SESSION["gbs_svfusions_gene_list"] == "") { // Empty array of genes to search (means all will be searched) $gene_list_to_search = array(); // If at least one gene list was selected or genes were typed into the manual entry box } else { // If at least one gene list was selected - if (isset($_POST["svfusions_gene_list_selection"])) { - $gene_list_to_search = determine_gene_list($_POST["svfusions_gene_list_selection"], $_SESSION["gbs_svfusions_gene_list"]); + if (isset($_POST["gbs_gene_list_selection"])) { + $gene_list_to_search = determine_gene_list($_POST["gbs_gene_list_selection"], $_SESSION["gbs_svfusions_gene_list"]); // Otherwise just parse the manual entry list } else { $gene_list_to_search = determine_gene_list("", $_SESSION["gbs_svfusions_gene_list"]); diff --git a/config.ini b/config.ini index 560ec22..09d1742 100644 --- a/config.ini +++ b/config.ini @@ -32,6 +32,8 @@ default_minimum_variant_quality=0 default_exclude_failed_variants=true default_gbs_cnlessthan=1.5 default_gbs_cngreaterthan=2.5 +default_gbs_minblocksize=0 +default_gbs_exclude_failed_variants=true [query_databases] ; Setting any option below to true implies you adhere to the terms of use of the respective data source (e.g. for research use only) diff --git a/functions/gene_list_functions.php b/functions/gene_list_functions.php index b6f193e..3d0985d 100755 --- a/functions/gene_list_functions.php +++ b/functions/gene_list_functions.php @@ -11,7 +11,8 @@ function fetch_gene_lists() { $sql .= "list_name, "; $sql .= "(SELECT COUNT(*) FROM KCCG_GENE_LISTS.genes_in_lists WHERE list_id = gene_lists.list_id) AS num_genes "; $sql .= "FROM "; - $sql .= "KCCG_GENE_LISTS.gene_lists"; + $sql .= "KCCG_GENE_LISTS.gene_lists "; + $sql .= "ORDER BY list_name"; $sql .= ";"; $statement = $GLOBALS["mysql_connection"]->prepare($sql); @@ -22,12 +23,46 @@ function fetch_gene_lists() { $gene_list[$list["list_name"]] = $list["num_genes"]; } - // If more than 1 gene list was found, sort them naturally - if (count($gene_list) > 1) { - array_multisort(array_keys($gene_list), SORT_NATURAL, $gene_list); // Natural sort by gene list name + return $gene_list; +} + +############################################# +# FETCH GENOMICS ENGLAND PANELAPP GENE COUNTS +############################################# + +function fetch_panel_counts_ge_panelapp() { + $ge_panelapp_panels = array(); + + $sql = "SELECT "; + $sql .= "panels.name, "; + $sql .= "genes_in_panels.confidence_level, "; + $sql .= "COUNT(*) AS num_genes "; + $sql .= "FROM "; + $sql .= "GEPANELAPP.genes_in_panels "; + $sql .= "LEFT JOIN GEPANELAPP.panels ON GEPANELAPP.genes_in_panels.panel_id = GEPANELAPP.panels.id "; + $sql .= "GROUP BY panels.name, genes_in_panels.confidence_level "; + $sql .= "ORDER BY panels.name"; + $sql .= ";"; + + $statement = $GLOBALS["mysql_connection"]->prepare($sql); + + $statement->execute(); + + while ($panels = $statement->fetch()) { + $ge_panelapp_panels[$panels["name"]][$panels["confidence_level"]] = $panels["num_genes"]; + } + // Format: $ge_panelapp_panels[][] = number of genes + + // Go through each panel + foreach (array_keys($ge_panelapp_panels) as $ge_panelapp_panel) { + // If the current panel has both high and moderate evidence genes + if (isset($ge_panelapp_panels[$ge_panelapp_panel]["HighEvidence"], $ge_panelapp_panels[$ge_panelapp_panel]["ModerateEvidence"])) { + // Inject in a new evidence level which combines the high and moderate counts + $ge_panelapp_panels[$ge_panelapp_panel]["HighModerateEvidence"] = $ge_panelapp_panels[$ge_panelapp_panel]["HighEvidence"] + $ge_panelapp_panels[$ge_panelapp_panel]["ModerateEvidence"]; + } } - return $gene_list; + return $ge_panelapp_panels; } ############################################# diff --git a/functions/session_variable_functions.php b/functions/session_variable_functions.php index 241fc37..1a0e397 100755 --- a/functions/session_variable_functions.php +++ b/functions/session_variable_functions.php @@ -20,9 +20,8 @@ function clean_session($logout = NULL) { $_SESSION["gbs_family"] = ""; $_SESSION["gbs_analysis_type"] = ""; $_SESSION["gbs_regions"] = ""; // For the genomic coordinates analysis type - $_SESSION["gbs_gene_list_selection"] = ""; // For the gene list(s) analysis type + $_SESSION["gbs_gene_list_selection"] = ""; // For the GBS gene list selection (regardless of analysis type) $_SESSION["gbs_gene_list"] = ""; // For the gene list(s) analysis type - $_SESSION["gbs_svfusions_gene_list_selection"] = ""; // For the SV Fusions analysis type $_SESSION["gbs_svfusions_gene_list"] = ""; // For the SV Fusions analysis type $_SESSION["gbs_cnlessthan"] = ""; // For most the the analysis types $_SESSION["gbs_cngreaterthan"] = ""; // For most the the analysis types diff --git a/gbs_query.php b/gbs_query.php index 044e20b..5daae52 100755 --- a/gbs_query.php +++ b/gbs_query.php @@ -71,7 +71,10 @@ $gene_lists = fetch_gene_lists(); - if ($gene_lists === false) { + // Extract GE PanelApp panels from the database + $ge_panelapp_panels = fetch_panel_counts_ge_panelapp(); + + if ($gene_lists === false || $ge_panelapp_panels === false) { error("Could not fetch gene lists from the database."); $requirements_failed_flag = 1; @@ -337,17 +340,17 @@ // Add onclick javascript events to show analysis descriptions or options and hide/show the CN restriction section based on analysis type if ($analysis_type == "gene_lists") { - echo " onclick=\"showdiv('lists'); document.getElementById('cnrestriction').style.display = 'block'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'block';\""; + echo " onclick=\"showdiv('lists'); document.getElementById('cnrestriction').style.display = 'block'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'block'; document.getElementById('genelistrestriction').style.display = 'block';\""; } elseif ($analysis_type == "sample_overlaps") { - echo " onclick=\"showdiv('sample_overlaps'); document.getElementById('cnrestriction').style.display = 'block'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'block';\""; + echo " onclick=\"showdiv('sample_overlaps'); document.getElementById('cnrestriction').style.display = 'block'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'block'; document.getElementById('genelistrestriction').style.display = 'none';\""; } elseif ($analysis_type == "method_overlaps") { - echo " onclick=\"showdiv('method_overlaps'); document.getElementById('cnrestriction').style.display = 'block'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'block';\""; + echo " onclick=\"showdiv('method_overlaps'); document.getElementById('cnrestriction').style.display = 'block'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'block'; document.getElementById('genelistrestriction').style.display = 'none';\""; } elseif ($analysis_type == "genomic_coordinates") { - echo " onclick=\"showdiv('positions'); document.getElementById('cnrestriction').style.display = 'block'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'block';\""; + echo " onclick=\"showdiv('positions'); document.getElementById('cnrestriction').style.display = 'block'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'block'; document.getElementById('genelistrestriction').style.display = 'none';\""; } elseif ($analysis_type == "rohmer") { - echo " onclick=\"showdiv('rohmer'); document.getElementById('cnrestriction').style.display = 'none'; document.getElementById('failedvariantsrestriction').style.display = 'none'; document.getElementById('minblocksizerestriction').style.display = 'block';\""; + echo " onclick=\"showdiv('rohmer'); document.getElementById('cnrestriction').style.display = 'none'; document.getElementById('failedvariantsrestriction').style.display = 'none'; document.getElementById('minblocksizerestriction').style.display = 'block'; document.getElementById('genelistrestriction').style.display = 'none';\""; } elseif ($analysis_type == "svfusions") { - echo " onclick=\"showdiv('svfusions'); document.getElementById('cnrestriction').style.display = 'none'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'none';\""; + echo " onclick=\"showdiv('svfusions'); document.getElementById('cnrestriction').style.display = 'none'; document.getElementById('failedvariantsrestriction').style.display = 'block'; document.getElementById('minblocksizerestriction').style.display = 'none'; document.getElementById('genelistrestriction').style.display = 'block';\""; } // Select the current analysis type if it was previously selected or one has not been selected before @@ -395,36 +398,10 @@ echo "

Description

"; echo "

This analysis type lets you find all variants that overlap with your genes of interest by one or more bases. For example, if a variant caller identifies a deletion at coordinates 1:20,000-30,000 and one of your genes of interest is at 1:29,000-45,000, this represents a 1,000bp overlap at 1:29,000-30,000.

"; - - echo "

Gene lists

"; - - echo "

Select one or more gene lists

"; - - echo ""; - - echo "

Clear

"; - - echo "

Search custom gene list

"; - - $input_search_genes = ""; - } else { - $input_search_genes .= "placeholder=\"e.g. BRCA1;PIK3CA;TP53\">"; - } - echo $input_search_genes; # Print the box - echo "

Separate multiple genes with a semicolon, comma or space.

"; echo ""; + ###################### + // The sample overlapping blocks selection div echo "
This analysis will help you discover locations in the genome where the same variant caller has identified variants that overlap between samples. Overlaps must be by at least 1 base to be returned. For example, if Sample1 has a deletion variant called by Method1 at coordinates 1:20,000-30,0000 and Sample2 has 2 duplication variants called by Method1 at 1:21,000-22,000 and 1:27,000-40,000, this means both of the variants in Sample2 overlap with the 1 variant in Sample1 and will be returned as two overlaps (at 1:21,000-22,000 and 1:27,000-30,000).

"; echo "
"; + ###################### + // The method overlapping blocks selection div echo "
This analysis will help you discover locations in the genome where multiple variant callers have independently found variants that overlap with one another in the same sample. Overlaps must be by at least 1 base to be returned. For example, if Sample1 has a deletion variant called by Method1 at coordinates 1:20,000-30,0000 and 2 deletion variants called by Method2 at 1:21,000-24,000 and 1:25,000-40,000, this represents 2 genomic locations where the methods have called overlapping variants (1:20,000-24,000 and 1:25,000-40,000).

"; echo "
"; + ###################### + // The genomic coordinates blocks selection div echo "
Separate multiple regions to search with a semicolon.

"; echo "
"; + + ###################### // The ROHmer selection div echo "
This analysis lets you find regions of homozygosity in affected individuals that are more likely to harbour a pathogenic variant due to consanguinity. These regions are identified by first extracting all shared RoH blocks for all affected samples then subtracting any overlapping regions of homozygosity present in unaffected individuals. The remaining regions of interest are shared by affected individuals and not present in any unaffected individual.

"; echo "
"; + ###################### + // The SV Fusions selection div echo "
Description"; echo "

This analysis will help you find all variants that have the potential to cause a fusion between a gene and either another gene or an intergenic region of the genome. Select a gene list or enter a manual gene list to restrict your search to specific genes, otherwise don't select anything to search the entire genome.

"; + echo "
"; + + ############################################# + + echo "
"; + } else { + echo ">"; + } + + echo "
"; + echo "

Gene lists

"; + + echo "

Select one or more gene lists

"; + + echo ""; + + echo "

Clear

"; + + echo "

Genomics England PanelApp Panels

"; - echo "

Gene lists

"; - - echo "

Select one or more gene lists

"; - - echo ""; + echo ""; + + foreach (array_keys($ge_panelapp_panels) as $ge_panelapp_panel_name) { + foreach (array_keys($ge_panelapp_panels[$ge_panelapp_panel_name]) as $ge_panelapp_confidence) { + // Only interested in high and highmoderate evidence levels + if (!in_array($ge_panelapp_confidence, array("HighEvidence", "HighModerateEvidence"))) { + continue; + } + + echo ""; + } + } + + echo ""; + + echo "

Clear

"; + + echo "

Search custom gene list

"; - echo "

Clear

"; - - echo "

Search custom gene list

"; - - $input_search_genes = ""; - } else { - $input_search_genes .= "placeholder=\"e.g. BRCA1;PIK3CA;TP53\">"; - } - echo $input_search_genes; # Print the box - echo "

Separate multiple genes with a semicolon, comma or space.

"; + $input_search_genes = ""; + } else { + $input_search_genes .= "placeholder=\"e.g. BRCA1;PIK3CA;TP53\">"; + } + echo $input_search_genes; # Print the box + echo "

Separate multiple genes with a semicolon, comma or space.

"; + echo "
"; + echo "
"; echo "
"; ############################################# diff --git a/query.php b/query.php index dd6e6fe..ef22f43 100755 --- a/query.php +++ b/query.php @@ -79,6 +79,9 @@ // Extract gene lists from the database $gene_lists = fetch_gene_lists(); + // Extract GE PanelApp panels from the database + $ge_panelapp_panels = fetch_panel_counts_ge_panelapp(); + ############################################# # ONLY SEARCH GENOMIC LOCATIONS ############################################# @@ -124,6 +127,45 @@ error("Could not extract gene lists from the database."); } + ###################### + + echo "

Genomics England PanelApp Panels

"; + + echo ""; + } else { + echo ""; // Need to close select in order to print error + + error("Could not extract GE PanelApp panels from the database."); + } + echo "

Clear

"; + + ###################### + echo "

Search custom gene list

"; $input_search_genes = "Genomics England PanelApp Panels"; + + echo ""; + } else { + echo ""; // Need to close select in order to print error + + error("Could not extract GE PanelApp panels from the database."); + } + echo "

Clear

"; + + ###################### echo "

Exclude custom gene list

";