Skip to content

Commit

Permalink
Merge pull request #91 from jotsetung/master
Browse files Browse the repository at this point in the history
Fix bug in normalize-MSnExp
  • Loading branch information
LaurentGatto committed Jun 8, 2016
2 parents b716757 + f0a9806 commit 6b7fa18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
29 changes: 16 additions & 13 deletions R/functions-MSnExp.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,22 @@ clean_MSnExp <- function(object, all, verbose = TRUE) {


normalise_MSnExp <- function(object,method) {
sapply(featureNames(object),
function(x) {
sp <- get(x,envir=assayData(object))
xx <- normalise(sp,method)
assign(x,xx,envir=assayData(object))
invisible(TRUE)
})
object@processingData@processing <- c(object@processingData@processing,
paste0("Spectra normalised (",method,"): ",
date()))
object@processingData@normalised <- TRUE
if (validObject(object))
return(object)
## Can not directly assign to assayData, as that environment is locked!
e <- new.env()
sapply(featureNames(object),
function(x) {
sp <- get(x,envir=assayData(object))
xx <- normalise(sp,method)
assign(x,xx,envir=e)
invisible(TRUE)
})
object@processingData@processing <- c(object@processingData@processing,
paste0("Spectra normalised (",method,"): ",
date()))
object@processingData@normalised <- TRUE
object@assayData <- e
if (validObject(object))
return(object)
}

bin_MSnExp <- function(object, binSize=1, verbose=TRUE) {
Expand Down
3 changes: 2 additions & 1 deletion R/readMSData.R
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ readMSData <- function(files,
## Create 'fdata' and 'pdata' objects
nms <- ls(assaydata)
if (is.null(pdata)) {
.pd <- data.frame(sampleNames = 1)
.pd <- data.frame(sampleNames = basename(files))
rownames(.pd) <- basename(files)
pdata <- new("NAnnotatedDataFrame",
data = .pd)
}
Expand Down

0 comments on commit 6b7fa18

Please sign in to comment.