Mercurial > repos > lecorguille > camera_annotate
changeset 36:b6a8143c397c draft
planemo upload commit aa538ae477bc2f901c95d916e11d70eab75b5e00
author | lecorguille |
---|---|
date | Fri, 01 Feb 2019 11:29:35 -0500 |
parents | b02797fbead1 |
children | 636e36a64d31 |
files | CAMERA.r README.rst abims_CAMERA_annotateDiffreport.xml lib.r repository_dependencies.xml |
diffstat | 5 files changed, 111 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/CAMERA.r Fri Aug 17 06:45:55 2018 -0400 +++ b/CAMERA.r Fri Feb 01 11:29:35 2019 -0500 @@ -83,11 +83,6 @@ rplotspdf = listArguments[["rplotspdf"]]; listArguments[["rplotspdf"]]=NULL } -dataMatrixOutput = "dataMatrix.tsv" -if (!is.null(listArguments[["dataMatrixOutput"]])){ - dataMatrixOutput = listArguments[["dataMatrixOutput"]]; listArguments[["dataMatrixOutput"]]=NULL -} - variableMetadataOutput = "variableMetadata.tsv" if (!is.null(listArguments[["variableMetadataOutput"]])){ variableMetadataOutput = listArguments[["variableMetadataOutput"]]; listArguments[["variableMetadataOutput"]]=NULL @@ -129,7 +124,7 @@ pdf(file=rplotspdf, width=16, height=12) if (thefunction %in% c("annotatediff")) { - results_list=annotatediff(xset=xset,listArguments=listArguments,variableMetadataOutput=variableMetadataOutput,dataMatrixOutput=dataMatrixOutput) + results_list=annotatediff(xset=xset,listArguments=listArguments,variableMetadataOutput=variableMetadataOutput) xa=results_list[["xa"]] diffrep=results_list[["diffrep"]] variableMetadata=results_list[["variableMetadata"]]
--- a/README.rst Fri Aug 17 06:45:55 2018 -0400 +++ b/README.rst Fri Feb 01 11:29:35 2019 -0500 @@ -2,6 +2,14 @@ Changelog/News -------------- +**Version 2.2.5 - 01/02/2019** + +- NEW: zip export are back for pictures (eic and boxplot) and diffreport tables + +**Version 2.2.4 - 09/10/2018** + +- NES: CAMERA.annotate no longer export a DataMatrix. fillChromPeaks does the job + **Version 2.2.3 - 30/04/2018** - NEW: support the new xcms 3.0.0 wrapper
--- a/abims_CAMERA_annotateDiffreport.xml Fri Aug 17 06:45:55 2018 -0400 +++ b/abims_CAMERA_annotateDiffreport.xml Fri Feb 01 11:29:35 2019 -0500 @@ -1,4 +1,4 @@ -<tool id="abims_CAMERA_annotateDiffreport" name="CAMERA.annotate" version="2.2.3"> +<tool id="abims_CAMERA_annotateDiffreport" name="CAMERA.annotate" version="2.2.5"> <description>CAMERA annotate function. Returns annotation results (isotope peaks, adducts and fragments) and a diffreport if more than one condition.</description> @@ -18,7 +18,6 @@ ## output variableMetadataOutput '$variableMetadata' - dataMatrixOutput '$datamatrix' ## groupFWHM sigma $groupfwhm.sigma @@ -67,6 +66,8 @@ h $diffreport.options.h w $diffreport.options.w mzdec $diffreport.options.mzdec + tabular2 $diffreport.options.tabular2 + png2 $diffreport.options.png2 #end if @COMMAND_PEAKLIST@ @@ -160,6 +161,14 @@ <param name="w" type="integer" value="640" label="Numeric variable for the width of the eic and boxplots print out made" help="[width]" /> <param name="mzdec" type="integer" value="2" label="Number of decimal places of title m/z values in the eic plot" help="[mzdec]" /> <param name="sortpval" type="boolean" checked="false" truevalue="TRUE" falsevalue="FALSE" label="logical indicating whether the reports should be sorted by p-value" help="[sortpval]"/> + <param name="tabular2" type="select" label="Export the Diffreport files in "> + <option value="zip" selected="true">Zip</option> + <option value="datasetcollection">Individual file in a Dataset Collection</option> + </param> + <param name="png2" type="select" label="Export the EIC and boxplots in "> + <option value="zip" selected="true">Zip</option> + <option value="pdf">Individual pdf</option> + </param> </when> <when value="hide"> </when> @@ -172,7 +181,6 @@ <outputs> <data name="variableMetadata" format="tabular" label="${image.name[:-6]}.annotate.variableMetadata.tsv" /> - <data name="datamatrix" format="tabular" label="${image.name[:-6]}.annotate.dataMatrix.tsv" /> <data name="rdata_quick_false" format="rdata.camera.quick" label="${image.name[:-6]}.annotate.${$quick_block.findadducts.polarity}.Rdata" > <filter>quick_block['quick'] == 'FALSE'</filter> <change_format> @@ -183,11 +191,25 @@ <data name="rdata_quick_true" format="rdata.camera.quick" label="${image.name[:-6]}.annotate.quick.Rdata" > <filter>quick_block['quick'] == 'TRUE'</filter> </data> - <data name="output_diffreport" format="text" label="${image.name[:-6]}.annotateDiffreport" hidden="true"> - <filter>diffreport['options']['option'] == 'show'</filter> - <discover_datasets pattern="__designation_and_ext__" directory="pdf" visible="true" /> - <discover_datasets pattern="__designation_and_ext__" directory="tabular" visible="true" /> + + <data name="output_diffreport_eic_zip" format="zip" label="${image.name[:-6]}.annotateDiffreport_eic.zip" from_work_dir="eic.zip" > + <filter>diffreport['options']['option'] == 'show' and diffreport['options']['png2'] == 'zip'</filter> + </data> + <data name="output_diffreport_box_zip" format="zip" label="${image.name[:-6]}.annotateDiffreport_box.zip" from_work_dir="box.zip" > + <filter>diffreport['options']['option'] == 'show' and diffreport['options']['png2'] == 'zip'</filter> </data> + <collection name="output_diffreport_picture_pdf" type="list" label="${image.name[:-6]}.annotateDiffreport.pdf"> + <filter>diffreport['options']['option'] == 'show' and diffreport['options']['png2'] == 'pdf'</filter> + <discover_datasets pattern="__designation_and_ext__" directory="pdf" format="pdf" visible="true" /> + </collection> + + <data name="output_diffreport_table_zip" format="zip" label="${image.name[:-6]}.annotateDiffreport.pdf" from_work_dir="tabular.zip"> + <filter>diffreport['options']['option'] == 'show' and diffreport['options']['tabular2'] == 'zip'</filter> + </data> + <collection name="output_diffreport_table_collection" type="list" label="${image.name[:-6]}.annotateDiffreport_table"> + <filter>diffreport['options']['option'] == 'show' and diffreport['options']['tabular2'] == 'datasetcollection'</filter> + <discover_datasets pattern="__designation_and_ext__" directory="tabular" format="tabular" visible="true" /> + </collection> </outputs> <tests> @@ -197,23 +219,20 @@ <expand macro="test_annotate_quick_true"/> <expand macro="test_file_load_zip"/> <output name="variableMetadata" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.variableMetadata.tsv" /> - <output name="datamatrix" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.dataMatrix.tsv" /> </test>--> <test> <param name="image" value="faahKO-single.xset.merged.group.retcor.group.fillpeaks.RData"/> <expand macro="test_annotate_diffreport"/> <expand macro="test_annotate_quick_true"/> <expand macro="test_file_load_single"/> - <output name="variableMetadata" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.variableMetadata.tsv" /> - <output name="datamatrix" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.dataMatrix.tsv" /> + <output name="variableMetadata" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.variableMetadata.tsv" lines_diff="2" /> </test> <test> <param name="image" value="faahKO-single.xset.merged.group.retcor.group.fillpeaks-xcms3.RData"/> <expand macro="test_annotate_diffreport"/> <expand macro="test_annotate_quick_true"/> <expand macro="test_file_load_single"/> - <output name="variableMetadata" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.variableMetadata-xcms3.tsv" /> - <output name="datamatrix" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.dataMatrix-xcms3.tsv" /> + <output name="variableMetadata" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.variableMetadata-xcms3.tsv" lines_diff="2" /> </test> <test> <param name="image" value="faahKO-single.xset.merged.group.retcor.group.fillpeaks.RData"/> @@ -229,8 +248,7 @@ </section> </conditional> <expand macro="test_file_load_single"/> - <output name="variableMetadata" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.rules.variableMetadata.tsv" /> - <output name="datamatrix" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.rules.dataMatrix.tsv" /> + <output name="variableMetadata" file="faahKO.xset.group.retcor.group.fillPeaks.annotate.rules.variableMetadata.tsv" lines_diff="2"/> </test> </tests> @@ -287,19 +305,19 @@ +===========================+=======================================+================================================+ |CAMERA_combinexsAnnot |xset.annotate.Rdata | rdata.camera.positive or rdata.camera.negative | +---------------------------+---------------------------------------+------------------------------------------------+ -|Determine Vdk or Lowess |xset.annotate.dataMatrix.tsv | Tabular | +|Determine Vdk or Lowess |xset.annotate.variableMetadata.tsv | Tabular | +---------------------------+---------------------------------------+------------------------------------------------+ -|Normalization Vdk/Lowess |xset.annotate.dataMatrix.tsv | Tabular | +|Normalization Vdk/Lowess |xset.annotate.variableMetadata.tsv | Tabular | +---------------------------+---------------------------------------+------------------------------------------------+ -|Anova |xset.annotate.dataMatrix.tsv | Tabular | +|Anova |xset.annotate.variableMetadata.tsv | Tabular | +---------------------------+---------------------------------------+------------------------------------------------+ -|PCA |xset.annotate.dataMatrix.tsv | Tabular | +|PCA |xset.annotate.variableMetadata.tsv | Tabular | +---------------------------+---------------------------------------+------------------------------------------------+ -|Hierarchical Clustering |xset.annotate.dataMatrix.tsv | Tabular | +|Hierarchical Clustering |xset.annotate.variableMetadata.tsv | Tabular | +---------------------------+---------------------------------------+------------------------------------------------+ -The output file **xset.annotate.dataMatrix.tsv** is an tabular file. You can continue your analysis using it in the following tools: +The output file **xset.annotate.variableMetadata.tsv** is an tabular file. You can continue your analysis using it in the following tools: | Determine Vdk or Lowess | Normalization Vdk/Lowess @@ -361,10 +379,6 @@ | For each metabolite (row) : | the value of the intensity in each sample, fold, anova, mzmed, mzmin, mzmax, rtmed, rtmin, rtmax, npeaks, isotopes, adduct and pcgroup -xset.annotate.dataMatrix.tsv - - | A tabular file which represents for each metabolite (row), the value of the intensity in each sample (column). - xset.annotate.zip | It contains filebase_eic, filebase_box and filebase.tsv for one conditon vs another (Anova analysis). @@ -377,7 +391,7 @@ .. class:: infomark -The output **"xset.annotate.dataMatrix.tsv"** is a tabular file. You can continue your analysis using it in the following tools of the workflow: +The output **"xset.annotate.variableMetadata.tsv"** is a tabular file. You can continue your analysis using it in the following tools of the workflow: | Determine Vdk or Lowess (Data correction) | Normalization Vdk/Lowess (Data correction) @@ -418,10 +432,6 @@ Output files ------------ -**Example of an xset.annotate.dataMatrix.tsv output** - -.. image:: annotatediffreport_dataMatrix.png - **Example of a part of xset.annotate.variableMetadata.tsv output** .. image:: annotatediffreport_variableMetadata.png @@ -432,6 +442,14 @@ Changelog/News -------------- +**Version 2.2.5 - 01/02/2019** + +- NEW: zip export are back for pictures (eic and boxplot) and diffreport tables + +**Version 2.2.4 - 09/10/2018** + +- NEW: CAMERA.annotate no longer export a DataMatrix. fillChromPeaks does the job + **Version 2.2.3 - 30/04/2018** - NEW: support the new xcms 3.0.0 wrapper
--- a/lib.r Fri Aug 17 06:45:55 2018 -0400 +++ b/lib.r Fri Feb 01 11:29:35 2019 -0500 @@ -34,6 +34,18 @@ } #@author G. Le Corguille +#The function create a zip archive from the different png generated by diffreport +diffreport_png2zip <- function() { + zip("eic.zip",dir(pattern="_eic")) + zip("box.zip",dir(pattern="_box")) +} + +#The function create a zip archive from the different tabular generated by diffreport +diffreport_tabular2zip <- function() { + zip("tabular.zip",dir(pattern="tabular/*")) +} + +#@author G. Le Corguille #This function convert if it is required the Retention Time in minutes RTSecondToMinute <- function(variableMetadata, convertRTMinute) { if (convertRTMinute){ @@ -57,7 +69,7 @@ } #The function annotateDiffreport without the corr function which bugs -annotatediff <- function(xset=xset, listArguments=listArguments, variableMetadataOutput="variableMetadata.tsv", dataMatrixOutput="dataMatrix.tsv") { +annotatediff <- function(xset=xset, listArguments=listArguments, variableMetadataOutput="variableMetadata.tsv") { # Resolve the bug with x11, with the function png options(bitmapType='cairo') @@ -108,11 +120,6 @@ peakList=getPeaklist(xa,intval=listArguments[["intval"]]) peakList=cbind(groupnames(xa@xcmsSet),peakList); colnames(peakList)[1] = c("name"); - # --- dataMatrix --- - dataMatrix = peakList[,(make.names(colnames(peakList)) %in% c("name", make.names(sampnames(xa@xcmsSet))))] - write.table(dataMatrix, sep="\t", quote=FALSE, row.names=FALSE, file=dataMatrixOutput) - - # --- Multi condition : diffreport --- diffrepOri=NULL if (!is.null(listArguments[["runDiffreport"]]) & nlevels(sampclass(xset))>=2) { @@ -149,11 +156,16 @@ write.table(diffrep, sep="\t", quote=FALSE, row.names=FALSE, file=paste("tabular/",filebase,"_tsv.tabular",sep="")) if (listArguments[["eicmax"]] != 0) { - diffreport_png2pdf(filebase) + if (listArguments[["png2"]] == "pdf") + diffreport_png2pdf(filebase) } } } } + if (listArguments[["png2"]] == "zip") + diffreport_png2zip() + if (listArguments[["tabular2"]] == "zip") + diffreport_tabular2zip() } # --- variableMetadata --- @@ -330,24 +342,24 @@ getEIC <- function(object, mzrange, rtrange = 200, groupidx, sampleidx = sampnames(object), rt = c("corrected", "raw")) { - + files <- filepaths(object) grp <- groups(object) samp <- sampnames(object) prof <- profinfo(object) - + rt <- match.arg(rt) - + if (is.numeric(sampleidx)) sampleidx <- sampnames(object)[sampleidx] sampidx <- match(sampleidx, sampnames(object)) - + if (!missing(groupidx)) { if (is.numeric(groupidx)) groupidx <- groupnames(object)[unique(as.integer(groupidx))] grpidx <- match(groupidx, groupnames(object, template = groupidx)) } - + if (missing(mzrange)) { if (missing(groupidx)) stop("No m/z range or groups specified") @@ -369,7 +381,7 @@ else if (is.null(dim(mzrange))) stop("mzrange must be a matrix") colnames(mzrange) <- c("mzmin", "mzmax") - + if (length(rtrange) == 1) { if (missing(groupidx)) rtrange <- matrix(rep(range(object@rt[[rt]][sampidx]), nrow(mzrange)), @@ -380,11 +392,11 @@ } else if (is.null(dim(rtrange))) stop("rtrange must be a matrix or single number") colnames(rtrange) <- c("rtmin", "rtmax") - + ## Ensure that we've got corrected retention time if requested. if (is.null(object@rt[[rt]])) stop(rt, " retention times not present in 'object'!") - + ## Ensure that the defined retention time range is within the rtrange of the ## object: we're using the max minimal rt of all files and the min maximal rt rtrs <- lapply(object@rt[[rt]], range) @@ -406,17 +418,17 @@ rtrange[lower_rt_outside, "rtmin"] <- rtr[1] rtrange[upper_rt_outside, "rtmax"] <- rtr[2] } - + if (missing(groupidx)) gnames <- character(0) else gnames <- groupidx - + eic <- vector("list", length(sampleidx)) names(eic) <- sampleidx - + for (i in seq(along = sampidx)) { - + ## cat(sampleidx[i], "") flush.console() ## getXcmsRaw takes care of rt correction, susetting to scanrage and other @@ -428,7 +440,7 @@ gc() } ## cat("\n") - + invisible(new("xcmsEIC", eic = eic, mzrange = mzrange, rtrange = rtrange, rt = rt, groupnames = gnames)) } @@ -449,15 +461,15 @@ metlin = FALSE, h = 480, w = 640, mzdec=2, missing = numeric(), ...) { - + if ( nrow(object@groups)<1 || length(object@groupidx) <1) { stop("No group information. Use group().") } - + if (!is.numeric(w) || !is.numeric(h)) stop("'h' and 'w' have to be numeric") ## require(multtest) || stop("Couldn't load multtest") - + value <- match.arg(value) groupmat <- groups(object) if (length(groupmat) == 0) @@ -466,20 +478,20 @@ n <- length(samples) classlabel <- sampclass(object) classlabel <- levels(classlabel)[as.vector(unclass(classlabel))] - + values <- groupval(object, "medret", value=value) indecies <- groupval(object, "medret", value = "index") - + if (!all(c(class1,class2) %in% classlabel)) stop("Incorrect Class Labels") - + ## c1 and c2 are column indices of class1 and class2 resp. c1 <- which(classlabel %in% class1) c2 <- which(classlabel %in% class2) ceic <- which(classlabel %in% classeic) if (length(intersect(c1, c2)) > 0) stop("Intersecting Classes") - + ## Optionally replace NA values with the value provided with missing if (length(missing)) { if (is.numeric(missing)) { @@ -493,21 +505,21 @@ warning("`NA` values in xcmsSet. Use fillPeaks() on the object to fill", "-in missing peak values. Note however that this will also ", "insert intensities of 0 for peaks that can not be filled in.") - + mean1 <- rowMeans(values[,c1,drop=FALSE], na.rm = TRUE) mean2 <- rowMeans(values[,c2,drop=FALSE], na.rm = TRUE) - + ## Calculate fold change. ## For foldchange <1 set fold to 1/fold ## See tstat to check which was higher fold <- mean2 / mean1 fold[!is.na(fold) & fold < 1] <- 1/fold[!is.na(fold) & fold < 1] - + testval <- values[,c(c1,c2)] ## Replace eventual infinite values with NA (CAMERA issue #33) testval[is.infinite(testval)] <- NA testclab <- c(rep(0,length(c1)),rep(1,length(c2))) - + if (min(length(c1), length(c2)) >= 2) { tstat <- mt.teststat(testval, testclab, ...) pvalue <- xcms:::pval(testval, testclab, tstat) @@ -543,18 +555,18 @@ values<-values[tsidx,] } else tsidx <- 1:nrow(values) - + if (length(filebase)) write.table(twosamp, paste(filebase, ".tsv", sep = ""), quote = FALSE, sep = "\t", col.names = NA) - + if (eicmax > 0) { if (length(unique(peaks(object)[,"rt"])) > 1) { ## This looks like "normal" LC data - + eicmax <- min(eicmax, length(tsidx)) eics <- getEIC(object, rtrange = eicwidth*1.1, sampleidx = ceic, groupidx = tsidx[seq(length = eicmax)]) - + if (length(filebase)) { eicdir <- paste(filebase, "_eic", sep="") boxdir <- paste(filebase, "_box", sep="") @@ -572,7 +584,7 @@ } } plot(eics, object, rtrange = eicwidth, mzdec=mzdec) - + if (length(filebase)) dev.off() } else { @@ -596,13 +608,13 @@ height = h/72, onefile = FALSE) } } - + plotSpecWindow(object, gidxs = tsidx[seq(length = eicmax)], borderwidth=1) - + if (length(filebase)) dev.off() } } - + invisible(twosamp) }
--- a/repository_dependencies.xml Fri Aug 17 06:45:55 2018 -0400 +++ b/repository_dependencies.xml Fri Feb 01 11:29:35 2019 -0500 @@ -1,5 +1,5 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <repositories> - <repository changeset_revision="3319a4f78021" name="rdata_camera_datatypes" owner="lecorguille" toolshed="https://testtoolshed.g2.bx.psu.edu" /> - <repository changeset_revision="8ce71291b600" name="rdata_xcms_datatypes" owner="lecorguille" toolshed="https://testtoolshed.g2.bx.psu.edu" /> -</repositories> + <repository changeset_revision="3319a4f78021" name="rdata_camera_datatypes" owner="lecorguille" toolshed="https://testtoolshed.g2.bx.psu.edu"/> + <repository changeset_revision="8ce71291b600" name="rdata_xcms_datatypes" owner="lecorguille" toolshed="https://testtoolshed.g2.bx.psu.edu"/> +</repositories> \ No newline at end of file