This page lists all the documented elements of the MassJ.jl package covering all modules and submodules.

Main module

MassJ.MassJModule

Main module for MassJ.jl– A Julia package to load and process mass spectrometry data.

source

Types


Submodule with types and structures used to stored the data and dispatch to the right methods.

Data types

MassJ.MScontainerType
abstract type MScontainer  end

Abstract type containing any imported data belongs to the MScontainer type.

source
MassJ.MSscanType
struct MSscan <: MScontainer

Data structure used to store individual mass spectrometry scans.

struct MSscan <: MScontainer
    num::Int                          # scan number
    rt::Float64                       # retention time
    tic::Float64                      # total ion current
    mz::Vector{Float64}              # m/z values
    int::Vector{Float64}             # intensity values
    level::Int                        # MS level
    basePeakMz::Float64              # base peak m/z
    basePeakIntensity::Float64       # base peak intensity
    precursor::Float64               # precursor m/z
    polarity::String                 # polarity
    activationMethod::String         # activation method
    collisionEnergy::Float64         # collision energy
    chargeState::Int                 # precursor charge state (0 = unknown)
    spectrumType::Symbol             # :centroid, :profile, or :unknown
    driftTime::Float64               # ion mobility drift time or 1/K0 (-1.0 = not present)
    compensationVoltage::Float64     # FAIMS/DMS compensation voltage (0.0 = not present)
    mobilityType::Symbol             # :DTIMS, :TIMS, :TWIMS, :FAIMS, or :none
    metadata::Dict{String,Any}       # additional format-specific metadata
end
source
MassJ.MSscansType
struct MSscans  <: MScontainer

Data structure designed to store mass spectra obtained after filtering operation along with the history of these operations.

struct MSscans  <: MScontainer
    num::Vector{Int}                  # scan numbers
    rt::Vector{Float64}               # retention times
    tic::Float64                      # total ion current
    mz::Vector{Float64}               # m/z values
    int::Vector{Float64}              # intensity values
    level::Vector{Int}                # MS levels
    basePeakMz::Float64               # base peak m/z
    basePeakIntensity::Float64        # base peak intensity
    precursor::Vector{Float64}        # precursor m/z values
    polarity::Vector{String}          # polarities
    activationMethod::Vector{String}  # activation methods
    collisionEnergy::Vector{Float64}  # collision energies
    s::Vector{Float64}                # variance
    chargeState::Vector{Int}          # precursor charge states (0 = unknown)
    spectrumType::Symbol              # :centroid, :profile, or :unknown
    driftTime::Vector{Float64}        # ion mobility drift times or 1/K0 (-1.0 = not present)
    compensationVoltage::Vector{Float64} # FAIMS/DMS compensation voltages (0.0 = not present)
    mobilityType::Symbol              # :DTIMS, :TIMS, :TWIMS, :FAIMS, or :none
    metadata::Dict{String,Any}        # additional format-specific metadata
end
source
MassJ.ChromatogramType
struct Chromatogram  <: MScontainer

Data structure used to retrieve chromatography data.

struct Chromatogram  <: MScontainer   
    rt::Vector{Float64}               # retention time
    ic::Vector{Float64}               # ion current
    maxic::Float64
end
source
MassJ.MobilogramType
struct Mobilogram <: MScontainer

Data structure used to retrieve ion mobility data (intensity vs drift time or 1/K0).

struct Mobilogram <: MScontainer
    dt::Vector{Float64}               # drift time or 1/K0 values
    ic::Vector{Float64}               # ion current
    maxic::Float64                    # maximum ion current
    mobilityType::Symbol              # :DTIMS, :TIMS, :TWIMS, or :none
end
source
MassJ.IonogramType
struct Ionogram <: MScontainer

Data structure used to retrieve differential mobility data (intensity vs compensation voltage).

struct Ionogram <: MScontainer
    cv::Vector{Float64}               # compensation voltage values
    ic::Vector{Float64}               # ion current
    maxic::Float64                    # maximum ion current
end
source
MassJ.IsotopeType
struct Isotope

Data structure used to store individual properties of the isotopes.

struct Isotope
    m::Float64           # mass
    f::Float64           # natural frequency
    logf::Float64        # logarithm of the natural frequency
    Z::Int               # atomic number
    A::Int               # mass number
    active::Bool         # is radioactive
end
source

Methods Types

MassJ.MethodTypeType
abstract type MethodType  end

Type containing all the methods used for filtering the data.

source
MassJ.BasePeakType
struct BasePeak <: MethodType

Structure for multiple dispatching to retrieve base peak chromatogram.

source
MassJ.TICType
struct TIC <: MethodType

Dispatching to retrieve total ion current chromatogram.

source
MassJ.∆MZType
struct ∆MZ{argT <: Union{Real, AbstractVector{<:Real} }} <: MethodType

Structure for multiple dispatching to retrieve extracted ion current chromatogram around an m/z ± ∆mz value given by arg = [mz, ∆mz]

source
MassJ.MZType
struct MZ{argT <: Union{Real, AbstractVector{<:Real} }} <: MethodType

Structure for multiple dispatching to retrieve extracted ion current chromatogram around for m/z in the range arg = [mz1, mz2].

source
MassJ.SGType
struct SG{argT <: Int} <: MethodType   #Savitzky-Golay filtering

Structure for multiple dispatching to Savitzky-Golay filtering, providing the order, window size and derivative to be performed. Defaults values are provided in functions calls.

