Skip to content

Commit

Permalink
Add check for NA, NaN, Inf values in cell attributes (see issue #85)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Hafemeister committed Dec 15, 2020
1 parent 07f41f3 commit ad50748
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ make_cell_attr <- function(umi, cell_attr, latent_var, batch_var, latent_var_non
new_attr <- do.call(cbind, new_attr)
cell_attr <- cbind(cell_attr, new_attr[, setdiff(colnames(new_attr), colnames(cell_attr)), drop = TRUE])
}

# make sure no NA, NaN, Inf values are in cell attributes - they would cause
# problems later on
rel_attr <- cell_attr[, c(latent_var, batch_var, latent_var_nonreg)]
if (any(is.na(rel_attr)) ||
any(is.nan(rel_attr)) ||
any(is.infinite(rel_attr))) {
stop('cell attributes cannot contain any NA, NaN, or infinite values')
}

return(cell_attr)
}

Expand Down

0 comments on commit ad50748

Please sign in to comment.