Question: about the use of subsetByFilter()
0
gravatar for Bogdan
2.7 years ago by
Bogdan580
Palo Alto, CA, USA
Bogdan580 wrote:

Dear Martin, and all, 

would like to ask for an advice about the use of the function subsetByFilter(vcf, filter). 

I have the following piece of R code that is working (below) -- thanks Martin for suggestions !

vcf <- readVcf("AML_out.vcf.bgzip",genome="hg38")

AFADfilter = function(x) {
            af <- geno(x)$AF[,"TUMOR"] > 0.05
            ad <- sum(as(geno(x)$AD[,"TUMOR"], "List")) >= 5
            af & ad
                         }

z <- vcf[AFADfilter(vcf)]
writeVcf(z,"output.vcf")

However, if I want to use the function subsetByFilter(), there is an error message :

subsetByFilter(vcf, filter=AFADfilter)

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘subsetByFilter’ for signature ‘"CollapsedVCF", "function"’
vcf • 784 views
ADD COMMENTlink modified 2.7 years ago by Martin Morgan ♦♦ 23k • written 2.7 years ago by Bogdan580
Answer: about the use of subsetByFilter()
3
gravatar for Martin Morgan
2.7 years ago by
Martin Morgan ♦♦ 23k
United States
Martin Morgan ♦♦ 23k wrote:

The filter argument is supposed to be a FilterRules object, so

subsetByFilter(vcf, filter=FilterRules(list(AFADfilter=AFADfilter)))
ADD COMMENTlink modified 2.7 years ago • written 2.7 years ago by Martin Morgan ♦♦ 23k

I see, it is a same rule as before, when filtering on VCF files, and not working on VCF objects. Thanks a lot Martin, have a happy, warm and fruitful week !

ADD REPLYlink written 2.7 years ago by Bogdan580
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 118 users visited in the last hour