Lab 2 Acetomenaphen

bad-example-2

intro

Fourier-transform infrared spectrometry (FT-IR) and a high performance liquid chromatography (HPLC) where used to assess the purity of acetaminophen samples from two distributors and determine if they are contaminated or overly concentrated. Two locations reported that the tablets should have 110 mg of acetaminophen with no contaminants.

calculations and results

In [1]:
using DataFrames

Ref = readtable("Tylenol_Ref.csv", separator = ',',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

Ref[:base] = Ref[:A] .- minimum(Ref[:A])
Ref[:rel] = Ref[:base] ./ maximum(Ref[:base])

SampA = readtable("Samp_30A_Ave.csv", separator = ',',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

SampA[:base] = SampA[:A] .- minimum(SampA[:A])
SampA[:rel] = SampA[:base] ./ maximum(SampA[:base])


SampB = readtable("Samp_32B_Ave.csv", separator = '\t',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

SampB[:base] = SampB[:A] .- minimum(SampB[:A])
SampB[:rel] = SampB[:base] ./ maximum(SampB[:base])

using PyPlot

plot(Ref[:cm1], Ref[:rel], label = "Tylenol Reference")
plot(SampA[:cm1], SampA[:rel], label = "Sample 20190207E_30A")
plot(SampB[:cm1], SampB[:rel], label = "Sample 20190207A_32B")

legend()
xlabel("Wavenumber (cm-1)")
ylabel("Relative Absorbance")
ax = gca()
ax[:set_xlim]([600,4000])
ax[:set_ylim]([0,1]);
SystemError: opening file Tylenol_Ref.csv: No such file or directory

Stacktrace:
 [1] #systemerror#39(::Nothing, ::Function, ::String, ::Bool) at ./error.jl:106
 [2] systemerror at ./error.jl:106 [inlined]
 [3] #open#293(::Bool, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Function, ::String) at ./iostream.jl:283
 [4] #open at ./iostream.jl:0 [inlined]
 [5] open(::String, ::String) at ./iostream.jl:339
 [6] #open#294(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(DataFrames, Symbol("#_r#304")){Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool}, ::String, ::Vararg{String,N} where N) at ./iostream.jl:367
 [7] open at ./iostream.jl:367 [inlined]
 [8] #readtable#303(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::typeof(readtable), ::String) at /home/jrun/.julia/packages/DataFrames/IKMvt/src/deprecated.jl:1129
 [9] (::getfield(DataFrames, Symbol("#kw##readtable")))(::NamedTuple{(:separator, :header, :skipstart, :names),Tuple{Char,Bool,Int64,Array{Symbol,1}}}, ::typeof(readtable), ::String) at ./none:0
 [10] top-level scope at In[1]:2
In [2]:
using DataFrames

Ref = readtable("Tylenol_Ref.csv", separator = ',',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

Ref[:base] = Ref[:A] .- minimum(Ref[:A])
Ref[:rel] = Ref[:base] ./ maximum(Ref[:base])

SampA = readtable("Samp_30A_Ave.csv", separator = ',',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

SampA[:base] = SampA[:A] .- minimum(SampA[:A])
SampA[:rel] = SampA[:base] ./ maximum(SampA[:base])


SampB = readtable("Samp_32B_Ave.csv", separator = '\t',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

SampB[:base] = SampB[:A] .- minimum(SampB[:A])
SampB[:rel] = SampB[:base] ./ maximum(SampB[:base])

using PyPlot

plot(Ref[:cm1], Ref[:rel], label = "Tylenol Reference")
plot(SampA[:cm1], SampA[:rel], label = "Sample 20190207E_30A-1")
plot(SampB[:cm1], SampB[:rel], label = "Sample 20190207A_32B-1")

legend()
xlabel("Wavenumber (cm-1)")
ylabel("Relative Absorbance")
ax = gca()
ax[:set_xlim]([600,4000])
ax[:set_ylim]([0,1]);
SystemError: opening file Tylenol_Ref.csv: No such file or directory

Stacktrace:
 [1] #systemerror#39(::Nothing, ::Function, ::String, ::Bool) at ./error.jl:106
 [2] systemerror at ./error.jl:106 [inlined]
 [3] #open#293(::Bool, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Function, ::String) at ./iostream.jl:283
 [4] #open at ./iostream.jl:0 [inlined]
 [5] open(::String, ::String) at ./iostream.jl:339
 [6] #open#294(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(DataFrames, Symbol("#_r#304")){Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool}, ::String, ::Vararg{String,N} where N) at ./iostream.jl:367
 [7] open at ./iostream.jl:367 [inlined]
 [8] #readtable#303(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::typeof(readtable), ::String) at /home/jrun/.julia/packages/DataFrames/IKMvt/src/deprecated.jl:1129
 [9] (::getfield(DataFrames, Symbol("#kw##readtable")))(::NamedTuple{(:separator, :header, :skipstart, :names),Tuple{Char,Bool,Int64,Array{Symbol,1}}}, ::typeof(readtable), ::String) at ./none:0
 [10] top-level scope at In[2]:2

HQI_IR = (Ref[:A] SampA[:A]) ./ ( (Ref[:A] Ref[:A]) . (SampA[:A] SampA[:A]))

I don't know how to do this HQI

In [3]:
using DataFrames

std1 = readtable("std05ppm1.csv", separator = ',',
    header = true,
    names = [Symbol("time"), Symbol("int")])

std2 = readtable("std05ppm2.csv", separator = ',',
    header = true,
    names = [Symbol("time"), Symbol("int")])


week1 = readtable("week1_ave.csv", separator = ',',
    header = true,
    names = [Symbol("time"), Symbol("int")])

week2 = readtable("week2_ave.csv", separator = ',',
    header = true,
    names = [Symbol("time"), Symbol("int")])

hplc_cal1 = readtable("hplc_cal1.csv", separator = ',',
    header = true,
    names = [Symbol("conc"), Symbol("peak_area")])

hplc_cal2 = readtable("hplc_cal2.csv", separator = ',',
    header = true,
    names = [Symbol("conc"), Symbol("peak_area")])

using PyPlot

plot(std1[:time], std1[:int], label = "0.5 ppm Calibration Standard
    Peak Area = 1110.1")
plot(week1[:time], week1[:int], label = "Sample 20190207A_30A-1
    Peak Area = 225.6")
legend()
xlabel("Time (min)")
ylabel("Intensity")
ax = gca()
ax[:set_xlim]([0,10])
ax[:set_ylim]([0,83]);

#WEEK 1 HPLC
In [4]:
plot(std2[:time], std2[:int], label = "0.5 ppm Calibration Standard
    Peak Area = 1105.0")
plot(week2[:time], week2[:int], label = "Sample 20190207E_30A-1
    Peak Area = 380.8")

legend()
xlabel("Time (min)")
ylabel("Intensity")
ax = gca()
ax[:set_xlim]([0,10])
ax[:set_ylim]([0,80]);
In [5]:
using GLM
hplc_curve1 = lm(@formula(peak_area ~ conc), hplc_cal1)

x = collect(0:0.5:35)
b = round(coef(hplc_curve1)[1], digits = 4);
m = round(coef(hplc_curve1)[2], digits = 4);
rsq = round(r2(hplc_curve1), digits = 4);

using PyPlot

scatter(hplc_cal1[:conc], hplc_cal1[:peak_area], label = "Acetaminophen Calibration Standards")
plot(x, x .* m .+ b, "--",
    label = string("A = ", m, "C + ", abs(b), "; R2 = ", rsq)
    )

legend()
xlabel("Concentration (ppm)")
ylabel("Peak Area")
ax = gca()
ax[:set_xlim]([0,30])
ax[:set_ylim]([0,50000]);

# WEEK 1 CAL CURVE
In [6]:
using GLM
hplc_curve2 = lm(@formula(peak_area ~ conc), hplc_cal2)

x = collect(0:0.5:35)
b = round(coef(hplc_curve2)[1], digits = 4);
m = round(coef(hplc_curve2)[2], digits = 4);
rsq = round(r2(hplc_curve2), digits = 4);

using PyPlot

scatter(hplc_cal2[:conc], hplc_cal2[:peak_area], label = "Acetaminophen Calibration Standards")
plot(x, x .* m .+ b, "--",
    label = string("A = ", m, "C + ", abs(b), "; R2 = ", rsq)
    )

legend()
xlabel("Concentration (ppm)")
ylabel("Peak Area")
ax = gca()
ax[:set_xlim]([0,30])
ax[:set_ylim]([0,50000]);

# WEEK 2 CAL CURVE
In [7]:
using DataFrames

Ref = readtable("Tylenol_Ref.csv", separator = ',',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

Ref[:base] = Ref[:A] .- minimum(Ref[:A])
Ref[:rel] = Ref[:base] ./ maximum(Ref[:base])

SampA = readtable("Samp_30A_Ave.csv", separator = ',',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

SampA[:base] = SampA[:A] .- minimum(SampA[:A])
SampA[:rel] = SampA[:base] ./ maximum(SampA[:base])


SampB = readtable("Samp_32B_Ave.csv", separator = '\t',
    header = true, skipstart = 1,
    names = [Symbol("cm1"), Symbol("A")])

SampB[:base] = SampB[:A] .- minimum(SampB[:A])
SampB[:rel] = SampB[:base] ./ maximum(SampB[:base])
SystemError: opening file Tylenol_Ref.csv: No such file or directory

Stacktrace:
 [1] #systemerror#39(::Nothing, ::Function, ::String, ::Bool) at ./error.jl:106
 [2] systemerror at ./error.jl:106 [inlined]
 [3] #open#293(::Bool, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Function, ::String) at ./iostream.jl:283
 [4] #open at ./iostream.jl:0 [inlined]
 [5] open(::String, ::String) at ./iostream.jl:339
 [6] #open#294(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(DataFrames, Symbol("#_r#304")){Bool,Char,Array{Char,1},Char,Array{String,1},Array{String,1},Array{String,1},Bool,Int64,Array{Symbol,1},Array{Any,1},Bool,Char,Bool,Int64,Array{Int64,1},Bool,Symbol,Bool,Bool}, ::String, ::Vararg{String,N} where N) at ./iostream.jl:367
 [7] open at ./iostream.jl:367 [inlined]
 [8] #readtable#303(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::typeof(readtable), ::String) at /home/jrun/.julia/packages/DataFrames/IKMvt/src/deprecated.jl:1129
 [9] (::getfield(DataFrames, Symbol("#kw##readtable")))(::NamedTuple{(:separator, :header, :skipstart, :names),Tuple{Char,Bool,Int64,Array{Symbol,1}}}, ::typeof(readtable), ::String) at ./none:0
 [10] top-level scope at In[7]:2
In [8]:
using PyPlot

plot(Ref[:cm1], Ref[:rel], label = "Tylenol Reference")
plot(SampA[:cm1], SampA[:rel], label = "Sample 20190207E_30A")
plot(SampB[:cm1], SampB[:rel], label = "Sample 20190207A_32B")

legend()
xlabel("Wavenumber (cm-1)")
ylabel("Relative Absorbance")
ax = gca()
ax[:set_xlim]([600,4000])
ax[:set_ylim]([0,1]);
MethodError: Cannot `convert` an object of type Symbol to an object of type Ref
Closest candidates are:
  convert(::Type{Ref}, !Matched::Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R) at /home/jrun/.julia/packages/CategoricalArrays/ucKV2/src/value.jl:81
  convert(::Type{S}, !Matched::T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)) where {S, T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)} at /home/jrun/.julia/packages/CategoricalArrays/ucKV2/src/value.jl:91
  convert(::Type{T}, !Matched::T) where T at essentials.jl:154
  ...

Stacktrace:
 [1] setindex!(::Array{Ref,1}, ::Symbol, ::Int64) at ./array.jl:769
 [2] getindex(::Type{Ref}, ::Symbol) at ./array.jl:366
 [3] top-level scope at In[8]:2
In [9]:
using GLM
hplc_curve = lm(@formula(peak_area ~ conc), hplc_cal)

x = collect(0:0.5:35)
b = round(coef(hplc_curve)[1], digits = 4);
m = round(coef(hplc_curve)[2], digits = 4);
rsq = round(r2(hplc_curve), digits = 4);

using PyPlot

scatter(hplc_cal[:conc], hplc_cal[:peak_area], label = "Acetaminophen Calibration Standards")
plot(x, x .* m .+ b, "--",
    label = string("A = ", m, "C + ", abs(b), "; R2 = ", rsq)
    )

legend()
xlabel("Concentration (ppm)")
ylabel("Peak Area")
ax = gca()
ax[:set_xlim]([0,30])
ax[:set_ylim]([0,50000]);

# AVERAGE CAL CURVE
UndefVarError: hplc_cal not defined

Stacktrace:
 [1] top-level scope at In[9]:2
In [ ]: