polyfun icon indicating copy to clipboard operation
polyfun copied to clipboard

Assertion Error when using functional susie fine mappping

Open dietina opened this issue 2 years ago • 7 comments

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.

dietina avatar Jul 12 '22 20:07 dietina

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?

omerwe avatar Jul 13 '22 14:07 omerwe

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!

dietina avatar Jul 14 '22 14:07 dietina

@dietina, you can send example data to [email protected]. 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...

omerwe avatar Jul 14 '22 19:07 omerwe

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

liqingbioinfo avatar Jul 26 '22 00:07 liqingbioinfo

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

omerwe avatar Jul 26 '22 13:07 omerwe

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

dietina avatar Jul 28 '22 16:07 dietina

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

omerwe avatar Jul 30 '22 14:07 omerwe

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!

keyrunad avatar Dec 15 '22 14:12 keyrunad

@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.

omerwe avatar Dec 20 '22 09:12 omerwe

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?

noeri-mohamed-hoesein avatar Dec 04 '23 14:12 noeri-mohamed-hoesein

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

omerwe avatar Dec 08 '23 11:12 omerwe

If this email [email protected] is still in use I can send you the data with which I got this error

noeri-mohamed-hoesein avatar Dec 08 '23 11:12 noeri-mohamed-hoesein

sure

omerwe avatar Dec 10 '23 21:12 omerwe