text: user4595: I have called structural variants and now I have
  Sample  Type    Chrom1   Start1        End1 Strand1
  t_005   DEL 1   28677074    28677079    +
  t_005   INS 1   186383731   186383738   +
  t_005   DEL 1   245902589   245902590   +
  t_005   DEL 2   56345643    56345645    +
  t_005   DEL 3   59766214    59766217    +
  t_005   DEL 3   60270545    60270548    +
  
  I have an annotation file like
  > head(sv[,1:5])
    ENSG00000233440 13 23708313 23708703   HMGA1P6
  1 ENSG00000207157 13 23726725 23726825    RNY3P4
  2 ENSG00000229483 13 23743974 23744736 LINC00362
  3 ENSG00000229483 13 23743974 23744736 LINC00362
  4 ENSG00000252952 13 23791571 23791673  RNU6-58P
  5 ENSG00000235205 13 23817659 23821323  TATDN2P3
  6 ENSG00000232849 13 93708910 93710179 LINC00363
  > 
  
  How I could relate each gene name from annotation file to my genomic range file?
  
  EDITED
  
  Sample  Type    Chrom1  Start1  End1    Strand1 Chrom2  Start2  End2    Strand2
  t_005   DEL 1   28677074    28677079    +   1   28706324    28706329    -
  t_005   INS 1   186383731   186383738   +   1   186383731   186383732   -
  t_005   DEL 1   245902589   245902590   +   1   246007384   246007385   -
  t_005   DEL 2   56345643    56345645    +   2   56345829    56345830    -
  t_005   DEL 3   59766214    59766217    +   3   59785325    59785328    -
  t_005   DEL 3   60270545    60270548    +   3   60705591    60705594    -
  t_005   DUP 3   60744344    60744345    -   3   60806306    60806307    +
  t_005   DUP 3   60882109    60882112    -   3   60934155    60934158    +
  t_005   DEL 3   77973091    77973093    +   3   77991398    77991400    -
  t_005   DEL 3   95972796    95972800    +   3   95974511    95974515    -
  
  
  user650: You received an answer from Kamil for a similar question here: https://bioinformatics.stackexchange.com/a/8532/650
  You can adapt the code they gave you to compare Chrom1 == sv[2] & Start1 >= sv[3] & End1<=sv[4] to find events that happen within a gene. For events spanning genes, you're going to need to write a collapsing function for the gene names and a different way to compare overlaps instead of Start >= sv[3] & End <= sv[4].
  
original_text: 4595: <p>I have called structural variants and now I have</p>
  
  <pre><code>Sample  Type    Chrom1   Start1        End1 Strand1
  t_005   DEL 1   28677074    28677079    +
  t_005   INS 1   186383731   186383738   +
  t_005   DEL 1   245902589   245902590   +
  t_005   DEL 2   56345643    56345645    +
  t_005   DEL 3   59766214    59766217    +
  t_005   DEL 3   60270545    60270548    +
  </code></pre>
  
  <p>I have an annotation file like</p>
  
  <pre><code>&gt; head(sv[,1:5])
    ENSG00000233440 13 23708313 23708703   HMGA1P6
  1 ENSG00000207157 13 23726725 23726825    RNY3P4
  2 ENSG00000229483 13 23743974 23744736 LINC00362
  3 ENSG00000229483 13 23743974 23744736 LINC00362
  4 ENSG00000252952 13 23791571 23791673  RNU6-58P
  5 ENSG00000235205 13 23817659 23821323  TATDN2P3
  6 ENSG00000232849 13 93708910 93710179 LINC00363
  &gt; 
  </code></pre>
  
  <p>How I could relate each gene name from annotation file to my genomic range file?</p>
  
  <blockquote>
    <p>EDITED</p>
  </blockquote>
  
  <pre><code>Sample  Type    Chrom1  Start1  End1    Strand1 Chrom2  Start2  End2    Strand2
  t_005   DEL 1   28677074    28677079    +   1   28706324    28706329    -
  t_005   INS 1   186383731   186383738   +   1   186383731   186383732   -
  t_005   DEL 1   245902589   245902590   +   1   246007384   246007385   -
  t_005   DEL 2   56345643    56345645    +   2   56345829    56345830    -
  t_005   DEL 3   59766214    59766217    +   3   59785325    59785328    -
  t_005   DEL 3   60270545    60270548    +   3   60705591    60705594    -
  t_005   DUP 3   60744344    60744345    -   3   60806306    60806307    +
  t_005   DUP 3   60882109    60882112    -   3   60934155    60934158    +
  t_005   DEL 3   77973091    77973093    +   3   77991398    77991400    -
  t_005   DEL 3   95972796    95972800    +   3   95974511    95974515    -
  </code></pre>
   650: <p>You received an answer from Kamil for a similar question here: <a href="https://bioinformatics.stackexchange.com/a/8532/650">https://bioinformatics.stackexchange.com/a/8532/650</a></p>
  
  <p>You can adapt the code they gave you to compare <code>Chrom1 == sv[2] &amp; Start1 &gt;= sv[3] &amp; End1&lt;=sv[4]</code> to find events that happen within a gene. For events spanning genes, you're going to need to write a collapsing function for the gene names and a different way to compare overlaps instead of <code>Start &gt;= sv[3] &amp; End &lt;= sv[4]</code>.</p>
  