This page lists all the documented elements of the MassJ.jl package covering all modules and submodules.
Main module
MassJ.MassJ — Module
Main module for MassJ.jl– A Julia package to load and process mass spectrometry data.
Types
Submodule with types and structures used to stored the data and dispatch to the right methods.
Data types
MassJ.MScontainer — Type
abstract type MScontainer endAbstract type containing any imported data belongs to the MScontainer type.
MassJ.MSscan — Type
struct MSscan <: MScontainerData 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
endMassJ.MSscans — Type
struct MSscans <: MScontainerData 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
endMassJ.Chromatogram — Type
struct Chromatogram <: MScontainerData structure used to retrieve chromatography data.
struct Chromatogram <: MScontainer
rt::Vector{Float64} # retention time
ic::Vector{Float64} # ion current
maxic::Float64
endMassJ.Mobilogram — Type
struct Mobilogram <: MScontainerData 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
endMassJ.Ionogram — Type
struct Ionogram <: MScontainerData 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
endMassJ.Isotope — Type
struct IsotopeData 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
endMethods Types
MassJ.MethodType — Type
abstract type MethodType endType containing all the methods used for filtering the data.
MassJ.BasePeak — Type
struct BasePeak <: MethodTypeStructure for multiple dispatching to retrieve base peak chromatogram.
MassJ.TBPD — Type
struct TBPD{argT1 <: Symbol, argT2 <: Real, argT3 <: Real} <: MethodTypeStructure 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.
MassJ.SNRA — Type
struct SNRA{argT1 <: Real, argT2 <: Int} <: MethodTypeStructure 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.
MassJ.TopHat — Type
TopHat{argT <: Int} <: MethodTypeStructure for multiple dispatching to TopHat baseline correction. Region is used to specify the dimension over which this operation is performed.
MassJ.LOESS — Type
LOESS{argT <: Int} <: MethodTypeStructure for multiple dispatching to LOcally Weighted Error Sum of Squares regression (LOESS) baseline correction.
MassJ.IPSA — Type
struct IPSA{argT1 <: Int, argT2 <: Int} <: MethodTypeStructure for multiple dispatching to iterative polynomial smoothing algorithm (IPSA) baseline correction.
MassJ.UniDec — Type
struct UniDec <: MethodTypeStructure for multiple dispatching to UniDec deconvolution algorithm.
MassJ.Charges — Type
struct Charges <: MethodTypeStructure for multiple dispatching to UniDec charge deconvolution algorithm.
MassJ.Masses — Type
struct Masses <: MethodTypeStructure for multiple dispatching to UniDec mass deconvolution algorithm.
Filters
MassJ.FilterType — Type
abstract type FilterType endThis type contains the structures for filtering the data.
MassJ.Level — Type
struct Level{argT <: Union{Int, AbstractVector{<:Int} }} <: FilterTypeUsed to dispatch filters to MS level.
MassJ.Scan — Type
Scan{argT <: Union{Int, AbstractVector{<:Int} }} <: FilterTypeDispatch filter to scan num.
MassJ.Polarity — Type
struct Polarity{argT <: Union{String, AbstractVector{<:String} }} <: FilterTypeDispatch filter to polarity.
MassJ.Activation_Method — Type
struct Activation_Method{argT <: Union{String, AbstractVector{<:String} }} <: FilterTypeDispatch filter to activation methods
MassJ.Activation_Energy — Type
struct Activation_Energy{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterTypeDispatch filter to activation energies.
MassJ.Precursor — Type
struct Precursor{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterTypeDispatch filter to precursor.
MassJ.DriftTime — Type
struct DriftTime{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterTypeDispatch filter to ion mobility drift time or 1/K0 values.
MassJ.CompensationVoltage — Type
struct CompensationVoltage{argT <: Union{Real, AbstractVector{<:Real} }} <: FilterTypeDispatch filter to FAIMS/DMS compensation voltage.
I/O
Module for importing and exporting data. Dispatch to specific methods according to the file extension
MassJ.info — Method
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+"MassJ.load — Method
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, ...)MassJ.retention_time — Method
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
...MassJ.chromatogram — Method
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]))MassJ.average — Method
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], ...mzXML
Interface to the mzXML file format.
MassJ.info_mzxml — Function
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.
MassJ.load_mzxml_all — Function
load_mzxml_all(filename::String)Load an entire an mzxml file.
MassJ.load_mzxml — Function
load_mzxml(filename::String, index::Int)Load from an mzxml file the scan num that matches the input index.
MassJ.load_mzxml_spectrum — Function
load_mzxml_spectrum(c::XMLElement)From an XMLElement, returns the data into an MSscan.
MassJ.retention_time — Method
retention_time(msRun::XMLElement)From an XMLElement returns the retention time.
MassJ.filter — Method
filter(msRun::XMLElement, argument::Level{<:Int})Search for scans matching the argument level and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Level{<:AbstractVector}Search for scans matching the argument levels and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Scan{<:Int})Search for scans matching the argument scan num and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Scan{<:AbstractVector}Search for scans matching the argument scan nums and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Polarity{<:String})Search for scans matching the argument polarity and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Polarity{<:AbstractVector})Search for scans matching the argument polarities and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::RT{<:Real})Search for scans matching the argument retention time and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::RT{<:AbstractVector}Search for scans matching the argument retention times within the range and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::RT{<:AbstractVector{<:AbstractVector} } )Search for scans matching the argument retention times within the ranges and returns a list of index
MassJ.filter — Method
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
MassJ.filter — Method
filter(msRun::XMLElement, argument::Precursor{<:Real})Search for scans matching the argument precursor mz and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Precursor{<:AbstractVector})Search for scans matching the argument precusors mz and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Activation_Energy{<:Real})Search for scans matching the argument activation energy and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Activation_Energy{<:AbstractVector})Search for scans matching the argument activation energies and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Activation_Method{<:String})Search for scans matching the argument activation method and returns a list of index
MassJ.filter — Method
filter(msRun::XMLElement, argument::Activation_Method{<:AbstractVector})Search for scans matching the argument activation methods and returns a list of index
MassJ.extracted_chromatogram — Method
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
MassJ.composite_spectra — Method
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.
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_mzml — Function
info_mzml(filename::String, info::Vector{String}, verbose::Bool=false)Returns the information content of an mzML file into a string.
MassJ.load_mzml_all — Function
load_mzml_all(filename::String)Load all spectra from an mzML file. Returns a Vector{MSscan}.
MassJ.load_mzml — Function
load_mzml(filename::String, target_num::Int)Load a single scan from an mzML file by scan number.
MassJ.load_mzml_spectrum — Function
load_mzml_spectrum(spec::XMLElement, scan_index::Int)Parse a single <spectrum> element and return an MSscan.
MassJ.retention_time_mzml — Function
retention_time_mzml(filename::String)Extract retention times from an mzML file without loading full spectra.
MassJ.find_mzml_root — Function
find_mzml_root(xdoc::XMLDocument)Navigate to the mzML element, handling both raw mzML and indexedmzML wrappers. Returns the mzML element.
MassJ.get_cv_param — Function
get_cv_param(elem::XMLElement, accession::String)Search for a cvParam child with the given accession. Returns the XMLElement or nothing.
MassJ.get_cv_value — Function
get_cv_value(elem::XMLElement, accession::String, default="")Get the value attribute of a cvParam with the given accession. Returns default if not found.
MassJ.has_cv_param — Function
has_cv_param(elem::XMLElement, accession::String)Check whether elem has a cvParam child with the given accession.
MGF
Interface to the MGF (Mascot Generic Format) file format. Text-based format for centroided MS/MS peak lists.
MassJ.load_mgf_all — Function
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.
MassJ.build_mgf_scan — Function
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.
MassJ.info_mgf — Function
info_mgf(filename::String, info::Vector{String}, verbose::Bool=false)Returns summary information about an MGF file.
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_all — Function
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.
MassJ.build_msp_scan — Function
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.
MassJ.info_msp — Function
info_msp(filename::String, info::Vector{String}, verbose::Bool=false)Returns summary information about an MSP file.
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_all — Function
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.
MassJ.load_imzml_spectrum — Function
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.
MassJ.info_imzml — Function
info_imzml(filename::String, info::Vector{String}, verbose::Bool=false)Returns summary information about an imzML file.
Filtering
MassJ.average — Method
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], ...MassJ.chromatogram — Method
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])MassJ.retention_time — Method
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
....MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Scan{<:Int})Search for scans matching the argument scan num and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Scan{<:AbstractVector})Search for scans matching the argument scan nums and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Level{<:Int})Search for scans matching the argument MS level and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Level{<:AbstractVector})Search for scans matching the argument MS levels and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Precursor{<:Real})Search for scans matching the argument precursor mz and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Precursor{<:AbstractVector})Search for scans matching the argument precursors mz and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Activation_Energy{<:Real})Search for scans matching the argument activation energy and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Activation_Energy{<:AbstractVector})Search for scans matching the argument activation energies and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Activation_Method{<:String})Search for scans matching the argument activation method and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Activation_Method{<:AbstractVector})Search for scans matching the argument activation methods and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Polarity{<:String})Search for scans matching the argument polarity and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::Polarity{<:AbstractVector})Search for scans matching the argument polarities and returns a list of the corresponding indexes
MassJ.filter — Method
filter(scans::Vector{MSscan}, argument::RT{<:Real})Search for scans matching the argument retention time and returns a list of the corresponding indexes
MassJ.filter — Method
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
MassJ.filter — Method
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
MassJ.filter — Method
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
MassJ.extracted_chromatogram — Method
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
MassJ.composite_spectra — Method
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.
Extracting subsets
MassJ.extract — Method
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, ...)MassJ.extract — Method
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, ....MassJ.build_subset — Method
build_subset(filename::String, indices::Vector{Int})Returns a Vector of MSscan from the input file according to the scan num (indices).
MassJ.build_subset — Method
build_subset(scans::Vector{MSscan}, indices::Vector{Int})Returns a Vector of MSscan according to the input scan num.
Process
Mass spectrum
MassJ.smooth — Method
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, ....MassJ.smooth — Method
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 .....MassJ.savitzky_golay_filtering — Method
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.
MassJ.centroid — Method
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, ....MassJ.centroid — Method
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, ....MassJ.snra — Method
snra(scan::MScontainer, thres::Real, region::Int)Signal to Noise Ratio Analysis method returning the m/z and intensity of the peaks detected.
MassJ.tbpd — Method
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.
MassJ.gauss — Method
gauss(x::Real, p::AbstractArray)Gaussian shape function.
MassJ.lorentz — Method
lorentz(x::Real, p::AbstractArray)Cauchy-Lorentz shape function.
MassJ.voigt — Method
voigt(x::Real, p::AbstractArray)Pseudo-Voigt profile function used by the TBPD method.
Missing docstring for MassJ.tbpd(scan::MScontainer, shape::Symbol, R::Real, thres::Real). Check Documenter's build log for details.
MassJ.baseline_correction — Method
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, ....MassJ.baseline_correction — Method
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, ....MassJ.tophat_filter — Method
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.
Missing docstring for MassJ.tophat_filter(scans::Vector{MSscan}, region::Int ). Check Documenter's build log for details.
Missing docstring for MassJ.loess(scans::Vector{MSscan}, iter::Int ). Check Documenter's build log for details.
MassJ.loess — Method
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).
MassJ.ipsa — Method
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.
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.deconv — Function
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, ....Simulations
MassJ.formula — Function
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.
MassJ.masses — Function
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.0masses(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.0MassJ.isotopic_distribution — Function
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 MassJ.simulate — Function
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)Plots
MassJ.plots — Module
Plotting module for MScontainer data type (MSscan, MSscans and Chromatogram).
julia> plot(scans[1])
julia> plot(chr)MassJ.plots.normalisation — Method
normalisation(cr::MassJ.Chromatogram)Normalization function for plotting chromatograms in raltive intensity.
MassJ.plots.normalisation — Method
normalisation(ms::MassJ.MScontainer)Normalization function for plotting mass spectra in relative intensity.
MassJ.plots.scaling — Method
scaling(cr::MassJ.Chromatogram)Scaling function to display retention times of chromatograms in minutes instead of seconds.
RecipesBase.apply_recipe — Method
h(cr::MassJ.Chromatogram; method = :relative)Allows plotting directly chromatograms. The defaults relative intensity plotting may be changed by setting method = :absolute.
RecipesBase.apply_recipe — Method
g(ms::MassJ.MSscans; method = :relative)Allows plotting directly mass spectra MSscans. The defaults relative intensity plotting may be changed by setting method = :absolute.
RecipesBase.apply_recipe — Method
f(ms::MSscan; method = :relative)Allows plotting directly mass spectra MSscan. The defaults relative intensity plotting may be changed by setting method = :absolute.
Utilities
Base overloaded
Utility function
MassJ.add_ion_current — Method
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.
MassJ.num2pnt — Method
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.
MassJ.savitzky_golay — Method
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.
MassJ.extremefilt — Method
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.
MassJ.morpholaplace — Method
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.
MassJ.morphogradient — Method
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.
MassJ.tophat — Method
tophat(input::AbstractArray, region::Int)Performs the Top Hat of the input Array, defined by the difference between the input and its morphological opening.
MassJ.bottomhat — Method
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.
MassJ.opening — Method
opening(input::AbstractArray, region::Int)Performs the morphological opening of the input Array, which is the dilatation of the erosion of the input
MassJ.closing — Method
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.
MassJ.erosion — Method
erosion(input::AbstractArray, region::Int)Performs the morphological erosion of the input, which is the minimum-filtering over the structuring element region.
MassJ.dilatation — Method
dilatation(input::AbstractArray, region::Int)Performs the morphological dilatation of the input, which is the maximum-filtering over the structuring element region
MassJ.convolve — Method
convolve(a::AbstractArray, b::AbstractArray)Convolve arrays a and b using the Fourier transform algorithm.