source
MassJ.TBPDType
struct TBPD{argT1 <: Symbol, argT2 <: Real, argT3 <: Real}  <: MethodType

Structure for multiple dispatching to Template Based Peak Detection centroiding, providing the shape of the template function, the resolution and threshold. Defaults values are provided in functions calls.

source
MassJ.SNRAType
struct SNRA{argT1 <: Real, argT2 <: Int}  <: MethodType

Structure for multiple dispatching to Signal to Noise Ratio Analysis centroiding, providing the threshold value and the size of the region. Defaults values are provided in functions calls.

source
MassJ.TopHatType
TopHat{argT <: Int} <: MethodType

Structure for multiple dispatching to TopHat baseline correction. Region is used to specify the dimension over which this operation is performed.

source
MassJ.LOESSType
LOESS{argT <: Int} <: MethodType

Structure for multiple dispatching to LOcally Weighted Error Sum of Squares regression (LOESS) baseline correction.

source
MassJ.IPSAType
struct IPSA{argT1 <: Int, argT2 <: Int} <: MethodType

Structure for multiple dispatching to iterative polynomial smoothing algorithm (IPSA) baseline correction.

source
MassJ.UniDecType
struct UniDec <: MethodType

Structure for multiple dispatching to UniDec deconvolution algorithm.

source
MassJ.ChargesType
struct Charges <: MethodType

Structure for multiple dispatching to UniDec charge deconvolution algorithm.

source
MassJ.MassesType
struct Masses <: MethodType

Structure for multiple dispatching to UniDec mass deconvolution algorithm.

source

Filters

MassJ.FilterTypeType
abstract type FilterType end

This type contains the structures for filtering the data.

source
MassJ.RTType
RT{argT <: Union{Real, AbstractVector{<:Real},  AbstractVector{<:AbstractVector{<:Real}} }}

This type contains the structures for filtering the data.

source
MassJ.ICType
struct IC{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterType

Used for multiple dispatching to Template Base Peak Detection centroiding, providing the shape of the template function, the resolution and threshold. Defaults values are provided in functions calls.

source
MassJ.LevelType
struct Level{argT <: Union{Int, AbstractVector{<:Int} }} <: FilterType

Used to dispatch filters to MS level.

source
MassJ.ScanType
 Scan{argT <: Union{Int, AbstractVector{<:Int} }} <: FilterType

Dispatch filter to scan num.

source
MassJ.PolarityType
struct Polarity{argT <: Union{String, AbstractVector{<:String} }} <: FilterType

Dispatch filter to polarity.

source
MassJ.Activation_MethodType
struct Activation_Method{argT <: Union{String, AbstractVector{<:String} }} <: FilterType

Dispatch filter to activation methods

source
MassJ.Activation_EnergyType
struct Activation_Energy{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterType

Dispatch filter to activation energies.

source
MassJ.PrecursorType
struct Precursor{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterType

Dispatch filter to precursor.

source
MassJ.DriftTimeType
struct DriftTime{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterType

Dispatch filter to ion mobility drift time or 1/K0 values.

source
MassJ.CompensationVoltageType
struct CompensationVoltage{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterType

Dispatch filter to FAIMS/DMS compensation voltage.

source

I/O


Module for importing and exporting data. Dispatch to specific methods according to the file extension

MassJ.infoMethod
info(filename::String; verbose::Bool = false)

Reads the content of a mass spectrometry file and returns a Vector{String} containing the number of scans and the different scan types described by their MS level, polarity and, for MS/MS data, the precursor m/z followed by the activation method and collision energy. Each entry is unique, providing a summary of the input file. With verbose = true, the function also returns instrument metadata (parentFile, manufacturer, model, ionisation, mass analyzer, detector, software, data processing) when available.

Supported file formats: mzXML, mzML, MGF, MSP, imzML.

Examples

julia> info("test.mzXML")
4-element Array{String,1}:
 "51 scans"
 "MS1+"
 "MS2+ 1255.5  CID(CE=18)"
 "MS3+ 902.33  PQD(CE=35)"

julia> info("test.mzML")
4-element Array{String,1}:
 "3 scans"
 "MS1+"
 "MS2+ 400.0  CID(CE=25.0)"
 "MS2+ 500.0  HCD(CE=30.0)"

julia> info("library.msp")
4-element Array{String,1}:
 "3 scans"
 "MS2+ 195.0877"
 "MS2- 179.0344"
 "MS1+"
source
MassJ.loadMethod
load(filename::String)

Loads the mass spectra from a file and returns a Vector{MSscan} where each element contains one scan. The function dispatches to the appropriate reader based on the file extension.

Supported file formats: mzXML, mzML, MGF, MSP, imzML, TXT.

Examples

julia> scans = load("test.mzXML")
6-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.1384, 5.08195e6, ...)

julia> scans = load("test.mzML")
3-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.5, 19000.0, ...)

julia> scans = load("test.mgf")
3-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.5, 4800.0, ...)

julia> scans = load("library.msp")
3-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.0, 178600.0, ...)

julia> scans = load("sample.imzML")
10000-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.0, 8000.0, ...)
source
MassJ.retention_timeMethod
retention_time(filename::String)

Returns a Vector{Float64} with the retention times (in minutes) of each scan in the file.

Supported file formats: mzXML, mzML, MGF, MSP, imzML.

Examples

