Skip to content

Commit c7b0745

Browse files
authored
LDpred2.R: if --merge-by-rsid is used, ignore --col-bp <arg> (#193)
* LDpred2.R: if `--merge-by-rsid` option is used, ignore `--col-bp` arg Fixes #191 * should check for NULL, not NA w. argparser * --merge-by-rsid should be boolean flag
1 parent 2877fc7 commit c7b0745

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ If MD5 sum is not listed for a certain release then it means that the container
3939

4040
* Miscellaneous goes here
4141

42+
## [1.3.6] - 2023-08-17
43+
44+
### Fixed
45+
46+
* Ignore LDpred2 `--col-bp <column>` arg in case `--merge-by-rsid` is used
47+
4248
## [1.3.5] - 2023-08-17
4349

4450
### Updated

scripts/pgs/LDpred2/ldpred2.R

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ par <- add_argument(par, "--col-chr", help="CHR number column", default="CHR", n
3434
par <- add_argument(par, "--col-snp-id", help="SNP ID (RSID) column", default="SNP", nargs=1)
3535
par <- add_argument(par, "--col-A1", help="Effective allele column", default="A1", nargs=1)
3636
par <- add_argument(par, "--col-A2", help="Noneffective allele column", default="A2", nargs=1)
37-
par <- add_argument(par, "--col-bp", help="SNP position column", default="BP", nargs=1)
37+
par <- add_argument(par, "--col-bp", help="SNP position column. Will be ignored if --merge-by-rsid flag is used", default="BP", nargs=1)
3838
par <- add_argument(par, "--col-stat", help="Effect estimate column", default="BETA", nargs=1)
3939
par <- add_argument(par, "--col-stat-se", help="Effect estimate standard error column", default="SE", nargs=1)
4040
par <- add_argument(par, "--col-pvalue", help="P-value column", default="P", nargs=1)
@@ -52,7 +52,7 @@ par <- add_argument(par, "--hyper-p-max", help="Maximum (<1) of hyperparameter p
5252
par <- add_argument(par, "--ldpred-mode", help='Ether "auto" or "inf" (infinitesimal)', default="inf")
5353
par <- add_argument(par, "--cores", help="Number of CPU cores to use, otherwise use the available number of cores minus 1", default=nb_cores())
5454
par <- add_argument(par, '--set-seed', help="Set a seed for reproducibility", nargs=1)
55-
par <- add_argument(par, "--merge-by-rsid", help="Merge using rsid (the default is to merge by chr:bp:a1:a2 codes)", nargs=0)
55+
par <- add_argument(par, "--merge-by-rsid", help="Merge using rsid (the default is to merge by chr:bp:a1:a2 codes).", flag=TRUE)
5656

5757
parsed <- parse_args(par)
5858

@@ -86,7 +86,14 @@ colStat <- parsed$col_stat
8686
colStatSE <- parsed$col_stat_se
8787
colPValue <- parsed$col_pvalue
8888
colN <- parsed$col_n
89-
mergeByRsid <- !is.na(parsed$merge_by_rsid)
89+
mergeByRsid <- parsed$merge_by_rsid
90+
91+
# unset colBP in case of merging by rsid
92+
if (mergeByRsid) {
93+
cat(paste('The --merge-by-rsid flag is used; --col-bp', colBP, 'will be ignored\n'))
94+
colBP <- NULL
95+
}
96+
9097
# Polygenic score
9198
nameScore <- parsed$name_score
9299
# If the PGS is assigned a name, the diagnostic plot (auto mode only)
@@ -113,8 +120,13 @@ setSeed <- parsed$set_seed
113120

114121
# These vectors are used to convert headers in the sumstat files to those
115122
# used by bigsnpr
116-
colSumstatsOld <- c( colChr, colSNPID, colBP, colA1, colA2, colStat, colStatSE)
117-
colSumstatToGeno <- c("chr", "rsid", "pos", "a1", "a0", "beta", "beta_se")
123+
if (mergeByRsid) {
124+
colSumstatsOld <- c(colChr, colSNPID, colA1, colA2, colStat, colStatSE)
125+
colSumstatToGeno <- c("chr", "rsid", "a1", "a0", "beta", "beta_se")
126+
} else {
127+
colSumstatsOld <- c(colChr, colSNPID, colBP, colA1, colA2, colStat, colStatSE)
128+
colSumstatToGeno <- c("chr", "rsid", "pos", "a1", "a0", "beta", "beta_se")
129+
}
118130

119131
# If the user has requested to merge scores to an existing output file
120132
if (fileOutputMerge) {

tests/test_LDpred2/scripts/extended.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
LDP="$RSCRIPT $DIR_SCRIPTS/ldpred2.R --file-keep-snps $fileKeepSNPS \
22
--merge-by-rsid \
33
--col-stat beta --col-stat-se beta_se \
4-
--col-snp-id rsid --col-bp pos --col-A1 a1 --col-A2 a0 \
4+
--col-snp-id rsid --col-bp ignored --col-A1 a1 --col-A2 a0 \
55
--out ${fileOut}_imputed.inf"
66

77
# Create sumstats with characters in chromosome column
@@ -36,14 +36,14 @@ if [ $? -eq 1 ]; then echo "$dump"; exit; fi
3636
LDP="$RSCRIPT $DIR_SCRIPTS/ldpred2.R --file-keep-snps $fileKeepSNPS \
3737
--merge-by-rsid \
3838
--col-stat beta --col-stat-se beta_se \
39-
--col-snp-id rsid --col-chr Chr --col-bp pos --col-A1 a0 --col-A2 a1 \
39+
--col-snp-id rsid --col-chr Chr --col-bp ignored --col-A1 a0 --col-A2 a1 \
4040
--geno-file-rds $fileOutputSNPR --sumstats $fileInputSumStats"
4141

42-
echo "TEST error: Bad ldpred mode"
42+
echo "Test error: Bad ldpred mode"
4343
dump=$( { $LDP --ldpred-mode infinite --out $fileOut.inf; } 2>&1 )
4444
if [ $? -eq 0 ]; then echo "No error received"; exit; fi
4545

46-
echo "TEST error: Bad imputation mode"
46+
echo "Test error: Bad imputation mode"
4747
dump=$( { $LDP --ldpred-mode inf --geno-impute bad-mode --out $fileOut.inf; } 2>&1 )
4848
if [ $? -eq 0 ]; then echo "No error received"; exit; fi
4949

version/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
_MINOR = "3"
33
# On main and in a nightly release the patch should be one ahead of the last
44
# released build.
5-
_PATCH = "5"
5+
_PATCH = "6"
66
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
77
# https://semver.org/#is-v123-a-semantic-version for the semantics.
88
_SUFFIX = ""

0 commit comments

Comments
 (0)