Skip to content

Commit

Permalink
#1 cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanse committed Oct 23, 2020
1 parent e1580fb commit 63274c7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 27 deletions.
84 changes: 59 additions & 25 deletions R/rawR.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ readChromatogram <- function(rawfile,
if (!file.exists(rawfile)){
stop(paste0('file ', rawfile, ' is not available. return.'))
}

if (!.isMonoAssemblyWorking()){
stop('the mono assembly are not available.')
}

tfstdout <- tempfile()
tfi <- tempfile()
tfo <- tempfile()
Expand Down Expand Up @@ -432,23 +432,36 @@ readChromatogram <- function(rawfile,
#message(length(rv))
rv <- lapply(rv,
function(x){
x$type <- type
x$filename <- rawfile
x$tol <- tol
x$filter <- filter
# x$times.max <- x$times[which.max(x$intensities)][1]
class(x) <- c(class(x), 'rawRchromatogram');
x})

}else{
if (mono){
rvs <- system2("mono", args = c(shQuote(exe), shQuote(rawfile), "chromatogram", shQuote(filter)), stdout=tfstdout)
}else{
rvs <- system2(exe, args = c(shQuote(rawfile), "chromatogram", shQuote(filter)),stdout=tfstdout)
}
rv <- read.csv(tfstdout, header = TRUE, comment.char = "#")
DF <- read.csv(tfstdout, header = TRUE, comment.char = "#")

rv <- list(bpc = list(times=DF$rt,
intensities=DF$intensity.BasePeak),

tic = list(times=DF$rt,
intensities=DF$intensity.TIC),
massRange = list(times=DF$rt,
intensities=DF$intensity.MassRange))
}
unlink(c(tfi, tfo, tfstdout))

attr(rv, 'filter') <- filter
attr(rv, 'filename') <- rawfile

if (type=='xic'){
attr(rv, 'type') <- 'xic'
attr(rv, 'tol') <- tol
}else{
attr(rv, 'type') <- 'bpc'
}
class(rv) <- 'rawRchromatogramSet'
rv
}
Expand Down Expand Up @@ -865,20 +878,41 @@ plot.rawRchromatogram <- function(x, legend = TRUE, ...){
#'
#' @export plot.rawRchromatogramSet
plot.rawRchromatogramSet <- function(x, ...){
plot(0, 0, type='n',
xlim=range(unlist(lapply(x, function(o){o$times}))),
ylim=range(unlist(lapply(x, function(o){o$intensities}))),
frame.plot = FALSE,
xlab='retention time [in min]',
ylab='intensities', ...
)

cm <- hcl.colors(length(x), "Set 2")
mapply(function(o, co){lines(o$times, o$intensities, col=co)}, x, cm)
legend("topleft",
as.character(sapply(x, function(o){o$mass})),
col=cm,
pch=16,
title='target mass [m/z]',
bty='n',cex = 0.75)
if(attr(x, 'type')=='xic'){


plot(0, 0, type='n',
xlim=range(unlist(lapply(x, function(o){o$times}))),
ylim=range(unlist(lapply(x, function(o){o$intensities}))),
frame.plot = FALSE,
xlab='retention time [in min]',
ylab='intensities', ...
)

cm <- hcl.colors(length(x), "Set 2")
mapply(function(o, co){lines(o$times, o$intensities, col=co)}, x, cm)
legend("topleft",
as.character(sapply(x, function(o){o$mass})),
col=cm,
pch=16,
title='target mass [m/z]',
bty='n',cex = 0.75)
}else{
plot(0, 0, type='n',
xlim = range(c(x$bpc$times, x$tic$times)),
ylim = range(c(x$bpc$intensities, x$tic$intensities)),
frame.plot = FALSE,
xlab = 'retention time [in min]',
ylab = 'intensities', ...
)
lines(x$bpc$times, x$bpc$intensities, col='red')
lines(x$tic$times, x$tic$intensities)

legend("topleft",
c('bpc','tic'),
col=c('red','black'),
pch=16,
title='target mass [m/z]',
bty='n',cex = 0.75)
}
}
2 changes: 1 addition & 1 deletion man/readChromatogram.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vignettes/JPR_TechnicalNote.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ author: "Tobias Kockmann^1‡^ & Christian Panse^1,2‡^"
date: "`r Sys.Date()`"
bibliography: rawR.bib
output:
pdf_document: default
html_document:
df_print: paged
citation_package: natbib
pdf_document: default
vignette: |
%\usepackage[utf8]{inputenc}
%\VignetteEncoding{UTF-8}
Expand Down Expand Up @@ -111,7 +111,9 @@ names(iRT) <- c("LGGNEQVTR", "YILAGVENSK", "GTFIIDPGGVIR", "GTFIIDPAAVIR",
C <- readChromatogram(rawfile, iRT, tol=10)
par(mfrow=c(2, 1))
plot(C)
plot(readChromatogram(rawfile, type='bpc')
```


Expand Down

0 comments on commit 63274c7

Please sign in to comment.