julia> retention_time("test.mzXML")
6-element Array{Float64,1}:
  0.1384
  0.7307
  2.1379
  ...
source
MassJ.chromatogramMethod
chromatogram(filename::String, filters::FilterType...; method::MethodType=TIC())

Returns a Chromatogram holding the retention time (rt), the ion current (ic) and the maximum value (maxic) for all the mass spectra within the file. The method keyword controls how the ion current is computed: TIC() (default) for total ion current, BasePeak() for base peak intensity, ∆MZ([mz, Δ]) for extracted ion current around mz ± Δ, or MZ([mz1, mz2]) for a m/z range.

The data may be filtered using FilterType arguments: Level(N), Precursor(mz), Activation_Method("method"), Activation_Energy(ce), Polarity("+"), Scan(n), RT([t1,t2]), IC([min,max]).

Supported file formats: mzXML, mzML, MGF, MSP, imzML.

Examples

julia> chrom = chromatogram("test.mzXML")
MassJ.Chromatogram([0.1384, ...], [5.08195e6, ...], 5.08195e6)

julia> chrom = chromatogram("test.mzML", method = MassJ.BasePeak())
MassJ.Chromatogram([0.5, 1.0, 1.5], [8000.0, 2000.0, 1200.0], 8000.0)

julia> chrom = chromatogram("test.mzXML", MassJ.Level(1), method = MassJ.∆MZ([500,5]))
source
MassJ.averageMethod
average(filename::String, arguments::FilterType...; stats::Bool=true)

Returns the average mass spectrum as an MSscans container, along with the sample standard deviation of the intensities when stats=true (default). The data may be filtered using FilterType arguments.

Supported file formats: mzXML, mzML, MGF, MSP, imzML.

Examples

julia> spectrum = average("test.mzXML")
MassJ.MSscans([1, 2, 3, ...

julia> spectrum = average("test.mzML", MassJ.Level(2))
MassJ.MSscans([2, 3], ...

julia> spectrum = average("test.mzXML", MassJ.Precursor(1255.5), MassJ.RT([1, 60]))
MassJ.MSscans([2, 5, 8, 11], ...
source

mzXML


Interface to the mzXML file format.

MassJ.info_mzxmlFunction
info_mzxml(filename::String, info::Vector{String}, verbose::Bool=false)

Returns the information content of an mzXML file into a string. Verbosity is controlled by the verbose Boolean variable set by default to false.

source
MassJ.load_mzxmlFunction
load_mzxml(filename::String, index::Int)

Load from an mzxml file the scan num that matches the input index.

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Level{<:Int})

Search for scans matching the argument level and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Level{<:AbstractVector}

Search for scans matching the argument levels and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Scan{<:Int})

Search for scans matching the argument scan num and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Scan{<:AbstractVector}

Search for scans matching the argument scan nums and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Polarity{<:String})

Search for scans matching the argument polarity and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Polarity{<:AbstractVector})

Search for scans matching the argument polarities and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::RT{<:Real})

Search for scans matching the argument retention time and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::RT{<:AbstractVector}

Search for scans matching the argument retention times within the range and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::RT{<:AbstractVector{<:AbstractVector} } )

Search for scans matching the argument retention times within the ranges and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::IC{<:AbstractVector})

Search for scans matching for which the total ion current is within the input range returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Precursor{<:Real})

Search for scans matching the argument precursor mz and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Precursor{<:AbstractVector})

Search for scans matching the argument precusors mz and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Activation_Energy{<:Real})

Search for scans matching the argument activation energy and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Activation_Energy{<:AbstractVector})

Search for scans matching the argument activation energies and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Activation_Method{<:String})

Search for scans matching the argument activation method and returns a list of index

source
MassJ.filterMethod
filter(msRun::XMLElement, argument::Activation_Method{<:AbstractVector})

Search for scans matching the argument activation methods and returns a list of index

source
MassJ.extracted_chromatogramMethod
extracted_chromatogram(filename::String, indices::Vector{Int},method::MethodType)

Returns the extracted chromatogram for input file according to the selected method and for set of scan num as input

source
MassJ.composite_spectraMethod
composite_spectra(filename::String, indices::Vector{Int}, stats::Bool)

Returns the average MSscans for input filename and according to the input scan num. Calculation of variance is controlled by the stats Boolean variable.

source

mzML


Interface to the mzML file format (PSI standard). Uses the same binary decoding pipeline as mzXML (Codecs, Libz) but with little-endian byte order and separate m/z and intensity arrays.

MassJ.info_mzmlFunction
info_mzml(filename::String, info::Vector{String}, verbose::Bool=false)

Returns the information content of an mzML file into a string.

source
MassJ.load_mzml_allFunction
load_mzml_all(filename::String)

Load all spectra from an mzML file. Returns a Vector{MSscan}.

source
MassJ.load_mzmlFunction
load_mzml(filename::String, target_num::Int)

Load a single scan from an mzML file by scan number.

source
MassJ.load_mzml_spectrumFunction
load_mzml_spectrum(spec::XMLElement, scan_index::Int)

Parse a single <spectrum> element and return an MSscan.

source
MassJ.find_mzml_rootFunction
find_mzml_root(xdoc::XMLDocument)

Navigate to the mzML element, handling both raw mzML and indexedmzML wrappers. Returns the mzML element.

source
MassJ.get_cv_paramFunction
get_cv_param(elem::XMLElement, accession::String)

