VanLoo-lab / ascat

ASCAT R package
https://www.mdanderson.org/research/departments-labs-institutes/labs/van-loo-laboratory/resources.html#ASCAT
162 stars 85 forks source link

readAllelesFiles throws error #145

Closed liannesuurenbroek closed 1 year ago

liannesuurenbroek commented 1 year ago

Hi, I got the following error when using ascat.prepareHTS using my own alleles and loci data:

Error in tmp[, 2] & !is.na(tmp[, 3]) : 
  operations are possible only for numeric, logical or complex types
Calls: ascat.prepareHTS ... readAllelesFiles -> do.call -> lapply -> FUN -> [ -> [.data.frame

I think I found the source of the error in line 334 of the readAllelesFiles function in ASCAT/R/ascat.prepareHTS.R: tmp=tmp[!is.na(tmp[,2] & !is.na(tmp[,3])),] Since tmp[,2] is a letter in my case (instead of a number in the standard allele files), this line throws an error. I think the code should instead say: tmp=tmp[!is.na(tmp[,2]) & !is.na(tmp[,3]),] Is this correct? Thanks!

tlesluyes commented 1 year ago

Hi @liannesuurenbroek,

Both tmp[,2] and tmp[,3] should be integers, not letters. I don't know if the documentation clearly explains what the allele files should contain, apologies for any confusion. I'll check and add a short description. It should be integers and follows the order of the output from alleleCounter: A, C, G and T. As an example, here is the very beginning of our reference file for WES (chr 1; tab-separated):

position a0 a1 10642 3 1 11008 2 3 11012 2 3

This means that chr1:10642 is a G>A SNP and both chr1:11008 and chr1:11012 are C>G SNPs.

You can easily convert letters to integers using: c('A'=1,'C'=2,'G'=3,'T'=4)[tmp[,2]] (please check that tmp[,2] only contains A/C/G/T). Hope this helps, let me know if something is still unclear.

Cheers,

Tom.

liannesuurenbroek commented 1 year ago

Hi,

I was indeed wondering about that, but I couldn't find which integer corresponds to which nucleotide so I assumed I could also fill in the letters. Thanks for the explanation!

tlesluyes commented 1 year ago

Hi @liannesuurenbroek,

No problem, I've updated the doc (https://github.com/VanLoo-lab/ascat/tree/master/ReferenceFiles/WES#file-format) so it's now described.

Cheers,

Tom.