comorment / containers

CoMorMent-Containers
https://www.comorment.uio.no
GNU General Public License v3.0
22 stars 9 forks source link

`LDpred2`: Crash with characters and integers in chromosome column #255

Open espenhgn opened 4 months ago

espenhgn commented 4 months ago

Problem reported by Siim, similar to #51, except that the order of `chr` <integer> and `chr` <character> is reverted.

I need to run the LDPred2 separately on all chromosomes (can add all the sumstats as final step manually) but get the following error:

8,358,512 variants to be matched.
Error in `vctrs::vec_in()`:
! Can't combine `chr` <integer> and `chr` <character>.
Backtrace:
     x
  1. +-bigsnpr::snp_match(...)
  2. | +-...[]
  3. | +-base::`[.data.frame`(...)
  4. | \-vctrs::vec_in(sumstats[, join_by[1:2]], info_snp[, join_by[1:2]])
  5. \-vctrs (local) `<fn>`()
  6.   \-vctrs::vec_default_ptype2(...)
  7.     +-base::withRestarts(...)
  8.     | \-base (local) withOneRestart(expr, restarts[[1L]])
  9.     |   \-base (local) doWithOneRestart(return(expr), restart)
 10.     \-vctrs::stop_incompatible_type(...)
 11.       \-vctrs:::stop_incompatible(...)
 12.         \-vctrs:::stop_vctrs(...)
 13.           \-rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))
Execution halted

Has anyone reported this on the updated version while using the .bgen files? Maybe I missed some instructions?

For clartity the run.sh has following content:

#!/bin/bash
#SBATCH --job-name=chr21  # job name
#SBATCH --output=SCF1_chr21_LDpred2.txt  # output
#SBATCH --error=SCF1_chr21.txt  # errors
#SBATCH --mail-type=END
#SBATCH --mail-type=FAIL
#SBATCH --[mail-user=user@domain.edu](mailto:mail-user=user@domain.edu)
#SBATCH --time=48:00:00  # walltime
#SBATCH --cpus-per-task=2  # number of CPUS for task
#SBATCH --mem-per-cpu=30GB
#SBATCH --partition=amd

module load any/singularity/3.7.3

# point to input/output files
export fileGeno=/GEN/4_latest_freeze/imputation_EstRef/hg38/EstBB_chr21.bgen
export fileGenoRDS=chr21.nomiss.rds
export fileSNPList=/COMOR/containers/scripts/pgs/LDpred2/Chr21_for_LDPred2.csv
export fileSumstats=/COMOR/containers/scripts/pgs/LDpred2/SCF_sumstats/SCF1_allBMI_regenie_forPRS.txt
export fileOut=SCF1_chr21
export colPheno=SCF1

# set environmental variables. Replace "<path/to/comorment>" with
# the full path to the folder containing cloned "containers" and "ldpred2_ref" repositories
export GENOMICS=/gpfs/space/GI/GV/EGCUT_data/genotype_data/GSA_arrays
export COMORMENT=/gpfs/space/GI/GV/Projects/PsychGen/CoMorMent
export SIF=$COMORMENT/containers/singularity
export REFERENCE=$COMORMENT/containers/reference
export LDPRED2_REF=$COMORMENT/ldpred2_ref
export SINGULARITY_BIND=$REFERENCE:/REF,${LDPRED2_REF}:/ldpred2_ref,$COMORMENT:/COMOR,$GENOMICS:/GEN

export RSCRIPT="singularity exec --home=$PWD:/home $SIF/r.sif Rscript"

# convert genotype to LDpred2 format
$RSCRIPT createBackingFile.R --file-input $fileGeno --file-output $fileGenoRDS --file-snp-list $fileSNPList

# Generate PGS usign LDPRED-inf
$RSCRIPT ldpred2.R \
 --genomic-build hg38 \
 --ldpred-mode inf \
 --col-stat BETA \
 --col-stat-se SE \
 --col-A1 EFFECT_ALLELE \
 --col-A2 OTHER_ALLELE \
 --col-chr CHR \
 --col-bp POS \
 --col-snp-id RSID \
 --stat-type BETA \
 --geno-file-rds $fileGenoRDS \
 --sumstats $fileSumstats \
 --out $fileOut.inf
github-actions[bot] commented 1 month ago

This issue appears to be stale due to non-activity