Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed #260

Open
ritawyt opened this issue Nov 6, 2023 · 2 comments

Comments

@ritawyt
Copy link

ritawyt commented Nov 6, 2023

I'm running this code and run into an index error:
treetime --tree /Users/ouotodou/Desktop/treeee.nex --dates /Users/ouotodou/Desktop/sampled_metadata.csv --aln /Users/ouotodou/Desktop/sampled_sequences.fasta

Attempting to parse dates...
Using column 'strain' as name. This needs match the taxon names in the tree!!
Using column 'date' as date.

0.00 -TreeAnc: set-up

0.13 -WARNING: character 0 is unknown. Treating it as missing information

0.13 -WARNING: character 1 is unknown. Treating it as missing information
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/treetime/treetime.py", line 57, in run
return self._run(**kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/treetime/treetime.py", line 215, in _run
self.optimize_tree(infer_gtr=infer_gtr,
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/treetime/treeanc.py", line 1356, in optimize_tree
self.optimize_branch_lengths_joint(store_old=False)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/treetime/treeanc.py", line 1157, in optimize_branch_lengths_joint
new_len = max(0,self.optimal_branch_length(node))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/treetime/treeanc.py", line 1202, in optimal_branch_length
return self.gtr.optimal_t_compressed(node.branch_state['pair'],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/treetime/gtr.py", line 854, in optimal_t_compressed
hamming_distance = np.sum(multiplicity[seq_pair[:,1]!=seq_pair[:,0]])/np.sum(multiplicity)
~~~~~~~~^^^^^
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

ERROR: too many indices for array: array is 1-dimensional, but 2 were indexed

ERROR in TreeTime.run: An error occurred which was not properly handled in TreeTime. If this error persists, please let us know by filing a new issue including the original command and the error above at: https://github.com/neherlab/treetime/issues

Has anyone encountered this error before and knows how to solve it? Thank you so much!

@ritawyt
Copy link
Author

ritawyt commented Nov 6, 2023

I'm using binary data, so the sequences are consist of 0s and 1s

@rneher
Copy link
Member

rneher commented Jan 22, 2024

Hi @ritawyt, sorry about the slow reply. this is difficult to debug without being able to run the command. Is this data you can share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants