[BioC] problem about using 'rtracklayer' package to retrieve SNP chromosome position
James W. MacDonald
jmacdon at med.umich.edu
Fri Jul 17 18:06:23 CEST 2009
Hi LiGang,
LiGang wrote:
> Dear list,
>
> using rtracklayer, it's possible to retrieve data with functions
> of 'ucscTableQuery' and 'getTable'.
> however, these functions could only retrieve data given a genomic range.
> For example, using following code could retrieve snps between 10000 to 20000
> basepair on chromosome 2.
>
> ####======================
> library(rtracklayer)
> browserSession("UCSC")->session
> ucscTableQuery(session, "snp129",GenomicRanges(10000,20000, 2))->todo
> tableName(todo)<-"snp129"
> getTable(todo)
> ####======================
>
> my question is how to retrieve data using identifiers(names/accessions).
> for example, is it possible to retrieve chromosome position given the rs
> number of several SNPs, such as
> rs10003974
> rs10087355
> rs10075230
> ...
>
> is there any function in 'rtracklayer' package can do this?
I don't know if you can do this with rtracklayer, but it isn't difficult
to do it with RMySQL.
> library(RMySQL)
Loading required package: DBI
> con <- dbConnect("MySQL", user = "genome", host =
"genome-mysql.cse.ucsc.edu", dbname = "hg18")
> snps <- scan("clipboard", what = "c")
Read 3 items
> snps
[1] "rs10003974" "rs10087355" "rs10075230"
> sql <- paste("select name, chrom, chromEnd from snp129 where name in
('", paste(snps, collapse = "','"), "');", sep = "")
> dbGetQuery(con, sql)
name chrom chromEnd
1 rs10003974 chr4 154710828
2 rs10075230 chr5 44862908
3 rs10087355 chr8 41531957
Or you could use biomaRt
> mart <- useMart("snp", "hsapiens_snp")
Checking attributes ... ok
Checking filters ... ok
> getBM(c("refsnp_id","chr_name","chrom_start"), "refsnp", snps, mart)
refsnp_id chr_name chrom_start
1 rs10003974 4 154491378
2 rs10075230 5 44827151
3 rs10087355 8 41412800
Best,
Jim
>
> thanks!
>
> LiGang
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
--
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826
More information about the Bioconductor
mailing list