AlexTISYoung / snipar

Imputation of parental genotypes, inference of sibling IBD segments, family based GWAS, and polygenic score analyses.
MIT License
23 stars 4 forks source link

IndexError: index 3 is out of bounds for axis 2 with size 3 #26

Closed GiulioCentorame closed 1 year ago

GiulioCentorame commented 1 year ago

Hi there, Thank you for writing this, I have been trying it and it's been working mostly well. I have encountered this error while trying to run impute.py:

$  impute.py --bgen /path/to/data.chr_@ --ibd /path/to/chr_@.ibd --king /path/to/king.kin0 --agesex /path/to/agesex.txt --threads 28 --out /path/to/out.@ --chr_range 1-22
2023-05-26 07:48:53,587 INFO impute - main: creating pedigree ...
2023-05-26 07:48:53,827 INFO preprocess_data - create_pedigree: loaded kinship file
2023-05-26 07:48:54,634 INFO preprocess_data - create_pedigree: loaded agesex file
2023-05-26 07:48:54,672 INFO preprocess_data - create_pedigree: creating age and sex dictionaries
2023-05-26 07:48:55,513 INFO preprocess_data - create_pedigree: dictionaries created
2023-05-26 07:48:55,514 INFO preprocess_data - create_pedigree: creating pedigree objects
2023-05-26 07:48:56,003 INFO impute - main: pedigree loaded.
2023-05-26 07:48:56,003 INFO impute - run_imputation: processing /path/to/data.chr_1,None
2023-05-26 07:48:56,003 INFO preprocess_data - prepare_data: For file /path/to/data.chr_1;None: Finding which chromosomes
2023-05-26 07:48:56,226 INFO preprocess_data - prepare_data: with chromosomes [1] initializing non_gts data
2023-05-26 07:48:56,226 INFO preprocess_data - prepare_data: with chromosomes [1] loading and filtering pedigree file ...
2023-05-26 07:48:56,910 INFO preprocess_data - prepare_data: with chromosomes [1] loading bim file ...
2023-05-26 07:48:56,910 INFO preprocess_data - prepare_data: with chromosomes [1] loading and transforming ibd file ...
2023-05-26 07:48:58,911 INFO preprocess_data - prepare_data: ibd loaded.
2023-05-26 07:48:58,911 INFO preprocess_data - prepare_data: with chromosomes ['1'] initializing non_gts data done ...
2023-05-26 07:48:58,994 INFO preprocess_data - prepare_gts: with chromosomes ['1'] initializing gts data with start=0 end=82
Traceback (most recent call last):
  File "/mnt/storage/home/my_username/scratch/.conda/envs/snipar/bin/impute.py", line 419, in <module>
    main(args)
  File "/mnt/storage/home/my_username/scratch/.conda/envs/snipar/bin/impute.py", line 313, in main
    run_imputation(args)
  File "/mnt/storage/home/my_username/scratch/.conda/envs/snipar/bin/impute.py", line 195, in run_imputation
    phased_gts, unphased_gts, iid_to_bed_index, pos, freqs, hdf5_output_dict = prepare_gts(phased_address, unphased_address, bim, pedigree_output, ped_ids, chromosomes, start, end, pcs, pc_ids, find_optimal_pc)
  File "/mnt/storage/home/my_username/scratch/.conda/envs/snipar/lib/python3.9/site-packages/snipar/imputation/preprocess_data.py", line 710, in prepare_gts
    phased_gts[probs[:,:,3] > 0.99, 1] = 0
IndexError: index 3 is out of bounds for axis 2 with size 3

I am using a subset of the original phased data (in .bgen) for the imputation, and I estimated the IBD segments on a separate set of genotyped data (with the same IDs). I tried to replicate this issue on the original files; unfortunately, they're too big to fit in memory. What am I doing wrong?

Thank you in advance and sorry if it's trivial!

GiulioCentorame commented 1 year ago

Just noticed that the starting files I was using did not have phase information for some reason, so that explains the error message

AlexTISYoung commented 1 year ago

Thanks, Guilio, let me know if you need any further assistance.