Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Tolerate extra empty columns
Browse files Browse the repository at this point in the history
  • Loading branch information
holte committed Aug 30, 2016
1 parent 5a05231 commit aca68e5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions analysis/R/read_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,17 @@ ReadCountsFile <- function(counts_file, params, adjust_counts = FALSE) {
nrow(counts), params$m))
}

if ((ncol(counts) - 1) != params$k) {
stop(paste0("Counts file: number of columns should equal to k + 1: ",
ncol(counts)))
# Tolerate extra empty columns
if (ncol(counts) > (params$k + 1)) {
extra <- counts[,(params$k + 2):ncol(counts)]
if (all(extra == 0)) {
counts <- counts[,1:(params$k + 1)]
}
}

if (ncol(counts) != params$k + 1) {
stop(sprintf("Counts file: Got %d columns, should equal to k + 1: %d",
ncol(counts), params$k + 1))
}

if (any(counts < 0)) {
Expand Down

0 comments on commit aca68e5

Please sign in to comment.