Giter Club home page Giter Club logo

locuscomparer's Introduction

LocusCompareR

1. Installation

LocusCompareR is an R package for visualization of GWAS-eQTL colocalization events.

Use the following commands to install LocusCompareR. If you don't have devtools, uncomment the first line to install it.

# install.packages("devtools")
devtools::install_github("boxiangliu/locuscomparer")

2. Example

To illustrate the use of locuscompare, we use the GWAS dataset from Nikpay et al. (2015) and the coronary artery eQTL dataset from GTEx v7 at the PHACTR1 locus:

library(locuscomparer)
gwas_fn = system.file('extdata','gwas.tsv', package = 'locuscomparer')
eqtl_fn = system.file('extdata','eqtl.tsv', package = 'locuscomparer')
locuscompare(in_fn1 = gwas_fn, in_fn2 = eqtl_fn, title1 = 'CAD GWAS', title2 = 'Coronary Artery eQTL')

The output from the main function is a figure like the following:

The labeled SNP is the lead SNP (in this case for both studies), and other SNPs are colored according to their LD $r^2$ with the lead SNP.

3. Using your own dataset:

The input to locuscompare::main() is a two-column tab-delimited text file with two columns:

  1. rsid
  2. pval

Here is an example file:

rsid	pval
rs62156064	0.564395
rs7562234	0.399642
rs11677377	0.34308
rs35076156	0.625237

You can download the example files below: GWAS and eQTL datasets.

Then run the following commands:

library(locuscomparer)
gwas_fn = 'path/to/gwas.tsv'
eqtl_fn = 'path/to/eqtl.tsv'
locuscompare(in_fn1 = gwas_fn, in_fn2 = eqtl_fn, title = 'GWAS', title2 = 'eQTL')

4. Documentations

To view documentation for each function, type ?[function name] in the R console.

LocusCompareR current export the following functions:

Data munging

  • assign_color: Assign color to each SNP according to LD.
  • get_lead_snp: Add a column of SNP labels to input data.frame.
  • get_position: Append two columns, chromosome (chr) and position (pos), to the input data.frame.

Plotting

  • locuscompare: Make a locuscompare plot.
  • make_combined_plot: Generated a combined plot with two locuszoom plots and a locuscompare plot.
  • make_locuszoom: Make a simple locuszoom plot.
  • make_scatterplot: Make a scatter plot (called the LocusCompare plot)

Data loading

  • read_metal" Read association summary statistics from file.
  • retrieve_LD: Retrive SNP pairwise LD from database.

5. Citation

If you use locuscompare, please cite the following paper: https://www.nature.com/articles/s41588-019-0404-0

Boxiang Liu, Michael J. Gloudemans, Abhiram S. Rao, Erik Ingelsson & Stephen B. Montgomery (2019) Abundant associations with gene expression complicate GWAS follow-up, Nature Genetics

locuscomparer's People

Contributors

boxiangliu avatar mikegloudemans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

locuscomparer's Issues

Wrong SNP being assigned purple colour

The merge function in assign_color can flip the order of SNPs where one rsid is a substring of the other, e.g. rs123456 and rs1234567. In the following if statement, the line color[rsid == snp,'color'] = 'purple' should then colour the lead SNP (snp = "rs123456") purple; however, it colours rs1234567 purple instead.

The core issue is that the line color[rsid == snp,'color'] uses the input structure rsid (which is just a renaming of merged$rsid) to mask color, rather than color$rsid. Since rsid has the ordering of SNPs prior to the reordering by merge and color$rsid the ordering post merge, it changes the colour of the wrong SNP.

This can be fixed simply by changing color[rsid == snp,'color'] to color[color$rsid == snp,'color'].

I'm not sure if this only happens for SNPs with rsids that are substrings of other SNP rsids, or why the merge function does this at all, but this fix should ensure that any change in ordering during merge is irrelevant.

Fail to connection to server during query

