khramts / assocplots

MIT License
32 stars 14 forks source link

Index Error #3

Open nnekaede opened 6 years ago

nnekaede commented 6 years ago

My data looks a little different than the one from the tutorial. I converted it from a pandas DataFrame to a NumPy array using this line of code: # convert dataframe to numpy array for assocplots manhattan_plot_data = manhattan_plot_df.values

My data looks like such when it is a np array: [['Y' 15016019.0 'ENSG00000000419' 0.11661291909180488] ['Y' 15016019.0 'ENSG00000000457' 0.3375253528924895] ['Y' 15016019.0 'ENSG00000000938' 0.7934988001982753] ... ['Y' 15016019.0 'ENSG00000107929' 0.0015774481443468435] ['Y' 15016019.0 'ENSG00000184743' 0.024884285526804023] ['Y' 15016019.0 'ENSG00000169895' 0.0021853699533324845]]

When I run this line of code: manhattan_plot_data['f3'], manhattan_plot_data['f1'], manhattan_plot_data['f0'].astype(str)

I get the following error:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-136-1ae52f7f6bbe> in <module>()
      1 ## create plot
----> 2 manhattan (manhattan_plot_data['f3'], manhattan_plot_data['f1'], manhattan_plot_data['f0'].astype(str), '70 Individuals',
      3                type='single',
      4                chrs_plot=[str(i) for i in range(1,23)],
      5                chrs_names=chrs_names,

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Could you please tell me what I am doing wrong?

khramts commented 6 years ago

From the data you showed I am not sure if this is only for "Y" or you have more elements in column ['f0']. If it is only for "Y", you can write "chrs_plot=['Y']", or if there are other elements in that list you can write "chrs_plot=np.unique(manhattan_plot_data['f0'].astype(str))" (line 4).