Basics

JuChrom.AbstractChromMSType
AbstractChromMS <: AbstractChromatogram

Supertype for all chromatogram implementations that include mass-charge ratio (m/z) data (ions) and associated abundance values (intensities) (e.g., ChromMS). This type can have one or more ion intensity values associated with a given scan time. Intensities are stored in a matrix where the row index represents the scan time and the column index represents the ion.

See also AbstractChromatogram, AbstractChromMS, ChromMS, scantimes, ions, intensities, metadata, rimapper.

source
JuChrom.ChromMSType
ChromMS(scantimes::AbstractVector{<:Unitful.Time}, ions::AbstractVector{<:Real}, 
intensities::AbstractMatrix{<:Real}; metadata::Dict=Dict{Any, Any}(), 
rimapper::Union{AbstractRiMapper, Nothing}=nothing) <: AbstractChromMS

Construct a ChromMS object that includes scantimes, ions, intensities, and metadata. Ensure that both scantimes and ions are in ascending order. The scan times must include a time unit. All time units supported by the Unitful.jl package (e.g., u"s", u"minute") are accepted. You can optionally use the keyword argument rimapper to include a retention index mapper.

See also AbstractChromatogram, AbstractChromMS, scantimes, ions, intensities, metadata.

In the following examples, the types of scantimes, ions, and intensities are explicitely annotated to demonstrate that the ChromMS object preserves these types.

Examples

julia> ChromMS(Int32[1, 2, 3]u"s", Int64[85, 100], Int32[0 12; 34 956; 23 1])
ChromMS {scan times: Int32, ions: Int64, intensities: Int32}
3 scans; scan times: 1 s, 2 s, 3 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> ChromMS([1.1f0, 2.1f0]u"s", [35.1f0, 76.2f0], Int64[0 12; 34 956], Dict(:id => 4))
ChromMS {scan times: Float32, ions: Float32, intensities: Int64}
2 scans; scan times: 1.1f0 s, 2.1f0 s
2 ions: m/z 35.1, 76.2
intensity range: 0 - 956
metadata: 1 entry

julia> ChromMS([2, 1, 3]u"s", [85, 100], [0 12; 34 956; 23 1])
ERROR: ArgumentError: scan times not in ascending order
[...]

julia> ChromMS([1, 2, 3]u"s", [100, 85], [0 12; 34 956; 23 1])
ERROR: ArgumentError: ions not in ascending order
[...]
source
JuChrom.ChromType
Chrom(scantimes::AbstractVector{<:Unitful.Time}, 
intensities::AbstractVector{<:Real}, metadata::Dict=Dict{Any, Any}; 
rimapper::Union{AbstractRiMapper, Nothing}=nothing) <: AbstractChrom

Construct a Chrom object that includes scantimes, intensities, and metadata. Ensure that both scantimes and ions are in ascending order. The scan times must include a time unit. All time units supported by the Unitful.jl package (e.g., u"s", u"minute") are accepted. You can optionally use the keyword argument rimapper to include a retention index mapper.

See also AbstractChromatogram, AbstractChrom, scantimes, intensities, metadata, rimapper.

In the following examples, the types of scantimes and intensities are explicitely annotated to demonstrate that the Chrom object preserves these types.

Examples

julia> Chrom(Int64[1, 2, 3]u"s", Int32[12, 956, 1])
Chrom {scan times: Int64, intensities: Int32}
3 scans; scan times: 1 s, 2 s, 3 s
intensity range: 1 - 956
metadata: 0 entries

julia> Chrom(Int32[1, 2, 3]u"s", Float64[12.0, 956.0, 1.0], Dict("name" => "sample"))
Chrom {scan times: Int32, intensities: Float64}
3 scans; scan times: 1 s, 2 s, 3 s
intensity range: 1.0 - 956.0
metadata: 1 entry

julia> Chrom([2, 1, 3]u"s", [12.0, 956.0, 1.0])
ERROR: ArgumentError: scan times not in ascending order
[...]
source
JuChrom.LinearAscendingType
LinearAscending(; start::Real=0, stop::Real=1) <: IonScanOrder

Construct a LinearAscending ion scan order object. This object specifies that ions were scanned in linear ascending order (i.e., smallest ion first, largest ion last) during each scan. The time allocated to scan each ion is assumed to be equal, resulting from dividing the total scan interval time equally among the ions. The optional start and stop parameters allow you to limit the time interval during which ions were scanned in each scan. These parameters specify relative points within the scan interval: 0 ≤ start < stop ≤ 1. The default values are start=0 and stop=1, meaning the scan of the smallest ion began at the start of the scan interval and the scan of the largest ion concluded at the end of the interval. In contrast, setting the start value to 0.5 indicates that ions were scanned only during the second half of the scan interval. For instance, this could occur if the instrument switched between SIM mode and Scan mode during each scan interval, operating in Scan mode only during the second half, which generated the data in question.

See also AbstractChromMS, LinearDescending, ionscantimeshift, ionscantimes, ionscantime, ionscantimeindex, ions, minion, maxion, ioncount, scanduration, scantimes, minscantime, maxscantime.

Examples

julia> LinearAscending()
LinearAscending{Int64, Int64}(0, 1)

