Skip to content

Commit aadcdb9

Browse files
authored
Merge pull request #59 from uclahs-cds/nzeltser-cran-fixes
cran fixes
2 parents 00c2446 + 9045e5b commit aadcdb9

15 files changed

+177
-138
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Title: Utilities for the Application of a Polygenic Score to a VCF
44
Version: 1.0.0
55
Authors@R: c(
66
person('Paul', 'Boutros', role = 'cre', email = '[email protected]'),
7-
person('Nicole', 'Zeltser', role = 'aut', comment = c(ORCID = '000-0001-7246-2771')),
7+
person('Nicole', 'Zeltser', role = 'aut', comment = c(ORCID = '0000-0001-7246-2771')),
88
person('Rachel', 'Dang', role = 'ctb'))
99
Description: This tool is intended to simply and transparently parse
1010
genotype/dosage data from an input VCF, match genotype coordinates

NAMESPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ importFrom(
3535

3636
export(
3737
apply.polygenic.score,
38+
combine.pgs.bed,
39+
combine.vcf.with.pgs,
3840
convert.alleles.to.pgs.dosage,
3941
convert.allele.frequency.to.dosage,
4042
convert.pgs.to.bed,
4143
format.chromosome.notation,
4244
get.pgs.percentiles,
4345
import.pgs.weight.file,
4446
import.vcf,
45-
merge.pgs.bed,
46-
merge.vcf.with.pgs,
4747
parse.pgs.input.header,
4848
create.pgs.density.plot,
4949
create.pgs.rank.plot,

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# ApplyPolygenicScore Unreleased
2+
3+
## Changed
4+
* Renamed functions starting with reserved vocabulary for S3 generic methods merge. -> combine.
5+
16
# ApplyPolygenicScore 1.0.0 (2024-07-25)
27

38
* First release

R/apply-pgs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ apply.polygenic.score <- function(
278278
### End Input Validation ###
279279

280280
# merge VCF and PGS data
281-
merged.vcf.with.pgs.data <- merge.vcf.with.pgs(
281+
merged.vcf.with.pgs.data <- combine.vcf.with.pgs(
282282
vcf.data = vcf.data,
283283
pgs.weight.data = pgs.weight.data
284284
)$merged.vcf.with.pgs.data;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @title Merge VCF with PGS
1+
#' @title Combine VCF with PGS
22
#' @description Match PGS SNPs to corresponding VCF information by genomic coordinates using a merge operation.
33
#' @param vcf.data A data.frame containing VCF data. Required columns: \code{CHROM, POS}.
44
#' @param pgs.weight.data A data.frame containing PGS data. Required columns: \code{CHROM, POS}.
@@ -26,12 +26,12 @@
2626
#' );
2727
#' pgs.import <- import.pgs.weight.file(pgs.weight.path);
2828
#'
29-
#' merge.data <- merge.vcf.with.pgs(
29+
#' merge.data <- combine.vcf.with.pgs(
3030
#' vcf.data = vcf.import$dat,
3131
#' pgs.weight.data = pgs.import$pgs.weight.data
3232
#' );
3333
#' @export
34-
merge.vcf.with.pgs <- function(vcf.data, pgs.weight.data) {
34+
combine.vcf.with.pgs <- function(vcf.data, pgs.weight.data) {
3535

3636
# check that inputs are data.frames
3737
if (!is.data.frame(vcf.data)) {

R/convert-pgs-to-bed.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ convert.pgs.to.bed <- function(pgs.weight.data, chr.prefix = TRUE, numeric.sex.c
7878
return(pgs.bed);
7979
}
8080

81-
#' @title Merge PGS BED files
81+
#' @title Combine PGS BED files
8282
#' @description Merge overlapping PGS coordinates in multiple BED files.
8383
#' @param pgs.bed.list A named list of data.frames containing PGS coordinates in BED format.
8484
#' @param add.annotation.data A logical indicating whether an additional annotation data column should be added to the annotation column.
@@ -99,9 +99,9 @@ convert.pgs.to.bed <- function(pgs.weight.data, chr.prefix = TRUE, numeric.sex.c
9999
#' annotation = c('d', 'e', 'f')
100100
#' );
101101
#' bed.input <- list(bed1 = bed1, bed2 = bed2);
102-
#' merge.pgs.bed(bed.input);
102+
#' combine.pgs.bed(bed.input);
103103
#' @export
104-
merge.pgs.bed <- function(pgs.bed.list, add.annotation.data = FALSE, annotation.column.index = 4, slop = 0) {
104+
combine.pgs.bed <- function(pgs.bed.list, add.annotation.data = FALSE, annotation.column.index = 4, slop = 0) {
105105

106106
# check that pgs.bed.list is a named list
107107
if (!is.list(pgs.bed.list) | is.null(names(pgs.bed.list))) {

R/plot-pgs.R

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,34 +71,45 @@ split.pgs.by.phenotype <- function(pgs, phenotype.data) {
7171
#' @param border.padding numeric padding for plot borders
7272
#' @return If no output directory is provided, a multipanel lattice plot object is returned, otherwise a plot is written to the indicated path and \code{NULL} is returned.
7373
#' @examples
74-
#' set.seed(200);
74+
#' set.seed(100);
7575
#' pgs.data <- data.frame(
76-
#' PGS = rnorm(200, 0, 1)
76+
#' PGS = rnorm(100, 0, 1)
7777
#' );
7878
#' temp.dir <- tempdir();
7979
#'
8080
#' # Basic Plot
81-
#' create.pgs.density.plot(pgs.data, output.dir = temp.dir, filename.prefix = 'basic-plot');
81+
#' create.pgs.density.plot(
82+
#' pgs.data,
83+
#' output.dir = temp.dir,
84+
#' filename.prefix = 'basic-plot',
85+
#' width = 6,
86+
#' height = 6
87+
#' );
8288
#'
8389
#' # Plot multiple PGS outputs
84-
#' pgs.data$PGS.with.normalized.missing <- rnorm(200, 1, 1);
85-
#' create.pgs.density.plot(pgs.data, output.dir = temp.dir);
90+
#' pgs.data$PGS.with.normalized.missing <- rnorm(100, 1, 1);
91+
#' \donttest{create.pgs.density.plot(pgs.data, output.dir = temp.dir);}
8692
#'
8793
#' # Plot phenotype categories
88-
#' pgs.data$sex <- sample(c('male', 'female', 200, replace = TRUE));
94+
#' \donttest{
95+
#' pgs.data$sex <- sample(c('male', 'female', 100, replace = TRUE));
8996
#' create.pgs.density.plot(
90-
#' pgs.data, output.dir = temp.dir,
97+
#' pgs.data,
98+
#' output.dir = temp.dir,
9199
#' filename.prefix = 'multiple-pgs',
92100
#' phenotype.columns = 'sex'
93101
#' );
94-
#'
102+
#'}
95103
#' # Plot multiple phenotypes
96-
#' pgs.data$letters <- sample(letters[1:5], 200, replace = TRUE);
104+
#' \donttest{
105+
#' pgs.data$letters <- sample(letters[1:5], 100, replace = TRUE);
97106
#' create.pgs.density.plot(
98-
#' pgs.data, output.dir = temp.dir,
107+
#' pgs.data,
108+
#' output.dir = temp.dir,
99109
#' filename.prefix = 'multiple-phenotypes',
100110
#' phenotype.columns = c('sex', 'letters')
101111
#' );
112+
#' }
102113
#' @export
103114
create.pgs.density.plot <- function(
104115
pgs.data,
@@ -370,11 +381,11 @@ create.pgs.density.plot <- function(
370381
#' @param border.padding numeric padding for plot borders
371382
#' @return If no output directory is provided, a multipanel lattice plot object is returned, otherwise a plot is written to the indicated path and \code{NULL} is returned.
372383
#' @examples
373-
#' set.seed(200);
384+
#' set.seed(100);
374385
#'
375386
#' pgs.data <- data.frame(
376-
#' PGS = rnorm(200, 0, 1),
377-
#' continuous.phenotype = rnorm(200, 2, 1)
387+
#' PGS = rnorm(100, 0, 1),
388+
#' continuous.phenotype = rnorm(100, 2, 1)
378389
#' );
379390
#' temp.dir <- tempdir();
380391
#'
@@ -383,26 +394,32 @@ create.pgs.density.plot <- function(
383394
#' pgs.data,
384395
#' output.dir = temp.dir,
385396
#' filename.prefix = 'basic-plot',
386-
#' phenotype.columns = 'continuous.phenotype'
397+
#' phenotype.columns = 'continuous.phenotype',
398+
#' width = 6,
399+
#' height = 6
387400
#' );
388401
#'
389402
#' # Plot multiple PGS outputs
390-
#' pgs.data$PGS.with.normalized.missing <- rnorm(200, 1, 1);
403+
#' \donttest{
404+
#' pgs.data$PGS.with.normalized.missing <- rnorm(100, 1, 1);
391405
#' create.pgs.with.continuous.phenotype.plot(
392406
#' pgs.data,
393407
#' output.dir = temp.dir,
394408
#' filename.prefix = 'multiple-pgs',
395409
#' phenotype.columns = 'continuous.phenotype'
396410
#' );
411+
#'}
397412
#'
398413
#' # Plot multiple phenotypes
399-
#' pgs.data$continuous.phenotype2 <- rnorm(200, 10, 1);
414+
#' \donttest{
415+
#' pgs.data$continuous.phenotype2 <- rnorm(100, 10, 1);
400416
#' create.pgs.with.continuous.phenotype.plot(
401417
#' pgs.data,
402418
#' output.dir = temp.dir,
403419
#' filename.prefix = 'multiple-phenotypes',
404420
#' phenotype.columns = c('continuous.phenotype', 'continuous.phenotype2')
405421
#' );
422+
#' }
406423
#' @export
407424
create.pgs.with.continuous.phenotype.plot <- function(
408425
pgs.data,

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ If you wish to apply a PGS to a cohort, we recommend that genotypes for the whol
5757
We recommend starting by filtering your input VCF for just the variants in your PGS weight files. Several software tools are available to do this, and most all require a coordinate BED file. A description of BED format can be found [here](https://bedtools.readthedocs.io/en/latest/content/general-usage.html).
5858

5959
The function `import.pgs.weight.file` can be used to import your PGS weight files into R.
60-
The functions `convert.pgs.to.bed` and `merge.pgs.bed` can be used to make the conversion, and merge several BED dataframes into one, respectively.
60+
The functions `convert.pgs.to.bed` and `combine.pgs.bed` can be used to make the conversion, and merge several BED dataframes into one, respectively.
6161

6262
2. Import your VCF file.
6363

@@ -67,7 +67,7 @@ If you wish to apply a PGS to a cohort, we recommend that genotypes for the whol
6767
3. Apply your PGS.
6868

6969
Provide your imported VCF and PGS weight files to `apply.polygenic.score`. It's as simple as that.
70-
Under the hood, this function begins by calling `merge.vcf.with.pgs`. The merge function also outputs a list of variants in your PGS that could not be found in your VCF data, which you can obtain by calling the function independently.
70+
Under the hood, this function begins by calling `combine.vcf.with.pgs`. The merge function also outputs a list of variants in your PGS that could not be found in your VCF data, which you can obtain by calling the function independently.
7171
`apply.polygenic.score` outputs lots of useful information along with the score and provides various customizeable options, such as methods for handling missing sites (see [this discussion](https://github.com/uclahs-cds/package-ApplyPolygenicScore/discussions/17) for more) and basic analyses with phenotype data.
7272

7373
4. Create summary plots.
Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)