Skip to content

Commit

Permalink
with annotation funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
vortexing committed Oct 2, 2019
1 parent 81fa95c commit 94ea5c2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export(summarizeS3Objects)
export(tgrAnnotate)
export(tgrDefinitions)
export(undefinedAnnotations)
export(unusedAnnotations)
export(usedIdentifiers)
export(validateDataFrame)
export(validateDataset)
Expand Down
22 changes: 21 additions & 1 deletion R/annotationfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ undefinedAnnotations <- function() {
stop("You have missing environment variables. Please set creds in env vars.")}
else message("Credentials set successfully.")
commonKnowledge <- tgrDefinitions()
sciMeta <- tgrAnnotate(harmonizedOnly = T, DAG = "all", evenEmptyCols = F)
sciMeta <- tgrAnnotate(harmonizedOnly = T, DAG = "all", evenEmptyCols = T)
# Remove project memberships
defineMe <- sciMeta %>% dplyr::select(-dplyr::starts_with("data_is_"))
categorical <- commonKnowledge %>% dplyr::filter(Type == "categorical")
Expand All @@ -56,3 +56,23 @@ undefinedAnnotations <- function() {
return(makeMeaning)
}

#' (Admin) Finds unused REDCap variables
#'
#' Pulls sample data down from REDCap and compares them with the defined annotation list in GitHub and identifies variables previously used in REDCap that have definitions in GitHub that need to be removed.
#'
#' @return A data frame that is list in the format of commonKnowledge data in the tgr-annotations repo with annotations and values to remove.
#' @author Amy Paguirigan
#' @details
#' Requires **admin** REDCap credentials to be set in the environment.
#' @export
unusedAnnotations <- function() {
if ("" %in% Sys.getenv(c("REDURI", "TGR", "S3A", "S3SA"))) {
stop("You have missing environment variables. Please set creds in env vars.")}
else message("Credentials set successfully.")
commonKnowledge <- tgrDefinitions()
sciMeta <- tgrAnnotate(harmonizedOnly = F, DAG = "all", evenEmptyCols = T)
unused <- commonKnowledge %>% dplyr::filter(!Annotation %in% colnames(sciMeta)) %>% dplyr::filter(Category != "Bioinformatics")

return(unused)
}

20 changes: 20 additions & 0 deletions man/unusedAnnotations.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94ea5c2

Please sign in to comment.