tobyjohnson / gtx

Genetics ToolboX R package
30 stars 9 forks source link

regionplot should give better error messages when there are not enough SNPs #46

Open dalloliogm opened 6 years ago

dalloliogm commented 6 years ago

regionplot should give a better error output when the plot fails because there are not enough SNPs in the region.

This may happen for several reasons - in my case, because the coordinates where from a wrong reference genome.

> regionplot("eqtl_gene_blood_zhernakova", chrom = '6', pos = 32566577, surround = 5e3, ensemblid = 'ENSG00000013573')
analysis [ eqtl_gene_blood_zhernakova ] requires entity type [ ensg ]
Inferred entity [ ENSG00000013573 ] from Ensembl gene id [ ENSG00000013573 ]
analysis [ eqtl_gene_blood_zhernakova ] requires entity type [ ensg ]
Recognized entity [ ENSG00000013573 ] as Ensembl gene id
No signals from conditional/joint analyses overlap this region
Warning message in min(which(ps >= cred * ps[length(ps)])):
“no non-missing arguments to min; returning Inf”
Error in rgb((255 - 171) * posterior/max(posterior) + 171, (0 - 171) * : color intensity NA, not in 0:255
Traceback:

1. regionplot("eqtl_gene_blood_zhernakova", chrom = "6", pos = 32566577, 
 .     surround = 5000, ensemblid = "ENSG00000013573")
2. within(pvals, {
 .     posterior <- norm1(abf.Wakefield(beta, se, priorsd = 1, log = TRUE), 
 .         log = TRUE)
 .     posterior <- ifelse(!is.na(posterior), posterior, 0)
 .     c95 <- credset(posterior)
 .     colour <- rgb((255 - 171) * posterior/max(posterior) + 171, 
 .         (0 - 171) * posterior/max(posterior) + 171, (0 - 171) * 
 .             posterior/max(posterior) + 171, alpha = 127, maxColorValue = 255)
 . })
3. within.data.frame(pvals, {
 .     posterior <- norm1(abf.Wakefield(beta, se, priorsd = 1, log = TRUE), 
 .         log = TRUE)
 .     posterior <- ifelse(!is.na(posterior), posterior, 0)
 .     c95 <- credset(posterior)
 .     colour <- rgb((255 - 171) * posterior/max(posterior) + 171, 
 .         (0 - 171) * posterior/max(posterior) + 171, (0 - 171) * 
 .             posterior/max(posterior) + 171, alpha = 127, maxColorValue = 255)
 . })
4. eval(substitute(expr), e)
5. eval(substitute(expr), e)
6. rgb((255 - 171) * posterior/max(posterior) + 171, (0 - 171) * 
 .     posterior/max(posterior) + 171, (0 - 171) * posterior/max(posterior) + 
 .     171, alpha = 127, maxColorValue = 255)