omerwe / polyfun

PolyFun (POLYgenic FUNctionally-informed fine-mapping)
MIT License
85 stars 21 forks source link

Expose SuSiE arg max_iter as --susie-max-iter #85

Closed jdblischak closed 2 years ago

jdblischak commented 2 years ago

I'd like to be able to increase the max number of iterations because I sometimes get warnings that SuSiE failed to converge after the default of 100 iterations.

Testing

I tested this new flag with the example from test_polyfun.py, which takes 5 iterations to converge.

# New flag has no effect when it is equal to or above the required number of iterations
python finemapper.py \
  --geno example_data/chr1 \
  --sumstats example_data/chr1.finemap_sumstats.txt.gz \
  --n 383290 \
  --chr 1 \
  --start 46000001 \
  --end 49000001 \
  --method susie \
  --max-num-causal 5 \
  --out /tmp/finemap.1.46000001.49000001.gz \
  --threads 1 \
  --verbose \
  --susie-max-iter 5

# Confirmed it is being passed to SuSiE by triggering the warning
python finemapper.py \
  --geno example_data/chr1 \
  --sumstats example_data/chr1.finemap_sumstats.txt.gz \
  --n 383290 \
  --chr 1 \
  --start 46000001 \
  --end 49000001 \
  --method susie \
  --max-num-causal 5 \
  --out /tmp/finemap.1.46000001.49000001.gz \
  --threads 1 \
  --verbose \
  --susie-max-iter 4

[WARNING]  R[write to console]: Warning message:

[WARNING]  R[write to console]: In (function (bhat, shat, R, n, var_y, XtX, Xty, yty, X_colmeans = NA,  :
[WARNING]  R[write to console]:

[WARNING]  R[write to console]:  IBSS algorithm did not converge in 4 iterations!
                  Please check consistency between summary statistics and LD matrix.
                  See https://stephenslab.github.io/susieR/articles/susierss_diagnostic.html

# New flag has no effect on FINEMAP
python finemapper.py \
  --geno example_data/chr1 \
  --sumstats example_data/chr1.finemap_sumstats.txt.gz \
  --n 383290 \
  --chr 1 \
  --start 46000001 \
  --end 49000001 \
  --method finemap \
  --finemap-exe <path-to-finemap-exe> \
  --max-num-causal 5 \
  --out /tmp/finemap.1.46000001.49000001.gz \
  --threads 1 \
  --verbose \
  --susie-max-iter 4
jdblischak commented 2 years ago

Also I confirmed that this new flag is backwards compatible with susieR 0.8.0 because susie_bhat() also accepts ... and passes them to susie_ss() (and the default max_iter was also 100).

https://github.com/stephenslab/susieR/blob/0.8.0/R/susie_ss.R#L261

omerwe commented 2 years ago

Thanks @jdblischak, great idea!