# Packages for mass spectrometry?

**URL:** <https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481>\
**Category:** Biology, Health, and Medicine\
**Created:** [July 22, 2020, 10:06am UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481 "2020-07-22T10:06:43Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugeleo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eugeleo/32/6440_2.png) [@Eugeleo](https://discourse.julialang.org/u/Eugeleo)\
**Post date:** [July 22, 2020, 10:06am UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/1 "2020-07-22T10:06:43Z")

</div>

My bachelor thesis concerns working mass spectrometry data; I’ll need to be able to load the spectra, visualise them, and most importantly, given a spectrum and a peptide fragment I’ll need to decide how likely it is that they match together. Also, I’m not that skilled in MS/MS yet, do there might be some other needs that I don’t foresee now.

Now, I’d very much love to do my work in Julia, but based on what I found on google, the state of mass spectrometry library ecosystem is much better with Python; I decided to ask here as a last resort, in case I’ve missed something (I’d be glad if that were the case).

So, with that said — what is the state of mass spectrometry libraries? Is there anybody doing mass spectrometry in Julia? Do you think my needs could be met with Julia?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [July 22, 2020, 12:51pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/2 "2020-07-22T12:51:11Z")

</div>

The only package I’ve built is  
[https://github.com/timholy/mzXML.jl](https://github.com/timholy/mzXML.jl)

It’s still got a REQUIRE file, so you can tell it’s been a while.

In principle Julia would be great for mass spec, I’d love to see more work in this area.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [July 22, 2020, 4:21pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/3 "2020-07-22T16:21:04Z")

</div>

> [@Eugeleo](#):
>
> Do you think my needs could be met with Julia?

I can’t answer the rest of your questions, but to this one, I would say unambiguously “yes!” But perhaps the implied question was “Do you think my needs could be met with julia without me needing to write the libraries myself,” in which case, maybe not.

The most straightforward path is probably to wrap the existing python libraries using eg PyCall. This way, you can accomplish the things you need to accomplish that require complex libraries right away, but get to use Julia for things like statistical analysis. And then, if you find some piece of the python library doesn’t work the way you want or is too slow, you can break of just that chunk and start re-writing it in Julia.

This way, you can remain productive on your primary task and still get to use Julia for everything else, plus potentially contribute to the ecosystem for the folks that come after you.

---

<div class="post-metadata">

**Author:** ![Eugeleo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eugeleo/32/6440_2.png) [@Eugeleo](https://discourse.julialang.org/u/Eugeleo)\
**Post date:** [July 22, 2020, 4:41pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/4 "2020-07-22T16:41:50Z")

</div>

Oh yeah, that’s what I meant — I should’ve phrased my question more carefully. The foray into mass spectrometry is very much a one-off thing to me, and as the focus of the thesis isn’t really the implementation of the basic ms/ms algorithms, I would prefer not to have to write them myself.

I’m thinking it might be easier just to write the data prep in Python, save it to some intermediary file and load it into Julia for the analysis. Or do you find the FFI to be so good that you’d write it all in Julia.

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [July 22, 2020, 4:56pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/5 "2020-07-22T16:56:55Z")

</div>

Some of the mass spectrometry tools you’d want you can find in ChemometricsTools.jl. I’m more into Spectroscopy personally but I could bake in some more MS tools over time.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [July 22, 2020, 8:12pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/6 "2020-07-22T20:12:47Z")

</div>

> [@Eugeleo](#):
>
> I’m thinking it might be easier just to write the data prep in Python, save it to some intermediary file and load it into Julia for the analysis.

This is a perfectly sensible strategy. One pitfall to look out for is the complexity of your coding environment in terms of reproducibility - it might paradoxically be easier to manage your python dependencies from Conda.jl.

But if you document your python environment and your Julia environment separately and there’s no overlap, it should be ok.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [November 8, 2020, 4:22pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/7 "2020-11-08T16:22:17Z")

</div>

Update: we now have

[https://github.com/timholy/MzXML.jl](https://github.com/timholy/MzXML.jl)

[https://github.com/timholy/MzCore.jl](https://github.com/timholy/MzCore.jl)

[https://github.com/timholy/MzPlots.jl](https://github.com/timholy/MzPlots.jl)

All three are registered packages, so you can just `pkg> add` them.

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [November 8, 2020, 7:49pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/8 "2020-11-08T19:49:26Z")

</div>

Awesome stuff TimHoly. Do you handle arrays whose bin spacing is uniform but varies in scale from file-to-file? If so, I’ve noticed a common abstraction/need that goes all over the ecosystem. For example the thread about JuliaTelecom has an implementation of this, and I have like 2-3 versions which (aren’t released) that I’m unhappy with.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [November 8, 2020, 7:54pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/9 "2020-11-08T19:54:57Z")

</div>

Great question. The utilities try to be agnostic about internal storage format. The MzXML package, which has to pick something, uses a vector of `scan`s, and a `scan` holds a list of `mz => intensity` pairs so in fact there is no binning.

However, for visualization binning is necessary. Therefore I support a `copyto!` method for an `AxisArray`, and use the binning of the array (and range on the axes) to determine how to do the binning. In `mzplot`, the display is interactive: as you zoom in further, it uses finer bins, so you can go from a very coarse resolution to very fine. All this seems necessary when you are dealing with arrays that effectively have 10^6 rows!

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [November 8, 2020, 8:02pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/10 "2020-11-08T20:02:51Z")

</div>

Interesting that it’s stored as pairs - but that makes sense. Yes for visualization it is the norm to downsample resolution :). Processing untargetted MS can be pretty intensive computationally. Reminds me of some stuff I did back in grad school (TOF-SIMS, etc). Fun stuff!

---

<div class="post-metadata">

**Author:** ![fieldofnodes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fieldofnodes/32/15858_2.png) [@fieldofnodes](https://discourse.julialang.org/u/fieldofnodes)\
**Post date:** [January 30, 2021, 2:30am UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/11 "2021-01-30T02:30:16Z")

</div>

Could the linked package read Agilent .MS files?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [February 1, 2021, 9:21am UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/12 "2021-02-01T09:21:50Z")

</div>

You’ll have to convert them to mzXML. mzML is supposedly not very different and could probably also be supported, but I’ve never looked at it.

---

<div class="post-metadata">

**Author:** ![fieldofnodes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fieldofnodes/32/15858_2.png) [@fieldofnodes](https://discourse.julialang.org/u/fieldofnodes)\
**Post date:** [February 1, 2021, 10:09am UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/13 "2021-02-01T10:09:48Z")

</div>

Thanks. I am new to Mass Spec type data, but I am interested in seeing how I can get the Mass Spec data, such as for all peaks in a single data set (unstructured) I imagine. I would like to look at several files at once for comparison, without needing something like OpenChrom or some other chem software. Assuming I convert to the mzXML, would the Julia packages you developed be able to do this? Thanks, any pointers would be great.

---

<div class="post-metadata">

**Author:** ![li210](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/li210/32/221519_2.png) [@li210](https://discourse.julialang.org/u/li210)\
**Post date:** [April 9, 2026, 6:24pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/14 "2026-04-09T18:24:04Z")

</div>

Hello,  
any updates, new packages/projects related to mass spectrometry/proteomics?

With some new open source communities in C++/Rust, creating bindings shouldn’t be a problem. For example [Rustims](https://github.com/theGreatHerrLebert/rustims) has official rudimentary Julia api.

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [April 9, 2026, 8:55pm UTC](https://discourse.julialang.org/t/packages-for-mass-spectrometry/43481/15 "2026-04-09T20:55:45Z")

</div>

There is currently a [pending registration](https://github.com/JuliaRegistries/General/pull/152475) for a package [MassJ.jl](https://github.com/ajgiuliani/MassJ.jl) (not enthusiastic about the name, but that’s what it is unless someone manages to convince the author to rename it within the remainder of the waiting period)