Search for a cvParam child with the given accession. Returns the XMLElement or nothing.

source
MassJ.get_cv_valueFunction
get_cv_value(elem::XMLElement, accession::String, default="")

Get the value attribute of a cvParam with the given accession. Returns default if not found.

source
MassJ.has_cv_paramFunction
has_cv_param(elem::XMLElement, accession::String)

Check whether elem has a cvParam child with the given accession.

source

MGF


Interface to the MGF (Mascot Generic Format) file format. Text-based format for centroided MS/MS peak lists.

MassJ.load_mgf_allFunction
load_mgf_all(filename::String)

Load all spectra from an MGF file. Returns a Vector{MSscan}. Each BEGIN IONS...END IONS block becomes one MSscan.

source
MassJ.build_mgf_scanFunction
build_mgf_scan(params::Dict{String,String}, mz::Vector{Float64}, int::Vector{Float64}, index::Int)

Build an MSscan from parsed MGF ion block parameters and peak data.

source
MassJ.info_mgfFunction
info_mgf(filename::String, info::Vector{String}, verbose::Bool=false)

Returns summary information about an MGF file.

source

MSP


Interface to the MSP (NIST Mass Spectral Library) file format. Text-based format used by NIST, MoNA, MassBank, and GNPS for spectral libraries.

MassJ.load_msp_allFunction
load_msp_all(filename::String)

Load all spectra from an MSP file. Returns a Vector{MSscan}. Each entry (Name: ... Num Peaks: ... peak data ... blank line) becomes one MSscan.

source
MassJ.build_msp_scanFunction
build_msp_scan(params::Dict{String,String}, mz::Vector{Float64}, int::Vector{Float64}, index::Int)

Build an MSscan from parsed MSP entry parameters and peak data.

source
MassJ.info_mspFunction
info_msp(filename::String, info::Vector{String}, verbose::Bool=false)

Returns summary information about an MSP file.

source

imzML


Interface to the imzML file format for imaging mass spectrometry. Consists of an XML metadata file (.imzML) and a companion binary data file (.ibd). Supports both continuous and processed storage modes, and stores spatial coordinates in the metadata dictionary.

MassJ.load_imzml_allFunction
load_imzml_all(filename::String)

Load all spectra from an imzML file. Returns a Vector{MSscan}. The spatial coordinates (x, y) are stored in the metadata dict of each scan. Requires the companion .ibd file in the same directory.

source
MassJ.load_imzml_spectrumFunction
load_imzml_spectrum(spec::XMLElement, scan_index::Int, ibd_io::IO,
                    is_continuous::Bool, shared_mz::Vector{Float64},
                    shared_mz_read::Bool)

Parse a single <spectrum> element from imzML and read its binary data from the .ibd file.

source
MassJ.info_imzmlFunction
info_imzml(filename::String, info::Vector{String}, verbose::Bool=false)

Returns summary information about an imzML file.

source

Filtering

MassJ.averageMethod
average(scans::Vector{MSscan}, arguments::FilterType...; stats::Bool=true)

Returns the average mass spectrum container (MSscans) along with the sample standard deviation of the intensities with stats=true (default) for all the mass spectra within the Array of mass spectrum container MSscan.. The data may be filtered by level, precursor mass, activation methods, etc, using the arguments MassJ.Level(N), MassJ.Precursor(mz), MassJ.Activation_Method("method"), or any combination of these arguments.

Examples

julia> spectrum = average("test.mzxml")
MassJ.MSscans([1, 2, 3 ....
julia> spectrum = average("test.mzxml", MassJ.Level(1) )
MassJ.MSscans([1, 4, 7, 10,
julia> spectrum = average("test.mzxml", MassJ.Precursor(1255.5) )
MassJ.MSscans([2, 5, 8, 11, ...
julia> spectrum = average("test.mzxml", MassJ.Activation_Method("PQD") )
MassJ.MSscans([3, 6, 9, 12, 15,
julia> spectrum = average("test.mzxml", MassJ.Activation_Method("PQD"), MassJ.Polarity("+"), MassJ.RT([10,20]))
MassJ.MSscans([9, 12, 15, 18], ...
source
MassJ.chromatogramMethod
chromatogram(scans::Vector{MSscan}, filters::FilterType...; method::MethodType=TIC())

Returns the retention time and the total ion current by default for all the mass spectra within the Array of mass spectrum container MSscan. Alternatively, other options may be supplied such as method = MassJ.BasePeak, which returs the base peak intensity, method = MassJ.∆MZ([500,5]), which returns the ion current for the range mz = 500 ± 5, or method = MassJ.MZ([200,1000]) which return the ion current in the range from m/z 200 to m/z 1000. The data may be filtered by ms level, precursor mass, activation methods, etc, using the arguments MassJ.Level(N), MassJ.Precursor(mz), MassJ.Activation_Method("method")...

Examples

julia> rt, ic = chromatogram("test.mzxml")
([0.1384  …  60.4793], [4.74795e6  …  17.4918])
julia> rt, ic = chromatogram("test.mzxml", method = MassJ.BasePeak() )
([0.1384  …  60.4793], [102558.0  …  1.23181])
julia> rt, ic = chromatogram("test.mzxml", method = MassJ.∆MZ([500,5]) )
([0.1384  …  60.4793], [46036.6  …  14.2529])
julia> rt, ic = chromatogram("test.mzxml", method = MassJ.MZ([200,1000]))
([0.1384  …  60.4793], [4.74795e6  …  17.4918])
source
MassJ.retention_timeMethod
retention_time(scans::Vector{MSscan})

Returns an array composed of the retention times of the individual mass spectra.

Examples

julia> retention_time("scans")
51-element Array{Float64,1}:
  0.1384
  0.7307
  2.1379
....
source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Scan{<:Int})

Search for scans matching the argument scan num and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Scan{<:AbstractVector})

Search for scans matching the argument scan nums and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Level{<:Int})

Search for scans matching the argument MS level and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Level{<:AbstractVector})

Search for scans matching the argument MS levels and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Precursor{<:Real})

Search for scans matching the argument precursor mz and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Precursor{<:AbstractVector})

Search for scans matching the argument precursors mz and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Activation_Energy{<:Real})

Search for scans matching the argument activation energy and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Activation_Energy{<:AbstractVector})

Search for scans matching the argument activation energies and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Activation_Method{<:String})

