Perform imputation of missing values (represented by NA) in one assay in a SummarizedExperiment, and generate a new assay containing the complete data (including imputed values).

doImputation(sce, imputeMethod, assayName, imputedAssayName, ...)

Arguments

sce

A SummarizedExperiment object (or a derivative).

imputeMethod

Character scalar giving the imputation method. Currently, "MinProb" (provided in the MsCoreUtils package), "impSeqRob" (provided in the rrcovNA package), "MinProbGlobal" (a reimplementation of the MinProb algorithm using a global mean value rather than sample-specific ones), "MinProbGlobalOffset" (like "MinProbGlobal", but a constant or relative offset can be specified to shift the mean of the imputed values), and "MinProbOffset" (like "MinProbGlobalOffset" but imputing separately for each row or column) are supported. In addition, a custom function can be used by setting imputeMethod = "custom" and providing the function in the FUN argument (this will be passed on to MsCoreUtils::impute_matrix).

assayName

Character scalar giving the name of the assay in sce to be imputed. The matrix should have missing values represented as NA.

imputedAssayName

Character scalar providing the name that will be given to the assay containing the imputed values.

...

Additional arguments that will be passed on to the imputation function.

Value

An object of the same type as sce with an additional assay named imputedAssayName.

Details

For the pre-defined imputation functions defined by einprot, these are the available arguments:

"MinProbGlobal":

lowQuantile = 0.01, multSigma = 1 (similar to q and sigma in MsCoreUtils::MsCoreUtils::impute_MinProb).

"MinProbOffset":

lowQuantile = 0.01, multSigma = 1, margin = 2L, constOffset = NULL, relOffset = NULL. margin indicates whether to impute along rows or columns. constOffset defines a constant shift of the mean of the imputed values relative to the low quantile. relOffset instead defines the shift as a multiple of the standard deviation of the distribution of imputed values.

"MinProbGlobalOffset":

lowQuantile = 0.01, multSigma = 1, constOffset = NULL, relOffset = NULL. Similar interpretation as for "MinProbOffset".

If imputeMethod = "custom", any suitable function that accepts a matrix as input and returns a matrix of the same shape can be provided to the FUN argument. In addition, any argument to the function can also be specified. The function and all arguments will be passed on to impute_matrix.

Author

Charlotte Soneson

Examples

## Import data
sce <- importExperiment(system.file("extdata", "mq_example",
                                    "1356_proteinGroups.txt",
                                    package = "einprot"),
                        iColPattern = "^iBAQ\\.")$sce

## Log-transform iBAQ values
SummarizedExperiment::assay(sce, "log2_iBAQ") <-
    log2(SummarizedExperiment::assay(sce, "iBAQ"))

## Replace non-finite values by NA
SummarizedExperiment::assay(sce, "log2_iBAQ")[!is.finite(
    SummarizedExperiment::assay(sce, "log2_iBAQ"))] <- NA

## Impute missing values
sce <- doImputation(sce, imputeMethod = "MinProb", assayName = "log2_iBAQ",
                    imputedAssayName = "imputed_iBAQ")
#> Imputing along margin 2 (samples/columns).
#> [1] 1.265887
SummarizedExperiment::assayNames(sce)
#>  [1] "iBAQ"                  "MS.MS.Count"           "LFQ.intensity"        
#>  [4] "Intensity"             "Sequence.coverage"     "Unique.peptides"      
#>  [7] "Razor.unique.peptides" "Peptides"              "Identification.type"  
#> [10] "log2_iBAQ"             "imputed_iBAQ"         

## Use another method from MsCoreUtils (specified as a custom function)
sce2 <- doImputation(sce, imputeMethod = "custom", assayName = "log2_iBAQ",
                     imputedAssayName = "imputed_iBAQ_knn",
                     FUN = MsCoreUtils::impute_knn)
#> Imputing along margin 1 (features/rows).
#> Imputing along margin 1 (features/rows).
#> Warning: 165 rows with more than 50 % entries missing;
#>  mean imputation used for these rows
## Alternatively, just specify one of the methods supported by MsCoreUtils::impute_matrix
sce3 <- doImputation(sce, imputeMethod = "custom", assayName = "log2_iBAQ",
                     imputedAssayName = "imputed_iBAQ_knn",
                     method = "knn")
#> Imputing along margin 1 (features/rows).
#> Warning: 165 rows with more than 50 % entries missing;
#>  mean imputation used for these rows
identical(SummarizedExperiment::assay(sce2, "imputed_iBAQ_knn"),
          SummarizedExperiment::assay(sce3, "imputed_iBAQ_knn"))
#> [1] TRUE