diff --git a/NAMESPACE b/NAMESPACE index d1c6afeeab92b0e99df6719e4b8fbbb4898a84a2..0f870cca68b9697f9bb3144ac25e81151f33fd75 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,6 +4,7 @@ export(mb.do) export(mb.prep) export(presc.do) export(presc.p) +export(presc.plot) export(presc.single) export(presc.v) export(sw.do) diff --git a/R/mix.R b/R/mix.R index 394379fc5570aa1e81442c421c02a829a9f6ecbb..dc14ce5a49baf1dd5eedc66785c40e94263b1585 100644 --- a/R/mix.R +++ b/R/mix.R @@ -537,6 +537,61 @@ presc.p<-function(fn_data,fn_cmpd_l,mode,cl=NULL,ppm_lim_fine=10,EIC_limit=0.001 } +##' Plot the output of prescreen. +##' +##' @title Plot the Output of Prescreen +##' @param wd Sequence of data dirs containing the prescreen subdir. +##' @param out The name of the output file. +##' @return Nothing useful. +##' @author Todor Kondić +##' @export +presc.plot <- function(wd,out="prescreen.pdf") { + dfdir <- file.path(wd,"prescreen") + pdf(out) + ## Get the basenames of eic files. + eics <- list.files(path=dfdir[[1]],patt=".*eic.csv") + maybekids <- sapply(strsplit(eics,split="\\."),function(x) {paste(x[[1]][1],'.kids.csv',sep='')}) + for (i in seq(length(eics))) { + eic <- eics[[i]] + maybekid <- maybekids[[i]] + plot.new() + dfs <- lapply(file.path(dfdir,eic),read.csv,stringsAsFactors = F) + + + ## Find max intensity for the first in the group. + imx <- which.max(dfs[[1]]$intensity) + int_max <- dfs[[1]]$intensity[[imx]] + rt_max <- dfs[[1]]$rt[[imx]] + rt_min_max <- as.numeric(rt_max)/60. + + + rt_rng <- range(sapply(dfs,function(x) x$rt)) + int_rng <- range(sapply(dfs,function(x) x$intensity)) + plot.window(rt_rng,int_rng) + box() + + ## Plot eic across the directory set. + for (df in dfs) { + lines(df$intensity ~ df$rt) + } + + ## Find existing children and plot them across the directory + ## set. + maybes <- file.path(dfdir,maybekid) + indkids <- which(file.exists(maybes)) + kids <- maybes[indkids] + dfs <- lapply(kids,read.csv,stringsAsFactors=F) + for (df in dfs) { + lines(intensity~retentionTime,data=df,type="h",col="blue") + } + title(main=i,xlab="retention time [s]",ylab="intensity") + text(as.numeric(rt_max),as.numeric(int_max),labels=as.numeric(rt_min_max),pos=4) + axis(1) + axis(2) + gc() + } + dev.off() +} diff --git a/man/presc.plot.Rd b/man/presc.plot.Rd new file mode 100644 index 0000000000000000000000000000000000000000..f8bfe688135df47c34ddfb7b60c87b29280dc3f0 --- /dev/null +++ b/man/presc.plot.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mix.R +\name{presc.plot} +\alias{presc.plot} +\title{Plot the Output of Prescreen} +\usage{ +presc.plot(wd, out = "prescreen.pdf") +} +\arguments{ +\item{wd}{Sequence of data dirs containing the prescreen subdir.} + +\item{out}{The name of the output file.} +} +\value{ +Nothing useful. +} +\description{ +Plot the output of prescreen. +} +\author{ +Todor Kondić +}