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.
- fixes SomaLogic#81
- Loading branch information
Showing
5 changed files
with
146 additions
and
93 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
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,74 @@ | ||
|
||
|
||
|
||
|
||
# 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" | ||
) | ||
|
||
# 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]]) | ||
} | ||
|
||
# data: somascan data, as a `soma_adat` object | ||
.lift_plasma_to_v4.0 <- function(data) { | ||
scaleAnalytes(data, .get_lift_ref("plasma")) | ||
} | ||
|
||
.lift_plasma_to_v4.1 <- function(data) { | ||
scaleAnalytes(data, .get_lift_ref("plasma", "v4.0_to_v4.1")) | ||
} | ||
|
||
.lift_serum_to_v4.0 <- function(data) { | ||
scaleAnalytes(data, .get_lift_ref("serum")) | ||
} | ||
|
||
.lift_serum_to_v4.1 <- function(data) { | ||
scaleAnalytes(data, .get_lift_ref("serum", "v4.0_to_v4.1")) | ||
} | ||
|
||
|
||
# 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 name of the scalar column from the annotations table. | ||
#' @param y the assay version from the adat header information. | ||
#' @noRd | ||
.check_direction <- function(x, y) { | ||
y <- tolower(y) | ||
if ( grepl("4\\.1.*4\\.0", x) & y == "v4" ) { | ||
stop( | ||
"Annotations table indicates v4.1 -> v4.0, however the ADAT object ", | ||
"already appears to be in version ", y, " space.", call. = FALSE | ||
) | ||
} | ||
if ( grepl("4\\.0.*4\\.1", x) & y == "v4.1" ) { | ||
stop( | ||
"Annotations table indicates v4.0 -> v4.1, however the ADAT object ", | ||
"already appears to be in version ", y, " space.", call. = FALSE | ||
) | ||
} | ||
invisible(NULL) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.