Skip to content

Commit

Permalink
Merge pull request #400 from Olink-Proteomics/optimization_develop_clean
Browse files Browse the repository at this point in the history
Remove duplicates functions that were moved to read_npx_utils
  • Loading branch information
klevdiamanti authored Jul 8, 2024
2 parents 8a4b4e4 + db48167 commit 9ad2850
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 601 deletions.
78 changes: 0 additions & 78 deletions OlinkAnalyze/R/read_npx_output.R

This file was deleted.

144 changes: 0 additions & 144 deletions OlinkAnalyze/R/utils.R
Original file line number Diff line number Diff line change
@@ -1,147 +1,3 @@
#' Help function checking that the olink_platform is acceptable.
#'
#' @param x The name of the Olink platform. One of `Explore 3072`, `Explore HT`,
#' `Target 96`, `Target 48`, `Flex` or `Focus`.
#' @param broader_platform Name of the broader Olink platform. One of `qPCR` or
#' `NGS`.
#'
#' @return
#' Nothing if platform is ok, otherwise an error.
#'
check_olink_platform <- function(x,
broader_platform = NULL) {

# input check ----

check_is_scalar_character(string = x,
error = TRUE)
if (!is.null(broader_platform)) {
check_olink_broader_platform(x = broader_platform)
}

# check platform ----

# filter the global variable accepted_olink_platforms to have a collection
# of platforms available.
if (is.null(broader_platform)) {

olink_platforms <- accepted_olink_platforms

} else {

olink_platforms <- accepted_olink_platforms |>
dplyr::filter(.data[["broader_platform"]] == .env[["broader_platform"]])

}

# Throw an error if unexpected platform
if (!(x %in% olink_platforms$name)) {

cli::cli_abort(
message = c(
"x" = "Unexpected Olink platform {.arg {rlang::caller_arg(x)}}!",
"i" = "Expected one of: {olink_platforms$name}"
),
call = rlang::caller_env(),
wrap = FALSE
)

}

}

#' Help function checking that the Olink data_type is acceptable.
#'
#' @param x The name of the Olink data type. One of `NPX`, `Quantified` or `Ct`.
#' @param broader_platform Name of the broader Olink platform. One of `qPCR` or
#' `NGS`.
#'
#' @return
#' Nothing if data_type is ok, otherwise an error.
#'
check_olink_data_type <- function(x,
broader_platform = NULL) {

# input check ----

check_is_scalar_character(string = x,
error = TRUE)
if (!is.null(broader_platform)) {
check_olink_broader_platform(x = broader_platform)
}

# check data_type ----

# filter the global variable accepted_olink_platforms to have a collection
# of data types available.
if (is.null(broader_platform)) {

olink_quant_methods <- accepted_olink_platforms

} else {

olink_quant_methods <- accepted_olink_platforms |>
dplyr::filter(
.data[["broader_platform"]] == .env[["broader_platform"]]
)
}

olink_quant_methods <- olink_quant_methods |>
dplyr::pull(
.data[["quant_method"]]
) |>
unlist() |>
unique()

# Throw an error if unexpected data_type
if (!(x %in% olink_quant_methods)) {

cli::cli_abort(
message = c(
"x" = "Unexpected Olink data type {.arg {rlang::caller_arg(x)}}!",
"i" = "Expected one of: {olink_quant_methods}"
),
call = rlang::caller_env(),
wrap = FALSE
)

}

}

#' Help function checking that the broader Olink platform is acceptable.
#'
#' @param x Name of the broader Olink platform. One of `qPCR` or `NGS`.
#'
#' @return
#' Nothing if broader Olink platform is ok, otherwise an error.
#'
check_olink_broader_platform <- function(x) {

# input check ----

check_is_scalar_character(string = x,
error = TRUE)

# check broader platform ----

if (!(x %in% unique(accepted_olink_platforms$broader_platform))) {

cli::cli_abort(
message = c(
"x" = "Unexpected Olink broader platform
{.arg {rlang::caller_arg(x)}}!",
"i" = "Expected one of:
{unique(accepted_olink_platforms$broader_platform)}"
),
call = rlang::caller_env(),
wrap = FALSE
)

}

}

#' Utility function removing columns with all values NA from a tibble or an
#' arrow object.
#'
Expand Down
8 changes: 1 addition & 7 deletions OlinkAnalyze/man/check_olink_broader_platform.Rd

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

8 changes: 1 addition & 7 deletions OlinkAnalyze/man/check_olink_data_type.Rd

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

8 changes: 1 addition & 7 deletions OlinkAnalyze/man/check_olink_platform.Rd

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

9 changes: 1 addition & 8 deletions OlinkAnalyze/man/check_out_df_arg.Rd

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

9 changes: 1 addition & 8 deletions OlinkAnalyze/man/convert_read_npx_output.Rd

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

Loading

0 comments on commit 9ad2850

Please sign in to comment.