Skip to content

Commit

Permalink
improving missing imputation
Browse files Browse the repository at this point in the history
  • Loading branch information
wolski committed Apr 13, 2022
1 parent 1fb1af1 commit 937bfa6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: prolfqua
Type: Package
Title: Proteomics Label Free Quantification
Version: 0.3.5
Version: 0.3.6
Authors@R: c(person("Witold", "Wolski",
email = c("[email protected]", "[email protected]"),
role = c("aut", "cre"),
Expand Down
28 changes: 17 additions & 11 deletions R/tidyMS_missigness.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,15 @@ interaction_missing_stats <- function(pdata,
#' head(res)
#' res <- missigness_impute_factors_interactions(xx, configur, value = "imputed")
#' head(res)
#' fun <- missigness_impute_factors_interactions(xx, configur, value = "nrMeasured")
#' fun
#' res <- missigness_impute_factors_interactions(xx, configur, value = "nrMeasured")
#' long <- missigness_impute_factors_interactions(xx, configur, value = "long")
#' long
#'
missigness_impute_factors_interactions <-
function(pdata,
config,
probs = 0.03,
value = c("nrReplicates", "nrMeasured", "meanArea", "imputed"),
value = c("long", "nrReplicates", "nrMeasured", "meanArea", "imputed"),
add.prefix = FALSE,
global = TRUE)
{
Expand All @@ -276,11 +278,15 @@ missigness_impute_factors_interactions <-
for (fun_name in names(fac_fun)) {
fac_res[[fun_name]] <- fac_fun[[fun_name]](value, add.prefix = add.prefix)
}
if(value == "long"){
intfact <- dplyr::bind_rows(fac_res)
} else {
intfact <- purrr::reduce(fac_res,
dplyr::inner_join,
by = c(config$table$hierarchyKeys(),
config$table$isotopeLabel, "value"))

intfact <- purrr::reduce(fac_res,
dplyr::inner_join,
by = c(config$table$hierarchyKeys(),
config$table$isotopeLabel, "value"))
}
return(dplyr::ungroup(intfact))
}

Expand Down Expand Up @@ -431,6 +437,7 @@ get_imputed_contrasts_deprec <- function(data, config, contrasts, probs = 0.03,
#' @param data data.frame
#' @param config AnalysisConfiguration
#' @param contrast list of contrasts
#' @param present estimate lod from group with default 1 present values.
#' @keywords internal
#' @family missingness
#' @family modelling
Expand Down Expand Up @@ -460,12 +467,11 @@ get_imputed_contrasts_deprec <- function(data, config, contrasts, probs = 0.03,
get_imputed_contrasts <- function(pepIntensity,
config,
Contr,
present = 0,
present = 1,
global = TRUE){

fun <- .missigness_impute_interactions(pepIntensity, config)
long <- fun("long")
x3 <- long |> filter(nrNAs == (max(long$nrNAs) - (present + 1))) |> pull(meanArea) |> mean(na.rm=TRUE)
long <- missigness_impute_factors_interactions(pepIntensity, config, value = "long" )
x3 <- long |> filter(nrNAs == (max(long$nrNAs) - present)) |> pull(meanArea) |> mean(na.rm=TRUE)

long <- long |> mutate(imputed_b = ifelse(is.na(meanArea), x3, meanArea))

Expand Down
4 changes: 3 additions & 1 deletion man/get_imputed_contrasts.Rd

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

8 changes: 5 additions & 3 deletions man/missigness_impute_factors_interactions.Rd

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

1 change: 1 addition & 0 deletions vignettes/Modelling2Factors.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pMerged$config$table$fkeysDepth()
#ContrastsSimpleImpute$debug("get_contrasts")
contrSimple <- prolfqua::ContrastsSimpleImpute$new(pMerged, Contrasts)
contrdfSimple <- contrSimple$get_contrasts()
#na.omit(contrdfSimple)
pl <- contrSimple$get_Plotter()
pl$histogram_diff()
pl$volcano()
Expand Down

0 comments on commit 937bfa6

Please sign in to comment.