Skip to content

Commit

Permalink
add non-parametric tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nilchia committed Jan 11, 2025
1 parent 08d140f commit e0900ec
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tools/spacexr/macros.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<macros>
<token name="@TOOL_VERSION@">2.2.1=r43hdfd78af_0</token>
<token name="@TOOL_VERSION@">2.2.1</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@PROFILE@">23.0</token>
<xml name="requirements">
Expand Down
68 changes: 59 additions & 9 deletions tools/spacexr/spacexr_cside.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
<import>macros.xml</import>
</macros>
<expand macro="edam"/>
<expand macro="requirements"/>
<expand macro="requirements">
<requirement type="package" version="3.5.1">r-ggplot2</requirement>
</expand>
<command detect_errors="exit_code"><![CDATA[
mkdir -p 'inputs' 'results' 'logs' 'figures' &&
ln -s '$rctd' 'inputs/rctd.rds' &&
touch 'results/cside_script.R' &&
cat '$cside_script' > 'results/cside_script.R' &&
Rscript '$cside_script'
#if 'plots' in $output_selector:
mv 'results/de_plots/*.pdf' 'results/de_plots_quant/*.pdf' 'results/de_plots_two_regions/*.pdf' 'figures'
#end if
]]></command>
<configfiles>
<configfile name="cside_script"><![CDATA[
Expand Down Expand Up @@ -127,6 +126,7 @@ for (cell_type in cell_types) {
# create plots
#if 'plots' in $output_selector:
library('ggplot2')
make_all_de_plots(myRCTD, "figures")
#end if
# save rds file
Expand Down Expand Up @@ -186,7 +186,15 @@ saveRDS(myRCTD, file = 'results/cside_results.rds')
<discover_datasets pattern="(?P&lt;name&gt;.+)\.tabular$" format="tabular" directory="results"/>
</collection>
<collection name="de_plots" type="list" label="${tool.name} on ${on_string}: DE plots">
<discover_datasets pattern="(?P&lt;name&gt;.+)\.pdf$" format="pdf" directory="figures"/>
<discover_datasets pattern="(?P&lt;name&gt;.+)\.pdf$" format="pdf" directory="figures/de_plots"/>
<filter>output['output_selector'] and 'plots' in output['output_selector']</filter>
</collection>
<collection name="de_plots_quant" type="list" label="${tool.name} on ${on_string}: DE plots (quant)">
<discover_datasets pattern="(?P&lt;name&gt;.+)\.pdf$" format="pdf" directory="figures/de_plots_quant"/>
<filter>output['output_selector'] and 'plots' in output['output_selector']</filter>
</collection>
<collection name="de_plots_two_regions" type="list" label="${tool.name} on ${on_string}: DE plots (two regions)">
<discover_datasets pattern="(?P&lt;name&gt;.+)\.pdf$" format="pdf" directory="figures/de_plots_two_regions"/>
<filter>output['output_selector'] and 'plots' in output['output_selector']</filter>
</collection>
<data name="out_rds" format="rds" from_work_dir="results/cside_results.rds" label="${tool.name} on ${on_string}: RDS file">
Expand All @@ -197,6 +205,7 @@ saveRDS(myRCTD, file = 'results/cside_results.rds')
</data>
</outputs>
<tests>
<!-- test non_parametric -->
<test expect_num_outputs="2">
<param name="rctd" value="myRCTD_merfish.rds"/>
<param name="de_type" value="non_parametric"/>
Expand All @@ -206,17 +215,58 @@ saveRDS(myRCTD, file = 'results/cside_results.rds')
<param name="fdr" value="0.25"/>
<param name="output_selector" value="rscript" />
<output_collection name="de_results" type="list">
<element name="type8" ftype="tabular">
<element name="Astrocytes" ftype="tabular">
<assert_contents>
<has_text_matching expression="Z_score.*log_fc.*se.*paramindex_best.*conv.*p_val"/>
<has_text_matching expression="Gad1.*3.83906924067553.*-3.69433997573756.*0.962300949562319.*6.*TRUE.*0.00172902241856182"/>
</assert_contents>
</element>
<element name="Astrocytes_sig" ftype="tabular">
<assert_contents>
<has_text_matching expression="Z_score.*log_fc.*se.*paramindex_best.*conv.*p_val"/>
<has_text_matching expression="Glra3.*3.92715715940966.*-7.29911426576817.*1.85862545589222.*8.*TRUE.*0.00120338145955865"/>
</assert_contents>
</element>
</output_collection>
<output name="out_rscript">
<assert_contents>
<has_text_matching expression="run.CSIDE.nonparam"/>
</assert_contents>
</output>
</test>
<!-- test fig and rds -->
<test expect_num_outputs="6">
<param name="rctd" value="myRCTD_merfish.rds"/>
<param name="de_type" value="non_parametric"/>
<param name="cell_types" value="Astrocytes"/>
<param name="cell_type_threshold" value="10"/>
<param name="gene_threshold" value="0.001"/>
<param name="fdr" value="0.25"/>
<param name="output_selector" value="rds,rscript,plots" />
<output_collection name="de_results" type="list">
<element name="Astrocytes" ftype="tabular">
<assert_contents>
<has_text_matching expression="Hello"/>
<has_text_matching expression="Z_score.*log_fc.*se.*paramindex_best.*conv.*p_val"/>
<has_text_matching expression="Gad1.*3.83906924067553.*-3.69433997573756.*0.962300949562319.*6.*TRUE.*0.00172902241856182"/>
</assert_contents>
</element>
<element name="type8_sig" ftype="tabular">
<element name="Astrocytes_sig" ftype="tabular">
<assert_contents>
<has_text_matching expression="Hello"/>
<has_text_matching expression="Z_score.*log_fc.*se.*paramindex_best.*conv.*p_val"/>
<has_text_matching expression="Glra3.*3.92715715940966.*-7.29911426576817.*1.85862545589222.*8.*TRUE.*0.00120338145955865"/>
</assert_contents>
</element>
</output_collection>
<output_collection name="de_plots" type="list">
<element name="de_genes_Astrocytes" file="de_genes_Astrocytes.pdf" ftype="pdf" compare="sim_size"/>
</output_collection>
<output_collection name="de_plots_quant" type="list">
<element name="de_genes_Astrocytes" file="de_genes_Astrocytes_quant.pdf" ftype="pdf" compare="sim_size"/>
</output_collection>
<output_collection name="de_plots_two_regions" type="list">
<element name="de_genes_Astrocytes" file="de_genes_Astrocytes_two_regions" ftype="pdf" compare="sim_size"/>
</output_collection>
<output name="out_rds" file="cside.rds" ftype="rds" compare="sim_size"/>
<output name="out_rscript">
<assert_contents>
<has_text_matching expression="run.CSIDE.nonparam"/>
Expand Down
Binary file added tools/spacexr/test-data/cside.rds
Binary file not shown.
Binary file added tools/spacexr/test-data/de_genes_Astrocytes.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit e0900ec

Please sign in to comment.