comparison classification.xml @ 7:6f4c34f8d5ba draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit f986c51abe33c7f622d429a3c4a79ee24b33c1f3"
author galaxyp
date Thu, 23 Apr 2020 08:03:28 -0400
parents 47fc5b518ffc
children 277dc652246e
comparison
equal deleted inserted replaced
6:b574b84afc4d 7:6f4c34f8d5ba
1 <tool id="cardinal_classification" name="MSI classification" version="@VERSION@.3"> 1 <tool id="cardinal_classification" name="MSI classification" version="@VERSION@.0">
2 <description>spatial classification of mass spectrometry imaging data</description> 2 <description>spatial classification of mass spectrometry imaging data</description>
3 <macros> 3 <macros>
4 <import>macros.xml</import> 4 <import>macros.xml</import>
5 </macros> 5 </macros>
6 <expand macro="requirements"> 6 <expand macro="requirements">
7 <requirement type="package" version="3.0">r-ggplot2</requirement>
8 <requirement type="package" version="2.3">r-gridextra</requirement> 7 <requirement type="package" version="2.3">r-gridextra</requirement>
9 <requirement type="package" version="0.20_35">r-lattice</requirement> 8 <requirement type="package" version="3.2.1">r-ggplot2</requirement>
10 </expand> 9 </expand>
11 <command detect_errors="exit_code"> 10 <command detect_errors="exit_code">
12 <![CDATA[ 11 <![CDATA[
13 12
14 @INPUT_LINKING@ 13 @INPUT_LINKING@
23 22
24 ################################# load libraries and read file ######################### 23 ################################# load libraries and read file #########################
25 24
26 library(Cardinal) 25 library(Cardinal)
27 library(gridExtra) 26 library(gridExtra)
28 library(lattice)
29 library(ggplot2) 27 library(ggplot2)
30 28
31 @READING_MSIDATA_INRAM@ 29
30 @READING_MSIDATA@
31
32 msidata = as(msidata, "MSImageSet") ##coercion to MSImageSet
32 33
33 34
34 ## remove duplicated coordinates 35 ## remove duplicated coordinates
35 msidata <- msidata[,!duplicated(coord(msidata))] 36 msidata <- msidata[,!duplicated(coord(msidata))]
36 37
243 grid.table(summary_table5, rows= NULL) 244 grid.table(summary_table5, rows= NULL)
244 245
245 ### image of the best m/z 246 ### image of the best m/z
246 minimumy = min(coord(msidata)[,2]) 247 minimumy = min(coord(msidata)[,2])
247 maximumy = max(coord(msidata)[,2]) 248 maximumy = max(coord(msidata)[,2])
248 print(image(msidata, mz = topLabels(msidata.pls)[1,1], normalize.image = "linear", contrast.enhance = "histogram",ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy), smooth.image="gaussian", main="best m/z heatmap")) 249 print(image(msidata, mz = topFeatures(msidata.pls)[1,1], normalize.image = "linear", contrast.enhance = "histogram",ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy), smooth.image="gaussian", main="best m/z heatmap"))
249 250
250 ### m/z and pixel information output 251 ### m/z and pixel information output
251 pls_classes = data.frame(msidata.pls\$classes[[1]]) 252 pls_classes = data.frame(msidata.pls\$classes[[1]])
252 ## pixel names and coordinates 253 ## pixel names and coordinates
253 ## to remove potential sample names and z dimension, split at comma and take only x and y 254 ## to remove potential sample names and z dimension, split at comma and take only x and y
260 ## remove msidata to clean up RAM space 261 ## remove msidata to clean up RAM space
261 rm(msidata) 262 rm(msidata)
262 gc() 263 gc()
263 pls_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, pls_classes) 264 pls_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, pls_classes)
264 colnames(pls_classes2) = c("pixel names", "x", "y","predicted condition") 265 colnames(pls_classes2) = c("pixel names", "x", "y","predicted condition")
265 pls_toplabels = topLabels(msidata.pls, n=Inf) 266 pls_toplabels = topFeatures(msidata.pls, n=Inf)
266 pls_toplabels[,4:6] <-round(pls_toplabels[,4:6],6) 267 pls_toplabels[,4:6] <-round(pls_toplabels[,4:6],6)
267 write.table(pls_toplabels, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 268 write.table(pls_toplabels, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
268 write.table(pls_classes2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 269 write.table(pls_classes2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
269 270
270 ## image with predicted classes 271 ## image with predicted classes
409 grid.table(summary_table5, rows= NULL) 410 grid.table(summary_table5, rows= NULL)
410 411
411 ### image of the best m/z 412 ### image of the best m/z
412 minimumy = min(coord(msidata)[,2]) 413 minimumy = min(coord(msidata)[,2])
413 maximumy = max(coord(msidata)[,2]) 414 maximumy = max(coord(msidata)[,2])
414 print(image(msidata, mz = topLabels(msidata.opls)[1,1], normalize.image = "linear", contrast.enhance = "histogram",smooth.image="gaussian", ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy), main="best m/z heatmap")) 415 print(image(msidata, mz = topFeatures(msidata.opls)[1,1], normalize.image = "linear", contrast.enhance = "histogram",smooth.image="gaussian", ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy), main="best m/z heatmap"))
415 416
416 opls_classes = data.frame(msidata.opls\$classes[[1]]) 417 opls_classes = data.frame(msidata.opls\$classes[[1]])
417 ## pixel names and coordinates 418 ## pixel names and coordinates
418 ## to remove potential sample names and z dimension, split at comma and take only x and y 419 ## to remove potential sample names and z dimension, split at comma and take only x and y
419 x_coords = unlist(lapply(strsplit(names(pixels(msidata)), ","), `[[`, 1)) 420 x_coords = unlist(lapply(strsplit(names(pixels(msidata)), ","), `[[`, 1))
427 428
428 ## remove msidata to clean up RAM space 429 ## remove msidata to clean up RAM space
429 rm(msidata) 430 rm(msidata)
430 gc() 431 gc()
431 432
432 opls_toplabels = topLabels(msidata.opls, n=Inf) 433 opls_toplabels = topFeatures(msidata.opls, n=Inf)
433 opls_toplabels[,4:6] <-round(opls_toplabels[,4:6],6) 434 opls_toplabels[,4:6] <-round(opls_toplabels[,4:6],6)
434 write.table(opls_toplabels, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 435 write.table(opls_toplabels, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
435 write.table(opls_classes2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 436 write.table(opls_classes2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
436 437
437 ## image with predicted classes 438 ## image with predicted classes
575 grid.table(summary_table5, rows= NULL) 576 grid.table(summary_table5, rows= NULL)
576 577
577 ### image of the best m/z 578 ### image of the best m/z
578 minimumy = min(coord(msidata)[,2]) 579 minimumy = min(coord(msidata)[,2])
579 maximumy = max(coord(msidata)[,2]) 580 maximumy = max(coord(msidata)[,2])
580 print(image(msidata, mz = topLabels(msidata.ssc)[1,1], normalize.image = "linear", contrast.enhance = "histogram",smooth.image="gaussian", ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy), main="best m/z heatmap")) 581 print(image(msidata, mz = topFeatures(msidata.ssc)[1,1], normalize.image = "linear", contrast.enhance = "histogram",smooth.image="gaussian", ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy), main="best m/z heatmap"))
581 582
582 ## m/z and pixel information output 583 ## m/z and pixel information output
583 ssc_classes = data.frame(msidata.ssc\$classes[[1]]) 584 ssc_classes = data.frame(msidata.ssc\$classes[[1]])
584 585
585 ## pixel names and coordinates 586 ## pixel names and coordinates
595 rm(msidata) 596 rm(msidata)
596 gc() 597 gc()
597 598
598 ssc_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, ssc_classes) 599 ssc_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, ssc_classes)
599 colnames(ssc_classes2) = c("pixel names", "x", "y","predicted condition") 600 colnames(ssc_classes2) = c("pixel names", "x", "y","predicted condition")
600 ssc_toplabels = topLabels(msidata.ssc, n=Inf) 601 ssc_toplabels = topFeatures(msidata.ssc, n=Inf)
601 ssc_toplabels[,6:9] <-round(ssc_toplabels[,6:9],6) 602 ssc_toplabels[,6:9] <-round(ssc_toplabels[,6:9],6)
602 write.table(ssc_toplabels, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 603 write.table(ssc_toplabels, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
603 write.table(ssc_classes2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 604 write.table(ssc_classes2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
604 605
605 ## image with predicted classes 606 ## image with predicted classes
662 pixel_names = gsub(" = ", "y_", pixel_names) 663 pixel_names = gsub(" = ", "y_", pixel_names)
663 x_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,2] 664 x_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,2]
664 y_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,3] 665 y_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,3]
665 predicted_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, predicted_classes) 666 predicted_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, predicted_classes)
666 colnames(predicted_classes2) = c("pixel names", "x", "y","predicted condition") 667 colnames(predicted_classes2) = c("pixel names", "x", "y","predicted condition")
667 predicted_toplabels = topLabels(prediction, n=Inf) 668 predicted_toplabels = topFeatures(prediction, n=Inf)
668 if (colnames(predicted_toplabels)[4] == "coefficients"){ 669 if (colnames(predicted_toplabels)[4] == "coefficients"){
669 predicted_toplabels[,4:6] <-round(predicted_toplabels[,4:6],5) 670 predicted_toplabels[,4:6] <-round(predicted_toplabels[,4:6],5)
670 671
671 }else{ 672 }else{
672 predicted_toplabels[,6:9] <-round(predicted_toplabels[,6:9],5)} 673 predicted_toplabels[,6:9] <-round(predicted_toplabels[,6:9],5)}
998 </conditional> 999 </conditional>
999 <param name="output_rdata" value="True"/> 1000 <param name="output_rdata" value="True"/>
1000 <output name="mzfeatures" file="features_test6.tabular"/> 1001 <output name="mzfeatures" file="features_test6.tabular"/>
1001 <output name="pixeloutput" file="pixels_test6.tabular"/> 1002 <output name="pixeloutput" file="pixels_test6.tabular"/>
1002 <output name="classification_images" file="test6.pdf" compare="sim_size"/> 1003 <output name="classification_images" file="test6.pdf" compare="sim_size"/>
1003 <output name="classification_rdata" file="test6.rdata" compare="sim_size" /> 1004 <output name="classification_rdata" file="test6.rdata" compare="sim_size" delta="15000"/>
1004 </test> 1005 </test>
1005 1006
1006 <test expect_num_outputs="4"> 1007 <test expect_num_outputs="4">
1007 <param name="infile" value="testfile_squares.rdata" ftype="rdata"/> 1008 <param name="infile" value="testfile_squares.rdata" ftype="rdata"/>
1008 <conditional name="type_cond"> 1009 <conditional name="type_cond">
1088 1089
1089 ]]> 1090 ]]>
1090 </help> 1091 </help>
1091 <expand macro="citations"/> 1092 <expand macro="citations"/>
1092 </tool> 1093 </tool>
1094