Dear developer,
I am frequently encountering the following problem at runtime, is there any way to cope with this problem?

Error in dbSendQuery(conn, statement, ...) : 
  could not run statement: Lost connection to server during query

could not run statement: MySQL server has gone away

Hi Boxiang,

I'm testing the locuscomparer package on my Mac.
The environment is R 3.6 and the sample data works very well.
But when I load my own datasets, it always shows the following msg after running a while.

Error in .local(conn, statement, ...) : 
  could not run statement: MySQL server has gone away

My datasets are a GWAS data ~ 260M, and the GTEx v7 data ~ 3.5G.
Do you have any clue for this error msg? Is it due to the large size dataset?

Thanks so much.

Compilation failure: no DLL was created

Good morning,

I would really like to use LocusCompareR as it seems like a great pacakges, but I'm having trouble installing LocusComparer on R 3.5.3 and Windows 10. I can load devtools properly, but when doing
devtools::install_github("boxiangliu/locuscomparer")
I get the following error message after the dependencies have been installed:

\* installing *source* package 'locuscomparer' ... ** libs no DLL was created ERROR: compilation failed for package 'locuscomparer' \* removing 'C:/Users/Jenny/Documents/R/win-library/3.5/locuscomparer' In R CMD INSTALL Error in i.p(...) : (converted from warning) installation of package ‘C:/Users/Jenny/AppData/Local/Temp/RtmpWkwypc/file18646fe17717/locuscomparer_1.0.0.tar.gz’ had non-zero exit status

I've tried other versions of R (3.5.1, 3.4.3), reinstalling Rtools (trying both version 34 and 35), using another computer (same problem), only installing the 32 bit or 64 bit version of R, and I keep getting similar compilation issues. Other packages work fine. I would really appreciate any help in getting it to work.

Many thanks!

/Jenny

Problems with plotting extreme small P-values

P-values exceeded R's folate limit would automatically be transformed to 0, resulting an infinite value of -log10 (P), and the figure would be very weird. I suggest reading in the P-value columns as character first, and then to transform it to -log10 value. (split the P-value by the number before and after e)

Failed to connect to database: Error: Can't connect to MySQL server on 'locuscompare-us-west-2a.cvocub39nnri.us-west-2.rds.amazonaws.com' (111)

Hi, I am trying to run this command locuscompare(in_fn1 = gwas_fn, in_fn2 = eqtl_fn, title1 = 'CAD GWAS', title2 = 'Coronary Artery eQTL')

but having the persistent issue for three days.

Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'locuscompare-us-west-2a.cvocub39nnri.us-west-2.rds.amazonaws.com' (111)
Warning message:
In rm(config) : object 'config' not found

I have already tried my best but still do not know how to run it smoothly.

I am working on ubuntu behind a corporate proxy. So, I thought at first it was a proxy issue due to the lacking of MySQL server and AWS account on my device. But, when I use it on my mac, it is working like a charm without any installation and creation of MySQL server and AWS account. However, I still need to use this tool on my work PC because of input data privacy issue.

Does it mean I need to create an AWS account and adjust the network setting in it to access MySQL server on this URL 'locuscompare-us-west-2a.cvocub39nnri.us-west-2.rds.amazonaws.com'?

Please let me know how to run this tool behind a corporate proxy.

Fail to connect to database

Hi,

While running locuscompare function I encountered this error:

Error in .local(drv, ...) :
  Failed to connect to database: Error: Unknown MySQL server host 'locuscompare-us-west-2a.cvocub39nnri.us-west-2.rds.amazonaws.com' (2)
Calls: locuscompare ... get_position -> <Anonymous> -> <Anonymous> -> .local
Execution halted
Warning message:
In rm(config) : object 'config' not found

I did not have this problem when I was doing the same thing before, though.

Thanks

implementation with zscores?

Hi there,

Thanks for this great tool. It is very convenient to use and makes great plots. I'm wondering if you've considered adding an option to plot zscores instead of pvalues. As you probably know, when samples sizes get large enough, pvalues are sufficiently close to zero that R and other programs cannot distinguish between them and they get truncated to some arbitrarily small number.

One could argue that we shouldn't bother trying to interpret differences between such small numbers. But i think for plotting purposes, the visual might be better if zscores were used instead of pvalues -- so you don't end up with a cluster of points on a flat line at the edge of "detection." If there's a reason you've chosen not to do this, I'd also be interested to know!

Thanks again for the great tool.

a problem about legend

Hi boxiangliu:
Thank you for your tool to plot the COLOC, but I have a problem about the legend, the "r2" deviate downward. As shown below(I did not change any drawing parameters in LINUX R 3.6.1):
1611562572(1)
but it is normal in Windows10. I think this tool should be very good, but I don’t know why this problem occurs. It has troubled me for a long time, so I want to ask you to help me

Top SNP level is not showing for GWAS plot

Top SNP level is not showing for GWAS plot. get this error Warning message:
ggrepel: 1 unlabeled data points (too many overlaps). Consider increasing max.overlaps. Any solution to this?

SNPs with r2 <0.2 are grey, not blue, after latest commit

Hi!

In the latest commit 15 May 2019, the SNPs that are missing in the LD lookup table are coloured grey in the main table, which is great. However, it seems that since SNPs with r2 < 0.2 with the lead SNP are dropped from the LD table, they are also coded as grey. Is there any possibility to update so that SNPs without LD are coded grey and SNPs with r2 0-0.2 are dark blue?

Thank you very much - and thanks for a great software!

Best,
Jenny

Error while running locuscomparer

Hello Boxiang,

I was trying to run your tool and encountered the following error:

Error in .local(conn, statement, ...) :
could not run statement: MySQL server has gone away

I'm not entirely sure what the problem is. I would appreciate your help. Thank you.

Nelson Barrientos

minor dependency issue when installing

Hi, I installed your package and got the following error:

> library(locuscomparer)
Error: package or namespace load failed for ‘locuscomparer’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 namespace ‘rlang’ 0.3.0.1 is already loaded, but >= 0.3.1 is required

Got around that by updating rlang to 0.3.1. Maybe you can incorporate this into the dependencies?

How can I change Y axes

Hi,

Very useful tool! A simple question is how can I change Y axes in locuscomparer?

Thanks!
Ya

Error with RMySQL

Hi,
I am using locuscomparer under a linux environment. When I run the function locuscompare(), it shows an error as follows:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/jhuli/R/x86_64-pc-linux-gnu-library/4.1/RMySQL/libs/RMySQL.so':
libmariadb.so.3: cannot open shared object file: No such file or directory
Warning message:
In rm(config) : object 'config' not found

I already have RMySQL installed, so I am not sure what I can do to fix this. Could you help me with this? Thank you!

How could I add a main title for the figure?

Hello,
Thanks for developing this convenient tools! But I ran into some problems.
It seems like no option to add a main title for the figure in locuscompare, which is an important function in some case. And it's also difficult to add a title without plot() or ggplot2().

I would appreciate your help. Thank you.

Points sometimes don't color correctly

Thanks for the great package! However, I have noticed that the points sometimes don't color correctly: the lead SNP isn't purple but another (random?) SNP is. Also, it would be great if we could accommodate "secondary lead" SNPs that are labelled but not as big as the lead SNP. Currently, when I try multiple lead SNPs, they're labelled correctly but I can't tell which one is the main lead SNP that defines LD. I have reinstalled the package a few days ago:

Packaged: 2019-08-20 13:25:13 UTC;
Built: R 3.5.3; ; 2019-08-20 13:25:14 UTC; windows

Wrong coloring with one lead SNP:
image

Wrong coloring with multiple lead SNPs:
image

Change source for LD computation

With GTEx release v8 being released soon, is it possible to compute LD from other sources? I'm assuming the default is 1k genomes, but is there an option to compute LD from GTEx, for example?

