comparison combine.xml @ 20:a9a28e46d54a draft default tip

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 91e77c139cb3b7c6d67727dc39140dd79355fa0c
author galaxyp
date Thu, 04 Jul 2024 13:47:49 +0000
parents aad328eb6c0f
children
comparison
equal deleted inserted replaced
19:bf06d196e23d 20:a9a28e46d54a
1 <tool id="cardinal_combine" name="MSI combine" version="@VERSION@.0"> 1 <tool id="cardinal_combine" name="MSI combine" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05">
2 <description> 2 <description>
3 combine several mass spectrometry imaging datasets into one 3 combine several mass spectrometry imaging datasets into one
4 </description> 4 </description>
5 <macros> 5 <macros>
6 <import>macros.xml</import> 6 <import>macros.xml</import>
7 </macros> 7 </macros>
8 <expand macro="requirements"> 8 <expand macro="requirements"/>
9 <requirement type="package" version="3.3.5">r-ggplot2</requirement>
10 <requirement type="package" version="0.12">r-maldiquantforeign</requirement>
11 <requirement type="package" version="1.20">r-maldiquant</requirement>
12 </expand>
13 <command detect_errors="exit_code"> 9 <command detect_errors="exit_code">
14 <![CDATA[ 10 <![CDATA[
15 #for $i, $infile in enumerate($infiles): 11 #for $i, $infile in enumerate($infiles):
16 #if $infile.ext == 'imzml' 12 #if $infile.ext == 'imzml'
17 ln -s '${infile.extra_files_path}/imzml' infile_${i}.imzML && 13 cp '${infile.extra_files_path}/imzml' infile_${i}.imzML &&
18 ln -s '${infile.extra_files_path}/ibd' infile_${i}.ibd && 14 cp '${infile.extra_files_path}/ibd' infile_${i}.ibd &&
19 #elif $infile.ext == 'analyze75' 15 #elif $infile.ext == 'analyze75'
20 ln -s '${infile.extra_files_path}/hdr' infile_${i}.hdr && 16 cp '${infile.extra_files_path}/hdr' infile_${i}.hdr &&
21 ln -s '${infile.extra_files_path}/img' infile_${i}.img && 17 cp '${infile.extra_files_path}/img' infile_${i}.img &&
22 ln -s '${infile.extra_files_path}/t2m' infile_${i}.t2m && 18 cp '${infile.extra_files_path}/t2m' infile_${i}.t2m &&
23 #else 19 #else
24 ln -s '$infile' infile_${i}.RData && 20 ln -s '$infile' infile_${i}.RData &&
25 #end if 21 #end if
26 #end for 22 #end for
27 #if $annotation_cond.annotation_tabular == 'annotation' 23 #if $annotation_cond.annotation_tabular == 'annotation'
101 loadRData <- function(fileName){ 97 loadRData <- function(fileName){
102 load(fileName) 98 load(fileName)
103 get(ls()[ls() != "fileName"]) 99 get(ls()[ls() != "fileName"])
104 } 100 }
105 msidata_$i = loadRData('infile_${i}.RData') 101 msidata_$i = loadRData('infile_${i}.RData')
106 ## keep compatibility with old .RData files:
107 msidata_$i\$column1 = NULL
108 msidata_$i\$column2 = NULL
109 msidata_$i\$column3 = NULL
110 msidata_$i\$column4 = NULL
111 msidata_$i\$column5 = NULL
112 msidata_$i\$combined_sample = NULL
113 msidata_$i <- as(msidata_$i, "MSImagingExperiment") 102 msidata_$i <- as(msidata_$i, "MSImagingExperiment")
103
114 #end if 104 #end if
115 105
116 ## remove duplicated coordinates, otherwise combine will fail 106 ## remove duplicated coordinates, otherwise combine will fail
117 print(paste0(sum(duplicated(coord(msidata_$i))), " duplicated coordinates were removed from input file")) 107 print(paste0(sum(duplicated(coord(msidata_$i))), " duplicated coordinates were removed from input file"))
118 msidata_${i} <- msidata_${i}[,!duplicated(coord(msidata_${i}))] 108 msidata_${i} <- msidata_${i}[,!duplicated(coord(msidata_${i}))]
126 pData(msidata_${i})\$'3DPositionY' <- NULL 116 pData(msidata_${i})\$'3DPositionY' <- NULL
127 117
128 ############ 3) Read and process annotation tabular files ###################### 118 ############ 3) Read and process annotation tabular files ######################
129 119
130 #if str($annotation_cond.annotation_tabular) == 'annotation' 120 #if str($annotation_cond.annotation_tabular) == 'annotation'
131 print("annotations")
132 121
133 ## read annotation tabular, set first two columns as x and y, merge with coordinates dataframe and order according to pixelorder in msidata 122 ## read annotation tabular, set first two columns as x and y, merge with coordinates dataframe and order according to pixelorder in msidata
134 input_annotation = read.delim("annotation_file_${i}.tabular", header = $annotation_cond.tabular_header, stringsAsFactors = FALSE) 123 input_annotation = read.delim("annotation_file_${i}.tabular", header = $annotation_cond.tabular_header, stringsAsFactors = FALSE)
135 colnames(input_annotation)[1:2] = c("x", "y") 124 colnames(input_annotation)[1:2] = c("x", "y")
136 125
137 msidata_coordinates = cbind(coord(msidata_$i)[,1:2], 1:ncol(msidata_$i)) 126 msidata_coordinates = cbind(coord(msidata_$i)[,1:2], 1:ncol(msidata_$i))
138 colnames(msidata_coordinates)[3] = "pixel_index" 127 colnames(msidata_coordinates)[3] = "pixel_index"
139 128
140 annotation_df = merge(msidata_coordinates, input_annotation, by=c("x", "y"), all.x=TRUE) 129 annotation_df = merge(msidata_coordinates, input_annotation, by=c("x", "y"), all.x=TRUE)
141 annotation_df_sorted = annotation_df[order(annotation_df\$pixel_index),]## orders pixel according to msidata 130 annotation_df_sorted = annotation_df[order(annotation_df\$pixel_index),]
142 annotation_df_sorted\$pixel_index = NULL 131 annotation_df_sorted\$pixel_index = NULL
143 132
144 ## extract columnnames from (last) annotation tabular (for QC plot names) 133 ## extract columnnames from (last) annotation tabular (for QC plot names)
145 annotation_colnames = colnames(input_annotation) 134 annotation_colnames = colnames(input_annotation)
146 135
169 158
170 ##################### 5) shift coordinates automatically ####################### 159 ##################### 5) shift coordinates automatically #######################
171 160
172 #elif str( $combine_conditional.combine_method ) == 'automatic_combine': 161 #elif str( $combine_conditional.combine_method ) == 'automatic_combine':
173 162
174 ## use name of Galaxy inputfile as sample annotation 163 ## use name of Galaxy input file as sample annotation
175 sample_name = character() 164 sample_name = character()
176 #set escaped_element_identifier = re.sub('[^\w\-\s\[/]]', '_', str($infile.element_identifier)) 165 #set escaped_element_identifier = re.sub('[^\w\-\s\[/]]', '_', str($infile.element_identifier))
177 166
178 if (ncol(msidata_$i)>0 & nrow(msidata_$i) >0) 167 if (ncol(msidata_$i)>0 & nrow(msidata_$i) >0)
179 { 168 {