forked from SomaLogic/SomaDataIO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure of
lift_adat()
functionality
- `lift_adat()` now takes a `bridge =` argument, replacing the `anno.tbl =` argument. Lifting is now performed internally for a better (and safer) user experience, without the necessity of an external annotations file. - the majority of this refactoring was internal and the user should not experience a major disruption to the API. - fixes SomaLogic#81, fixes SomaLogic#78
- Loading branch information
Showing
8 changed files
with
163 additions
and
146 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
Binary file not shown.
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,68 @@ | ||
|
||
# map external commercial names to | ||
# internal SomaScan version names | ||
# ---------------------------------- | ||
# 1) bridge 2) lref obj | ||
# ---------------------------------- | ||
.bridge_map <- c( | ||
"7k_to_5k" = "v4.1_to_v4.0", | ||
"5k_to_7k" = "v4.0_to_v4.1", | ||
"11k_to_7k" = "v5.0_to_v4.1", | ||
"7k_to_11k" = "v4.1_to_v5.0" | ||
) | ||
|
||
map_ver2k <- c(V3 = "112k", v3 = "1129", v3.0 = "1129", | ||
V4 = "5k", v4 = "5k", v4.0 = "5k", | ||
V4.1 = "7k", v4.1 = "7k", | ||
V5 = "11k", v5 = "11k", v5.0 = "11k") | ||
|
||
map_k2ver <- c("1129" = "v3.0", "5k" = "v4.0", "7k" = "v4.1", "11k" = "v5.0") | ||
|
||
# matrx: either serum or plasma | ||
# bridge: direction of the bridge | ||
.get_lift_ref <- function(matrx = c("plasma", "serum"), bridge) { | ||
matrx <- match.arg(matrx) | ||
bridge <- .bridge_map[bridge] | ||
df <- lref[[matrx]][, c("SeqId", bridge)] | ||
setNames(df[[2L]], df[[1L]]) | ||
} | ||
|
||
|
||
# Checks ---- | ||
# check that SomaScan data has been ANML normalized | ||
# x = Header attributes | ||
.check_anml <- function(x) { | ||
steps <- x$ProcessSteps | ||
if ( is.null(steps) | !grepl("ANML", steps, ignore.case = TRUE) ) { | ||
stop("ANML normalized SOMAscan data is required for lifting.", | ||
call. = FALSE) | ||
} | ||
invisible(NULL) | ||
} | ||
|
||
#' @param x the 'from' space. | ||
#' @param y the bridge variable, e.g. '5k_to_7k'. | ||
#' @return The 'to' space, from the 'y' param. | ||
#' @noRd | ||
.check_direction <- function(x, y) { | ||
x <- tolower(x) | ||
from <- gsub("(.*)_to_(.*)$", "\\1", y) | ||
to <- gsub("(.*)_to_(.*)$", "\\2", y) | ||
|
||
if ( isFALSE(x == from) ) { | ||
stop( | ||
"You have indicated a bridge from ", .value(from), | ||
" space, however your RFU data appears to be in version ", | ||
.value(x), " space.", call. = FALSE | ||
) | ||
} | ||
if ( isTRUE(x == to) ) { | ||
stop( | ||
"You have indicated a bridge to ", .value(to), | ||
" space, however your RFU data already appears to be in ", | ||
.value(x), " space.", call. = FALSE | ||
) | ||
} | ||
|
||
invisible(to) | ||
} |
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.