Skip to content

Commit

Permalink
drop explicit factor NAs
Browse files Browse the repository at this point in the history
  • Loading branch information
mschubert committed Nov 6, 2024
1 parent a28758d commit ab2eb1e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion process/deseq/calc.r
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ genes_and_sets = function(eset, design=DESeq2::design(eset), sets=list(),
clean_obj = function(eset, design=DESeq2::design(eset)) {
# remove samples where design value is NA
drop_sample = rep(FALSE, ncol(eset))
for (key in all.vars(design))
for (key in all.vars(design)) {
if (is.factor(eset[[key]]))
eset[[key]] = forcats::fct_na_level_to_value(eset[[key]])
drop_sample = drop_sample | is.na(colData(eset)[[key]])
}
if (any(drop_sample)) {
warning("Dropping sample(s): ",
paste(colnames(eset)[drop_sample], collapse=", "), immediate.=TRUE)
Expand Down

0 comments on commit ab2eb1e

Please sign in to comment.