Search for scans matching the argument activation method and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Activation_Method{<:AbstractVector})

Search for scans matching the argument activation methods and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Polarity{<:String})

Search for scans matching the argument polarity and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::Polarity{<:AbstractVector})

Search for scans matching the argument polarities and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::RT{<:Real})

Search for scans matching the argument retention time and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::RT{<:AbstractVector})

Search for scans matching the argument retention time in the specified range and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::RT{<:AbstractVector{<:AbstractVector} } )

Search for scans matching the argument retention time in the specified ranges and returns a list of the corresponding indexes

source
MassJ.filterMethod
filter(scans::Vector{MSscan}, argument::IC{<:AbstractVector})

Search for scans matching the argument total ion current within the specified ranges and returns a list of the corresponding indexes

source
MassJ.extracted_chromatogramMethod
extracted_chromatogram(scans::Vector{MSscan}, indices::Vector{Int},method::MethodType)

Returns the extracted chromatogram for input Array of MSscan according to the selected method and for set of scan num as input

source
MassJ.composite_spectraMethod
composite_spectra(scans::Vector{MSscan}, indices::Vector{Int}, stats::Bool)

Returns the average MSscans for input Array of MSscan and according to the input scan num. Calculation of variance is controlled by the stats Boolean variable.

source

Extracting subsets

MassJ.extractMethod
extract(filename::String, arguments::FilterType...)

Returns a Vector{MSscan} containing the scans that match the given FilterType conditions. Without arguments, returns all scans.

Supported file formats: mzXML, mzML, MGF, MSP, imzML.

Examples

julia> sub_set = extract("test.mzXML", MassJ.Level(2))
2-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(2, 0.7307, 9727.2, ...)
 MassJ.MSscan(5, 4.3442, 12203.5, ...)

julia> sub_set = extract("test.mzML", MassJ.Level(1))
1-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.5, 19000.0, ...)

julia> sub_set = extract("library.msp", MassJ.Polarity("+"))
1-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.0, 178600.0, ...)
source
MassJ.extractMethod
extract(scans::Vector{MSscan}, arguments::FilterType...)

Search for scans matching the argument MS level and returns an array of matching MSscans otherwise returns an ErrorException: "No matching spectra found."

Examples

