-
Notifications
You must be signed in to change notification settings - Fork 9
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
42 changed files
with
1,410 additions
and
231 deletions.
There are no files selected for viewing
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
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
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
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,41 @@ | ||
# --------------------------------------------------------------------------- | ||
# Title: dashboard_template_functions.R | ||
# Description: This script contains helper functions used in | ||
# templates/dashboardTemplate.Rmd | ||
# --------------------------------------------------------------------------- | ||
|
||
#' This function gets the database to synapse id mapping table, | ||
#' maps the provided database_name to its synapse id and returns it | ||
#' | ||
#' @param database_name (str) database name in database | ||
#' to synapse id mapping table | ||
#' @param database_synid_mappingid (str) synapse id of the database | ||
#' to synapse id mapping table | ||
#' | ||
#' @return (str) synapse id of the mapped database name | ||
get_syn_id_from_mapped_database <- function(database_name, database_synid_mappingid){ | ||
database_synid_mapping = synTableQuery(sprintf('select * from %s', | ||
database_synid_mappingid)) | ||
database_synid_mappingdf = as.data.frame(database_synid_mapping) | ||
table_synid = database_synid_mappingdf$Id[database_synid_mappingdf$Database == database_name] | ||
return(table_synid) | ||
} | ||
|
||
#' This function creates a table of failed annotation counts by grouped columns | ||
#' @param maf_data (data.frame) input maf data frame | ||
#' @param group_by_cols (str vector) list of columns to create counts by | ||
#' @param counts_col_name (str) name to give to the counts column | ||
#' | ||
#' @return (data.frame) counts table | ||
get_failed_annotation_table_counts <- function(maf_data, group_by_cols, counts_col_name){ | ||
table_counts <- table(maf_data[maf_data$Annotation_Status == "FAILED", group_by_cols]) | ||
|
||
if (nrow(table_counts) == 0){ | ||
counts_table <- data.frame(matrix(ncol = length(group_by_cols) + 1, nrow = 0)) | ||
} else{ | ||
counts_table <- as.data.frame(table_counts) | ||
} | ||
colnames(counts_table) <- c(group_by_cols, counts_col_name) | ||
counts_table <- counts_table[do.call(order, counts_table[group_by_cols]), ] | ||
return(counts_table) | ||
} |
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,69 @@ | ||
# tests for dashboard_template_functions.R | ||
|
||
source("../../dashboard_template_functions.R") | ||
|
||
library(synapser) | ||
library(testthat) | ||
|
||
sample_counts_table <- function() { | ||
data <- data.frame( | ||
Center = factor(c("GOLD","SAGE", "TEST"), | ||
levels = c("GOLD", "SAGE", "TEST")), | ||
Counts = c(1, 2, 1) | ||
) | ||
return(data) | ||
} | ||
|
||
empty_counts_table <- function() { | ||
data <- data.frame( | ||
Center = logical(), | ||
Counts = logical() | ||
) | ||
return(data) | ||
} | ||
|
||
sample_maf_table <- function() { | ||
data <- data.frame( | ||
Center = c("TEST", "TEST", "SAGE", "SAGE", "GOLD", "BRONZE"), | ||
Tumor_Sample_Barcode = c("SAGE1", "SAGE2", "SAGE3", "SAGE4", "SAGE5", "SAGE6"), | ||
Annotation_Status = c("SUCCESS", "FAILED", "FAILED", "FAILED", "FAILED", "SUCCESS") | ||
) | ||
return(data) | ||
} | ||
|
||
sample_maf_table_no_failed_annotations <- function() { | ||
data <- data.frame( | ||
Center = c("TEST", "SAGE", "GOLD"), | ||
Tumor_Sample_Barcode = c("SAGE1", "SAGE2", "SAGE3"), | ||
Annotation_Status = c("SUCCESS", "SUCCESS", "SUCCESS") | ||
) | ||
return(data) | ||
} | ||
|
||
|
||
test_that("get_syn_id_from_mapped_database_gets_correct_value", { | ||
synLogin() | ||
result <- get_syn_id_from_mapped_database( | ||
database_name = "main", | ||
database_synid_mappingid = "syn11600968" | ||
) | ||
expect_equal(result, "syn7208886") | ||
}) | ||
|
||
|
||
test_that("get_failed_annotation_table_counts_returns_expected_output", { | ||
result <- get_failed_annotation_table_counts( | ||
maf_data=sample_maf_table(), | ||
group_by_cols="Center", | ||
counts_col_name="Counts") | ||
expect_equal(result, sample_counts_table()) | ||
}) | ||
|
||
test_that("get_failed_annotation_table_counts_returns_empty_table_with_no_failed_annotations", { | ||
result <- get_failed_annotation_table_counts( | ||
maf_data=sample_maf_table_no_failed_annotations(), | ||
group_by_cols="Center", | ||
counts_col_name="Counts") | ||
expect_equal(result, empty_counts_table()) | ||
}) | ||
|
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
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
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Configuration to obtain registry classes""" | ||
|
||
import importlib | ||
import logging | ||
|
||
|
Oops, something went wrong.