Base

JuChrom.bsplineinterpolationFunction
bsplineinterpolation(retentiontimes::AbstractVector{<:Unitful.Time}, 
retentionindices::AbstractVector{<:Real}; extrapolation::Bool=false, force::Bool=false)

Return a function that maps retention time to a retention index. The function uses a B-spline for interpolation calculated from a vector of retention times and a corresponding vector of retention indices. For retention time values outside the range used to compute the B-spline, the function employs linear extrapolation to estimate a retention index. However, an optional keyword argument, extrapolation, can be used to disable extrapolation, in which case the function returns nothing for values outside the retention time range. The function will raise an error if the resulting mapping function does not produce continuously increasing values. However, by setting the force keyword argument to true, the function will return a mapping function even if it does not yield continuously increasing values. This can be useful for identifying problematic or erroneous calibration points.

See also scantimes, retentionindices.

Examples

julia> rts, ris = (1:8)*u"s", [1000, 1800, 3050, 3800, 5500, 6600, 6900, 7400];

julia> rt2ri, jacobian_rt2ri = JuChrom.bsplineinterpolation(rts, ris);

julia> rt2ri(1u"s") ≈ 1000.0
true

julia> rt2ri(1.5u"s") ≈ 1333.7469941600825
true

julia> rt2ri((1//30)u"minute") ≈ 1800.0
true

julia> rt2ri(9.1u"s") ≈ 7950.0
ERROR: ArgumentError: retention time outside range for calculating retention index
[...]

julia> rt2ri, jacobian_rt2ri = JuChrom.bsplineinterpolation(rts, ris; extrapolation=true);

julia> rt2ri(9.1u"s") ≈ 8053.1226382686355
true
source
JuChrom.piecewiselinearinterpolationFunction
piecewiselinearinterpolation(retentiontimes::AbstractVector{<:Unitful.Time}, 
retentionindices::AbstractVector{<:Real}; extrapolation::Bool=false) -> Float64

Return a function that maps retention time to retention index using piecewise linear interpolation based on a vector of retention times and a corresponding vector of retention indices. For retention time values outside the interpolation range, the function applies linear extrapolation to estimate the retention index. However, an optional extrapolation keyword can disable extrapolation, in which case the function will raise an error for values outside the retention time range.

See also scantimes, retentionindices.

Examples

julia> rts, ris = (1:8)*u"s", [1000, 1800, 3050, 3800, 5500, 6600, 6900, 7400];

julia> rt2ri = JuChrom.piecewiselinearinterpolation(rts, ris);

julia> rt2ri(1u"s") ≈ 1000.0
true

julia> rt2ri(1.5u"s") ≈ 1400.0
true

julia> rt2ri((1//30)u"minute") ≈ 1800.0
true

julia> rt2ri(9.1u"s")
ERROR: ArgumentError: retention time outside range for calculating retention index
[...]

julia> rt2ri = JuChrom.piecewiselinearinterpolation(rts, ris; extrapolation=true);

julia> rt2ri(9.1u"s") ≈ 7950.0
true
source
JuChrom.copy_with_eltypeFunction
JuChrom.copy_with_eltype(array::AbstractArray, elementtype::Type)

Create a mutable copy of the array with the type of its elements converted to elementtype.

Examples

julia> JuChrom.copy_with_eltype(Int[1, 2, 3, 4, 5, 6], Float64)
6-element Vector{Float64}:
 1.0
 2.0
 3.0
 4.0
 5.0
 6.0

julia> JuChrom.copy_with_eltype(Float64[1, 2, 3, 4, 5, 6], Int32)
6-element Vector{Int32}:
 1
 2
 3
 4
 5
 6

julia> JuChrom.copy_with_eltype(Float64[1.1, 2, 3, 4, 5, 6], Int32)
ERROR: InexactError: Int32(1.1)
[...]
source
JuChrom.findclosestFunction
JuChrom.findclosest(A::AbstractVector{<:Number}, x::Number) -> Int

Return the index of the number closest to x in a list A of numbers sorted in ascending order. If case of a tie, the index of the larger number is returned.

Examples

julia> JuChrom.findclosest([-2, -1, 0, 1, 2, 3, 4, 5], 0)
3

julia> JuChrom.findclosest([-2, -1, 0, 1, 2, 3, 4, 5], 1.5)
5

julia> JuChrom.findclosest([-2, -1, 0, 1, 2, 3, 4, 5], -1.5)
2
source
JuChrom.invertFunction
JuChrom.invert(dictionary::Dict)

Return a dictionary where the values from the input dictionary become the keys. Each key in the returned dictionary maps to a list of all original keys from dictionary that were associated with that value.

Example

julia> d = Dict(:a => 1.0, :b => 2.0, :c => 2.0, :d => 1.0)
Dict{Symbol, Float64} with 4 entries:
  :a => 1.0
  :b => 2.0
  :d => 1.0
  :c => 2.0

julia> JuChrom.invert(d)
Dict{Float64, Vector{Symbol}} with 2 entries:
  2.0 => [:b, :c]
  1.0 => [:a, :d]
source
JuChrom.nameFunction
JuChrom.name(::Type)

Return the name of the type.

Example

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

julia> JuChrom.name(typeof(chrom))
ChromMS
source
JuChrom.rt2riFunction
JuChrom.rt2ri(mapper::RiMapper)

Return the function that maps a retention time to its corresponding retention index. Note that direct use of this function is discouraged; users are encouraged to use the more versatile function retentionindex instead.

See also RiMapper, retentionindex.

Example

julia> rts, ris = [1.2, 2.4, 3.8, 5.0]u"minute", [1000, 2000, 3000, 4000];

julia> ld = RiMapper("Kovats", rts, ris);

julia> JuChrom.rt2ri(ld)(1.5u"minute") ≈ 1260.5733082706768
true

julia> JuChrom.rt2ri(ld)(1u"minute") ≈ 821.4487832484438
ERROR: ArgumentError: retention time outside range for calculating retention index
[...]
source
JuChrom.jacobian_rt2riFunction
jacobian_rt2ri(mapper::RiMapper)

Return the derivative function of the applied interpolation method, if it exists.

See also RiMapper, retentionindex.

Example

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

julia> jacobian_rt2ri(ld)(1.9u"minute") ≈ 999.9999999999998
true
source