stephenturner / qqman

An R package for creating Q-Q and manhattan plots from GWAS results
http://cran.r-project.org/web/packages/qqman/
GNU General Public License v3.0
154 stars 92 forks source link

Code on blog post: highlight=snps_to_highlight errors #5

Closed stephenturner closed 11 years ago

stephenturner commented 11 years ago

working on code-from-blog-post.r, getting error at line 19: D'oh! Highlight vector/list must be a subset of the SNP column.. This happens even though it appears all the SNPs are in my dataset:

> snps_to_highlight
 [1] "rs17134527" "rs7928420"  "rs636420"   "rs12221774" "rs4639959"  "rs10899166" "rs7940138"  "rs9787835"  "rs9787822"  "rs582132"  
[11] "rs689196"   "rs647159"   "rs1533763"  "rs882151"   "rs4944092"  "rs689095"   "rs2004652"  "rs4944097"  "rs12807555" "rs4945056" 
[21] "rs17134737" "rs11236673" "rs2371933"  "rs2846072"  "rs2851162"  "rs4944102"  "rs7101887"  "rs2005145"  "rs17134794" "rs11236692"
[31] "rs11236693" "rs2851469"  "rs2004607"  "rs12291710" "rs11236720" "rs2618075"  "rs949150"   "rs6592636"  "rs11236768" "rs10751255"
[41] "rs11236774" "rs1939468"  "rs2513514"  "rs11236782" "rs7130588"  "rs2508747"  "rs7927894"  "rs11236806" "rs11236809" "rs11601862"
[51] "rs7940340"  "rs7949206"  "rs11603047" "rs11236826" "rs1892952"  "rs7342189"  "rs731644"   "rs10793182" "rs10751260" "rs10899257"
[61] "rs11236880" "rs6592659"  "rs11236894" "rs10899261" "rs4944120"  "rs4945110"  "rs7938883"  "rs12362105" "rs7924748"  "rs11822653"
[71] "rs10793194" "rs12273016" "rs1149613"  "rs1149615"  "rs1149616"  "rs1149623"  "rs1149624"  "rs10899288" "rs11236960" "rs1225148" 
[81] "rs7924613"  "rs12794575" "rs7931561"  "rs7927658"  "rs7937883"  "rs2119457"  "rs3740765"  "rs6592695"  "rs7123496"  "rs17135325"
[91] "rs10899344" "rs949339"  
> snps_to_highlight %in% results$SNP
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[28] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[55] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[82] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
stephenturner commented 11 years ago

Commented this line out until it's fixed. I'm not sure I follow the logic why it's not working.

dcapurso commented 11 years ago

Looking into it now! Sorry for the long delay in getting to this. I have been traveling a lot this summer. Back to normal schedule now though

On Thu, Aug 29, 2013 at 11:48 AM, Stephen Turner notifications@github.comwrote:

Commented this line out until it's fixed. I'm not sure I follow the logic why it's not working.

— Reply to this email directly or view it on GitHubhttps://github.com/stephenturner/qqman/issues/5#issuecomment-23514105 .

dcapurso commented 11 years ago

I found the problem. The first line of manhattan() was:

d = na.omit(dataframe)

This is too general because it filters out some rows with NAs in non-essential columns (e.g., CHISQ, OR). This was filtering out some of the SNPs that you indicated to highlight with "snps_to_highlight". I modified the line to:

d = dataframe d = d [(!is.na(d$CHR) & !is.na(d$BP) & !is.na(d$P)), ]

But even with this more specific filtering, some of the "snps_to_highlight" are filtered out because of missing data.

"snps_to_highlight" should not be SNPs that have NA for CHR, BP, or P (such SNPs get filtered out of the results dataframe because they can't be plotted). I attached an updated version of code-from-blog-post.r that works by filtering "snps_to_highlight" before plotting. I am not committing these changes... I'll let you modify code-from-blog-post.r as you want, and then commit.

I will commit the changes to qqman.r

We can modify the error message and/or handling of this scenario if you want.

Best, Dan

On Thu, Aug 29, 2013 at 3:30 PM, Dan Capurso dancapurso1@gmail.com wrote:

Looking into it now! Sorry for the long delay in getting to this. I have been traveling a lot this summer. Back to normal schedule now though

On Thu, Aug 29, 2013 at 11:48 AM, Stephen Turner <notifications@github.com

wrote:

Commented this line out until it's fixed. I'm not sure I follow the logic why it's not working.

— Reply to this email directly or view it on GitHubhttps://github.com/stephenturner/qqman/issues/5#issuecomment-23514105 .

stephenturner commented 11 years ago

I can't see an attachment here. Hm, I think the best way to handle this situation - if they user wishes to highlight SNPs that aren't in the results (or have missing chr/bp/P-values), best to still plot the remaining snps, but issue a warning that the specific SNP wasn't in the results.

dcapurso commented 11 years ago

Here is the attachment. I will modify the handling of this as you indicated and commit shortly.

On Fri, Aug 30, 2013 at 5:52 AM, Stephen Turner notifications@github.comwrote:

I can't see an attachment here. Hm, I think the best way to handle this situation - if they user wishes to highlight SNPs that aren't in the results (or have missing chr/bp/P-values), best to still plot the remaining snps, but issue a warning that the specific SNP wasn't in the results.

— Reply to this email directly or view it on GitHubhttps://github.com/stephenturner/qqman/issues/5#issuecomment-23558811 .

dcapurso commented 11 years ago

Committed changes to qqman.r

On Fri, Aug 30, 2013 at 10:07 AM, Dan Capurso dancapurso1@gmail.com wrote:

Here is the attachment. I will modify the handling of this as you indicated and commit shortly.

On Fri, Aug 30, 2013 at 5:52 AM, Stephen Turner notifications@github.comwrote:

I can't see an attachment here. Hm, I think the best way to handle this situation - if they user wishes to highlight SNPs that aren't in the results (or have missing chr/bp/P-values), best to still plot the remaining snps, but issue a warning that the specific SNP wasn't in the results.

— Reply to this email directly or view it on GitHubhttps://github.com/stephenturner/qqman/issues/5#issuecomment-23558811 .

stephenturner commented 11 years ago

Looks good, thanks!