Mercurial > repos > lecorguille > xcms_retcor
comparison lib.r @ 36:e309e6af6744 draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 3922356e5edae763800a4311146e2fdeb52c296e
| author | lecorguille |
|---|---|
| date | Fri, 31 Aug 2018 09:02:01 -0400 |
| parents | 2b0a4c7a4a48 |
| children | 35a20d7c9f33 |
comparison
equal
deleted
inserted
replaced
| 35:2b0a4c7a4a48 | 36:e309e6af6744 |
|---|---|
| 389 } | 389 } |
| 390 | 390 |
| 391 | 391 |
| 392 # This function get the raw file path from the arguments | 392 # This function get the raw file path from the arguments |
| 393 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr | 393 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr |
| 394 getRawfilePathFromArguments <- function(singlefile, zipfile, args) { | 394 getRawfilePathFromArguments <- function(singlefile, zipfile, args, prefix="") { |
| 395 if (!is.null(args$zipfile)) zipfile <- args$zipfile | 395 if (!(prefix %in% c("","Positive","Negative","MS1","MS2"))) stop("prefix must be either '', 'Positive', 'Negative', 'MS1' or 'MS2'") |
| 396 if (!is.null(args$zipfilePositive)) zipfile <- args$zipfilePositive | 396 |
| 397 if (!is.null(args$zipfileNegative)) zipfile <- args$zipfileNegative | 397 if (!is.null(args[[paste0("zipfile",prefix)]])) zipfile <- args[[paste0("zipfile",prefix)]] |
| 398 | 398 |
| 399 if (!is.null(args$singlefile_galaxyPath)) { | 399 if (!is.null(args[[paste0("singlefile_galaxyPath",prefix)]])) { |
| 400 singlefile_galaxyPaths <- args$singlefile_galaxyPath; | 400 singlefile_galaxyPaths <- args[[paste0("singlefile_galaxyPath",prefix)]] |
| 401 singlefile_sampleNames <- args$singlefile_sampleName | 401 singlefile_sampleNames <- args[[paste0("singlefile_sampleName",prefix)]] |
| 402 } | 402 } |
| 403 if (!is.null(args$singlefile_galaxyPathPositive)) { | 403 if (exists("singlefile_galaxyPaths")){ |
| 404 singlefile_galaxyPaths <- args$singlefile_galaxyPathPositive; | 404 singlefile_galaxyPaths <- unlist(strsplit(singlefile_galaxyPaths,"\\|")) |
| 405 singlefile_sampleNames <- args$singlefile_sampleNamePositive | 405 singlefile_sampleNames <- unlist(strsplit(singlefile_sampleNames,"\\|")) |
| 406 } | 406 |
| 407 if (!is.null(args$singlefile_galaxyPathNegative)) { | 407 singlefile <- NULL |
| 408 singlefile_galaxyPaths <- args$singlefile_galaxyPathNegative; | 408 for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) { |
| 409 singlefile_sampleNames <- args$singlefile_sampleNameNegative | 409 singlefile_galaxyPath <- singlefile_galaxyPaths[singlefile_galaxyPath_i] |
| 410 } | 410 singlefile_sampleName <- singlefile_sampleNames[singlefile_galaxyPath_i] |
| 411 if (exists("singlefile_galaxyPaths")){ | 411 # In case, an url is used to import data within Galaxy |
| 412 singlefile_galaxyPaths <- unlist(strsplit(singlefile_galaxyPaths,"\\|")) | 412 singlefile_sampleName <- tail(unlist(strsplit(singlefile_sampleName,"/")), n=1) |
| 413 singlefile_sampleNames <- unlist(strsplit(singlefile_sampleNames,"\\|")) | 413 singlefile[[singlefile_sampleName]] <- singlefile_galaxyPath |
| 414 | 414 } |
| 415 singlefile <- NULL | 415 } |
| 416 for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) { | 416 return(list(zipfile=zipfile, singlefile=singlefile)) |
| 417 singlefile_galaxyPath <- singlefile_galaxyPaths[singlefile_galaxyPath_i] | 417 } |
| 418 singlefile_sampleName <- singlefile_sampleNames[singlefile_galaxyPath_i] | |
| 419 singlefile[[singlefile_sampleName]] <- singlefile_galaxyPath | |
| 420 } | |
| 421 } | |
| 422 return(list(zipfile=zipfile, singlefile=singlefile)) | |
| 423 } | |
| 424 | |
| 425 | 418 |
| 426 # This function retrieve the raw file in the working directory | 419 # This function retrieve the raw file in the working directory |
| 427 # - if zipfile: unzip the file with its directory tree | 420 # - if zipfile: unzip the file with its directory tree |
| 428 # - if singlefiles: set symlink with the good filename | 421 # - if singlefiles: set symlink with the good filename |
| 429 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr | 422 #@author Gildas Le Corguille lecorguille@sb-roscoff.fr |
| 478 return (xobject) | 471 return (xobject) |
| 479 # XCMS 3.x | 472 # XCMS 3.x |
| 480 if (class(xobject) == "XCMSnExp") { | 473 if (class(xobject) == "XCMSnExp") { |
| 481 # Get the legacy xcmsSet object | 474 # Get the legacy xcmsSet object |
| 482 suppressWarnings(xset <- as(xobject, 'xcmsSet')) | 475 suppressWarnings(xset <- as(xobject, 'xcmsSet')) |
| 483 sampclass(xset) <- xset@phenoData$sample_group | 476 if (!is.null(xset@phenoData$sample_group)) |
| 477 sampclass(xset) <- xset@phenoData$sample_group | |
| 478 else | |
| 479 sampclass(xset) <- "." | |
| 484 return (xset) | 480 return (xset) |
| 485 } | 481 } |
| 486 } | 482 } |
| 487 | 483 |
| 488 | 484 |
