Skip to content

Commit

Permalink
The method processAssayXcmsSet now uses all the factors to build the …
Browse files Browse the repository at this point in the history
…sclass object, instead of just the first one ISA-tools#12
  • Loading branch information
agbeltran committed Mar 8, 2013
1 parent dce2a69 commit 3f2f87c
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions R/Risa-ms.R
Expand Up @@ -6,19 +6,22 @@ processAssayXcmsSet.1factor = function(isa, assay.filename, ...){

i <- which(isa["assay.filenames"]==assay.filename)

#if 'Raw Spectral Data File' is one of the columns in the assay file = it is a mass spectrometry assay
if (isatab.syntax$raw.spectral.data.file %in% colnames(isa["data.filenames"][[i]]))
{
#mass spectrometry files
msfiles = isa["data.filenames"][[i]][[ isatab.syntax$raw.spectral.data.file ]]

#the assay file as an AnnotatedDataFrame
pd = try(read.AnnotatedDataFrame(file.path(isa["path"], isa["assay.filenames"][i]),
row.names = NULL, blank.lines.skip = TRUE, fill = TRUE,
varMetadata.char = "$", quote="\""))

#Adding the raw spectral data files as the row names
sampleNames(pd) = pd$Raw.Spectral.Data.File

if (length(grep(isatab.syntax$factor.value, colnames(isa["assay.files"][[i]]))) != 0) {
## If there are explicit factors, use them
## If there are explicit factors, use the first of them
sclass = isa["assay.files"][[i]][ which(isa["assay.files"][[i]][[isatab.syntax$sample.name]] %in% pd$Sample.Name), grep(isatab.syntax$factor.value, colnames(isa["assay.files"][[i]]))[1]]

wd <- getwd()
Expand All @@ -41,23 +44,16 @@ processAssayXcmsSet.1factor = function(isa, assay.filename, ...){


### specific function to deal with assays whose technology type is mass spectrometry using the xcms package
### it returns an xcmsSet
### TODO - change implementation to include all factors
### it returns an xcmsSet,
processAssayXcmsSet = function(isa, assay.filename, ...){


phenodata.data.frame <- as.data.frame(isa["factors"])

assay.names <- isa["assay.names"][assay.filename]

row.names(phenodata.data.frame) <- assay.names[[assay.filename]][[1]]


i <- which(isa["assay.filenames"]==assay.filename)

if (isatab.syntax$raw.spectral.data.file %in% colnames(isa["data.filenames"][[i]]))
{
{

#mass spectrometry files
msfiles = isa["data.filenames"][[i]][[ isatab.syntax$raw.spectral.data.file ]]
msfiles = isa["data.filenames"][[i]][[ isatab.syntax$raw.spectral.data.file ]]

pd = try(read.AnnotatedDataFrame(file.path(isa["path"], isa["assay.filenames"][i]),
row.names = NULL, blank.lines.skip = TRUE, fill = TRUE,
Expand All @@ -67,11 +63,12 @@ processAssayXcmsSet = function(isa, assay.filename, ...){

if (length(grep(isatab.syntax$factor.value, colnames(isa["assay.files"][[i]]))) != 0) {
## If there are explicit factors, use them
sclass = isa["assay.files"][[i]][ which(isa["assay.files"][[i]][[isatab.syntax$sample.name]] %in% pd$Sample.Name), grep(isatab.syntax$factor.value, colnames(isa["assay.files"][[i]]))[1]]
sclass <- as.data.frame(isa["factors"])

wd <- getwd()
setwd(isa["path"])
xset = xcmsSet(files=msfiles, sclass=sclass, ...)

setwd(wd)

} else {
Expand Down

0 comments on commit 3f2f87c

Please sign in to comment.