Skip to content

Commit a3b3da2

Browse files
authored
Merge pull request #10 from cjerzak/codex/explore-and-patch-important-bug
Fix infer_orientation_signs NA handling
2 parents 09608b0 + f9444f7 commit a3b3da2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lpme/R/lpme_DoBootPartition.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ lpme <- function(Y,
160160
if (!all(orientation_signs %in% c(1, -1))) {
161161
stop("orientation_signs must contain only 1 and -1.")
162162
}
163-
if(!all(unlist(observables) %in% c(0,1))){
163+
if(!all(na.omit(unlist(observables)) %in% c(0,1))){
164164
stop("Re-orientation in the non-binary case not yet implemented")
165165
}
166-
if(all(observables %in% c(0,1))){
166+
if(all(na.omit(unlist(observables)) %in% c(0,1))){
167167
colnames_observables <- colnames(observables)
168168
observables <- sapply(1:ncol(observables), function(d_){
169169
observables[, d_] <- orientation_signs[d_] * observables[, d_] +

lpme/R/orientation_helpers.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#' @export
2929
infer_orientation_signs <- function(Y, observables, method = c("Y", "PC1")) {
3030
method <- match.arg(method)
31-
if (!all(unlist(observables) %in% c(0, 1))) {
31+
# allow for missing values when validating the observables
32+
obs_vals <- na.omit(unlist(observables))
33+
if (!all(obs_vals %in% c(0, 1))) {
3234
stop("infer_orientation_signs currently supports only binary observables")
3335
}
3436
if (method == "PC1") {

0 commit comments

Comments
 (0)