title: How to create correct .vcf file based on data.frame in R? Subscript is out of bounds?
body: <p>currently I'm working with <code>signeR</code> package which allows you to create signatures of somatic mutations. First of all I'd like to reproduce their result from <a href="http://bioconductor.org/packages/release/bioc/vignettes/signeR/inst/doc/signeR-vignette.html" rel="nofollow noreferrer">vignette</a>.</p>
  
  <p>As you see there are two options of input data <code>.vcf</code> file and previously preprocessed  <code>mutation counts file</code> which is simple data frame obtained by their <code>genCountMatrixFromVcf()</code> function ..in fact from <code>.vcf...</code> </p>
  
  <p>Of course <a href="https://github.com/rvalieris/signeR/tree/master/inst/extdata" rel="nofollow noreferrer">here</a> you can find some example <code>.vcf</code> file and this mutation count matrix ready for further analysis.</p>
  
  <p>In vignette they used (as I read) <a href="ftp://ftp.sanger.ac.uk/pub/cancer/Nik-ZainalEtAl/" rel="nofollow noreferrer">this</a> data: <strong>SUBSTITUTIONS_13Apr2012_snz.txt</strong>.
  So I decided to create a <code>.vcf</code> file from this data frame and go through all steps of the vignette.</p>
  
  <p>So I made a several simple steps to build <code>.vcf</code> from mentioned above data:</p>
  
  <pre><code>dat &lt;- read.table('SUBSTITUTIONS_13Apr2012_snz.txt', header = T, sep = '\t')
  t &lt;- dat[,c(3,4,6,7)]
  t$chr &lt;- paste("chr", t$chr, sep="")
  colnames(t) &lt;- c('chr','pos1','ref','alt')
  t$ID &lt;- rep('.',nrow(t)) 
  t$QUAL &lt;- rep('.',nrow(t))
  t$FILTER &lt;- rep('.',nrow(t))         
  t$INFO &lt;- rep('.',nrow(t))
  t$FORMAT &lt;- rep('.',nrow(t))
  t$Sample &lt;- rep('.',nrow(t))
  t &lt;- t[, c('chr', 'pos1', 'ID', 'ref', 'alt', 'QUAL',   'FILTER',   'INFO')]
  colnames(t) &lt;- c('#CHROM',  'POS',  'ID',   'REF',  'ALT',  'QUAL', 'FILTER',   'INFO')
  </code></pre>
  
  <p>As a result we have:</p>
  
  <pre><code>&gt; head(t)
    #CHROM     POS ID REF ALT QUAL FILTER INFO
  1   chr1  809687  .   G   C    .      .    .
  2   chr1  819245  .   G   T    .      .    .
  3   chr1 1911011  .   C   G    .      .    .
  4   chr1 2112413  .   T   C    .      .    .
  5   chr1 2927666  .   A   G    .      .    .
  6   chr1 3359791  .   C   T    .      .    .
  </code></pre>
  
  <p>All mandatory columns for <code>.vcf</code> file are present. I made this type of files previously, than I used <code>readVcfAsVRanges()</code> everything worked fine.</p>
  
  <p>However here in <code>signeR</code> package there's some problem...
  Because if I wont to create this <strong>mutation count matrix</strong> I have an error:</p>
  
  <pre><code>vcfobj &lt;- readVcf("21_breast.vcf", "hg19")
  mut &lt;- genCountMatrixFromVcf(BSgenome.Hsapiens.UCSC.hg19, vcfobj)
  Error in normalizeDoubleBracketSubscript(i, x, exact = exact, error.if.nomatch = FALSE) : 
    subscript is out of bounds
  </code></pre>
  
  <p>So I tried to find out what is wrong with my <code>.vcf</code> file in comparison to 'working' ones...</p>
  
  <p>My file:</p>
  
  <pre><code>vcfobj
  class: CollapsedVCF 
  dim: 183916 0 
  rowRanges(vcf):
    GRanges with 5 metadata columns: paramRangeID, REF, ALT, QUAL, FILTER
  info(vcf):
    DataFrame with 0 columns: 
  geno(vcf):
    SimpleList of length 0:
  </code></pre>
  
  <p>Thier 'working' example file (in fact after run <code>genCountMatrixFromVcf()</code> function there's also error but different... Not important at this moment).</p>
  
  <pre><code>example &lt;- readVcf("example.vcf", "hg19")
  example
  class: CollapsedVCF 
  dim: 44 7 
  rowRanges(vcf):
    GRanges with 5 metadata columns: paramRangeID, REF, ALT, QUAL, FILTER
  info(vcf):
    DataFrame with 1 column: INFO
    Fields with no header: INFO 
  geno(vcf):
    SimpleList of length 5: GT, AD, DP, GQ, PL
  geno(header(vcf)):
        Number Type    Description                                                                           
     GT 1      String  Genotype                                                                              
     AD .      Integer Allelic depths for the ref and alt alleles in the order listed                        
     DP 1      Integer Approximate read depth (reads with MQ=255 or with bad mates are filtered)             
     GQ 1      Integer Genotype Quality                                                                      
     PL G      Integer Normalized, Phred-scaled likelihoods for genotypes as defined in the VCF specification
  </code></pre>
  
  <p>As you se the <code>dim</code> va.lues are different I have <code>0</code> there, so it might be the problem. So I'd like to ask you how to fix my <code>.vcf</code> file?</p>