-
Notifications
You must be signed in to change notification settings - Fork 18
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
17 changed files
with
240 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#' Helpers to Extract Information from an ADAT | ||
#' | ||
#' [getAdatVersion()] determines the the ADAT version | ||
#' number from a parsed ADAT header.\cr\cr | ||
#' [getSomaScanVersion()] determines the version of | ||
#' SomaScan assay that a `soma_adat` object was run on. | ||
#' These are elements of the `HEADER` attributes of the object.\cr\cr | ||
#' [checkSomaScanVersion()] determines if the version of | ||
#' is a recognized version of SomaScan.\cr | ||
#' \cr | ||
#' Table of current SomaScan Assay versions: | ||
#' \tabular{lll}{ | ||
#' **Version** \tab **Name** \tab **Size** \cr | ||
#' `V4` \tab 5k \tab 5284 \cr | ||
#' `v4.1` \tab 7k \tab 7596 \cr | ||
#' `v5.0` \tab 11k \tab 11083 \cr | ||
#' } | ||
#' | ||
#' @name adat-helpers | ||
#' @param atts The *attributes* of a `soma_adat` object. | ||
#' @return Either a character string of length 1, or `NULL`. | ||
#' \item{[getAdatVersion()]}{The key-value of the `Version` as a string.} | ||
#' \item{[getSomaScanVersion()]}{The key-value of the `AssayVersion` as a string.} | ||
#' \item{[checkSomaScanVersion()]}{Returns `NULL` (invisibly) if checks pass.} | ||
#' @author Stu Field | ||
#' @examples | ||
#' atts <- attributes(example_data) | ||
#' getAdatVersion(atts) | ||
#' | ||
#' atts$Header.Meta$HEADER$Version <- "1.0" | ||
#' getAdatVersion(atts) | ||
#' @export | ||
getAdatVersion <- function(atts) { | ||
|
||
x <- atts$Header.Meta$HEADER | ||
vidx <- grep("^Version$|^AdatVersion$", names(x)) | ||
|
||
if ( length(vidx) == 0L ) { | ||
stop( | ||
"Unable to identify ADAT Version from Header information. ", | ||
"Please check 'Header.Meta'.", call. = FALSE | ||
) | ||
} | ||
|
||
version <- as.character(x[[vidx]]) | ||
|
||
if ( length(version) > 1L ) { | ||
warning( | ||
"Version length > 1 ... there may be empty tabs in ", | ||
"the header block above the data matrix.", call. = FALSE | ||
) | ||
version <- version[1L] | ||
} | ||
|
||
if ( identical(version, "1.01") ) { | ||
stop( | ||
"Invalid Version (", .value("1.01"), "). Please modify to `1.0.1`.", | ||
call. = FALSE | ||
) | ||
} | ||
version | ||
} | ||
|
||
|
||
.ss_ver_map <- c(v3 = "1129", v3.0 = "1129", | ||
v4 = "5k", v4.0 = "5k", | ||
v4.1 = "7k", | ||
v5 = "11k", v5.0 = "11k") | ||
|
||
|
||
#' Gets the SomaScan version | ||
#' | ||
#' @rdname adat-helpers | ||
#' @inheritParams params | ||
#' @examples | ||
#' | ||
#' ver <- getSomaScanVersion(example_data) | ||
#' ver | ||
#' @export | ||
getSomaScanVersion <- function(adat) { | ||
as.character(attr(adat, "Header.Meta")$HEADER$AssayVersion) | ||
} | ||
|
||
|
||
#' Checks the SomaScan version | ||
#' | ||
#' @rdname adat-helpers | ||
#' @param ver `character(1)`. The SomaScan version as a string. | ||
#' @note The `"v"` is case insensitive. | ||
#' @examples | ||
#' | ||
#' is.null(checkSomaScanVersion(ver)) | ||
#' @export | ||
checkSomaScanVersion <- function(ver) { | ||
allowed <- c("v3.0", "v4", "v4.0", "v4.1", "v5", "v5.0") | ||
if ( !tolower(ver) %in% allowed ) { | ||
stop("Unsupported assay version: ", .value(ver), | ||
". Supported versions: ", .value(allowed), call. = FALSE) | ||
} | ||
invisible(NULL) | ||
} |
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
#' Common Parameters in \pkg{SomaReadr} | ||
#' | ||
#' The parameters below are commonly used throughout | ||
#' the \pkg{SomaReadr} package. | ||
#' | ||
#' @name params | ||
#' | ||
#' @param adat A `soma_adat` object (with intact attributes), | ||
#' typically created using [read_adat()]. | ||
#' | ||
#' @param x A `soma_adat` object (with intact attributes), | ||
#' typically created using [read_adat()]. | ||
#' | ||
#' @return A `soma_adat` class object. | ||
NULL |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.