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 in defining a locus: gene not found #28

Open dariushghasemi opened 2 days ago

dariushghasemi commented 2 days ago

Hi there,

I've been recently using locuszoomr instead of LocusZoom standalone tool. While defining a locus to draw the plot, this error occurred, which requires me to define gene argument. Once gene argument got introduced to locus function, the error went away.

It seems that the gene name is not an optional argument anymore (?)! Specially, defining other parameters such as fix_window or flank did not help to remove the error.

I have tried with two different versions of locuszoomr, v0.3.4 and v0.3.5. Note that I am using a local LD info computed by my own, which merged with the GWAS summary results in a data frame format called "gwas_ld".

Here are the arguments I used to reproduce the error:

loc <- locuszoomr::locus(
  gwas_ld,
  gene = 'ARHGEF3',
  seqname = 3,
  xrange = c(56849749, 56865776),
  #fix_window = 1e6,
  #flank = 0,
  index_snp = "3:56849749:C:T",
  chrom = "CHR",
  pos = "POS",
  labs = "SNPID",
  yvar = "MLOG10P",
  LD = "R2",
  ens_db = "EnsDb.Hsapiens.v75"
  )

With gene argument defined, the message is: ARHGEF3, chromosome 3, position 56437401 to 57437401 80 SNPs/datapoints

Without gene, locus function returns: Error in locuszoomr::locus(gwas_ld, seqname = 3, xrange = c(56849749, : gene not found

Thank you for your help! Dariush

myles-lewis commented 2 days ago

Hi Dariush,

It's simply to do with the default order of the arguments. gene is listed first, so unless you specify data = gwas_ld, then when gene is not specified as an argument then gwas_ld is passed to gene. Although the vast majority of users are using locuszoomr to plot GWAS data or similar, some might just want the genetracks to add to their own plots or heatmaps etc, so data is optional.

So your code will work if you write data = gwas_ld.

However, I will think about whether it is more intuitive to put data first in front of gene as an argument which avoid the error message that you received.

Bw, Myles

dariushghasemi commented 2 days ago

Hi Myles, Thank you so much for your prompt response.

Ups, my bad! So, it was a simple problem of arguments' order which I missed to obey! Yes, it worked! Correcting my scripts with adding 'data = gwas_ld' produced the scatter plot of the locus.

Of course, genes mapping is quite important for locusZoom plot. I was wondering what happens if a signal falls into none of the coding segments, the genes. How does the package deal with these situations?

Thanks again, Dariush

myles-lewis commented 2 days ago

It currently replies that there are no SNPs/datapoints in that region. But it does return a 'locus' object with the gene information. This won't plot anything using locus_plot() (it just returns an error message), but will plot the genetracks if you call genetracks() on the object.