"list index out of range" during Network Preparation

20 views
Skip to first unread message

Joshua Cook

unread,
Oct 23, 2018, 9:31:04 AM10/23/18
to HotNet
Hello,

I am running into an error when trying to run makeNetworkFiles.py:

My code is:

num_cores=1
num_network_permutations=20
num_heat_permutations=20
beta=0.5

MAKENETWORKFILES=$FUNCTIONS_DIR/makeNetworkFiles.py

python $MAKENETWORKFILES
\
   
-e $input_dir/STRING_edge_list \
   
-i $input_dir/STRING_gene_index \
   
--network_name string \
   
--prefix string \
   
--beta $beta \
   
-o $output_dir/networks \
   
-np $num_network_permutations \
   
-c $num_cores

And the output is:

Creating PPR matrix for real network

--------------------------------------

Traceback (most recent call last):
 
File "/n/data2/bidmc/medicine/haigis/Cook/KrasComutation/Pathway/running_HotNet2/hotnet2/makeNetworkFiles.py", line 92, in <module>

    run
(get_parser().parse_args(sys.argv[1:]))

 
File "/n/data2/bidmc/medicine/haigis/Cook/KrasComutation/Pathway/running_HotNet2/hotnet2/makeNetworkFiles.py", line 65, in run

    save_diffusion_to_file
( HOTNET2, args.beta, args.gene_index_file, args.edgelist_file, pprfile, params=params)

 
File "/n/data2/bidmc/medicine/haigis/Cook/KrasComutation/Pathway/running_HotNet2/hotnet2/hotnet2/network.py", line 51, in save_diffusion_to_file

    G
= load_network_from_file( index_file, edge_file)

 
File "/n/data2/bidmc/medicine/haigis/Cook/KrasComutation/Pathway/running_HotNet2/hotnet2/hotnet2/network.py", line 88, in load_network_from_file

    indexToGene
= dict((int(arr[0]), arr[1]) for arr in arrs)

 
File "/n/data2/bidmc/medicine/haigis/Cook/KrasComutation/Pathway/running_HotNet2/hotnet2/hotnet2/network.py", line 88, in <genexpr>

    indexToGene
= dict((int(arr[0]), arr[1]) for arr in arrs)

IndexError: list index out of range

I have checked that the gene index file has unique IDs for each gene in the network. Also, the variables pointing to the input do point to the correct files. I can't think of what else would cause this error. I have previously successfully run the example paper commands and my own input before this, but now can't generate the network files.

Thank you for any help,
Josh Cook

matthe...@brown.edu

unread,
Oct 23, 2018, 9:37:17 AM10/23/18
to HotNet
Hi Josh,

I would check that each line of your gene-index file has two entries.  For example, if there is only one entry for a line, then that would cause this error.

Best,
Matt

Joshua Cook

unread,
Oct 23, 2018, 9:47:35 AM10/23/18
to HotNet
Hello Matt,

Thank you for getting back to me.

I check the gene index file and found no missing values. I also checked the edge list, and all of the values are >0.

I also tried running the script on 2 cores because all of my previous successful attempts were multi-core runs, but still got the same error.

Any other thoughts?


Thank you,
Josh Cook

matthe...@brown.edu

unread,
Oct 23, 2018, 9:56:27 AM10/23/18
to HotNet
Hi Josh,

Please try replacing this line in hotnet2/network.py

indexToGene = dict((int(arr[0]), arr[1]) for arr in arrs)

with these lines

indexToGene = dict()
for i, arr in enumerate(arrs):
    try:
        indexToGene[int(arr[0])] = arr[1]
    except:
        print 'Error on line {}: {}'.format(i+1, arr)

This change will identify lines in your input file that may cause this error and skip them.

Best,
Matt

Joshua Cook

unread,
Oct 23, 2018, 11:57:16 AM10/23/18
to HotNet
Hi Matt,

That did the trick! It was a missing value on one line of the gene index file. I'm not sure how I missed it before, but thank you for your help.

Thank you,
Josh Cook
Reply all
Reply to author
Forward
0 new messages