IndexError: list index out of range with relatedness_v1.py
1
0
Entering edit mode
5.2 years ago
LTDavid ▴ 50

I'm running python code relatedness_v1.py which takes as input an IBD file and produces a relatedness matrix. When I run the code, I get an IndexError that I don't understand how to fix. To get the relatedness_v1.py code, visit this link http://faculty.washington.edu/sguy/ibd_relatedness.html. (I also needed to add () around the print parameter in the code for 3 lines.)

The command format is as follows:

zcat myibdfile.ibd.gz | python relatedness_v1.py mapfile cmthresh [vcfhead=myfile.vcf[.gz]] [kinship] [lower] [nofill] > outfile

Parameter cmthresh is the minimum length in cMs to be included in the relatedness matrix results. "Typical choices for this parameter would be 0 (no filtering), or 10 (focus on recent relatives)." The default for the [kinship] optional parameter is relatedness which is what I want.

I ran the code on the results of just chromosome 1 as follows:

zcat PhasedB4chrom1.ibd.gz | python relatedness_v1.py plink.chr1.GRCh37.map 2 lower nofill > PhasedB4chrom1.relatedness

I get the following error:

Traceback (most recent call last):
  File "relatedness_v1.py", line 88, in <module>
    length = float(bits[8])
IndexError: list index out of range

I tried increasing the bits but I really don't know what this error is referring to or what element it may be telling me that is missing. I get the same error when I use the full IBD file and complete map (as in, not reducing it to just chromosome 1).

I'm using Ubuntu 18.04.3 LTS.

python relatedness_v1 index error • 2.6k views
ADD COMMENT
1
Entering edit mode

it simply means the list 'bits' do not has the 9th element.

ADD REPLY
0
Entering edit mode
4.2 years ago
larryhems • 0

This error basically means you are trying to access a value at a List index which is out of bounds i.e greater than the last index of the list or less than the least index in the list. So the first element is 0, second is 1, so on. So if there are n elements in a python list, the last element is n-1 . If you try to access the empty or None element by pointing available index of the list, then you will get the "List index out of range " error. To solve this error, you should make sure that you're not trying to access a non-existent item in a list.

ADD COMMENT

Login before adding your answer.

Traffic: 1392 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6