-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEEMIFECorr_function.R
More file actions
66 lines (49 loc) · 2.29 KB
/
EEMIFECorr_function.R
File metadata and controls
66 lines (49 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
###
# function for calculating the IFE and correcting Raman masked file
#
# Adapted from CM code, as well as from following references:
# 1. McKnight et al, 2002 Lim Ocean, Vol46(1), DOI: 10.4319/lo.2001.46.1.0038
# 2.
# 30June2015
# Note that this gives the IFE correction factor, with the actual correction calculated in the loop
# Ashlee Jollymore's PhD project
############
# EEM.IFC = EEM*10.^(0.5*IFC) #perform inner filter calculation
innerfilter <- function(eem, abs, em, ex) {
# em fluor = emission wavelength at which fluorescence EEM was collected
# ex fluor = excitation wavelength at which fluorescence EEM was collected
# Need to interpolate abs wavelength to reflect wavelength at which fluorescence was collected
waves = as.numeric(gsub("X", "", colnames(abs))) # wavelengths at which abs collected
data = abs # column containing absorbance data
# Interpolation absorbance for emission wavelengths
emforIFC = em # emission wavalengths from fluorescence
# note that CM only takes from 1:125 of the emission wavelenghts.. apply to all?
em_abs = as.data.frame(approx(x = waves, y = data, xout = emforIFC, method = "linear")) #em_abs = interp1(waves,data,emforIFC)'; - initial CM line
#note that CM file also inserts 0.175 as first em_abs number? Code below
#em_abs(2:125) = em_abs(1:124);
#em_abs(1) = 0.1705;
# Interpolation absorbance for excitation wavelengths
exforIFC = ex
ex_abs = as.data.frame(approx(x = waves, y = data, xout = exforIFC, method = "linear"))
IFC <- matrix(ncol = (dim(ex_abs)[1]), nrow = (dim(em_abs)[1]))
colnames(IFC) <- ex_abs[,1]
rownames(IFC) <- em_abs[,1]
#loop adapted from CM file
for (f in 1:(dim(em_abs)[1])) {
for (b in 1:(dim(ex_abs)[1])) {
IFC[f,b]=ex_abs[f,2]+em_abs[b,2]
}
}
# Apply IFE (ODex + ODem) to EEMs
# EEM.IFE = EEM *10 ^(0.5 *IFC) Need to have something to ensure that if IFC = Na,
IFC <- as.data.frame(IFC)
IFC.2 <- IFC *0.5
IFC.2 <- as.data.frame(10^IFC.2)
# replace Nas in IFC with 1
IFC.2[is.na(IFC.2)] <- 1
# get corrected fluorescence
#eem[,c(1:2)] <- as.numeric(as.character(eem[,c(1:2)]))
EEM.IFC <- eem * IFC.2 #creating two columns of nas?!!?
return(EEM.IFC)
}
# will need to do something fro Nas arising because of differences in wavelengths