Hello

Simple question ( I hope!) 

I'm using this [VariantAnnotation][1] package from bioconductor to work with SNPs.

    myparam = ScanVcfParam(               # this function is a fast positional filter
        samples="3441_pseudo_gatk", 
        which= GRanges(chr[14],          # This is a chromossome name
                       ranges=IRanges(   # these are custom filters
                           start= 10,
                           end=10000)))

        VCF <- readVcf(TabixFile("my_potato.vcf.gz"), "Potato", param=myparam) 

VCF is a "Formal class CollapsedVCF". It's very complex and there are extensive [instructions][2], but I cannot find the answer to the most simple thing of them all:

> How do I parse the raw data of VCF in R?

 I know that if I write it out with:

    writeVcf(obj = VCF, filename =  "tmp.vcf")
I get exactly what I want in a file in my working directory. However, I would like parsing all lines in R as a vector to filter, as **I already wrote a filter that gives index positions**.

All of this because I don't like the filterVcf() function. It doesn't take advantage of the fact that VCF is already filtered by positions and is thus smaller than the original "my_potato.vcf.gz".

**EDIT** : Actually, I got a detail wrong. FilterVcf() can indeed use the positional filter myparam with param=myparam.

Thank you for the attention!    
Ricardo

  [1]: https://bioconductor.org/packages/release/bioc/html/VariantAnnotation.html
  [2]: https://bioconductor.org/packages/release/bioc/vignettes/VariantAnnotation/inst/doc/VariantAnnotation.pdf
> How do I parse the raw data of VCF in R?

You already know the answer to that: it's  the `readVcf()` function. You use the `VariantAnnotation` library to fully parse the file, or you use a text file parser if you need the raw input lines for some reason (you very rarely do).

See [here][1] for an example of where I needed to do exactly that to work around a bug in the `VariantAnnotation` library.

> I have a filtering function that outputs desired indexes (based on, for example, the value of info(VCF)$MQ ) but I can't subscript VCF with indexes because it's not a dataframe or a vector.

> I would simply like to filter out certain lines of the vcf. For example, to filter out lines 1,5,7:

Sub-setting a VCF using VariantAnnotation works exactly like you describe. Just subset the VCF using the notation you would use for a vector: `filteredVcf = vcf[-c(1, 5, 7)]` will removes the first, firth, and seventh variant from the VCF.

You can also subset using a logical vector. For example: ` highqualvcf = vcf[VariantAnnotation::fixed(vcf)$QUAL > 20]`

  [1]: https://github.com/hartwigmedical/scripts/blob/master/gridss/libgridss.R#L742