How to incorporate own LD instead of reference LD?

Hi,
I wonder if there is a way to use my own LD matrix to produce locuscompare plot, for example, I have multi-ancestry results but your package reference data does not provide LD in such scenario.

Thank you.
Xiaowei

Error in function get_lead_snp - in_fn1, in_fn2 are not in scope

I got the following error:
"ERROR: Error in sprintf("%s not found in the intersection of %s and %s", snp, : object 'in_fn1' not found\n"

I traced this to the function get_lead_snp, where objects in_fn1 and in_fn2 are used, but are not in scope since they aren't passed in to the function.

Cannot run example code (hangs)

Hello,
I've installed locuscomparer successfully as far as I can tell. I have RMySQL installed as well. When I run the example code provided, R simply hangs (for more than 10 min), with no indication that anything is happening.
The example code I'm referring to is:

gwas_fn = system.file('extdata','gwas.tsv', package = 'locuscomparer')
eqtl_fn = system.file('extdata','eqtl.tsv', package = 'locuscomparer')
locuscompare(in_fn1 = gwas_fn, in_fn2 = eqtl_fn, title1 = 'CAD GWAS', title2 = 'Coronary Artery eQTL')

This happens on my Mac (High Sierra) with RStudio + R 3.6.0, as well as on our unix server. On the server I get the message:
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'locuscompare-us-west-2a.cvocub39nnri.us-west-2.rds.amazonaws.com' (111)

On my Mac it simply hangs. Any clue as to what is going on?
Thanks!
Jeremy

No connection to MySQL server

Hi,

To be sure I downloaded the example data for locuscompareR. I'm getting all the time the same error message.

"Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'locuscompare-us-west-2a.cvocub39nnri.us-west-2.rds.amazonaws.com' (115)
Warning message:
In rm(config) : object 'config' not found"

Thanks for your assistance,

locuscompare

Hi
I am having two dataset , as below

eqtl_fn <- read.table(file="XXXXX/Artery_Coronary_v7_eQTL_PHACTR1.txt", header=T, as.is=T)
head(eqtl_fn)
gwas_fn <- read.table(file="XXXXX/CAD_GWAS.txt", header=T, as.is=T)
head(gwas_fn)

locuscompare(in_fn1=gwas_fn, in_fn2=eqtl_fn, title1="CAD GWAS", title2="Coronary Artery eQTL",
marker_col1= gwas_fn$rsnum, pval_col1=gwas_fn$pvalue, marker_col2=eqtl_fn$rsnum, pval_col2=eqtl_fn$pval_nominal)

keep having this error

Error in [.data.frame(d, , c("rsid", "pval", "logp")) :
undefined columns selected

your advise is appreciated.

Package dependency issue with RMySQL

Tried to run the example and got the following error

> library(locuscomparer)
> gwas_fn = system.file('extdata','gwas.tsv', package = 'locuscomparer')
> eqtl_fn = system.file('extdata','eqtl.tsv', package = 'locuscomparer')
> main(in_fn1 = gwas_fn, in_fn2 = eqtl_fn, title1 = 'CAD GWAS', title2 = 'Coronary Artery eQTL')
Error in loadNamespace(name) : there is no package called ‘RMySQL’

Since RMySQL is essential to run the main functions, you could have it as a dependency too. Does this make sense?

locuscompare

Hi, I keep having this issues.

gwas_fn = 'xxxxx/Desktop/CAD_GWAS.txt'
eqtl_fn = 'xxxxxx/Desktop/Artery_Coronary_v7_eQTL_PHACTR1.txt'

locuscompare(in_fn1 = gwas_fn, in_fn2 = eqtl_fn, title = 'CAD GWAS', title2 = 'Coronary Artery eQTL')

Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to server on 'locuscompare-us-west-2a.cvocub39nnri.us-west-2.rds.amazonaws.com' (10060)
Warning message:
In rm(config) : object 'config' not found

Please advise.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.