myles-lewis / locuszoomr

A pure R implementation of locuszoom for plotting genetic data at genomic loci accompanied by gene annotations.
GNU General Public License v3.0
18 stars 5 forks source link

Error: near ")": syntax error #16

Closed xsun1229 closed 7 months ago

xsun1229 commented 7 months ago

Hi Myles,

I've encountered a syntax error while using the locus function, and I'm having trouble diagnosing the problem. The error occurs when I execute the following code:

loc <- locus(data = gwas_select, seqname = chr, xrange =  range,ens_db = "EnsDb.Hsapiens.v75")
Chromosome 9, position 91453236 to 91553236
1214 SNPs/datapoints
Error: near ")": syntax error

I have reviewed the gwas_select object, and it appears to be consistent with other objects that I have successfully processed without encountering this issue. For your reference, here is the output for the chr and range variables:

> chr
[1] 9
> range
[1] 91453236 91553236

and the gwas object is gwas.txt

Could you please help me identify what might be causing this syntax error? Any insights or suggestions you could provide would be greatly appreciated.

Thank you! Xiaotong

myles-lewis commented 7 months ago

Hi Xiaotong, I downloaded your gwas.txt file and it runs fine on my system using the following code:

gwas_select <- read.table("../gwas.txt", header = T)

library(locuszoomr)
library("EnsDb.Hsapiens.v75")
loc <- locus(data = gwas_select, seqname = 9, xrange =  c(91453236, 91553236),
             ens_db = "EnsDb.Hsapiens.v75")
locus_plot(loc)

I don't get any errors - it plots fine. This region has no genes to plot. Are you sure you using the latest version 0.2.1 on CRAN? Which version of R and OS are you on? Also range is a known base R function. So defining it as a vector object is not ideal - better to use a different variable name. However it still works for me if you define range as a vector and then use it in the call.

Bw, Myles

xsun1229 commented 7 months ago

Thanks Myles!

After updating to the latest version, it works smoothly.

Best, Xiaotong