Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version passes R CMD check #14

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
Package: locuscomparer
Type: Package
Title: locuscomparer: Visualization of GWAS-QTL Colocalization Events
Version: 1.0.0
Author@R: c(
person('Boxiang','Liu', email = '[email protected]', role = c('aut','cre')),
person('Michael','Gloudemans', email = '[email protected]', role = c('ctb'),
person('Stephen', 'Montgomery', email = '[email protected]', role = c('ctb')))
Version: 1.0.0-3
Authors@R: c( person('Boxiang','Liu', email = '[email protected]',
role = c('aut','cre')), person('Michael','Gloudemans', email =
'[email protected]', role = c('ctb')), person('Stephen',
'Montgomery', email = '[email protected]', role =
c('ctb')))
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).
License: GPL-3
Encoding: UTF-8
LazyData: true
Imports: cowplot (>= 0.6.1),
ggplot2 (>= 2.2.1),
ggrepel (>= 0.6.5),
stringr (>= 1.2.0),
DBI (>= 1.0.0),
RMySQL (>= 0.10.17),
rlang (>= 0.3.1)
RoxygenNote: 6.1.1
Depends: R (>= 3.6)
Imports: cowplot (>= 0.6.1), ggplot2 (>= 2.2.1), ggrepel (>= 0.6.5),
stringr (>= 1.2.0), DBI (>= 1.0.0), RMySQL (>= 0.10.17), rlang
(>= 0.3.1)
RoxygenNote: 7.1.0
Suggests: testthat
NeedsCompilation: no
Packaged: 2020-05-06 17:38:45 UTC; stvjc
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(add_label)
export(assign_color)
export(get_lead_snp)
export(get_position)
Expand Down
4 changes: 4 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#' information on AWS server for locuscompare
#' @docType data
#' @format simple data.frame
"config"
57 changes: 47 additions & 10 deletions R/locuscompare.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ read_metal=function(in_fn,marker_col='rsid',pval_col='pval'){
#' @examples
#' in_fn = system.file('extdata', 'gwas.tsv', package = 'locuscomparer')
#' d1 = read_metal(in_fn, marker_col = 'rsid', pval_col = 'pval')
#' genome = "hg19"
#' get_position(d1, genome)
#' @export
get_position=function(x, genome = c('hg19','hg38')){
Expand Down Expand Up @@ -118,8 +119,8 @@ retrieve_LD = function(chr,snp,population){
#' # 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')
#' d1 = read_metal(in_fn_2, marker_col = 'rsid', pval_col = 'pval')
#' in_fn_2 = system.file('extdata', 'eqtl.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)
#' @export
Expand All @@ -143,10 +144,15 @@ get_lead_snp = function(merged, snp = NULL){
#' @examples
#' # the data.frame merged comes from the example for `get_lead_snp()`.
#' # the data.frame ld comes from the example for `retrieve_LD()`.
#' 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', 'eqtl.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)
#' @export
assign_color=function(rsid,snp,ld){

ld = ld[ld$SNP_A==snp,]
ld$color = as.character(cut(ld$R2,breaks=c(0,0.2,0.4,0.6,0.8,1), labels=c('blue4','skyblue','darkgreen','orange','red'), include.lowest=TRUE))

Expand Down Expand Up @@ -174,7 +180,13 @@ assign_color=function(rsid,snp,ld){
#' this can also be a single string.
#' @examples
#' # The data.frame merged comes from the example for `get_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', 'eqtl.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')
#' @export
add_label = function(merged, snp){
merged$label = ifelse(merged$rsid %in% snp, merged$rsid, '')
return(merged)
Expand Down Expand Up @@ -202,11 +214,19 @@ add_label = function(merged, snp){
#' @examples
#' # The data.frame `merged` comes from the example of `add_label()`.
#' # The data.frame `color` comes from the example of `assign_color()`.
#' 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', 'eqtl.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)
#' snp = 'rs9349379'
#' shape = ifelse(merged$rsid == snp, 23, 21)
#' names(shape) = merged$rsid
#' size = ifelse(merged$rsid == snp, 3, 2)
#' names(size) = merged$rsid
#' ld = retrieve_LD('6', 'rs9349379', 'AFR')
#' color = assign_color(rsid = merged$rsid, snp = 'rs9349379', ld)
#' merged = add_label(merged, snp)
#' make_scatterplot(merged, title1 = 'GWAS', title2 = 'eQTL', color, shape, size)
#' @export
make_scatterplot = function (merged, title1, title2, color, shape, size, legend = TRUE, legend_position = c('bottomright','topright','topleft')) {
Expand Down Expand Up @@ -262,15 +282,25 @@ make_scatterplot = function (merged, title1, title2, color, shape, size, legend
#' @param 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.
#' @examples
#' # The data.frame `d1` comes from the example of `read_metal()`,
#' # The data.frame `color` comes from the example of `assign_color()`.
#' \dontrun{ # clearly the function works but example setup is tricky
#' 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', 'eqtl.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)
#' snp = 'rs9349379'
#' merged = add_label(merged, snp)
#' d1 = add_label(d1, snp)
#' 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)
#' ld = retrieve_LD(chr, snp, "AFR")
#' color = assign_color(rsid = merged$rsid, snp = 'rs9349379', ld)
#' make_locuszoom(d1, title = 'GWAS', chr, color, shape, size)
#' }
#' @export
make_locuszoom=function(metal,title,chr,color,shape,size,ylab_linebreak=FALSE){

Expand Down Expand Up @@ -310,20 +340,26 @@ make_locuszoom=function(metal,title,chr,color,shape,size,ylab_linebreak=FALSE){
#' @param legend (boolean, optional) Should the legend be shown? Default: TRUE.
#' @param legend_position (string, optional) Either 'bottomright','topright', or 'topleft'. Default: 'bottomright'.
#' @param lz_ylab_linebreak (boolean, optional) Whether to break the line of y-axis of the locuszoom plot.
#' @param genome character(1) for get_position
#' If FALSE, the y-axis title and '-log10(p-value)'. will be on the same line. Default: FALSE.
#' @examples
#' # The data.frame `merged` comes from the example of `add_label()`.
#' # the data.frame `ld` comes from the example for `retrieve_LD()`.
#' 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', 'eqtl.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)
#' snp = 'rs9349379'
#' merged = add_label(merged, snp)
#' chr = '6'
#' ld = retrieve_LD(chr, snp, "AFR")
#' make_combined_plot(merged, 'GWAS', 'eQTL', ld, chr)
#' @export
make_combined_plot = function (merged, title1, title2, ld, chr, snp = NULL,
combine = TRUE, legend = TRUE,
legend_position = c('bottomright','topright','topleft'),
lz_ylab_linebreak=FALSE) {

lz_ylab_linebreak=FALSE, genome="hg19") {
snp = get_lead_snp(merged, snp)
# print(sprintf("INFO - %s", snp))

color = assign_color(merged$rsid, snp, ld)

shape = ifelse(merged$rsid == snp, 23, 21)
Expand All @@ -333,6 +369,7 @@ make_combined_plot = function (merged, title1, title2, ld, chr, snp = NULL,
names(size) = merged$rsid

merged = add_label(merged, snp)
if (!("pos" %in% names(merged))) merged = get_position(merged, genome)

p1 = make_scatterplot(merged, title1, title2, color,
shape, size, legend, legend_position)
Expand Down
5 changes: 5 additions & 0 deletions man/add_label.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/assign_color.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/config.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/get_lead_snp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/get_position.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions man/hello.Rd

This file was deleted.

22 changes: 17 additions & 5 deletions man/locuscompare.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions man/make_combined_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions man/make_locuszoom.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading