Skip to content

IndexError when running Elastic Net model in prediction tutorial #290

@1nessh

Description

@1nessh

Hi,

I'm trying to follow the Pyseer prediction tutorial, and after running the first step, I encountered an IndexError when fitting the Elastic Net Model.

Command

pyseer --vcf snps.vcf.gz --phenotypes resistances.pheno --wg enet \
--save-vars output/ma_snps --save-model penicillin.lasso --cpu 4 --alpha 1 > selected.txt

Error message

Fitting elastic net to top 67277 variants
Traceback (most recent call last):
  File "/Users/sanchezh/miniforge3/bin/pyseer", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/sanchezh/miniforge3/lib/python3.12/site-packages/pyseer/__main__.py", line 661, in main
    enet_betas = fit_enet(p, all_vars, cov, weights,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sanchezh/miniforge3/lib/python3.12/site-packages/pyseer/enet.py", line 173, in fit_enet
    enet_fit = cvglmnet(x = variants, y = p.values.astype('float64'), family = regression_type,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sanchezh/miniforge3/lib/python3.12/site-packages/glmnet_python/cvglmnet.py", line 244, in cvglmnet
    glmfit = glmnet(x = x, y = y, family = family, **options)    
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sanchezh/miniforge3/lib/python3.12/site-packages/glmnet_python/glmnet.py", line 454, in glmnet
    fit = lognet(x, is_sparse, irs, pcs, y, weights, offset, parm,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sanchezh/miniforge3/lib/python3.12/site-packages/glmnet_python/lognet.py", line 41, in lognet
    y = y[:, [1, 0]]
        ~^^^^^^^^^^^
IndexError: index 1 is out of bounds for axis 1 with size 1

Any ideas on what might be causing it?
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions