text: user9234: I have a large data-frame (excel file) of SNPs with genotyping data. I need to filter the data to get SNP information of a specific gene alone. The list is too long to do it manually. I was wondering of annotating the SNPs with the gene names so that I can filter using the gene name. Does anyone know of a good R package to perform the task?
  
  user11883: I assume your SNP file contains genomic positions - please clarify if not. For example, you could have an rsID column, chromsome, and position column that contain "rs3088379", "chr1", "54225281".
  Approach #1: use R, as you suggest.
  ensembldb is an R package that may be what you're looking for: https://bioconductor.org/packages/release/bioc/html/ensembldb.html.
  You could map the genomic positions of your SNPs to gene names by adapting their workflow: https://bioconductor.org/packages/release/bioc/vignettes/ensembldb/inst/doc/coordinate-mapping.html.
  After you've mapped the genomic position, you could filter for your gene name.
  Approach #2: use bedtools.
  You can convert your Excel file of genomic positions to a tab-delimited BED format. https://bedtools.readthedocs.io/en/latest/content/overview.html has an overview. So, your first SNP would turn into
  chr1 54225280 54225281 rs3088379
  
  --> make sure you turn 1-based to 0-based coordinates!
  You could then download the coordinates of your gene in BED format from your favorite source, like UCSC Table Browser.
  Then, you run bedtools intersect with your SNP BED and your gene BED. What remains is just that gene's SNPs.
  
original_text: 9234: <p>I have a large data-frame (excel file) of SNPs with genotyping data. I need to filter the data to get SNP information of a specific gene alone. The list is too long to do it manually. I was wondering of annotating the SNPs with the gene names so that I can filter using the gene name. Does anyone know of a good R package to perform the task?</p>
   11883: <p>I assume your SNP file contains genomic positions - please clarify if not. For example, you could have an rsID column, chromsome, and position column that contain &quot;rs3088379&quot;, &quot;chr1&quot;, &quot;54225281&quot;.</p>
  <p><strong>Approach #1:</strong> use R, as you suggest.</p>
  <p><code>ensembldb</code> is an R package that may be what you're looking for: <a href="https://bioconductor.org/packages/release/bioc/html/ensembldb.html" rel="nofollow noreferrer">https://bioconductor.org/packages/release/bioc/html/ensembldb.html</a>.</p>
  <p>You could map the genomic positions of your SNPs to gene names by adapting their workflow: <a href="https://bioconductor.org/packages/release/bioc/vignettes/ensembldb/inst/doc/coordinate-mapping.html" rel="nofollow noreferrer">https://bioconductor.org/packages/release/bioc/vignettes/ensembldb/inst/doc/coordinate-mapping.html</a>.
  After you've mapped the genomic position, you could filter for your gene name.</p>
  <p><strong>Approach #2:</strong> use bedtools.</p>
  <p>You can convert your Excel file of genomic positions to a tab-delimited BED format. <a href="https://bedtools.readthedocs.io/en/latest/content/overview.html" rel="nofollow noreferrer">https://bedtools.readthedocs.io/en/latest/content/overview.html</a> has an overview. So, your first SNP would turn into</p>
  <pre><code>chr1 54225280 54225281 rs3088379
  </code></pre>
  <p>--&gt; make sure you turn 1-based to 0-based coordinates!
  You could then download the coordinates of your gene in BED format from your favorite source, like <a href="https://genome.ucsc.edu/cgi-bin/hgTables?command=start" rel="nofollow noreferrer">UCSC Table Browser</a>.</p>
  <p>Then, you run <code>bedtools intersect</code> with your SNP BED and your gene BED. What remains is just that gene's SNPs.</p>
  