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

deimos.plot.stem(): KeyError with res object #21

Open
jessieolough opened this issue Apr 29, 2024 · 4 comments
Open

deimos.plot.stem(): KeyError with res object #21

jessieolough opened this issue Apr 29, 2024 · 4 comments

Comments

@jessieolough
Copy link

Hello,

I am trying to follow the DEIMoS documentation for the MS2 Extraction steps. At the end, where I have the final res object and I go to use the deimos.plot.stem() function, I get the following error message:

Traceback (most recent call last):
  File "C:\Users\jessieolough\AppData\Local\anaconda3\envs\deimos\Lib\site-packages\pandas\core\indexes\range.py", line 413, in get_loc
    return self._range.index(new_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: 61 is not in range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jessieolough\AppData\Local\anaconda3\envs\deimos\Lib\site-packages\pandas\core\indexing.py", line 1183, in __getitem__
    return self.obj._get_value(*key, takeable=self._takeable)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jessieolough\AppData\Local\anaconda3\envs\deimos\Lib\site-packages\pandas\core\frame.py", line 4221, in _get_value
    row = self.index.get_loc(index)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jessieolough\AppData\Local\anaconda3\envs\deimos\Lib\site-packages\pandas\core\indexes\range.py", line 415, in get_loc
    raise KeyError(key) from err
KeyError: 61

All the other preceding steps worked as expected and res is the same as the fragmentation spectra of the highest intensity MS1 feature table printed in the documentation.

Any help would be much appreciated.

Kind regards,
Jessica

@smcolby
Copy link
Contributor

smcolby commented May 9, 2024

Looks like the exact row indices of the output might not match. What is the first index you see in the output of cell 14? I.e.,
image

@jessieolough
Copy link
Author

Hi Sean,

Thanks for getting back. The output I get looks like this:
image

@smcolby
Copy link
Contributor

smcolby commented May 30, 2024

Yep, see how the data frame index starts at 58, not 61? So to select the top feature, you'd need to grab the row with index 58, i.e.:

deimos.plot.stem(np.array(res.loc[58, 'mz_ms2']),
                 np.array(res.loc[58, 'intensity_ms2']),
                 width=1)
plt.tight_layout()
plt.show()

Is this using the same underlying example data, or your own? I probably need to regenerate the documentation if the example data is no longer producing the same result.

@jessieolough
Copy link
Author

jessieolough commented Jun 18, 2024

Hi Sean,

Thanks! Ah yes, that fixed the issue. This is using the same underlying example data.

Kind regards,
Jess

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