julia> LinearAscending(; start=0.5)
LinearAscending{Float64, Int64}(0.5, 1)

julia> LinearAscending(; start=0.1, stop=0.5)
LinearAscending{Float64, Float64}(0.1, 0.5)

julia> LinearAscending(; start=0.5, stop=0.5)
ERROR: ArgumentError: start=0.5 and stop=0.5 do not satisfy condition 0 ≤ start < stop ≤ 1
[...]
source
JuChrom.LinearDescendingType
LinearDescending(; start::Real=0, stop::Real=1) <: IonScanOrder

Construct a LinearDescending ion scan order object. This object specifies that ions were scanned in linear descending order (i.e., largest ion first, smallest ion last) during each scan. The time allocated to scan each ion is assumed to be equal, resulting from dividing the total scan interval time equally among the ions. The optional start and stop parameters allow you to limit the time interval during which ions were scanned in each scan. These parameters specify relative points within the scan interval: 0 ≤ start < stop ≤ 1. The default values are start=0 and stop=1, meaning the scan of the largest ion began at the start of the scan interval and the scan of the smallest ion concluded at the end of the interval. In contrast, setting the start value to 0.5 indicates that ions were scanned only during the second half of the scan interval. For instance, this could occur if the instrument switched between SIM mode and Scan mode during each scan interval, operating in Scan mode only during the second half, which generated the data in question.

See also AbstractChromMS, LinearAscending, ionscantimeshift, ionscantimes, ionscantime, ionscantimeindex, ions, minion, maxion, ioncount, scanduration, scantimes, minscantime, maxscantime.

Examples

julia> LinearDescending()
LinearDescending{Int64, Int64}(0, 1)

julia> LinearDescending(; start=0.5)
LinearDescending{Float64, Int64}(0.5, 1)

julia> LinearDescending(; start=0.1, stop=0.5)
LinearDescending{Float64, Float64}(0.1, 0.5)

julia> LinearDescending(; start=0.5, stop=0.5)
ERROR: ArgumentError: start=0.5 and stop=0.5 do not satisfy condition 0 ≤ start < stop ≤ 1
[...]
source
JuChrom.binionsFunction
binions(chrom::ChromMS; ionbin::Function=integer)

Return a ChromMS object in which the ions are binned according to the ionbin function (the default is the integer function), and the intensities of the binned ions are summed.

See also AbstractChromMS, integer, intensities, ions, ioncount.

Examples

julia> chrom = ChromMS((1:3)u"s", [84.8, 85.2, 100.9], [0 24 12; 0 0 956; 23 0 1])
ChromMS {scan times: Int64, ions: Float64, intensities: Int64}
3 scans; scan times: 1 s, 2 s, 3 s
3 ions: m/z 84.8, 85.2, 100.9
intensity range: 0 - 956
metadata: 0 entries

julia> intensities(chrom)
3×3 Matrix{Int64}:
  0  24   12
  0   0  956
 23   0    1

julia> chrom_binnedions = binions(chrom)
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
3 scans; scan times: 1 s, 2 s, 3 s
2 ions: m/z 85, 101
intensity range: 0 - 956
metadata: 0 entries

julia> ions(chrom_binnedions)
2-element Vector{Int64}:
  85
 101

julia> intensities(chrom_binnedions)
3×2 Matrix{Int64}:
 24   12
  0  956
 23    1


julia> custom_ionbin(ion) = integer(ion, start=0.9);

julia> chrom_binnedions = binions(chrom, ionbin=custom_ionbin)
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
3 scans; scan times: 1 s, 2 s, 3 s
3 ions: m/z 84, 85, 101
intensity range: 0 - 956
metadata: 0 entries

julia> ions(chrom_binnedions)
3-element Vector{Int64}:
  84
  85
 101
source
JuChrom.integerFunction
integer(value::Real; start::Real=0.7) -> Int

Return the integer for the given value that satisfies the following condition: integer - 1 + start ≤ value < integer + start, where 0 ≤ start < 1.

See also AbstractChromMS, ChromMS, binions, ions.

Examples

julia> integer(29.7)
30

julia> integer(30.0)
30

julia> integer(30.69)
30

julia> integer(29.7, start=0.8)
29
source
JuChrom.intensitiesMethod
intensities(chrom::AbstractChrom; scanindexrange::OrdinalRange{T, S}) where {T<:Integer, 
S<:Integer}

Return the intensities. The optional keyword argument scanindexrange lets you select a subset of scans for which the intensities will be returned. Note that the function will return either a reference to the intensity vector or a view into the intensity vector, depending on whether a subset of scans is selected.

See also AbstractChrom, intensity, minintensity, maxintensity, scancount.

Examples

julia> chrom = Chrom([1, 2, 3]u"s", [123, 224, 103])
Chrom {scan times: Int64, intensities: Int64}
3 scans; scan times: 1 s, 2 s, 3 s
intensity range: 103 - 224
metadata: 0 entries

julia> intensities(chrom)  # reference to the data structure
3-element Vector{Int64}:
 123
 224
 103

julia> intensities(chrom)[:]  # a copy of these values
3-element Vector{Int64}:
 123
 224
 103

julia> intensities(chrom; scanindexrange=2:3)  # view into the data structure
2-element view(::Vector{Int64}, 2:3) with eltype Int64:
 224
 103

julia> intensities(chrom; scanindexrange=2:3)[:]  # a copy of these values
2-element Vector{Int64}:
 224
 103
source
JuChrom.intensitiesMethod
intensities(chrom::AbstractChromMS; scanindexrange::OrdinalRange{T1, S1}, 
ionindexrange::OrdinalRange{T2, S2}) where {T1<:Integer, S1<:Integer, T2<:Integer, 
S2<:Integer}

Return the intensities. The optional keyword arguments scanindexrange and ionindexrange allow you to select specific parts of the intensity matrix to be returned. Note that the function returns either a reference to the matrix or a view into it, depending on whether the keyword arguments specify subranges of the matrix.

See also AbstractChromMS, scancount, ioncount, minintensity, maxintensity.

Examples

julia> chrom = ChromMS([1, 2, 3]u"s", [85, 100], [0 12; 34 956; 23 1])
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
3 scans; scan times: 1 s, 2 s, 3 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> intensities(chrom)  # reference to the data structure
3×2 Matrix{Int64}:
  0   12
 34  956
 23    1

julia> intensities(chrom)[:, :]  # a copy of these values
3×2 Matrix{Int64}:
  0   12
 34  956
 23    1

julia> intensities(chrom, ionindexrange=1:1)  # all intensities of the ion at index 1
3×1 view(::Matrix{Int64}, 1:3, 1:1) with eltype Int64:
  0
 34
 23

julia> intensities(chrom, ionindexrange=1:1)[:]  # a copy of these values
3-element Vector{Int64}:
  0
 34
 23

julia> intensities(chrom, scanindexrange=1:1)  # intensities of all ions from scan 1
1×2 view(::Matrix{Int64}, 1:1, 1:2) with eltype Int64:
 0  12

julia> intensities(chrom, scanindexrange=1:1)[:]  # a copy of these values
2-element Vector{Int64}:
  0
 12

julia> intensities(chrom, scanindexrange=1:2, ionindexrange=1:2)
2×2 view(::Matrix{Int64}, 1:2, 1:2) with eltype Int64:
  0   12
 34  956

julia> intensities(chrom, scanindexrange=1:2, ionindexrange=1:2)[:, :]
2×2 Matrix{Int64}:
  0   12
 34  956
source
JuChrom.intensityMethod
intensity(chrom::AbstractChrom, scanindex::Integer)

Return the intensity for a scan by specifying its scanindex.

See also AbstractChrom, intensities, minintensity, maxintensity.

Examples

julia> chrom = Chrom([1, 2, 3]u"s", [123, 224, 103])
Chrom {scan times: Int64, intensities: Int64}
3 scans; scan times: 1 s, 2 s, 3 s
intensity range: 103 - 224
metadata: 0 entries

julia> intensity(chrom, 1)
123

julia> intensity(chrom, 2)
224
source
JuChrom.intensityMethod
intensity(chrom::AbstractChrom, time::Unitful.Time; precisetime::Bool=false)

Return the intensity at a given time. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. By default, the intensity associated with the scan whose timestamp is closest to the given time is returned. In case of a tie, the intensity of the scan with the later timestamp is used. If the optional parameter precisetime is set to true, the specified time must exactly match a timestamp in the vector; otherwise, an error is thrown.

See also AbstractChrom, intensities, scantimes, minscantime, maxscantime.

Examples

julia> chrom = Chrom([1.0, 2.0, 3.0]u"s", [123, 224, 103])
Chrom {scan times: Float64, intensities: Int64}
3 scans; scan times: 1.0 s, 2.0 s, 3.0 s
intensity range: 103 - 224
metadata: 0 entries

julia> intensity(chrom, 1.5u"s")
224

julia> intensity(chrom, 1u"s", precisetime=true)
123

julia> intensity(chrom, 1.5u"s", precisetime=true)
ERROR: ArgumentError: scantime 1.5 s does not exist
[...]
source
JuChrom.intensityMethod
intensity(chrom::AbstractChromMS, scanindex::Integer, ionindex::Integer)

Return the intensity of an ion in a scan, given the scanindex of the scan and the ionindex of the ion.

See also AbstractChromMS, scancount, ions, ioncount.

Examples

julia> chrom = ChromMS([1, 2, 3]u"s", [85, 100], [0 12; 34 956; 23 1])
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
3 scans; scan times: 1 s, 2 s, 3 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> intensity(chrom, 2, 1)
34

julia> intensity(chrom, 1, 2)
12
source
JuChrom.intensityMethod
intensity(chrom::AbstractChromMS, time::Unitful.Time, ion::Real; precisetime::Bool=false)

Return the intensity of an ion at a given time. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. By default, the intensity associated with the scan whose timestamp is closest to the given time is returned. In case of a tie, the intensity of the scan with the later timestamp is used. If the optional parameter precisetime is set to true, the specified time must exactly match a timestamp in the vector; otherwise, an error is thrown.

See also AbstractChromMS, intensities, ions, scantimes.

Examples

julia> chrom = ChromMS([1.0, 2.0, 3.0]u"s", [85, 100], [0 12; 34 956; 23 1])
ChromMS {scan times: Float64, ions: Int64, intensities: Int64}
3 scans; scan times: 1.0 s, 2.0 s, 3.0 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> intensity(chrom, 1.9u"s", 85)
34

julia> intensity(chrom, 2.9u"s", 85, precisetime=true)
ERROR: ArgumentError: scantime 2.9 s does not exist
[...]

julia> intensity(chrom, 3u"s", 85, precisetime=true)
23
source
JuChrom.ionMethod
ion(chrom::AbstractChromMS, ionindex::Integer)

Return the ion at the specified ionindex.

See also AbstractChromMS, ions, ionindex, minion, maxion, ioncount.

Examples

julia> chrom = ChromMS((1:3)u"s", [85, 100], [0 12; 34 956; 23 1]);

julia> ion(chrom, 1)
85

julia> ion(chrom, 2)
100

julia> ion(chrom, 3)
ERROR: BoundsError: attempt to access 2-element Vector{Int64} at index [3]
[...]
source
JuChrom.ionindexMethod
ionindex(chrom::AbstractChromMS, ion::Real) -> Int

Return the index of the specified ion. An error is thrown if the ion does not exist.

See also AbstractChromMS, ions, ioncount, ion, minion, maxion, ionscantime, ionscantimeshift.

Examples

julia> chrom = ChromMS((1:3)u"s", [85.2f0, 100.1f0], [0 12; 34 956; 23 1]);

julia> ionindex(chrom, 100.1)
2

julia> ionindex(chrom, 201.1)
ERROR: ArgumentError: ion 201.1 does not exist
[...]
source
JuChrom.ionscantimeFunction
ionscantime(δtᵢ::Function, chrom::AbstractChromMS, scanindex::Integer, ionindex::Integer; 
timeunit::Unitful.TimeUnits, ustripped::Bool=false)

Return the time at which an ion was actually scanned, given the scanindex, ionindex, and a function δtᵢ that computes the time difference between the timestamp of a scan and the scan time of the ion from the ionindex. The optional parameter timeunit allows you to specify the unit of the returned scan time. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. The optional keyword argument ustripped lets you choose whether the unit is included in the returned value. Note that the timestamp of a scan is assumed to be the time when the scanning of ion intensities associated with that scan was completed.

See also AbstractChromMS, scantimes, scantime, scantimeindex, ions, ionindex, ionscantimeshift, IonScanOrder, LinearAscending, LinearDescending.

Examples

julia> chrom = ChromMS([1.0, 2.0, 3.0]u"s", [85, 100], [0 12; 34 956; 23 1])
ChromMS {scan times: Float64, ions: Int64, intensities: Int64}
3 scans; scan times: 1.0 s, 2.0 s, 3.0 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> δtᵢ = ionscantimeshift(chrom, LinearDescending());

julia> ionscantime(δtᵢ, chrom, 2, 1)
2.0 s

julia> ionscantime(δtᵢ, chrom, 2, 2)
1.5 s

julia> ionscantime(δtᵢ, chrom, 2, 2; timeunit=u"minute")
0.025 minute

julia> ionscantime(δtᵢ, chrom, 2, 2; timeunit=u"minute", ustripped=true)
0.025
source
JuChrom.ionscantimeindexFunction
ionscantimeindex(δtᵢ::Function, chrom::AbstractChromMS, ionindex::Integer, 
time::Unitful.Time; precisetime::Bool=false) -> Int

Return the index of the scan where the scan time for the ion is closest to the specified time, given the ionindex and a function δtᵢ that computes the time difference between the timestamp of a scan and the scan time of the ion from the ionindex. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. In case of a tie, the larger scan index is returned. If the optional parameter precisetime is set to true, the ion must have been scanned exactly at the specified time; otherwise, an error is thrown.

See also AbstractChromMS, scantimeindex, ionscantime, ionscantimeshift, IonScanOrder, LinearAscending, LinearDescending, scantimes, scantime, ions, ion, ionindex.

Examples

julia> chrom = ChromMS([1, 2, 3]u"s", [85, 100], [0 12; 34 956; 23 1])
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
3 scans; scan times: 1 s, 2 s, 3 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> δtᵢ = ionscantimeshift(chrom, LinearDescending());

julia> ionscantime(δtᵢ, chrom, 2, 2)
1.5 s

julia> ionscantimeindex(δtᵢ, chrom, 2, 1.5u"s")
2

julia> ionscantimeindex(δtᵢ, chrom, 2, 1.6u"s")
2

julia> ionscantimeindex(δtᵢ, chrom, 2, 1.6u"s", precisetime=true)
ERROR: ArgumentError: ion has not been scanned at the time 1.6 s
[...]

julia> ionscantimeindex(δtᵢ, chrom, 2, 1.5u"s", precisetime=true)
2

julia> ionscantimeindex(δtᵢ, chrom, 1, 1.4u"s")
1

julia> ionscantime(δtᵢ, chrom, 1, 1)
1.0 s
source
JuChrom.ionscantimesFunction
ionscantimes(δtᵢ::Function, chrom::AbstractChromMS, ionindex::Integer; 
timeunit::Unitful.TimeUnits, ustripped::Bool=false)

