| Title: | locuscomparer: Visualization of GWAS-QTL Colocalization Events |
|---|---|
| Description: | locuscomparer is the standalone version of the LocusCompare webserver (www.locuscompare.ml:3838). locuscomparer performs visualization of colocalization of summary statistics from pairs of association datasets (e.g. GWAS and eQTL). |
| Authors: | Boxiang Liu [aut, cre], Michael Gloudemans [ctb], Stephen Montgomery [ctb] |
| Maintainer: | Boxiang Liu <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.0 |
| Built: | 2026-06-02 09:08:12 UTC |
| Source: | https://github.com/remlapmot/locuscomparer |
Add a column of SNP labels to input data.frame
add_label(merged, snp)add_label(merged, snp)
merged |
(data.frame) Input data.frame, which is a result by merging two association studies. See the example under 'get_lead_snp()' for generation of such data.frame. |
snp |
(character vector) A vector of SNP rsIDs. If only labeling one SNP, this can also be a single string. |
# Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) merged = add_label(merged, 'rs9349379')# Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) merged = add_label(merged, 'rs9349379')
Assign color to each SNP according to LD.
assign_color(rsid, snp, ld)assign_color(rsid, snp, ld)
rsid |
(character vector) A vector of rsIDs on which to assign color. |
snp |
(string) rsID for lead SNP. This SNP will be colored purple. Other SNPs will be assigned color based on their LD with the lead SNP. |
ld |
(data.frame) The output from 'retrieve_LD()'. |
# Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) ld <- retrieve_LD('6', 'rs9349379', 'AFR') color = assign_color(rsid = merged$rsid, snp = 'rs9349379', ld)# Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) ld <- retrieve_LD('6', 'rs9349379', 'AFR') color = assign_color(rsid = merged$rsid, snp = 'rs9349379', ld)
Example dataset
configconfig
## 'who' A data frame with 1 row and 3 columns:
"URL"
"locuscomparer"
"12345678"
Get the lead SNP from the list of SNPs in input data.frame The lead SNP is defined as the SNP with the lowest sum of p-values from the two studies.
get_lead_snp(merged, snp = NULL)get_lead_snp(merged, snp = NULL)
merged |
(data.frame) Input data.frame, which is a result by merging two association studies. |
snp |
(string, optional) SNP rsID. If NULL, the function will select the lead SNP based on the sum of p-values from the two studies. If an rsID is supplied, the function will simply return the rsID. |
# Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) get_lead_snp(merged)# Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) get_lead_snp(merged)
Append two columns, chromosome (chr) and position (pos), to the input data.frame.
get_position(x, genome = c("hg19", "hg38"))get_position(x, genome = c("hg19", "hg38"))
x |
(data.frame) Input data.frame. |
genome |
(string, optional) Genome assembly, either 'hg19' or 'hg38'. Default: 'hg19'. |
in_fn = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn, marker_col = 'rsid', pval_col = 'pval') get_position(d1)in_fn = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn, marker_col = 'rsid', pval_col = 'pval') get_position(d1)
Make a locuscompare plot.
locuscompare( in_fn1, in_fn2, marker_col1 = "rsid", pval_col1 = "pval", title1 = "eQTL", marker_col2 = "rsid", pval_col2 = "pval", title2 = "GWAS", snp = NULL, population = "EUR", combine = TRUE, legend = TRUE, legend_position = c("bottomright", "topright", "topleft"), lz_ylab_linebreak = FALSE, genome = c("hg19", "hg38") )locuscompare( in_fn1, in_fn2, marker_col1 = "rsid", pval_col1 = "pval", title1 = "eQTL", marker_col2 = "rsid", pval_col2 = "pval", title2 = "GWAS", snp = NULL, population = "EUR", combine = TRUE, legend = TRUE, legend_position = c("bottomright", "topright", "topleft"), lz_ylab_linebreak = FALSE, genome = c("hg19", "hg38") )
in_fn1 |
(string) Path to the input file for study 1. |
in_fn2 |
(string) Path to the input file for study 2. |
marker_col1 |
(string, optional) Name of the marker column. Default: 'rsid'. |
pval_col1 |
(string, optional) Name of the p-value column. Default: 'pval'. |
title1 |
(string) The title for the x-axis. |
marker_col2 |
(string, optional) Name of the marker column. Default: 'rsid'. |
pval_col2 |
(string, optional) Name of the p-value column. Default: 'pval'. |
title2 |
(string) The title for the y-axis. |
snp |
(string, optional) SNP rsID. If NULL, the function will select the lead SNP. Default: NULL. |
population |
(string, optional) One of the 5 popuations from 1000 Genomes: 'AFR', 'AMR', 'EAS', 'EUR', and 'SAS'. Default: 'EUR'. |
combine |
(boolean, optional) Should the three plots be combined into one plot? If FALSE, a list of three plots will be returned. Default: TRUE. |
legend |
(boolean, optional) Should the legend be shown? Default: TRUE. |
legend_position |
(string, optional) Either 'bottomright','topright', or 'topleft'. Default: 'bottomright'. |
lz_ylab_linebreak |
(boolean, optional) Whether to break the line of y-axis of the locuszoom plot. |
genome |
(string, optional) Genome assembly, either 'hg19' or 'hg38'. Default: 'hg19'. |
in_fn1 = system.file('extdata','gwas.tsv', package = 'locuscomparer') in_fn2 = system.file('extdata','eqtl.tsv', package = 'locuscomparer') locuscompare(in_fn1 = in_fn1, in_fn2 = in_fn2)in_fn1 = system.file('extdata','gwas.tsv', package = 'locuscomparer') in_fn2 = system.file('extdata','eqtl.tsv', package = 'locuscomparer') locuscompare(in_fn1 = in_fn1, in_fn2 = in_fn2)
Generated a combined plot with two locuszoom plots and a locuscompare plot. Each locuszoom plot represent an association study.
make_combined_plot( merged, title1, title2, ld, chr, snp = NULL, combine = TRUE, legend = TRUE, legend_position = c("bottomright", "topright", "topleft"), lz_ylab_linebreak = FALSE )make_combined_plot( merged, title1, title2, ld, chr, snp = NULL, combine = TRUE, legend = TRUE, legend_position = c("bottomright", "topright", "topleft"), lz_ylab_linebreak = FALSE )
merged |
(data.frame) An input data.frame which has the following columns: rsid, pval1 (p-value for study 1), logp1 (p-value for study 2), logp1 (log p-value for study 1), logp2 (log p-value for study 2), chr, pos. See the example for 'get_lead_snp()' on how to generate this data.frame. |
title1 |
(string) The title for the x-axis. |
title2 |
(string) The title for the y-axis. |
ld |
(data.frame) The output from 'retrieve_LD()'. |
chr |
(string) Chromosome name. e.g. '22'. Notice that the name should not contain 'chr'. |
snp |
(string, optional) SNP rsID. If NULL, the function will select the lead SNP. Default: NULL. |
combine |
(boolean, optional) Should the three plots be combined into one plot? If FALSE, a list of three plots will be returned. Default: TRUE. |
legend |
(boolean, optional) Should the legend be shown? Default: TRUE. |
legend_position |
(string, optional) Either 'bottomright','topright', or 'topleft'. Default: 'bottomright'. |
lz_ylab_linebreak |
(boolean, optional) Whether to break the line of y-axis of the locuszoom plot. If FALSE, the y-axis title and '-log10(p-value)'. will be on the same line. Default: FALSE. |
## Not run: # Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) merged = add_label(merged, 'rs9349379') ld <- retrieve_LD('6', 'rs9349379', 'AFR') make_combined_plot(merged, 'GWAS', 'eQTL', ld, chr) ## End(Not run)## Not run: # Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) merged = add_label(merged, 'rs9349379') ld <- retrieve_LD('6', 'rs9349379', 'AFR') make_combined_plot(merged, 'GWAS', 'eQTL', ld, chr) ## End(Not run)
Make a locuszoom plot. Details see http://locuszoom.org/.
make_locuszoom(metal, title, chr, color, shape, size, ylab_linebreak = FALSE)make_locuszoom(metal, title, chr, color, shape, size, ylab_linebreak = FALSE)
metal |
(data.frame) input file with two column, rsID and p-value. See 'read_metal()' for more details. |
title |
(string) y-axis title. |
chr |
(string) chromosome. |
color |
(data.frame) The output from 'assign_color()'. |
shape |
(data.frame) Specification of the shape of each SNP. See example blow on how to generate this data.frame. |
size |
(data.frame) Specification of the size of each SNP. See example below on how to generate this data.frame. |
ylab_linebreak |
(boolean, optional) Whether to break the line of y-axis. If FALSE, the y-axis title and '-log10(p-value)' will be on the same line. Default: FALSE. |
## Not run: # Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) merged = add_label(merged, 'rs9349379') ld <- retrieve_LD('6', 'rs9349379', 'AFR') color = assign_color(rsid = merged$rsid, snp = 'rs9349379', ld) snp = 'rs9349379' shape = ifelse(merged$rsid == snp, 23, 21) names(shape) = merged$rsid size = ifelse(merged$rsid == snp, 3, 2) names(size) = merged$rsid chr = '6' d1 = get_position(d1) make_locuszoom(d1, title = 'GWAS', chr, color, shape, size) ## End(Not run)## Not run: # Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) merged = add_label(merged, 'rs9349379') ld <- retrieve_LD('6', 'rs9349379', 'AFR') color = assign_color(rsid = merged$rsid, snp = 'rs9349379', ld) snp = 'rs9349379' shape = ifelse(merged$rsid == snp, 23, 21) names(shape) = merged$rsid size = ifelse(merged$rsid == snp, 3, 2) names(size) = merged$rsid chr = '6' d1 = get_position(d1) make_locuszoom(d1, title = 'GWAS', chr, color, shape, size) ## End(Not run)
Make a scatter plot (called the LocusCompare plot). Each axis of the LocusCompare plot represent the -log10(p-value) from an association study. Each point thus represent a SNP. By default, the lead SNP is a purple diamond, whereas the other SNPs are colored according to their LD with the lead SNP.
make_scatterplot( merged, title1, title2, color, shape, size, legend = TRUE, legend_position = c("bottomright", "topright", "topleft") )make_scatterplot( merged, title1, title2, color, shape, size, legend = TRUE, legend_position = c("bottomright", "topright", "topleft") )
merged |
(data.frame) An input data.frame which has the following columns: rsid, pval1 (p-value for study 1), logp1 (p-value for study 2), logp1 (log p-value for study 1), logp2 (log p-value for study 2), chr, pos. See the example for 'get_lead_snp()' on how to generate this data.frame. |
title1 |
(string) The title for the x-axis. |
title2 |
(string) The title for the y-axis. |
color |
(data.frame) The output from 'assign_color()'. |
shape |
(data.frame) Specification of the shape of each SNP. See example blow on how to generate this data.frame. |
size |
(data.frame) Specification of the size of each SNP. See example below on how to generate this data.frame. |
legend |
(boolean) Whether to include the legend. |
legend_position |
(string, optional) Either 'bottomright','topright', or 'topleft'. Default: 'bottomright'. |
# Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) merged = add_label(merged, 'rs9349379') ld <- retrieve_LD('6', 'rs9349379', 'AFR') color = assign_color(rsid = merged$rsid, snp = 'rs9349379', ld) snp = 'rs9349379' shape = ifelse(merged$rsid == snp, 23, 21) names(shape) = merged$rsid size = ifelse(merged$rsid == snp, 3, 2) names(size) = merged$rsid make_scatterplot(merged, title1 = 'GWAS', title2 = 'eQTL', color, shape, size)# Select the lead SNP in_fn_1 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn_1, marker_col = 'rsid', pval_col = 'pval') in_fn_2 = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d2 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval') merged = merge(d1, d2, by = "rsid", suffixes = c("1", "2"), all = FALSE) merged = add_label(merged, 'rs9349379') ld <- retrieve_LD('6', 'rs9349379', 'AFR') color = assign_color(rsid = merged$rsid, snp = 'rs9349379', ld) snp = 'rs9349379' shape = ifelse(merged$rsid == snp, 23, 21) names(shape) = merged$rsid size = ifelse(merged$rsid == snp, 3, 2) names(size) = merged$rsid make_scatterplot(merged, title1 = 'GWAS', title2 = 'eQTL', color, shape, size)
Read association summary statistics from file and append column. The file must contain 2 columns: markers, i.e SNPs, and p-value. The marker column should contain SNP rsIDs.
read_metal(in_fn, marker_col = "rsid", pval_col = "pval")read_metal(in_fn, marker_col = "rsid", pval_col = "pval")
in_fn |
(string) Path to the input file. |
marker_col |
(string, optional) Name of the marker column. Default: 'rsid'. |
pval_col |
(string, optional) Name of the p-value column. Default: 'pval'. |
in_fn = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn, marker_col = 'rsid', pval_col = 'pval')in_fn = system.file('extdata', 'gwas.tsv', package = 'locuscomparer') d1 = read_metal(in_fn, marker_col = 'rsid', pval_col = 'pval')
Retrive SNP pairwise LD from database. SNP pairwise lD are calculated based on 1000 Genomes Project Phase 3 version 5. For storage-efficiency, the output will only include SNPs with r2 > 0.2 with the input SNP.
retrieve_LD(chr, snp, population)retrieve_LD(chr, snp, population)
chr |
(string) Chromosome name. e.g. '22'. Notice that the name should not contain 'chr'. |
snp |
(string) SNP rsID. |
population |
(string) One of the 5 popuations from 1000 Genomes: 'AFR', 'AMR', 'EAS', 'EUR', and 'SAS'. |
retrieve_LD('6', 'rs9349379', 'AFR')retrieve_LD('6', 'rs9349379', 'AFR')