BIMSBbioinfo / pigx_sars-cov-2

PiGx SARS-CoV-2 wastewater sequencing pipeline
GNU General Public License v3.0
18 stars 3 forks source link

Potential error in sigmat deduplication when all columns are the same #152

Closed jonasfreimuth closed 1 year ago

jonasfreimuth commented 1 year ago

In this line, when all columns of the input matrix are the same, only one column should be returned. However the [ operator will turn single columns into vectors by default, causing an error in the downstream rename, as it can't deal with vectors:

Browse[1]> sigmut_mat_df[, !is_dupe] %>%
    rename(!!dupe_group_names) %>%
    replace(is.na(.), 0)

## Error in UseMethod("rename") :
##   no applicable method for 'rename' applied to an object of class "c('double', 'numeric')"

Proposed solution

Setting drop = FALSE in the [ call will disable this behavior.