Skip to content

Commit

Permalink
fix the shadow matrix: add NA
Browse files Browse the repository at this point in the history
  • Loading branch information
Carol-seven committed Jul 26, 2024
1 parent 5801a83 commit 0fa667f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
50 changes: 30 additions & 20 deletions R/imputations.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0fa667f

Please sign in to comment.