Return the times at which an ion was actually scanned, given the ionindex and a function δtᵢ that computes the time difference between the timestamp of a scan and the scan time of the ion from the ionindex. The optional parameter timeunit allows you to specify the unit for the returned scan times. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. The optional keyword argument ustripped lets you choose whether to include the unit in the returned value. Note that the timestamp of a scan is assumed to be the time when the scanning of ion intensities associated with that scan was completed.

See also AbstractChromMS, ionscantime, ionscantimeshift, IonScanOrder, LinearAscending, LinearDescending, scantimes, scantimeindex, ions, ionindex.

Examples

julia> chrom = ChromMS([1.0, 2.0, 3.0]u"s", [85, 100], [0 12; 34 956; 23 1])
ChromMS {scan times: Float64, ions: Int64, intensities: Int64}
3 scans; scan times: 1.0 s, 2.0 s, 3.0 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> δtᵢ = ionscantimeshift(chrom, LinearDescending());

julia> ionscantimes(δtᵢ, chrom, 1)
3-element Vector{Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}}:
 1.0 s
 2.0 s
 3.0 s

julia> ionscantimes(δtᵢ, chrom, 2)
3-element Vector{Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}}:
 0.5 s
 1.5 s
 2.5 s

julia> ionscantimes(δtᵢ, chrom, 2; timeunit=u"minute")
3-element Vector{Quantity{Float64, 𝐓, Unitful.FreeUnits{(minute,), 𝐓, nothing}}}:
 0.008333333333333333 minute
                0.025 minute
 0.041666666666666664 minute

julia> ionscantimes(δtᵢ, chrom, 2; timeunit=u"minute", ustripped=true)
3-element Vector{Float64}:
 0.008333333333333333
 0.025
 0.041666666666666664
source
JuChrom.ionscantimeshiftFunction
ionscantimeshift(chrom::AbstractChromMS, ionscanorder::IonScanOrder; error::Real=0.001)

Return a function, based on the ionscanorder, that calculates the time difference between the timestamp of a scan and the time when an ion was actually scanned, given the ion index as an argument. The time difference will be zero or negative, since the timestamp of a scan is considered to be when the scanning of the last ion was completed. The returned function assumes that the duration of each scan is consistent throughout the run. The optional keyword argument error lets you specify the maximum allowed deviation of the scan duration, as a fraction of the average scan time, between the timestamps of two consecutive scans.

See also AbstractChromMS, IonScanOrder, LinearAscending, LinearDescending, ionscantime, ions, minion, maxion, ioncount, scanduration, scantimes, minscantime, maxscantime.

Examples

julia> chrom = ChromMS([1.0, 2.0, 3.0]u"s", [85, 100], [0 12; 34 956; 23 1])
ChromMS {scan times: Float64, ions: Int64, intensities: Int64}
3 scans; scan times: 1.0 s, 2.0 s, 3.0 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> δtᵢ = ionscantimeshift(chrom, LinearAscending());

julia> δtᵢ(1)
-0.5 s

julia> δtᵢ(2)
0.0 s

julia> δtᵢ = ionscantimeshift(chrom, LinearDescending());

julia> δtᵢ(1)
0.0 s

julia> δtᵢ(2)
-0.5 s

julia> δtᵢ = ionscantimeshift(chrom, LinearDescending(start=0.5));

julia> δtᵢ(1)
0.0 s

julia> δtᵢ(2)
-0.25 s

julia> δtᵢ = ionscantimeshift(chrom, LinearDescending(stop=0.5));

julia> δtᵢ(1)
-0.5 s

julia> δtᵢ(2)
-0.75 s

julia> δtᵢ = ionscantimeshift(chrom, LinearDescending(start=0.25, stop=0.75));

julia> δtᵢ(1)
-0.25 s

julia> δtᵢ(2)
-0.5 s
source
JuChrom.ionsMethod
ions(chrom::AbstractChromMS)

Return the ions.

See also AbstractChromMS, ioncount, ion, minion, maxion, ionindex, ionscantime, ionscantimeshift.

In the following examples, the type of ions is explicitely annotated to demonstrate that the ChromMS object preserves this type.

Examples

julia> chrom = ChromMS([1, 2, 3]u"s", Int64[85, 100], [0 12; 34 956; 23 1]);

julia> ions(chrom)
2-element Vector{Int64}:
  85
 100

julia> chrom = ChromMS([1, 2, 3]u"s", Float32[85, 100], [0 12; 34 956; 23 1]);

julia> ions(chrom)
2-element Vector{Float32}:
  85.0
 100.0
source
JuChrom.maxintensityMethod
maxintensity(chrom::AbstractChrom[; scanindexrange::OrdinalRange{T, S}]) 
where {T<:Integer, S<:Integer})

Return the minimum intensity. The optional keyword argument scanindexrange allows you to specify a range of scans from which the minimum intensity is determined.

See also AbstractChrom, minintensity, intensities, intensity.

Examples

julia> chrom = Chrom([1, 2, 3]u"s", [12, 1, 956]);

julia> maxintensity(chrom)
956

julia> maxintensity(chrom, scanindexrange=1:2)
12
source
JuChrom.maxintensityMethod
maxintensity(chrom::AbstractChromMS[; scanindexrange::OrdinalRange{T1, S1}, 
ionindexrange::OrdinalRange{T2, S2}]) where {T1<:Integer, S1<:Integer, 
T2<:Integer, S2<:Integer})

