how to check if SNP falls in the exon region
1
0
Entering edit mode
6.4 years ago
woofung • 0

Hello,

I am a R beginner, and I have a stupid question that if I have a data frame like this, represents the chromosome position of 9 exons of a gene.

  exon_chrom_start exon_chrom_end
1         61955718       61955951
2         61956844       61956998
3         61957387       61957464
4         61958146       61958298
5         61959498       61959578
6         61959892       61960043
7         61950370       61950427
8         61955107       61955201
9         61962255       61965515

And I have another list of the positions of a batch of SNPs, for example, like

61948834
61958130
61956083
61948922
61950242
61950134
61956819

Is there a easy way to check if any of the SNP falls in the exons or not?

I tried to use match function but it didn't work for ranges set by two vectors( exon_chrom_start:exon_chrom_end)

Thank you,

R genome snp sequence gene • 2.2k views
ADD COMMENT
2
Entering edit mode
6.4 years ago

Your example SNVs do not have overlapping exons. I added one to include in the range.

output:

>  sqldf("select * from snvs left join exons on  snvs.V1 between exons.exon_chrom_start and exons.exon_chrom_end")
        V1 exon_chrom_start exon_chrom_end
1 61948834               NA             NA
2 61958130               NA             NA
3 61956083               NA             NA
4 61948922               NA             NA
5 61950242               NA             NA
6 61950134               NA             NA
7 61956819               NA             NA
8 61955725         61955718       61955951

Input:

> exons
  exon_chrom_start exon_chrom_end
1         61955718       61955951
2         61956844       61956998
3         61957387       61957464
4         61958146       61958298
5         61959498       61959578
6         61959892       61960043
7         61950370       61950427
8         61955107       61955201
9         61962255       61965515

> snvs
        V1
1 61948834
2 61958130
3 61956083
4 61948922
5 61950242
6 61950134
7 61956819
8 61955725

I added 8th SNV to include one in range.

ADD COMMENT
0
Entering edit mode

I've been looking for this R code for such a long time!! Thanks @cpad0112!!

ADD REPLY

Login before adding your answer.

Traffic: 2640 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6