I wrote the following filter to discard variants which have less than 20% of samples with less than 10 reads:
filterDp <- function(x, min.dp=10, min.prop.dp=0.2){ dp <- geno(x)$DP (rowSums(dp >= min.dp) / ncol(dp) < min.prop.dp) }
When I use it alone, it's working well:
filters <- FilterRules(list(dp=filterDp)) filterVcf(file=tabix.file, genome="test", destination=out.file, index=TRUE, filters=filters, param=vcf.params, verbose=TRUE) starting filter filtering 1202 records completed filtering compressing and indexing '...'
However, when I combine it with others, it fails:
filterBiall <- function(x){ (elementLengths(alt(vcf)) > 1) } filterSnv <- function(x){ (! isSNV(x)) }
filters <- FilterRules(list(dp=filterDp, biall=filterBiall, snv=filterSnv)) filterVcf(file=tabix.file, genome="test", destination=out.file, index=TRUE, filters=filters, param=vcf.params, verbose=TRUE) starting filter filtering 1202 records Error in extractROWS(x, eval(filter, x)) : error in evaluating the argument 'i' in selecting a method for function 'extractROWS': Error in eval(filter, x) : filter rule evaluated to inconsistent length:
Moreover, the error changes depending on the order of the filters:
filters <- FilterRules(list(dp=filterDp, biall=filterBiall, snv=filterSnv)) filterVcf(file=tabix.file, genome="test", destination=out.file, index=TRUE, filters=filters, param=vcf.params, verbose=TRUE) starting filter filtering 1202 records Error in extractROWS(x, eval(filter, x)) : error in evaluating the argument 'i' in selecting a method for function 'extractROWS': Error in rowSums(dp >= min.dp) 'x' must be an array of at least two dimensions
Do you have any idea?
I see... I managed to solve my problem by doing this:
Could you also mention this in the vignette? That would be great. Thanks a lot!