Skip to content

Commit

Permalink
Merge pull request #763 from MarenStillger/Update_test
Browse files Browse the repository at this point in the history
Update Cardinal Version 3.4.3
  • Loading branch information
bgruening authored Jul 4, 2024
2 parents 17fc7ee + 523c7c8 commit 91e77c1
Show file tree
Hide file tree
Showing 104 changed files with 18,418 additions and 44,853 deletions.
1,006 changes: 632 additions & 374 deletions tools/cardinal/classification.xml

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions tools/cardinal/colocalization.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<tool id="cardinal_colocalization" name="MSI colocalization" version="@[email protected]">
<tool id="cardinal_colocalization" name="MSI colocalization" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05">
<description>mass spectrometry imaging colocalization</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="requirements">
<requirement type="package" version="2.3">r-gridextra</requirement>
</expand>
<expand macro="requirements"/>
<command detect_errors="exit_code">
<![CDATA[
Expand Down
31 changes: 10 additions & 21 deletions tools/cardinal/combine.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
<tool id="cardinal_combine" name="MSI combine" version="@[email protected]">
<tool id="cardinal_combine" name="MSI combine" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05">
<description>
combine several mass spectrometry imaging datasets into one
</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="requirements">
<requirement type="package" version="3.3.5">r-ggplot2</requirement>
<requirement type="package" version="0.12">r-maldiquantforeign</requirement>
<requirement type="package" version="1.20">r-maldiquant</requirement>
</expand>
<expand macro="requirements"/>
<command detect_errors="exit_code">
<![CDATA[
#for $i, $infile in enumerate($infiles):
#if $infile.ext == 'imzml'
ln -s '${infile.extra_files_path}/imzml' infile_${i}.imzML &&
ln -s '${infile.extra_files_path}/ibd' infile_${i}.ibd &&
cp '${infile.extra_files_path}/imzml' infile_${i}.imzML &&
cp '${infile.extra_files_path}/ibd' infile_${i}.ibd &&
#elif $infile.ext == 'analyze75'
ln -s '${infile.extra_files_path}/hdr' infile_${i}.hdr &&
ln -s '${infile.extra_files_path}/img' infile_${i}.img &&
ln -s '${infile.extra_files_path}/t2m' infile_${i}.t2m &&
cp '${infile.extra_files_path}/hdr' infile_${i}.hdr &&
cp '${infile.extra_files_path}/img' infile_${i}.img &&
cp '${infile.extra_files_path}/t2m' infile_${i}.t2m &&
#else
ln -s '$infile' infile_${i}.RData &&
#end if
Expand Down Expand Up @@ -103,14 +99,8 @@ all_files = $num_infiles
get(ls()[ls() != "fileName"])
}
msidata_$i = loadRData('infile_${i}.RData')
## keep compatibility with old .RData files:
msidata_$i\$column1 = NULL
msidata_$i\$column2 = NULL
msidata_$i\$column3 = NULL
msidata_$i\$column4 = NULL
msidata_$i\$column5 = NULL
msidata_$i\$combined_sample = NULL
msidata_$i <- as(msidata_$i, "MSImagingExperiment")
#end if
## remove duplicated coordinates, otherwise combine will fail
Expand All @@ -128,7 +118,6 @@ all_files = $num_infiles
############ 3) Read and process annotation tabular files ######################
#if str($annotation_cond.annotation_tabular) == 'annotation'
print("annotations")
## read annotation tabular, set first two columns as x and y, merge with coordinates dataframe and order according to pixelorder in msidata
input_annotation = read.delim("annotation_file_${i}.tabular", header = $annotation_cond.tabular_header, stringsAsFactors = FALSE)
Expand All @@ -138,7 +127,7 @@ all_files = $num_infiles
colnames(msidata_coordinates)[3] = "pixel_index"
annotation_df = merge(msidata_coordinates, input_annotation, by=c("x", "y"), all.x=TRUE)
annotation_df_sorted = annotation_df[order(annotation_df\$pixel_index),]## orders pixel according to msidata
annotation_df_sorted = annotation_df[order(annotation_df\$pixel_index),]
annotation_df_sorted\$pixel_index = NULL
## extract columnnames from (last) annotation tabular (for QC plot names)
Expand Down Expand Up @@ -171,7 +160,7 @@ all_files = $num_infiles
#elif str( $combine_conditional.combine_method ) == 'automatic_combine':
## use name of Galaxy inputfile as sample annotation
## use name of Galaxy input file as sample annotation
sample_name = character()
#set escaped_element_identifier = re.sub('[^\w\-\s\[/]]', '_', str($infile.element_identifier))
Expand Down
20 changes: 12 additions & 8 deletions tools/cardinal/data_exporter.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="cardinal_data_exporter" name="MSI data exporter" version="@[email protected]">
<tool id="cardinal_data_exporter" name="MSI data exporter" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05">
<description>
exports imzML and Analyze7.5 to tabular files
</description>
Expand Down Expand Up @@ -102,7 +102,7 @@ if (class(msidata) == "MSImageSet"){
count = 1
for (subsample in levels(msidata\$annotation)){
subsample_pixels = msidata[,msidata\$annotation == subsample]
subsample_calc = rowMeans(spectra(subsample_pixels), na.rm=TRUE)
subsample_calc = rowMeans(as.matrix(spectra(subsample_pixels)), na.rm=TRUE)
sample_matrix = cbind(sample_matrix, subsample_calc)
count = count+1}
sample_matrix_mean = cbind(mz_names,sample_matrix)
Expand All @@ -117,7 +117,7 @@ if (class(msidata) == "MSImageSet"){
count = 1
for (subsample in levels(msidata\$annotation)){
subsample_pixels = msidata[,msidata\$annotation == subsample]
subsample_calc = apply(spectra(subsample_pixels),1,median, na.rm=TRUE)
subsample_calc = apply(as.matrix(spectra(subsample_pixels)),1,median, na.rm=TRUE)
sample_matrix = cbind(sample_matrix, subsample_calc)
count = count+1}
sample_matrix_median = cbind(mz_names,sample_matrix)
Expand Down Expand Up @@ -190,13 +190,13 @@ if (class(msidata) == "MSImageSet"){
for (mass in 1:length(inputcalibrantmasses)){
filtered_data = msidata[mz(msidata) >= inputcalibrantmasses[mass]-plusminusvalues[mass] & mz(msidata) <= inputcalibrantmasses[mass]+plusminusvalues[mass],]
if (nrow(filtered_data) > 1 & sum(spectra(filtered_data),na.rm=TRUE) > 0){
if (nrow(filtered_data) > 1 & sum(as.matrix(spectra(filtered_data)), na.rm=TRUE) > 0){
## intensity of all m/z > 0
intensity_sum = colSums(spectra(filtered_data), na.rm=TRUE) > 0
intensity_sum = colSums(as.matrix(spectra(filtered_data)), na.rm=TRUE) > 0
}else if(nrow(filtered_data) == 1 & sum(spectra(filtered_data), na.rm=TRUE) > 0){
}else if(nrow(filtered_data) == 1 & sum(as.matrix(spectra(filtered_data)), na.rm=TRUE) > 0){
## intensity of only m/z > 0
intensity_sum = spectra(filtered_data) > 0
intensity_sum = as.matrix(spectra(filtered_data)) > 0
}else{
intensity_sum = rep(FALSE, ncol(filtered_data))}
## for each pixel add sum of intensities > 0 in the given m/z range
Expand Down Expand Up @@ -343,7 +343,11 @@ if (class(msidata) == "MSImageSet"){
<param name="feature_header" value="False"/>
<param name="plusminus_ppm" value="200"/>
</conditional>
<output name="feature_output" file="features_out4.tabular"/>
<output name="feature_output">
<assert_contents>
<has_text text="100.120072029209"/>
</assert_contents>
</output>
<output name="pixel_output" file="pixel_out4.tabular"/>
</test>
</tests>
Expand Down
7 changes: 2 additions & 5 deletions tools/cardinal/filtering.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<tool id="cardinal_filtering" name="MSI filtering" version="@[email protected]">
<tool id="cardinal_filtering" name="MSI filtering" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05">
<description>tool for filtering mass spectrometry imaging data</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="requirements">
<requirement type="package" version="2.3">r-gridextra</requirement>
<requirement type="package" version="3.3.5">r-ggplot2</requirement>
</expand>
<expand macro="requirements"/>
<expand macro="print_version"/>
<command detect_errors="exit_code">
<![CDATA[
Expand Down
36 changes: 23 additions & 13 deletions tools/cardinal/macros.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
<macros>
<token name="@VERSION@">2.10.0</token>
<token name="@TOOL_VERSION@">3.4.3</token>
<token name="@VERSION_SUFFIX@">0</token>

<xml name="requirements">
<requirements>
<requirement type="package" version="@VERSION@">bioconductor-cardinal</requirement>
<!--requirement type="package" version="3.6.1">r-base</requirement-->
<requirement type="package" version="@TOOL_VERSION@">bioconductor-cardinal</requirement>
<requirement type="package" version="2.3">r-gridextra</requirement>
<requirement type="package" version="3.5.1">r-ggplot2</requirement>
<requirement type="package" version="0.14.1">r-maldiquantforeign</requirement>
<requirement type="package" version="1.22.2">r-maldiquant</requirement>
<requirement type="package" version="3.50.0">bioconductor-sva</requirement>
<requirement type="package" version="1.1.0.1">r-randomcolor</requirement>
<requirement type="package" version="1.1_3">r-rcolorbrewer</requirement>
<requirement type="package" version="2.23_24">r-kernsmooth</requirement>
<requirement type="package" version="1.3.0">r-scales</requirement>
<requirement type="package" version="1.0.12">r-pheatmap</requirement>
<yield/>
</requirements>
</xml>
Expand All @@ -17,12 +27,12 @@ echo $(R --version | grep version | grep -v GNU)", Cardinal version" $(R --vanil

<token name="@INPUT_LINKING@"><![CDATA[
#if $infile.ext == 'imzml'
ln -s '${infile.extra_files_path}/imzml' infile.imzML &&
ln -s '${infile.extra_files_path}/ibd' infile.ibd &&
cp '${infile.extra_files_path}/imzml' infile.imzML &&
cp '${infile.extra_files_path}/ibd' infile.ibd &&
#elif $infile.ext == 'analyze75'
ln -s '${infile.extra_files_path}/hdr' infile.hdr &&
ln -s '${infile.extra_files_path}/img' infile.img &&
ln -s '${infile.extra_files_path}/t2m' infile.t2m &&
cp '${infile.extra_files_path}/hdr' infile.hdr &&
cp '${infile.extra_files_path}/img' infile.img &&
cp '${infile.extra_files_path}/t2m' infile.t2m &&
#else
ln -s $infile infile.RData &&
#end if
Expand All @@ -38,13 +48,13 @@ echo $(R --version | grep version | grep -v GNU)", Cardinal version" $(R --vanil
get(ls()[ls() != "fileName"])
}
#if $infile.ext == 'imzml'
#if str($processed_cond.processed_file) == "processed":
msidata <- readImzML('infile', resolution=$processed_cond.accuracy, attach.only=TRUE, units = "$processed_cond.units")
msidata = collect(msidata, as.matrix=TRUE) ##coercion to continuous
centroided(msidata) = $centroids
#else
msidata <- readImzML('infile', attach.only=TRUE)
msidata <- readImzML('infile')
centroided(msidata) = $centroids
#end if
#elif $infile.ext == 'analyze75'
Expand Down Expand Up @@ -95,7 +105,7 @@ echo $(R --version | grep version | grep -v GNU)", Cardinal version" $(R --vanil
msidata <- readImzML('infile', resolution=$processed_cond.accuracy, units = "$processed_cond.units", attach.only=TRUE)
centroided(msidata) = $centroids
#else
msidata <- readImzML('infile', attach.only=TRUE)
msidata <- readImzML('infile')
centroided(msidata) = $centroids
#end if
#elif $infile.ext == 'analyze75'
Expand All @@ -117,13 +127,13 @@ echo $(R --version | grep version | grep -v GNU)", Cardinal version" $(R --vanil
<token name="@DATA_PROPERTIES_INRAM@"><![CDATA[
########################### QC numbers ########################
## including intensity calculations which need data in RAM
int_matrix = as.matrix(spectra(msidata)) ## only load once into RAM, then re-use
## Number of NA in spectra matrix
NAcount = sum(is.na(int_matrix))
## replace NA with zero to calculate data properties based on intensity matrix, no change in msidata
int_matrix[is.na(int_matrix)] <- 0
## Number of features (mz)
maxfeatures = length(features(msidata))
## Range mz
Expand Down
22 changes: 10 additions & 12 deletions tools/cardinal/mz_images.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<tool id="cardinal_mz_images" name="MSI mz images" version="@[email protected]">
<tool id="cardinal_mz_images" name="MSI mz images" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05">
<description>
mass spectrometry imaging m/z heatmaps
</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="requirements">
<requirement type="package" version="2.3">r-gridextra</requirement>
</expand>
<expand macro="requirements"/>
<command detect_errors="aggressive">
<![CDATA[
@INPUT_LINKING@
Expand Down Expand Up @@ -83,8 +81,8 @@ if (ncol(msidata)>0 & nrow(msidata) >0){
print("svg pixel image")
## reverse y axis for svg output = correct order and nice svg image
coord(msidata)\$y <- max(coord(msidata)\$y) - coord(msidata)\$y + 1
## works only with MSImageSet as expected
msidata = as(msidata, "MSImageSet")
msidata = as(msidata,"MSImagingExperiment")
svg(file="svg_pixel_output.svg", width=maximumx, height=maximumy)
par(mar=c(0,0,0,0), oma=c(0,0,0,0))## no margin for svg
Expand Down Expand Up @@ -132,7 +130,7 @@ dev.off()
<expand macro="pdf_filename"/>
<expand macro="reading_2_column_mz_tabular"/>

<param name="plusminus_dalton" value="0.25" type="float" label="plusminus m/" help="m/z range to add on either side of the given m/z to create a window in which the mean of all intensities will be computed"/>
<param name="plusminus_dalton" value="0.25" type="float" label="plusminus m/z" help="m/z range to add on either side of the given m/z to create a window in which the mean of all intensities will be computed"/>
<param name="image_contrast" type="select" label="Contrast enhancement" help="The 'histogram' equalization method flatterns the distribution of intensities. The hotspot 'suppression' method uses thresholding to reduce the intensities of hotspots">
<option value="none" selected="True">none</option>
<option value="suppression">suppression</option>
Expand Down Expand Up @@ -193,7 +191,7 @@ dev.off()
</data>
</outputs>
<tests>
<test>
<test expect_num_outputs="1">
<expand macro="infile_imzml"/>
<param name="calibrant_file" value="inputpeptides.tabular" ftype="tabular"/>
<param name="mz_column" value="1"/>
Expand All @@ -204,7 +202,7 @@ dev.off()
<param name="colorkey" value="True"/>
<output name="plots" file="Heatmaps_imzml.pdf" ftype="pdf" compare="sim_size"/>
</test>
<test>
<test expect_num_outputs="2">
<expand macro="infile_analyze75"/>
<param name="calibrant_file" value="inputpeptides2.tabular" ftype="tabular"/>
<param name="mz_column" value="1"/>
Expand All @@ -218,7 +216,7 @@ dev.off()
<output name="plots" file="Heatmaps_analyze75.pdf" ftype="pdf" compare="sim_size"/>
<output name="svg_output" file="analyze75.svg" ftype="svg" compare="sim_size"/>
</test>
<test>
<test expect_num_outputs="1">
<param name="infile" value="preprocessed.RData" ftype="rdata"/>
<param name="calibrant_file" value="inputpeptides.tabular" ftype="tabular"/>
<param name="mz_column" value="1"/>
Expand All @@ -228,7 +226,7 @@ dev.off()
<param name="filename" value="Testfile_rdata"/>
<output name="plots" file="Heatmaps_rdata.pdf" ftype="pdf" compare="sim_size"/>
</test>
<test>
<test expect_num_outputs="1">
<param name="infile" value="empty_spectra.rdata" ftype="rdata"/>
<param name="calibrant_file" value="inputpeptides2.tabular" ftype="tabular"/>
<param name="mz_column" value="1"/>
Expand All @@ -239,7 +237,7 @@ dev.off()
<param name="filename" value="Testfile_rdata"/>
<output name="plots" file="Heatmaps_LM8_file16.pdf" ftype="pdf" compare="sim_size"/>
</test>
<test>
<test expect_num_outputs="1">
<expand macro="processed_infile_imzml"/>
<conditional name="processed_cond">
<param name="processed_file" value="processed"/>
Expand Down
Loading

0 comments on commit 91e77c1

Please sign in to comment.