bioinform / ecTMB

Other
19 stars 10 forks source link

Bug in procMaf.R #4

Closed a-jartseva closed 4 years ago

a-jartseva commented 4 years ago

Hi!

I found a bug in procMaf.R line 253 (maf_dnp_converter function): https://github.com/bioinform/ecTMB/blob/cc5f9fd9c24802d4d0f0ee6b73c60b47ea681ba8/R/procMaf.R#L253

With my dataset, I got an error while performing readData, which traced back to this bug.

> trainset       = readData(trainData, exomef, covarf, mutContextf, ref)
Error in matrix(0, nrow = nrow(mutab.onp) * umaxchar[k], ncol = ncol(mutab.onp)) : 
  invalid 'nrow' value (too large or NA)

It appears that within the loop, the mutab.onp variable sometimes only contains one row, which means that it is treated as a vector and hence nrow(mutab.onp) returns NULL. It looks like the previous line, 252, was supposed to correct that, but it is formulated very strangely - length(mutab.onp) will depend on the number of accessory columns and will not necessarily be 8 when there is one row only. A fix along the lines of

if ( is.null(nrow(mutab.onp) ){mutab.onp = t(as.matrix(mutab.onp))}

is suggested.

Best regards, Aleksandra

lijingya commented 4 years ago

Thanks for suggestion. Will add this to the dev1.2.

a-jartseva commented 4 years ago

Great, thanks!