Return the maximum intensity. The optional keyword arguments scanindexrange and ionindexrange allow you to select a range of scans and ions from which the minimum intensity is determined.

See also AbstractChromMS, minintensity, intensities, intensity.

Examples

julia> chrom = ChromMS([1, 2, 3]u"s", [85, 100], [0 12; 34 1; 23 956]);

julia> maxintensity(chrom)
956

julia> maxintensity(chrom, scanindexrange=1:2)
34

julia> maxintensity(chrom, ionindexrange=1:1)
34

julia> maxintensity(chrom, scanindexrange=1:2, ionindexrange=2:2)
12
source
JuChrom.maxscantimeFunction
maxscantime(chrom::AbstractChromatogram[, scanindexrange::OrdinalRange{<:Integer, 
<:Integer}]; timeunit::Unitful.TimeUnits, ustripped::Bool)

Return the maximum scan time. The optional second positional argument allows you to specify the scan range for which the maximum scan time is returned. The optional keyword argument timeunit lets you change the unit of the returned scan time. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. The optional keyword argument ustripped lets you choose whether to include the unit in the returned value.

See also AbstractChromatogram, minscantime, scantimes, scantime,scancount.

Examples

julia> chrom = ChromMS([1.0, 2.0, 3.0]u"s", [85, 100], [0 12; 34 956; 23 1]);

julia> maxscantime(chrom)
3.0 s

julia> maxscantime(chrom, timeunit=u"minute")
0.05 minute

julia> maxscantime(chrom, timeunit=u"minute", ustripped=true)
0.05

julia> maxscantime(chrom, 1:2)
2.0 s

julia> maxscantime(chrom, 1:2, timeunit=u"minute", ustripped=true)
0.03333333333333333
source
JuChrom.metadataMethod
metadata(chrom::AbstractChromatogram) -> Dict{Any, Any}

Return the metadata.

See also AbstractChromatogram.

Examples

julia> chrom₁ = ChromMS(Int64[1, 2]u"s", Int64[85, 100], Int64[0 12; 34 956], Dict(:id => 4))
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
2 scans; scan times: 1 s, 2 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 1 entry

julia> metadata(chrom₁)
Dict{Any, Any} with 1 entry:
  :id => 4

julia> chrom₂ = ChromMS(Int64[1, 2]u"s", Int64[85, 100], Int64[0 12; 34 956])
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
2 scans; scan times: 1 s, 2 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> metadata(chrom₂)
Dict{Any, Any}()

julia> metadata(chrom₂)["name"] = "sample"
"sample"

julia> metadata(chrom₂)[:id] = 123
123

julia> metadata(chrom₂)
Dict{Any, Any} with 2 entries:
  "name" => "sample"
  :id    => 123

julia> chrom₂
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
2 scans; scan times: 1 s, 2 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 2 entries

julia> delete!(metadata(chrom₂), "name")
Dict{Any, Any} with 1 entry:
  :id => 123

julia> chrom₂
ChromMS {scan times: Int64, ions: Int64, intensities: Int64}
2 scans; scan times: 1 s, 2 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 1 entry
source
JuChrom.minintensityMethod
minintensity(chrom::AbstractChrom[, greaterthan::Real; 
scanindexrange::OrdinalRange{T, S}]) where {T<:Integer, S<:Integer})

Return the minimum intensity. The optional positional argument greaterthan allows you to specify a threshold value; the returned minimum intensity will be greater than this threshold. If no intensity exceeds the specified value, nothing is returned. The optional keyword argument scanindexrange allows you to specify a range of scans from which the minimum intensity is determined.

See also AbstractChrom, maxintensity, intensities, intensity.

Examples

julia> chrom = Chrom([1, 2, 3]u"s", [12, 956, 1]);

julia> minintensity(chrom)
1

julia> minintensity(chrom, 1)
12

julia> minintensity(chrom, scanindexrange=1:2)
12

julia> minintensity(chrom, 1, scanindexrange=2:3)
956
source
JuChrom.minintensityMethod
minintensity(chrom::AbstractChromMS[, greaterthan::Real; 
scanindexrange::OrdinalRange{T1, S1}, ionindexrange::OrdinalRange{T2, S2}]) 
where {T1<:Integer, S1<:Integer, T2<:Integer, S2<:Integer})

Return the minimum intensity. The optional positional argument greaterthan allows you to specify a threshold value; the returned minimum intensity will be greater than this threshold. If no intensity exceeds the specified value, nothing is returned. The optional keyword arguments scanindexrange and ionindexrange allow you to select a range of scans and ions from which the minimum intensity is determined.

See also AbstractChromMS, maxintensity, intensities, intensity.

Examples

julia> chrom = ChromMS([1, 2, 3]u"s", [85, 100], [0 12; 34 956; 23 1]);

julia> minintensity(chrom)
0

julia> minintensity(chrom, 0)
1

julia> minintensity(chrom, scanindexrange=2:3)
1

julia> minintensity(chrom, ionindexrange=1:1)
0

julia> minintensity(chrom, scanindexrange=2:3, ionindexrange=1:1)
23

julia> minintensity(chrom, 25, scanindexrange=2:3, ionindexrange=1:1)
34
source
JuChrom.minscantimeFunction
minscantime(chrom::AbstractChromatogram[, scanindexrange::OrdinalRange{<:Integer, 
<:Integer}}]; timeunit::Unitful.TimeUnits, ustripped::Bool=false)