julia> scans = load("test.mzxml")                          # load mass spectra
6-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ...
julia> sub_set = extract(scans)                            # extract a sub_set without conditions returns the original data
6-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
julia> sub_set = extract(scans, MassJ.Level(2) )      # extract MS/MS spectra
MassJ.MSscan(2, 0.7307, 9727.2, [345.083, 345.167, 345.25, 345.333, 345.417, 345.5, 345.583, 345.667, 345.75, 345.833  …  1999.25, 1999.33, 1999.42, 1999.5, 1999.58 ....
 MassJ.MSscan(5, 4.3442, 12203.5, [345.083, 345.167, 345.25, 345.333, 345.417, 345.5, 345.583, 345.667, 345.75, 345.833  …  1999.25, 1999.33, 1999.42, 1999.5, 1999.58, ....
source
MassJ.build_subsetMethod
build_subset(filename::String, indices::Vector{Int})

Returns a Vector of MSscan from the input file according to the scan num (indices).

source
MassJ.build_subsetMethod
build_subset(scans::Vector{MSscan}, indices::Vector{Int})

Returns a Vector of MSscan according to the input scan num.

source

Process


Mass spectrum


MassJ.smoothMethod
smooth(scan::MScontainer; method::MethodType=SG(5, 9))

Smooth the intensity of the input data and returns a similar structure.

Examples

julia> smoothed_data = MassJ.smooth(scans)
MassJ.MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
source
MassJ.smoothMethod
smooth(scans::Vector{MSscan}; method::MethodType=SG(5, 9, 0))

Smooth the intensity of the input data and returns a similar structure.

Examples

julia> scans = load("filename")
julia> smoothed_data = MassJ.smooth(scans)
6-element Array{MassJ.MSscan,1}:
 MassJ.MSscan(1, 0.1384, 5.08195e6 .....
source
MassJ.savitzky_golay_filteringMethod
savitzky_golay_filtering(scan::MassJ.MScontainer, order::Int, window::Int, deriv::Int)

Savitzky-Golay filtering to remove the high frequency noise of int data within the MSscan(s) container.

source
MassJ.centroidMethod
centroid(scan::MScontainer; method::MethodType=MethodType=SNRA(1., 100) )

Peak picking algorithm taking a MSscan or MSscans object as input and returning an object of the same type containing the detected peaks. Available algorithm are : Signal to Noise Ratio (SNR) and Template Based Peak Detection (TBPD). Default method is Signal to Noise Ratio Analysis (SNRA), with default threshold = 1.0 and region = 100.

Examples

julia> centroid(scans)
MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
source
MassJ.centroidMethod
centroid(scans::Vector{MSscan}; method::MethodType=SNRA(1., 100) )

Peak picking algorithm taking an array of MSscan as input and returning an object of the same type containing the detected peaks. Available algorithm are : Signal to Noise Ratio (SNR) and Template Based Peak Detection (TBPD). Default method is Signal to Noise Ratio Analysis (SNRA), with default threshold = 1.0 and region = 100.

Examples

julia> reduced_data = centroid(scans)
6-element Array{MassJ.MSscan,1}:
MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
source
MassJ.snraMethod
snra(scan::MScontainer, thres::Real, region::Int)

Signal to Noise Ratio Analysis method returning the m/z and intensity of the peaks detected.

source
MassJ.tbpdMethod
tbpd(scan::MassJ.MScontainer, shape::Symbol,  R::Real, thres::Real)

Template based peak detection algorithm returning the m/z and intensity of the peaks detected.

source
MassJ.voigtMethod
voigt(x::Real, p::AbstractArray)

Pseudo-Voigt profile function used by the TBPD method.

source
Missing docstring.

Missing docstring for MassJ.tbpd(scan::MScontainer, shape::Symbol, R::Real, thres::Real). Check Documenter's build log for details.

MassJ.baseline_correctionMethod
baseline_correction(scan::MScontainer; method::MethodType=TopHat(100) )

Baseline correction takes a MSscan or MSscans object as input and returns an object of the same type as the input with the mass spectra corrected for their base line. Available algorithms are Top Hat, Locally Weighted Error Sum of Squares regression (LOESS) and Iterative Polynomial Smoothing Algorithm (IPSA). The default method is TopHat with a structuring element width of 100 points.

Examples

julia> reduced_data = baseline_correction(scan)
MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
julia> reduced_data = baseline_correction(scans, method = MassJ.LOESS(1))
MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
julia> reduced_data = baseline_correction(scans, method = MassJ.IPSA(51,100))
6-element Array{MassJ.MSscan,1}:
MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
source
MassJ.baseline_correctionMethod
baseline_correction(scans::Vector{MSscan}; method::MethodType=TopHat(100) )

Baseline correction takes a Vector of MSscan as input and returns a Vector of MSscan with the mass spectra corrected for their base line. Available algorithms are Top Hat, Locally Weighted Error Sum of Squares regression (LOESS) and Iterative Polynomial Smoothing Algorithm (IPSA). The default method is TopHat with a structuring element width of 100 points.

Examples

julia> reduced_data = baseline_correction(scans)
6-element Array{MassJ.MSscan,1}:
MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
julia> reduced_data = baseline_correction(scans, method = MassJ.LOESS(1))
6-element Array{MassJ.MSscan,1}:
MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
julia> reduced_data = baseline_correction(scans, method = MassJ.IPSA(51,100))
6-element Array{MassJ.MSscan,1}:
MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
source
MassJ.tophat_filterMethod
tophat_filter(scan::MScontainer, region::Int)

Method taking a MScontainer object as input and returning an object of the same type with the mass spectra without their base line, using the TopHat filtering algorithm.

source
Missing docstring.

Missing docstring for MassJ.tophat_filter(scans::Vector{MSscan}, region::Int ). Check Documenter's build log for details.

Missing docstring.

Missing docstring for MassJ.loess(scans::Vector{MSscan}, iter::Int ). Check Documenter's build log for details.

MassJ.loessMethod
loess(scan::MScontainer, iter::Int )

Method taking a MSscan or MSscans object as input and returning an object of the same type with the mass spectra without their base line, using the LOESS (Locally Weighted Error Sum of Squares regression).

source
MassJ.ipsaMethod
ipsa(scan::MScontainer, width::Real, maxiter::Int)

Method taking a MSscan or MSscans object as input and returning an object of the same type with the mass spectra without their base line, using the iterative polynomial smoothing algorithm (IPSA) baseline correction.

source
Missing docstring.

Missing docstring for MassJ.ipsa(scans::Vector{MSscan}, width::Real, maxiter::Int). Check Documenter's build log for details.

Chromatogram


No functions yet. To be added.

Deconvolution


MassJ.deconvFunction
deconv(scan::MScontainer, method::Charges; FWHM::Real=-1, R::Real=-1, shape::Symbol=:autoguess, maxiter::Int=250, tol::Real=1e-06)

Returns the result of the deconvolution of an MSscan(s) object using the UniDec algorithm. The output is an object of the same type as the input. The deconv function takes an MSscan or MSscans object and a Charges method as mandatory inputs. Optional keyword arguments are: - FWHM: full width at half maximum of the peaks. - R: mass resolving power at m/z 500. - if neither R nor FWHM are provided, the peak width is obtained from the base peak FWHM of the mass spectrum. - shape: peak shape function: :gauss, :lorentz, :voigt or :autoguess (default). - maxiter: maximum number of iterations. Default value is 250. - tol: convergence criterion of the iterative procedure. Default is 1e-06.

Examples

julia> deconv_data = deconv(scans, Charges(adduct="H", range=(1,10)))
MassJ.MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
julia> deconv_data = deconv(scans, Charges(adduct="H", range=(5,15), width=2), R=5000)
MassJ.MSscans(1, 0.1384, 5.08195e6, [140.083, 140.167, 140.25, 140.333, 140.417, 140.5, 140.583, 140.667, 140.75, 140.833  …  1999.25, 1999.33, 1999.42, ....
source

Simulations


MassJ.formulaFunction
formula(formula::String)

Private function that reads the input chemical formula and sorts the atoms. It returns a dictionary in which the different entries represent the atoms and the values are the number of times the atoms have been found in the formula.

source
MassJ.massesFunction
masses(input::String)

Calculates the average, monoisotopic and nominal masses for the chemical formula given as an input. The result is returned in a dictionary with the following entries: "Monoisotopic", "Average" and "Nominal".

Examples

julia> masses("C254 H377 N65 O75 S6")
Dict("S" => 6,"C" => 254,"N" => 65,"H" => 377,"O" => 75)
Dict{String,Float64} with 3 entries:
  "Monoisotopic" => 5729.6
  "Average"      => 5733.55
  "Nominal"      => 5727.0
source
masses(f::Dict{String,Int})

Calculates the average, monoisotopic and nominal masses for the chemical formula dictionary, such as produced by MassJ.formula. The result is returned in a dictionary with the following entries: "Monoisotopic", "Average" and "Nominal".

Examples

julia> masses("C254 H377 N65 O75 S6")
Dict("S" => 6,"C" => 254,"N" => 65,"H" => 377,"O" => 75)
Dict{String,Float64} with 3 entries:
  "Monoisotopic" => 5729.6
  "Average"      => 5733.55
  "Nominal"      => 5727.0
source
MassJ.isotopic_distributionFunction
isotopic_distribution(input::String, p_target::Real; charge::Int = +1, tau::Real = 0.1, Elements::Dict{String,Array{MassJ.Isotope,1}} = MassJ.Elements)

Calculates the isotopic distribution of input formula for which the overall probabilities equals p_target using the isospec algorithm. The charge state is entered as an optional argument. The peaks detection threshold tau is by default set to 10%.

Examples

julia> isotopic_distribution("C254 H377 N65 O75 S6", 0.5)
Dict("S" => 6,"C" => 254,"N" => 65,"H" => 377,"O" => 75)
9×15 Array{Union{Float64, Int, String},2}:
     "Masses"   "Probability"     "12C"   "13C"   "32S"   "34S"   "33S"   "36S"    "14N"   "15N"    "16O"   "18O"   "17O"     "1H"   "2H"
 5731.61       0.112302        252       2       6       0       0       0       65       0       75       0       0       377      0    
 5732.61       0.102878        251       3       6       0       0       0       65       0       75       0       0       377      0    
 5730.6        0.0814037       253       1       6       0       0       0       65       0       75       0       0       377      0    
 5733.61       0.0704028       250       4       6       0       0       0       65       0       75       0       0       377      0    
 5734.62       0.0383896       249       5       6       0       0       0       65       0       75       0       0       377      0    
 5733.6        0.0301637       252       2       5       1       0       0       65       0       75       0       0       377      0    
 5729.6        0.0293871       254       0       6       0       0       0       65       0       75       0       0       377      0    
 5734.61       0.0276323       251       3       5       1       0       0       65       0       75       0       0       377      0    
``julia> isotopic_distribution("C254 H377 N65 O75 S6", 0.5, charge = +7)
Dict("S" => 6,"C" => 254,"N" => 65,"H" => 377,"O" => 75)
9×15 Array{Union{Float64, Int, String},2}:
    "Masses"   "Probability"     "12C"   "13C"   "32S"   "34S"   "33S"   "36S"    "14N"   "15N"    "16O"   "18O"   "17O"     "1H"   "2H"
 818.801      0.112302        252       2       6       0       0       0       65       0       75       0       0       377      0    
 818.944      0.102878        251       3       6       0       0       0       65       0       75       0       0       377      0    
 818.658      0.0814037       253       1       6       0       0       0       65       0       75       0       0       377      0    
 819.088      0.0704028       250       4       6       0       0       0       65       0       75       0       0       377      0    
 819.231      0.0383896       249       5       6       0       0       0       65       0       75       0       0       377      0    
 819.086      0.0301637       252       2       5       1       0       0       65       0       75       0       0       377      0    
 818.514      0.0293871       254       0       6       0       0       0       65       0       75       0       0       377      0    
 819.23       0.0276323       251       3       5       1       0       0       65       0       75       0       0       377      0    
source
MassJ.simulateFunction
simulate(I::Array{Union{Float64, Int, String}}, ∆mz::Real; model::Symbol=:gauss, Npoints::Int=1000)

From an isotopic distribution and a peak width returns a mass spectrum (MSScan). The number of points of the resulting mass spectrum is passed as an optional argument. Peak shape are :gauss (default), :lorentz, :voigt.

Examples

julia>  a = simulate(I, 0.4)
MassJ.MSscan(1, 0.0, 30898.192348114364, [5727.102517458742 ..., "", "", 0.0)
source

Plots


MassJ.plotsModule

Plotting module for MScontainer data type (MSscan, MSscans and Chromatogram).

julia> plot(scans[1])
julia> plot(chr)
source
MassJ.plots.scalingMethod
scaling(cr::MassJ.Chromatogram)

Scaling function to display retention times of chromatograms in minutes instead of seconds.

source
RecipesBase.apply_recipeMethod
h(cr::MassJ.Chromatogram; method = :relative)

Allows plotting directly chromatograms. The defaults relative intensity plotting may be changed by setting method = :absolute.

source
RecipesBase.apply_recipeMethod
g(ms::MassJ.MSscans; method = :relative)

Allows plotting directly mass spectra MSscans. The defaults relative intensity plotting may be changed by setting method = :absolute.

source
RecipesBase.apply_recipeMethod
f(ms::MSscan; method = :relative)

Allows plotting directly mass spectra MSscan. The defaults relative intensity plotting may be changed by setting method = :absolute.

source

Utilities


Base overloaded

Base.:+Method
+(a::MScontainer, b::MScontainer)

Addition of mass spectra elementwise.

julia> scans[1] - scans[2]
MassJ.MSscans([1, 2], [0.1384, 0.7307]
source
Base.:-Method
-(a::MScontainer, b::MScontainer)

Substraction of mass spectra elementwise. Negative scan num refers the 'b' MScontainer.

julia> a - b
MassJ.MSscans([1, 4], [0.1384, 3.7578, -0.1384, -3.7578]...
source
Base.:/Method
/(a::MSscan, N::Real)

Divide the intensity and the tic data of a MSscan by a number.

julia> scans[1] / 1.0e2
MassJ.MSscan(1, 0.1384, 50819.5, [140. ....
source
Base.:/Method
/(a::MSscans, N::Real)

Divide the intensity, tic and variance of a MSscans by a number.

julia> a / 1.0e2
MassJ.MSscans(1, 0.1384, 50819.5, [140. ....
source
Base.:*Method
*(a::MSscan, N::Real)

Multiply the intensity and the tic data of a MSscan by a number.

julia> scans[1] * 1.0e2
MassJ.MSscan(1, 0.1384, 50819.5, [140. ....
source
Base.:*Method
*(a::MSscans, N::Real)

Multiply the intensity, tic and variance of a MSscans by a number.

julia> a * 1.0e2
MassJ.MSscans(1, 0.1384, 50819.5, [140. ....
source
Base.:*Method
*(N::Real, a::MScontainer)

Commutation of multiplication of number with MScontainer.

source
Base.:*Method
*(a::MScontainer, b::MScontainer)

Multiplication of mass spectra elementwise.

julia> a * b
MassJ.MSscans([2, 5], [0.7307, 4.344
source

Utility function

MassJ.avgMethod
avg(a::MScontainer, b::MScontainer)

Returns the average of the input mass spectra and compute the variance using an incremental Welford algorithm.

julia> MassJ.avg(scans[1], scans[4])
MassJ.MSscans([1, 4], [0.1384, 3.7578], ....
source
MassJ.add_ion_currentMethod
add_ion_current(x::AbstractArray, y::AbstractArray, a::Real, b::Real)

Returns sum the ion current (int) within the m/z range defined by the a and b input values.

source
MassJ.num2pntMethod
num2pnt(x::AbstractArray, val::Real)

General purpose utility function used to retrieve the index of an array for which the value is closest to the input.

source
MassJ.savitzky_golayMethod
savitzky_golay(int::AbstractArray, order::Int, window::Int, deriv::Int)

Savitzky-Golay filter removes high frequency noise from data. Parameters: int::AbstractArray order::Int order of the polynomial window::Int length of the window, has to be an odd number deriv::Int the order of the derivative to be computed. Default = 0 leads to smoothing only.

source
MassJ.extremefiltMethod
extremefilt(input::AbstractArray, minmax::Function, region::Int)

Return the erosion or the dilation of the input over the region, which the size of the structuring element.

source
MassJ.morpholaplaceMethod
morpholaplace(input::AbstractArray, region::Int)

Performs morphological Laplacian of the input array, as defined by the addition of the dilatation and the erosion of the input array.

source
MassJ.morphogradientMethod
morphogradient(input::AbstractArray, region::Int)

Performs morphological gradient of the input array, defined by the difference between the dilatation and the erosion of the input array.

source
MassJ.tophatMethod
tophat(input::AbstractArray, region::Int)

Performs the Top Hat of the input Array, defined by the difference between the input and its morphological opening.

source
MassJ.bottomhatMethod
bottomhat(input::AbstractArray, region::Int)

Performs the Bottom Hat of the input Array, defined by the difference between the morphological closing of the input and the input.

source
MassJ.openingMethod
opening(input::AbstractArray, region::Int)

Performs the morphological opening of the input Array, which is the dilatation of the erosion of the input

source
MassJ.closingMethod
closing(input::AbstractArray, region::Int)

Performs the morphological closing of the input Array, which is defined as the erosion of the dilatation of the input.

source
MassJ.erosionMethod
erosion(input::AbstractArray, region::Int)

Performs the morphological erosion of the input, which is the minimum-filtering over the structuring element region.

source
MassJ.dilatationMethod
dilatation(input::AbstractArray, region::Int)

Performs the morphological dilatation of the input, which is the maximum-filtering over the structuring element region

source
MassJ.convolveMethod
convolve(a::AbstractArray, b::AbstractArray)

Convolve arrays a and b using the Fourier transform algorithm.

source