forked from knausb/vcfR
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
38 changed files
with
917 additions
and
261 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ Description: Facilitates easy manipulation of variant call format (VCF) data. | |
data may be written to a VCF file (*.vcf.gz). It also may be converted into | ||
other popular R objects (e.g., genlight, DNAbin). VcfR provides a link between | ||
VCF data and familiar R software. | ||
Version: 1.7.0 | ||
Version: 1.8.0 | ||
Authors@R: c( | ||
person(c("Brian", "J."), "Knaus", role = c("cre", "aut"), | ||
email = "[email protected]", comment = c(ORCID = "0000-0003-1665-4343")), | ||
|
@@ -41,7 +41,6 @@ Imports: | |
stats, | ||
stringr, | ||
tibble, | ||
tidyr, | ||
utils, | ||
vegan, | ||
viridisLite | ||
|
@@ -53,7 +52,8 @@ Suggests: | |
reshape2, | ||
rmarkdown, | ||
scales, | ||
testthat | ||
testthat, | ||
tidyr | ||
VignetteBuilder: knitr | ||
License: GPL | ||
RoxygenNote: 6.0.1 |
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,58 @@ | ||
|
||
|
||
#### check_keys #### | ||
#' @rdname check_keys | ||
#' @aliases check_keys | ||
#' | ||
#' @title Check that INFO and FORMAT keys are unique | ||
#' | ||
#' @param x an oblect of class vcfR | ||
#' | ||
#' @description | ||
#' The INFO and FORMAT columns contain information in key-value pairs. | ||
#' If for some reason a key is not unique it will create issues in retrieving this information. | ||
#' This function checks the keys defined in the meta section to make sure they are unique. | ||
#' Note that it does not actually check the INFO and FORMAT columns, just their definitions in the meta section. | ||
#' This is because each variant can have different information in their INFO and META cells. | ||
#' Checking these on large files will tehrefore come with a performance cost. | ||
#' | ||
#' @seealso queryMETA() | ||
#' | ||
#' @examples | ||
#' data(vcfR_test) | ||
#' check_keys(vcfR_test) | ||
#' queryMETA(vcfR_test) | ||
#' queryMETA(vcfR_test, element = 'DP') | ||
#' # Note that DP occurs as unique in INFO and FORMAT but they may be different. | ||
#' | ||
#' | ||
#' @export | ||
check_keys <- function(x) { | ||
if(class(x) != 'vcfR'){ | ||
stop( paste('Expecting a vcfR object, instead received:', class(x)) ) | ||
} | ||
|
||
# First check INFO. | ||
myKeys <- grep('INFO', x@meta, value = TRUE) | ||
myKeys <- sub('##INFO=<ID=','',myKeys) | ||
myKeys <- unlist(lapply(strsplit(myKeys, ','), function(x){x[1]})) | ||
myKeys <- table(myKeys) | ||
myKeys <- myKeys[myKeys > 1] | ||
if( length(myKeys) > 0){ | ||
warning(paste("The following INFO key occurred more than once:", names(myKeys), '\n')) | ||
} | ||
|
||
# Check FORMAT. | ||
myKeys <- grep('FORMAT', x@meta, value = TRUE) | ||
myKeys <- sub('##FORMAT=<ID=','',myKeys) | ||
myKeys <- unlist(lapply(strsplit(myKeys, ','), function(x){x[1]})) | ||
myKeys <- table(myKeys) | ||
myKeys <- myKeys[myKeys > 1] | ||
if( length(myKeys) > 0){ | ||
warning(paste("The following FORMAT key occurred more than once:", names(myKeys), '\n')) | ||
} | ||
|
||
} | ||
|
||
|
||
|
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
Oops, something went wrong.