Thank you very much for such a nice explanation! May you have a nice day!
Hello everyone!
Today I was trying to check whether all SNPs in my list (thousands of SNPs, GRCh37) belong to the particular chromosome (let's say chr 19) but I had some issues with it. I am doing everything on R and my strategy was this:
- To prepare list of SNP as a file (all starts with rs...)
- To download the human chromosome 19 from dbSNP
- To search my list as a pattern within downloaded chromosome
However, downloading process of chr 19 is going on for many hours already... And the fastest download option doesn't give the proper information for analysis.
I would love to know whether there is another way to check the list of SNPs for belonging to the particular chromosome in R?
Thanks in advance!
1 answer
Usign biomaRt:
#set up
library(biomaRt)
snpmart = useEnsembl(biomart = "snp", dataset="hsapiens_snp")
#Other useful functions
# listAttributes(snpmart)
# listFilters(snpmart)
Get SNPs that match with our list of IDs, here we have 2 SNP from chr1 and 1 SNPs from chr2:
getBM(attributes = c("refsnp_id", "chr_name", "chrom_start", "chrom_end"),
filters = c("snp_filter"),
values = list(c("rs17599629", "rs1218582", "rs11902236")),
mart = snpmart)
# refsnp_id chr_name chrom_start chrom_end
# 1 rs11902236 2 9977740 9977740
# 2 rs1218582 1 154861707 154861707
# 3 rs17599629 1 150685811 150685811
Now, to return only the ones which are on chr2, we can add "chr_name" filter:
getBM(attributes = c("refsnp_id", "chr_name", "chrom_start", "chrom_end"),
filters = c("chr_name", "snp_filter"),
values = list(c(2),
c("rs17599629", "rs1218582", "rs11902236")),
mart = snpmart)
# refsnp_id chr_name chrom_start chrom_end
# 1 rs11902236 2 9977740 9977740
Log in to answer this question.
Can you provide the code you are using for this and some example data?
I'm sorry that I did not reply to you! I am a bit new to bioinformatics and could not find a proper example data. However, @zx8754 helped me to resolve this question. May you have a nice day!