Skip to content

Commit

Permalink
warning on nas in prediction, error in test (openproblems-bio#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood authored May 30, 2024
1 parent 7404b19 commit a90f631
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/task/metrics/mean_correlation_r/script.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ prediction <- prediction[, genes]
de_test_X <- de_test$layers[[par$de_test_layer]]
prediction_X <- prediction$layers[[par$prediction_layer]]

if (any(is.na(de_test_X))) {
stop("NA values in de_test_X")
}
if (any(is.na(prediction_X))) {
warning("NA values in prediction_X")
prediction_X[is.na(prediction_X)] <- 0
}

cat("Calculate metrics\n")
out <- cor(t(de_test_X), t(prediction_X), method = "pearson")
pearson <- diag(out)
Expand Down
8 changes: 8 additions & 0 deletions src/task/metrics/mean_cosine_sim_r/script.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ prediction <- prediction[, genes]
de_test_X <- de_test$layers[[par$de_test_layer]]
prediction_X <- prediction$layers[[par$prediction_layer]]

if (any(is.na(de_test_X))) {
stop("NA values in de_test_X")
}
if (any(is.na(prediction_X))) {
warning("NA values in prediction_X")
prediction_X[is.na(prediction_X)] <- 0
}

cat("Clipping values\n")
threshold_0001 <- -log10(0.0001)
de_test_X_clipped_0001 <- pmax(pmin(de_test_X, threshold_0001), -threshold_0001)
Expand Down
3 changes: 2 additions & 1 deletion src/task/metrics/mean_rowwise_error_r/script.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ if (any(is.na(de_test_X))) {
stop("NA values in de_test_X")
}
if (any(is.na(prediction_X))) {
stop("NA values in prediction_X")
warning("NA values in prediction_X")
prediction_X[is.na(prediction_X)] <- 0
}

cat("Clipping values\n")
Expand Down

0 comments on commit a90f631

Please sign in to comment.