diff --git a/R/methods.R b/R/methods.R index 03dac22d..d9de0427 100755 --- a/R/methods.R +++ b/R/methods.R @@ -3132,6 +3132,7 @@ setGeneric("identify_abundant", function(.data, .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7) standardGeneric("identify_abundant")) @@ -3142,6 +3143,7 @@ setGeneric("identify_abundant", function(.data, .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7) { @@ -3250,6 +3252,7 @@ setGeneric("identify_abundant", function(.data, edgeR::filterByExpr( min.count = minimum_counts, group = string_factor_of_interest, + design = design, min.prop = minimum_proportion ) %>% not() |> @@ -3345,6 +3348,7 @@ setGeneric("keep_abundant", function(.data, .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7) standardGeneric("keep_abundant")) @@ -3355,6 +3359,7 @@ setGeneric("keep_abundant", function(.data, .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7) { @@ -3387,6 +3392,7 @@ setGeneric("keep_abundant", function(.data, .transcript = !!.transcript, .abundance = !!.abundance, factor_of_interest = !!factor_of_interest, + design = design, minimum_counts = minimum_counts, minimum_proportion = minimum_proportion ) |> diff --git a/R/methods_SE.R b/R/methods_SE.R index 1fe580e4..ec70b7be 100755 --- a/R/methods_SE.R +++ b/R/methods_SE.R @@ -1572,6 +1572,7 @@ setMethod("keep_variable", .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7) { @@ -1679,6 +1680,7 @@ setMethod("keep_variable", edgeR::filterByExpr( min.count = minimum_counts, group = string_factor_of_interest, + design = design, min.prop = minimum_proportion, lib.size = Matrix::colSums(., na.rm=TRUE) ) %>% @@ -1726,6 +1728,7 @@ setMethod("identify_abundant", .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7) { @@ -1745,7 +1748,8 @@ setMethod("identify_abundant", factor_of_interest = !!factor_of_interest, minimum_counts = minimum_counts, minimum_proportion = minimum_proportion, - .abundance = !!.abundance + .abundance = !!.abundance, + design = design ) .data[rowData(.data)$.abundant,] @@ -2818,14 +2822,14 @@ setMethod("describe_transcript", "RangedSummarizedExperiment", .describe_transcr #' @importFrom SummarizedExperiment as.data.frame .resolve_complete_confounders_of_non_interest <- function(se, ...){ - colData(se) = - colData(se) |> - as.data.frame() |> - .resolve_complete_confounders_of_non_interest_df(...) |> + colData(se) = + colData(se) |> + as.data.frame() |> + .resolve_complete_confounders_of_non_interest_df(...) |> DataFrame() - + se - + } #' resolve_complete_confounders_of_non_interest diff --git a/man/identify_abundant-methods.Rd b/man/identify_abundant-methods.Rd index 0bc9ba8d..2c31fbea 100644 --- a/man/identify_abundant-methods.Rd +++ b/man/identify_abundant-methods.Rd @@ -16,6 +16,7 @@ identify_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -26,6 +27,7 @@ identify_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -36,6 +38,7 @@ identify_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -46,6 +49,7 @@ identify_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -56,6 +60,7 @@ identify_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -66,6 +71,7 @@ identify_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) diff --git a/man/keep_abundant-methods.Rd b/man/keep_abundant-methods.Rd index efe98f34..ba92d824 100644 --- a/man/keep_abundant-methods.Rd +++ b/man/keep_abundant-methods.Rd @@ -16,6 +16,7 @@ keep_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -26,6 +27,7 @@ keep_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -36,6 +38,7 @@ keep_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -46,6 +49,7 @@ keep_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -56,6 +60,7 @@ keep_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) @@ -66,6 +71,7 @@ keep_abundant( .transcript = NULL, .abundance = NULL, factor_of_interest = NULL, + design = NULL, minimum_counts = 10, minimum_proportion = 0.7 ) diff --git a/man/resolve_complete_confounders_of_non_interest.Rd b/man/resolve_complete_confounders_of_non_interest.Rd index 01ad6808..9bfaa752 100644 --- a/man/resolve_complete_confounders_of_non_interest.Rd +++ b/man/resolve_complete_confounders_of_non_interest.Rd @@ -12,26 +12,26 @@ resolve_complete_confounders_of_non_interest(se, ...) \item{...}{Factors of non-interest (column names from `colData(se)`) to examine for complete confounders.} } \value{ -A `SummarizedExperiment` object with resolved confounders. The object retains its structure, including assays and metadata, +A `SummarizedExperiment` object with resolved confounders. The object retains its structure, including assays and metadata, but the column data (`colData`) is updated to reflect the resolved factors. } \description{ -This function identifies and resolves complete confounders among specified factors of non-interest within a `SummarizedExperiment` object. -Complete confounders occur when the levels of one factor are entirely predictable based on the levels of another factor. +This function identifies and resolves complete confounders among specified factors of non-interest within a `SummarizedExperiment` object. +Complete confounders occur when the levels of one factor are entirely predictable based on the levels of another factor. Such relationships can interfere with downstream analyses by introducing redundancy or collinearity. } \details{ -The function systematically examines pairs of specified factors and determines whether they are completely confounded. -If a pair of factors is found to be confounded, one of the factors is adjusted or removed to resolve the issue. +The function systematically examines pairs of specified factors and determines whether they are completely confounded. +If a pair of factors is found to be confounded, one of the factors is adjusted or removed to resolve the issue. The adjusted `SummarizedExperiment` object is returned, preserving all assays and metadata except the resolved factors. -Complete confounders of non-interest can create dependencies between variables that may bias statistical models or violate their assumptions. +Complete confounders of non-interest can create dependencies between variables that may bias statistical models or violate their assumptions. This function systematically addresses this by: 1. Identifying pairs of factors in the specified columns that are fully confounded. 2. Resolving confounding by adjusting or removing one of the factors from the `colData` slot. -The resolution strategy depends on the analysis context and can be modified in the helper function +The resolution strategy depends on the analysis context and can be modified in the helper function `resolve_complete_confounders_of_non_interest_pair_SE()`. By default, the function removes one of the confounded factors. } \examples{