From 0fa667f702120f210b8641417fc48520cbf26a86 Mon Sep 17 00:00:00 2001 From: Carol-seven <542046605@qq.com> Date: Fri, 26 Jul 2024 03:11:06 -0400 Subject: [PATCH] fix the shadow matrix: add NA --- R/imputations.R | 50 +++++++++++++++++++++++++++++------------------- docs/pkgdown.yml | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/R/imputations.R b/R/imputations.R index 8fc8529..6408124 100644 --- a/R/imputations.R +++ b/R/imputations.R @@ -194,10 +194,11 @@ impute.min_global <- function(dataSet, reportImputing = FALSE) { imputedData <- cbind(dataSet[,c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -290,10 +291,11 @@ impute.min_local <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[,c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -364,10 +366,11 @@ impute.knn <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[,c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -421,10 +424,11 @@ impute.knn_seq <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[, c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -478,10 +482,11 @@ impute.knn_trunc <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[, c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -568,10 +573,11 @@ impute.nuc_norm <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[, c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -628,10 +634,11 @@ impute.mice_norm <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[, c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -688,10 +695,11 @@ impute.mice_cart <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[, c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -751,10 +759,11 @@ impute.pca_bayes <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[, c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } @@ -817,10 +826,11 @@ impute.pca_prob <- function(dataSet, reportImputing = FALSE, imputedData <- cbind(dataSet[, c("R.Condition", "R.Replicate")], dataPoints) if (reportImputing) { + shadowMatrix[!is.na(shadowMatrix)] <- 0 + shadowMatrix[is.na(shadowMatrix) & !is.na(dataPoints)] <- 1 ## return the imputed data and the shadow matrix return(list(imputedData = imputedData, - shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], - ifelse(is.na(shadowMatrix) & !is.na(dataPoints), 1, 0)))) + shadowMatrix = cbind(dataSet[,c("R.Condition", "R.Replicate")], shadowMatrix))) } else { return(imputedData) } diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 5f39acf..1cd487c 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -4,7 +4,7 @@ pkgdown_sha: ~ articles: scaffold: scaffold.html usage_template: usage_template.html -last_built: 2024-07-26T06:13Z +last_built: 2024-07-26T07:08Z urls: reference: https://uconn-scs.github.io/msDiaLogue/reference article: https://uconn-scs.github.io/msDiaLogue/articles