omerwe / polyfun

PolyFun (POLYgenic FUNctionally-informed fine-mapping)
MIT License
88 stars 22 forks source link

Assertion Error when using functional susie fine mappping #116

Closed dietina closed 9 months ago

dietina commented 2 years ago

Hi Omer,

Can I know if we have some advice on how to fix this AssertionError ? :

Traceback (most recent call last): File "/filepath/finemapper.py", line 1262, in residual_var=args.susie_resvar, residual_var_init=args.susie_resvar_init, hess_resvar=args.susie_resvar_hess) File "/filepath/finemapper.py", line 743, in finemap assert np.isclose(prior_weights.sum(), 1) AssertionError

I used functional susie finemapping, and this issue happens in some certain CHRs, for example, CHR6 and CHR1, but it worked for CHR2 and CHR5. I have not encountered the issue when I ran non-functional susie finemapping for all CHRs(1-22).

Any advice would be appreciated! Thank you in advance Omer.

omerwe commented 2 years ago

Hi @dietina, I would need more information to help reproduce this... Can you run the example pipeline without an error? If yes, can you please prepare a short reproducible example that I can look at?

dietina commented 2 years ago

Thank you Omer! Yes I can run the pipeline code, and I am only having this issue on CHR 1, 6 and 11 in my real dataset. Other CHRs worked perfectly fine. I tried individual command (paste from .jobs txt) using Python command, however it gave me the same Assertation Error.

Can I know if I can send the data to your email?

Thank you!

omerwe commented 2 years ago

@dietina, you can send example data to omer.we@gmail.com. I suspect that this is somehow related to long-range LD regions: Both chromosomes 6 and 11 have such regions (as well as chromosome 8). However, I'm not aware of any long-range LD regions for chromosome 1...

liqingbioinfo commented 2 years ago

May I know the follow-ups for this issue? I encountered the same problem for chromosome 6. Is there any way to fix it?

omerwe commented 2 years ago

@liqingbioinfo please feel free to send me a reproducible example, and I'll try looking into it

dietina commented 2 years ago

Hi Omer and Liqing, sorry I was not able to login during the past days. This issue has not been fixed. I will come up with the example and send this to Omer. I am sorry for the delay. Can I know if there is any updates that may help with the issue? Thank you! @omerwe @liqingbioinfo

omerwe commented 2 years ago

Sorry, I can't do anything until I have a reproducible example in hand...

keyrunad commented 1 year ago

I have the same error for the job below:

python3 finemapper.py --chr 1 --geno ../1000G_EUR_Phase3_plink/1000G.EUR.QC.1 --start 140000001 --end 143000001 --out ../outputs/polyfun_all.chr1.140000001_143000001.gz --method susie --sumstats ../polyfun_sumstats --n 321498 --memory 1 --max-num-causal 5 --allow-missing

The reason seems to be df_sumstats_locus not having any rows except the header causing prior_weights at line 749 of finemapper.py to be empty and its sum to be 0. Happy to provide any other details if needed. Thanks in advance for all your help!

omerwe commented 1 year ago

@keyrunad thanks for looking into this. I updated the code to verify that df_sumstats_locus is not empty, which should at least print a more relevant error message (can you please git pull and make sure that it does)?

However, I still don't know where the error is coming from. I suspect that it's because the SNPs in the LD file and in the sumstats file are inconsistent, but I can't say more until I see a reproducible example, or at least a snapshot of the relevant files. If you can send these to me (see my email address at previous messages in this thread) that would be great.

noeri-mohamed-hoesein commented 11 months ago

Hi Omer, I also seem to be encountering a similar error with functional susie fine mapping:

Mapping files:   0%|          | 0/3 [00:00<?, ?it/s]
Mapping files:  33%|███▎      | 1/3 [00:04<00:09,  4.84s/it]
Mapping files:  67%|██████▋   | 2/3 [00:05<00:02,  2.25s/it]
Mapping files: 100%|██████████| 3/3 [00:06<00:00,  1.82s/it]
Mapping files: 100%|██████████| 3/3 [00:06<00:00,  2.19s/it]

  0%|          | 0/1 [00:00<?, ?it/s]
100%|██████████| 1/1 [00:04<00:00,  4.97s/it]
100%|██████████| 1/1 [00:04<00:00,  4.97s/it]
Traceback (most recent call last):
  File "/.../software/polyfun/finemapper.py", line 1275, in <module>
    df_finemap = finemap_obj.finemap(locus_start=args.start, locus_end=args.end, num_causal_snps=args.max_num_causal,
  File "/.../software/polyfun/finemapper.py", line 755, in finemap
    assert np.isclose(prior_weights.sum(), 1)
AssertionError

This is the command I'm using:

python /.../polyfun/finemapper.py \
    --geno /LD_reference_AFR_chr5 \
    --sumstats /.../polyfun.snpvar.men.afr.out \
    --n 1709 \
    --chr 5 \
    --start 75935061 \
    --end 76217073 \
    --method susie \
    --max-num-causal 10 \
    --cache-dir /.../LD_cache \
    --out /.../SuSiE_output/finemap.men.afr.5.7593506.76217073.L10.gz \
    --allow-missing \
    --allow-swapped-indel-alleles

But it only keeps happening in certain regions of chr 6 and chr 5. Do you have any advice on how I can fix this?

omerwe commented 10 months ago

As I wrote in the past, I can't fix this unless someone can send me a reproducible example, sorry...

noeri-mohamed-hoesein commented 10 months ago

If this email omer.we@gmail.com is still in use I can send you the data with which I got this error

omerwe commented 10 months ago

sure