\tableofcontents
knitr::opts_chunk$set(echo = TRUE)
This vignette shows how to use PTRMSR package to read .txt files, calculate AUC and return statistical analyses.
In this package, the functions beginning by ptrv use a single dataset as input. The functions beginning by ptrvList use names of several files to be used and a metaData file containing information about the different files. The objective of this paper is to use files produced by ptrViewer (or any other preprocessing of PTR-MS device returning files with ion, intensity and time as columns) then return curves and relevant statistics on the evaluations. Several biases can be corrected: (i) the breathing of the subject by calculating statistics by breathing cycle (use the parameter correction="cycle"), (ii) blank period during the evaluation that can be removed from the intensities (use blankCorrection = TRUE and noisePeriod=...). Some statistics are returned.
It could be interesting to see the raw data of one file. In this purpose, the function ptrReport returns several plots which could help to interpretation.
library(PTRMSR) wd="./../inst/extdata" setwd(wd) listFiles=list.files(pattern="*.txt") referenceBreath="m69.06906 (69.06906) (Conc)" file=listFiles[1] dataset=read.table(file=file,header=TRUE,sep="\t",check.names=FALSE) report=ptrvReport(dataset,selecIons="evolving", listIons=NULL, referenceBreath=referenceBreath, methodDetectStart="startPeakProportion", noisePeriodIBT=c(0,25),noisePeriodSig=c(0,25), noisePeriodDS=c(0,30), proportionOfMax=0.3,halfWindowSize=4,forMinExpiDivideMaxIntBy = 7, forMaxInspiDivideMaxIntBy =9) names(report$gg) report$gg$p_breath$p_cyclelimits report$gg$p_breath$p_smoothcycle
Regarding the breathing cycle detection, these two outputs gives the results of cycle limits and the smooth data for breathing (useful to adjust the parameters halfWindowSize and maxPeaks)
plot(report$gg$p_breath$p_cyclelimits)
Regarding the ions distributions
plot(report$gg$p_curves$p_raw) plot(report$gg$p_curves$p_cycle)
Regarding the breathing ion distribution
plot(report$gg$p_curves$p_breath_raw) plot(report$gg$p_curves$p_breath_cycle)
Do not hesitate to use plotly for interactive graphs to adjust the parameters
library(plotly) ggplotly(report$gg$p_curves$p_breath_raw)
All the data files (.txt from ptrViewer) and the metadata file (.csv) should be in a single repository (wd)
listFiles=list.files(pattern="*.txt")[-1] metaData2=read.table("metaData2.csv",sep=";",header=T) head(metaData2[,-c(2:3)])
This function allows statistics to be calculated for each file after breathing correction
setwd(wd) res_auc=ptrvListIntensityByTime(listFiles=listFiles, metaData=metaData2,ions=ion)
The results can be saved into csv files
res_auc$listRes write.table(file="auc.csv",sep=";",res_auc$listRes,row.names=F)
The stat option can be used to select the statistic.
res_tmax=ptrvListIntensityByTime(listFiles=listFiles,metaData=metaData2,ions=ionSigUnique,stat="tmax")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.