Mercurial > repos > galaxyp > mass_spectrometry_imaging_segmentations
diff segmentation_tool.xml @ 8:4a62874c21a3 draft default tip
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_segmentation commit 5feaf3d0e0da8cef1241fecc1f4d6f81324594e6
author | galaxyp |
---|---|
date | Wed, 22 Aug 2018 13:44:28 -0400 |
parents | adfef12c7e31 |
children |
line wrap: on
line diff
--- a/segmentation_tool.xml Fri Jul 06 14:14:27 2018 -0400 +++ b/segmentation_tool.xml Wed Aug 22 13:44:28 2018 -0400 @@ -1,4 +1,4 @@ -<tool id="mass_spectrometry_imaging_segmentations" name="MSI segmentation" version="1.10.0.3"> +<tool id="mass_spectrometry_imaging_segmentations" name="MSI segmentation" version="1.10.0.4"> <description>mass spectrometry imaging spatial clustering</description> <requirements> <requirement type="package" version="1.10.0">bioconductor-cardinal</requirement> @@ -45,7 +45,11 @@ #elif $infile.ext == 'analyze75' msidata = readAnalyze('infile') #else - load('infile.RData') + loadRData <- function(fileName){ + load(fileName) + get(ls()[ls() != "fileName"]) + } + msidata = loadRData('infile.RData') #end if @@ -186,6 +190,8 @@ #end if + ## set seed to make analysis reproducible + set.seed($setseed) #if str( $segm_cond.segmentationtool ) == 'pca': print('pca') @@ -198,9 +204,9 @@ method = "$segm_cond.pca_method", scale = $segm_cond.pca_scale, layout = c(ncomp, 1)) ### images in pdf file - print(image(pca_result, main="PCA image", lattice=lattice_input, strip = strip_input, col=colourvector)) + 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)))} + 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)))} ### 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){ @@ -208,10 +214,14 @@ ### values in tabular files pcaloadings = (pca_result@resultData\$ncomp\$loadings) ### loading for each m/z value + pcaloadings2 = cbind(rownames(pcaloadings), pcaloadings) + colnames(pcaloadings2) = c("mz", colnames(pcaloadings)) pcascores = (pca_result@resultData\$ncomp\$scores) ### scores for each pixel + pcascores2 = cbind(rownames(pcascores), pcascores) + colnames(pcascores2) = c("pixel names", colnames(pcascores)) - write.table(pcaloadings, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") - write.table(pcascores, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") + write.table(pcaloadings2, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") + write.table(pcascores2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") ## optional output as .RData #if $output_rdata: @@ -225,7 +235,7 @@ ##k-means skm = spatialKMeans(msidata, r=c($segm_cond.kmeans_r), k=c($segm_cond.kmeans_k), method="$segm_cond.kmeans_method") - print(image(skm, key=TRUE, main="K-means clustering", lattice=lattice_input, strip=strip_input, col= colourvector, layout=c(1,1))) + 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($segm_cond.kmeans_layout))) @@ -233,12 +243,13 @@ for (iteration in 1:length(skm@resultData)){ skm_cluster = ((skm@resultData)[[iteration]]\$cluster) skm_clusters = cbind(skm_clusters, skm_cluster) } - colnames(skm_clusters) = names((skm@resultData)) + skm_clusters2 = cbind(rownames(skm_clusters), skm_clusters) + colnames(skm_clusters2) = c("pixel names", names(skm@resultData)) skm_toplabels = topLabels(skm, n=$segm_cond.kmeans_toplabels) - - write.table(skm_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") - write.table(skm_clusters, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") + + write.table(skm_toplabels, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") + write.table(skm_clusters2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") ## optional output as .RData #if $output_rdata: @@ -253,7 +264,7 @@ ##centroids ssc = spatialShrunkenCentroids(msidata, r=c($segm_cond.centroids_r), k=c($segm_cond.centroids_k), s=c($segm_cond.centroids_s), method="$segm_cond.centroids_method") - print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=lattice_input, strip = strip_input, col= colourvector,layout=c(1,1))) + 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($segm_cond.centroids_layout))) print(plot(ssc, mode = "tstatistics",key = TRUE, lattice=lattice_input, layout = c($segm_cond.centroids_layout), main="t-statistics", col=colourvector)) plot(summary(ssc), main = "Number of segments") @@ -262,12 +273,13 @@ for (iteration in 1:length(ssc@resultData)){ ssc_class = ((ssc@resultData)[[iteration]]\$classes) ssc_classes = cbind(ssc_classes, ssc_class) } - colnames(ssc_classes) = names((ssc@resultData)) + ssc_classes2 = cbind(rownames(ssc_classes), ssc_classes) + colnames(ssc_classes2) = c("pixel names", names(ssc@resultData)) ssc_toplabels = topLabels(ssc, n=$segm_cond.centroids_toplabels) - write.table(ssc_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") - write.table(ssc_classes, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") + write.table(ssc_toplabels, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") + write.table(ssc_classes2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") ## optional output as .RData #if $output_rdata: @@ -379,6 +391,7 @@ </param> </repeat> <param name="output_rdata" type="boolean" display="radio" label="Results as .RData output"/> + <param name="setseed" type="integer" value="1" label="set seed" help="use same value to reproduce previous results"/> </inputs> <outputs> <data format="pdf" name="segmentationimages" from_work_dir="segmentationpdf.pdf" label = "$infile.display_name segmentation"/>