## load library
library("readBrukerFlexData")
## get examples directory
exampleDirectory <- system.file("Examples", package="readBrukerFlexData")
## read example spectra
## please note: filterZeroIntensities=TRUE is used for compatibility reasons.
## You should NOT use it!
noHpcSpec <- readBrukerFlexFile(file.path(exampleDirectory,
"hpc/fid/0_A20/1/1SRef/fid"), filterZeroIntensities=TRUE, useHpc=FALSE)
hpcSpec <- readBrukerFlexFile(file.path(exampleDirectory,
"hpc/fid/0_A20/1/1SRef/fid"), filterZeroIntensities=TRUE)
## plot spectrum
plot(noHpcSpec$spectrum$mass, noHpcSpec$spectrum$intensity, type="l",
col="red", xlim=c(1296, 1300))
lines(hpcSpec$spectrum$mass, hpcSpec$spectrum$intensity, type="l",
col="green", xlim=c(1296, 1300))
legend(x="topright", legend=c("no hpc", "hpc"), col=c("red", "green"), lwd=1)
## show difference between .hpc and original HPC
## load mzXML generated by Bruker Daltonics CompassXport 1.3.5
## you could do it like this:
#library("readMzXmlData")
#cpSpecHpcMzXml <- readMzXmlFile(file.path(exampleDirectory,
# "hpc/mzXML/hpc.mzXML"))
## or easily use:
data(cpSpecHpcMzXml)
## reduce R double precision to single precision because our CompassXport 1.3.5
## supports only mzXML with precision=32 (only for compatibility reasons)
noHpcSpec$spectrum$mass32 <-
readBrukerFlexData:::.double2singlePrecision(noHpcSpec$spectrum$mass)
hpcSpec$spectrum$mass32 <-
readBrukerFlexData:::.double2singlePrecision(hpcSpec$spectrum$mass)
## calculate deviance
d <- noHpcSpec$spectrum$mass32-cpSpecHpcMzXml$spectrum$mass
dHPC <- hpcSpec$spectrum$mass32-cpSpecHpcMzXml$spectrum$mass
## a little summary
cat("without .hpc:\n",
"not matching: ", length(cpSpecHpcMzXml$spectrum$mass[d!=0]), " of ",
length(cpSpecHpcMzXml$spectrum$mass), "; range: ",
range(abs(d[d!=0])), "\nwith .hpc:\n",
"not matching: ", length(cpSpecHpcMzXml$spectrum$mass[dHPC!=0]), " of ",
length(cpSpecHpcMzXml$spectrum$mass), "; range: ",
range(abs(d[dHPC!=0])), "\n")
##
## doing things manually
##
hpcMass <- readBrukerFlexData:::.hpc(mass=noHpcSpec$spectrum$mass,
minMass=noHpcSpec$metaData$hpc$limits["minMass"],
maxMass=noHpcSpec$metaData$hpc$limits["maxMass"],
hpcCoefficients=noHpcSpec$metaData$hpc$coefficients)
Run the code above in your browser using DataLab