diff --git a/R/Risa-ms.R b/R/Risa-ms.R index 926c391..04726da 100644 --- a/R/Risa-ms.R +++ b/R/Risa-ms.R @@ -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() @@ -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, @@ -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 {