Return the minimum scan time. The optional second positional argument scanindexrange allows you to specify a scan range for which the minimum scan time is returned. The optional keyword argument timeunit lets you change the unit of the returned scan time. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. The optional keyword argument ustripped lets you choose whether to include the unit in the returned value.

See also AbstractChromatogram, maxscantime, scantimes, scantime, scancount.

Examples

julia> chrom = ChromMS([1.0, 2.0, 3.0]u"s", [85, 100], [0 12; 34 956; 23 1]);

julia> minscantime(chrom)
1.0 s

julia> minscantime(chrom, timeunit=u"minute")
0.016666666666666666 minute

julia> minscantime(chrom, timeunit=u"minute", ustripped=true)
0.016666666666666666

julia> minscantime(chrom, 2:3)
2.0 s

julia> minscantime(chrom, 2:3, timeunit=u"minute", ustripped=true)
0.03333333333333333
source
JuChrom.rimapperMethod
rimapper(chrom::AbstractChromatogram)

Return the retention index mapper object. If no object is stored, the function returns nothing.

See also AbstractChromatogram, AbstractRiMapper, RiMapper.

Example

julia> chrom = Chrom([1, 2, 3, 4, 5]u"s", [12, 956, 23, 45, 25]);

julia> rimapper(chrom) === nothing
true

julia> ld = RiMapper("Kovats", (1:5)u"minute", 1000:1000:5000);

julia> chrom = Chrom([1, 2, 3, 4, 5]u"s", [12, 956, 23, 45, 25], rimapper=ld);

julia> rimapper(chrom)
RiMapper {index name: Kovats, calibration points: 5}
retention times: 1 minute, 2 minute, 3 minute, 4 minute, 5 minute
retention indices: 1000, 2000, 3000, 4000, 5000
interpolation method: NaturalCubicBSpline(false)
extrapolation method: nothing
metadata: 0 entries
source
JuChrom.rimapper!Method
rimapper!(chrom::AbstractChromatogram, rim::AbstractRiMapper)

Assign an retention index mapper to the AbstractChromatogram object.

See also AbstractChromatogram, AbstractRiMapper, RiMapper.

Example

julia> chrom = Chrom([1, 2, 3, 4, 5]u"s", [12, 956, 23, 45, 25]);

julia> rimapper(chrom) === nothing
true

julia> ld = RiMapper("Kovats", (1:5)u"minute", 1000:1000:5000);

julia> rimapper!(chrom, ld);

julia> rimapper(chrom)
RiMapper {index name: Kovats, calibration points: 5}
retention times: 1 minute, 2 minute, 3 minute, 4 minute, 5 minute
retention indices: 1000, 2000, 3000, 4000, 5000
interpolation method: NaturalCubicBSpline(false)
extrapolation method: nothing
metadata: 0 entries

julia> retentionindex(chrom, 2.2u"minute") ≈ 2200.0
true
source
JuChrom.rundurationFunction
runduration(chrom::AbstractChromatogram; timeunit::Unitful.TimeUnits, 
ustripped::Bool=false)

Return the duration of the run. The optional keyword argument timeunit lets you specify the unit for the returned time interval. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. The optional keyword argument ustripped lets you choose whether to include the unit in the returned value.

See also AbstractChromatogram, scantimes, minscantime, maxscantime, scancount.

Examples

julia> chrom = Chrom([30.1u"minute", 40.8u"minute", 51.5u"minute"], [12, 956, 23])
Chrom {scan times: Float64, intensities: Int64}
3 scans; scan times: 30.1 minute, 40.8 minute, 51.5 minute
intensity range: 12 - 956
metadata: 0 entries

julia> runduration(chrom)
21.4 minute

julia> runduration(chrom, timeunit=u"s")
1284.0 s

julia> runduration(chrom, timeunit=u"s", ustripped=true)
1284.0
source
JuChrom.scandurationFunction
scanduration(chrom::AbstractChromatogram; error::Real=0.01, 
timeunit::Unitful.TimeUnits, ustripped::Bool=false)

Calculates the periodicity with which the scans were recorded over time. The optional keyword argument error allows you to specify the maximum allowable deviation of the time interval between consecutive scans from the average scan time, as a fraction of the average scan time. The optional keyword argument timeunit lets you specify the unit for the returned value. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. The optional keyword argument ustripped lets you choose whether the unit is include in the returned value.

See also AbstractChromatogram, scantimes, minscantime, maxscantime, scancount, runduration.

Examples

julia> chrom = Chrom([1.0, 2.0, 3.0]u"s", [12, 956, 1]);

julia> scanduration(chrom)
1.0 s

julia> scanduration(chrom, timeunit=u"minute")
0.016666666666666666 minute

julia> scanduration(chrom, timeunit=u"minute", ustripped=true)
0.016666666666666666

julia> scanduration(Chrom([1.0, 1.99, 3.0]u"s", [12, 956, 1]))
ERROR: ArgumentError: maximum scan duration variation above threshold: 0.010000000000000009 > 0.01
[...]

