Mercurial > repos > galaxyp > cardinal_segmentations
diff segmentation.xml @ 4:9f7d1ec01767 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit ecdc3a64aa245d80dbc5487b2bf10a85a43adc6d
author | galaxyp |
---|---|
date | Fri, 22 Mar 2019 08:15:15 -0400 |
parents | 09b638ceee45 |
children | 4a2ac25d1063 |
line wrap: on
line diff
--- a/segmentation.xml Thu Feb 28 09:23:26 2019 -0500 +++ b/segmentation.xml Fri Mar 22 08:15:15 2019 -0400 @@ -1,4 +1,4 @@ -<tool id="cardinal_segmentations" name="MSI segmentation" version="@VERSION@.2"> +<tool id="cardinal_segmentations" name="MSI segmentation" version="@VERSION@.3"> <description>mass spectrometry imaging spatial clustering</description> <macros> <import>macros.xml</import> @@ -30,15 +30,10 @@ @READING_MSIDATA_INRAM@ -## to make sure that processed files work as well: -iData(msidata) = iData(msidata)[] ## remove duplicated coordinates -print(paste0(sum(duplicated(coord(msidata))), " duplicated coordinates were removed")) msidata <- msidata[,!duplicated(coord(msidata))] -## count and print number of NAs, all methods are not compatible with NAs -print(paste0("Number of NA in dataset: ", sum(is.na(spectra(msidata)[])), " - segmentation does not work with NA values")) @DATA_PROPERTIES_INRAM@ @@ -58,7 +53,7 @@ ############################################################################# grid.table(property_df, rows= NULL) -if (npeaks > 0 && sum(is.na(spectra(msidata)[]))==0) +if (npeaks > 0 && sum(is.na(spectra(msidata)))==0) { ######################## II) segmentation tools ############################# @@ -67,13 +62,13 @@ colourvector = c($color_string) ### preparation for images and plots: - #if str($image_cond.image_type) == "standard_image": + #if str($image_type) == "standard_image": print("standard image") - strip_input = TRUE + strip_input = FALSE lattice_input = FALSE - #elif str($image_cond.image_type) == "lattice_image": + #elif str($image_type) == "lattice_image": print("lattice image") strip_input = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)) @@ -112,11 +107,11 @@ ### images in pdf file print(image(pca_result, main="PCA image", lattice=lattice_input, strip = strip_input, col=colourvector, ylim=c(maximumy+2, minimumy-2))) for (PCs in 1:$segm_cond.pca_ncomp){ - print(image(pca_result, column = c(paste0("PC",PCs)), lattice=lattice_input, superpose = FALSE, col.regions = risk.colors(100), ylim=c(maximumy+2, minimumy-2)))} + print(image(pca_result, column = c(paste0("PC",PCs)), lattice=lattice_input,strip = strip_input, superpose = FALSE, main=paste0("PC", PCs), col.regions = risk.colors(100), ylim=c(maximumy+2, minimumy-2)))} ### plots in pdf file print(plot(pca_result, main="PCA plot", lattice=lattice_input, col= colourvector, strip = strip_input)) for (PCs in 1:$segm_cond.pca_ncomp){ - print(plot(pca_result, column = c(paste0("PC",PCs)),superpose = FALSE))} + print(plot(pca_result, column = c(paste0("PC",PCs)),main=paste0("PC", PCs),strip = FALSE,superpose = FALSE))} ### values in tabular files pcaloadings = formatC(pca_result@resultData\$ncomp\$loadings, format = "e", digits = 6)### loading for each m/z value @@ -155,7 +150,6 @@ gc() print(image(skm, key=TRUE, main="K-means clustering", lattice=lattice_input, strip=strip_input, col= colourvector, layout=c(1,1), ylim=c(maximumy+2, minimumy-2))) - print(plot(skm, main="K-means plot", lattice=lattice_input, col= colourvector, strip=strip_input, layout=c(1,1))) skm_clusters = data.frame(matrix(NA, nrow = pixelcount, ncol = 0)) @@ -194,9 +188,10 @@ ## remove msidata to clean up RAM space rm(msidata) gc() - print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=lattice_input, strip = strip_input, col= colourvector,layout=c(1,1), ylim=c(maximumy+2, minimumy-2))) - print(plot(ssc, main="Spatial shrunken centroids plot", lattice=lattice_input, col= colourvector, strip = strip_input,layout=c(1,1))) + print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=lattice_input, strip = TRUE, col= colourvector,layout=c(1,1), ylim=c(maximumy+2, minimumy-2))) + print(plot(ssc, main="Spatial shrunken centroids plot", lattice=lattice_input, col= colourvector, strip = TRUE,layout=c(1,1))) print(plot(ssc, mode = "tstatistics",key = TRUE, lattice=lattice_input, layout = c(1,1), main="t-statistics", col=colourvector)) + plot(summary(ssc), main = "Number of segments") ssc_classes = data.frame(matrix(NA, nrow = pixelcount, ncol = 0)) @@ -231,6 +226,28 @@ dev.off() + ## optional svg output with original coordinates + #if $svg_pixelimage: + print("svg image") + ## reverse y axis for svg output = correct order and nice svg image + + + svg(file="svg_pixel_output.svg", width=maximumx, height=maximumy) + par(mar=c(0,0,0,0)) + #if str( $segm_cond.segmentationtool ) == 'pca': + coord(pca_result)\$y <- max(coord(pca_result)\$y) - coord(pca_result)\$y + 1 + image(pca_result, strip = FALSE, colorkey=FALSE, axes=FALSE, xlab=NA, ylab=NA, col=colourvector) + #elif str( $segm_cond.segmentationtool ) == 'kmeans': + coord(skm)\$y <- max(coord(skm)\$y) - coord(skm)\$y + 1 + image(skm, key=FALSE, strip=FALSE, col= colourvector) + #elif str( $segm_cond.segmentationtool ) == 'centroids': + coord(ssc)\$y <- max(coord(ssc)\$y) - coord(ssc)\$y + 1 + image(ssc, key=FALSE, strip = FALSE, col= colourvector) + #end if + dev.off() + #end if + + }else{ print("Inputfile has no intensities > 0") dev.off() @@ -256,7 +273,6 @@ </param> <param name="pca_scale" type="boolean" truevalue="TRUE" falsevalue="FALSE" label="Scaling of data before analysis"/> </when> - <when value="kmeans"> <param name="kmeans_r" type="text" value="2" label="The spatial neighborhood radius of nearby pixels to consider (r)" help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"> @@ -297,14 +313,9 @@ label="Number of toplabels (m/z) which should be written in tabular output"/> </when> </conditional> - <conditional name="image_cond"> - <param name="image_type" type="select" label="Select the image type"> - <option value="standard_image" selected="True">standard</option> - <option value="lattice_image">lattice</option> - </param> - <when value="standard_image"/> - <when value="lattice_image"/> - </conditional> + <param name="image_type" type="boolean" checked="True" truevalue="standard_image" falsevalue="lattice_image" + label="Standard image" help="No: lattice function is used to display image"/> + <param name="svg_pixelimage" type="boolean" label="Export first segmentation image as svg"/> <repeat name="colours" title="Colours for the plots" min="1" max="50"> <param name="feature_color" type="color" label="Colours" value="#ff00ff" help="Numbers of colours should be the same as number of components"> <sanitizer> @@ -324,6 +335,9 @@ <data format="rdata" name="segmentation_rdata" label="${tool.name} on ${on_string}: results.RData"> <filter>output_rdata</filter> </data> + <data format="svg" name="svg_output" from_work_dir="svg_pixel_output.svg" label="${tool.name} on ${on_string}: image.svg"> + <filter>svg_pixelimage</filter> + </data> </outputs> <tests> <test> @@ -404,18 +418,22 @@ This tool provides three different Cardinal functions for unsupervised clustering/spatial segmentation of mass spectrometry imaging data. @MSIDATA_INPUT_DESCRIPTION@ + - NA intensities are not allowed + - duplicated coordinates will be removed + **Options** - PCA: principal component analysis -- k-means: spatially-aware k-means clustering -- spatial shrunken centroids: Allows the number of segments to decrease according to the data. This allows automatic selection of the number of clusters +- k-means: spatially-aware k-means clustering (adopted from `Alexandrov and Kobarg <https://doi.org/10.1093/bioinformatics/btr246>`_) +- spatial shrunken centroids: Allows the number of segments to decrease according to the data. This allows selection of the number of clusters (more details in `Bemis et al. <https://doi.org/10.1074/mcp.O115.053918>`_) **Output** - Pdf with the heatmaps and plots for the segmentation - Tabular file with information on m/z and pixels: loadings/scores (PCA), toplabels/clusters (k-means), toplabels/classes (spatial shrunken centroids) - Optional .RData file which contains the segmentation results and can be used for further exploration in R using the Cardinal package +- Optional: svg file with the first segmentation image ]]> </help>