julia> scanduration(Chrom([1.0, 1.99, 3.0]u"s", [12, 956, 1]), error=0.02)
1.0 s
source
JuChrom.scantimeFunction
scantime(chrom::AbstractChromatogram, scanindex::Integer; timeunit::Unitful.TimeUnits, 
ustripped::Bool=false)

Return the scan time for a given scanindex. The optional parameter timeunit lets you specify the unit for the returned scan time. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. The optional keyword argument ustripped lets you choose whether the unit is included in the returned value.

See also AbstractChromatogram, scantimes, minscantime, maxscantime, scancount, ionscantime.

Examples

julia> chrom = ChromMS([1, 2, 3]u"s", [85, 100], [0 12; 34 956; 23 1]);

julia> scantime(chrom, 2)
2 s

julia> scantime(chrom, 2, timeunit=u"minute")
1//30 minute

julia> scantime(chrom, 2, timeunit=u"minute", ustripped=true)
1//30
source
JuChrom.scantimeindexFunction
scantimeindex(chrom::AbstractChromatogram, time::Unitful.Time; 
precisetime::Bool=false) -> Int

Return the index of the scan time closest to time in the scan times. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. In case of a tie, the larger scan time is returned. If the optional parameter precisetime is set to true, the specified time must exactly match a scan time value; otherwise, an error is thrown.

See also AbstractChromatogram, scantimes, scantime, minscantime, maxscantime, scancount, ionindex.

Examples

julia> chrom = ChromMS([1.1f0, 2.1f0, 3.1f0]u"s", [85, 100], [0 12; 34 956; 23 1])
ChromMS {scan times: Float32, ions: Int64, intensities: Int64}
3 scans; scan times: 1.1f0 s, 2.1f0 s, 3.1f0 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> scantimeindex(chrom, 1.1f0u"s", precisetime=true)
1

julia> scantimeindex(chrom, 2.1u"s", precisetime=true)
2

julia> scantimeindex(chrom, 2.2u"s", precisetime=true)
ERROR: ArgumentError: scantime 2.2 s does not exist
[...]

julia> scantimeindex(chrom, 2.2u"s")
2
source
JuChrom.scantimesFunction
scantimes(chrom::AbstractChromatogram[, scanindexrange::OrdinalRange{<:Integer, 
<:Integer}]; timeunit::Unitful.TimeUnits, ustripped::Bool=false)

Return the scan times. The optional second positional argument allows you to specify a range of scan indices. The optional keyword argument timeunit lets you change the unit of the returned scan times. All time units defined in the package Unitful.jl (e.g., u"s", u"minute") are supported. The optional keyword argument ustripped lets you choose whether to include the unit in the returned values. Note: If no time unit conversion is applied and the unit is not stripped, the function returns a reference to or a view into the data structure.

See also AbstractChromatogram, scantime, minscantime, maxscantime, scancount.

In the following example, the type of scantimes is explicitely annotated to demonstrate that the ChromMS object preserves this type.

Example

julia> chrom = ChromMS(Float32[1.0, 2.0, 3.0]u"s", [85, 100], [0 12; 34 956; 23 1]);

julia> scantimes(chrom)  # reference to the data structure
3-element Vector{Quantity{Float32, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}}:
 1.0f0 s
 2.0f0 s
 3.0f0 s

julia> scantimes(chrom, timeunit=u"minute")
3-element Vector{Quantity{Float32, 𝐓, Unitful.FreeUnits{(minute,), 𝐓, nothing}}}:
 0.016666668f0 minute
 0.033333335f0 minute
 0.050000004f0 minute

julia> scantimes(chrom, timeunit=u"minute", ustripped=true)
3-element Vector{Float32}:
 0.016666668
 0.033333335
 0.050000004

julia> scantimes(chrom, 2:3)  # view into the data structure
2-element view(::Vector{Quantity{Float32, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}}, 2:3) with eltype Quantity{Float32, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}:
 2.0f0 s
 3.0f0 s

julia> scantimes(chrom, 2:3)[:]  # a copy of these values
2-element Vector{Quantity{Float32, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}}:
 2.0f0 s
 3.0f0 s

julia> scantimes(chrom, 2:3, timeunit=u"minute", ustripped=true)
2-element Vector{Float32}:
 0.033333335
 0.050000004
source
JuChrom.totalionchromatogramFunction
totalionchromatogram(chrom::ChromMS)

Compute the total ion chromatrogram.

See also ChromMS, scantimes, intensities, metadata.

In the following example, the type of the intensities is explicitely annotated to demonstrate that the returned Chrom object preserves this type.

Example

julia> chrom = ChromMS((1.1f0:3.1f0)u"s", [85, 100], Int64[0 12; 34 956; 23 1])
ChromMS {scan times: Float32, ions: Int64, intensities: Int64}
3 scans; scan times: 1.1f0 s, 2.1f0 s, 3.1f0 s
2 ions: m/z 85, 100
intensity range: 0 - 956
metadata: 0 entries

julia> tic = totalionchromatogram(chrom)
Chrom {scan times: Float32, intensities: Int64}
3 scans; scan times: 1.1f0 s, 2.1f0 s, 3.1f0 s
intensity range: 12 - 990
metadata: 0 entries

julia> intensities(tic)
3-element Vector{Int64}:
  12
 990
  24
source