Skip to content

Commit

Permalink
Update snapatac2 to 2.6.4 (galaxyproject#6157)
Browse files Browse the repository at this point in the history
* Update snapatac2 to 2.6.4

* add min_len parameter and fix test

* add tests back
  • Loading branch information
pavanvidem authored Jul 17, 2024
1 parent bfc4ff4 commit b37248e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 32 deletions.
24 changes: 12 additions & 12 deletions tools/snapatac2/macros.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<macros>
<token name="@TOOL_VERSION@">2.5.3</token>
<token name="@VERSION_SUFFIX@">2</token>
<token name="@TOOL_VERSION@">2.6.4</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@PROFILE@">23.0</token>
<xml name="requirements">
<requirement type="package" version="@TOOL_VERSION@">snapatac2</requirement>
<requirement type="package" version="5.18.0">plotly</requirement>
<requirement type="package" version="5.22.0">plotly</requirement>
<requirement type="package" version="0.2.1">python-kaleido</requirement>
<requirement type="package" version="0.19.19">polars</requirement>
<requirement type="package" version="14.0.1">pyarrow</requirement>
<requirement type="package" version="0.11.3">python-igraph</requirement>
<requirement type="package" version="0.8.33">hdbscan</requirement>
<requirement type="package" version="0.0.9">harmonypy</requirement>
<requirement type="package" version="1.1.0">polars</requirement>
<requirement type="package" version="16.1.0">pyarrow</requirement>
<requirement type="package" version="0.11.6">python-igraph</requirement>
<requirement type="package" version="0.8.37">hdbscan</requirement>
<requirement type="package" version="0.0.10">harmonypy</requirement>
<requirement type="package" version="1.7.4">scanorama</requirement>
<requirement type="package" version="3.0.1">macs3</requirement>
<requirement type="package" version="0.70.16">multiprocess</requirement>
Expand Down Expand Up @@ -158,10 +158,10 @@ with open('anndata_info.txt','w', encoding='utf-8') as ainfo:
<has_text_matching expression="height = 450"/>
</xml>
<xml name="param_counting_strategy">
<param argument="counting_strategy" type="select" label="he strategy to compute feature counts">
<option value="fragment">fragment</option>
<option value="insertion" selected="true">insertion</option>
<option value="paired-insertion">paired-insertion</option>
<param argument="counting_strategy" type="select" label="The strategy to compute feature counts">
<option value="fragment">"fragment": based on the number of fragments that overlap with a region of interest</option>
<option value="insertion" selected="true">"insertion": based on the number of insertions that overlap with a region of interest</option>
<option value="paired-insertion">"paired-insertion": similar to "insertion", but it only counts the insertions once if the pair of insertions of a fragment are both within the same region of interest</option>
</param>
</xml>

Expand Down
22 changes: 14 additions & 8 deletions tools/snapatac2/peaks_and_motif_analysis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ if __name__ == '__main__': ## a temporary fix https://github.com/kaizhang/SnapAT
nolambda = $method.nolambda,
shift = $method.shift,
extsize = $method.extsize,
#if $method.min_len
min_len = $method.min_len,
#end if
#if $method.blacklist
blacklist = '$method.blacklist',
#end if
Expand All @@ -62,7 +65,7 @@ peaks.write_csv('merged_peaks.tabular', separator = '\t')
#else if $method.method == 'pp.make_peak_matrix'
import polars
peaks = polars.read_csv('$method.merged_peaks', separator='\t')
sa.pp.make_peak_matrix(
adata = sa.pp.make_peak_matrix(
adata,
use_rep = peaks['Peaks'],
chunk_size = $method.chunk_size,
Expand All @@ -73,8 +76,7 @@ sa.pp.make_peak_matrix(
#if $method.max_frag_size
max_frag_size = $method.max_frag_size,
#end if
##counting_strategy = '$method.counting_strategy'
count_frag_as_reads = $method.count_frag_as_reads
counting_strategy = '$method.counting_strategy'
)
#else if $method.method == 'tl.marker_regions'
Expand Down Expand Up @@ -150,7 +152,9 @@ sa.pl.regions(
)
#end if
#if $method.method != 'pp.make_peak_matrix'
@CMD_anndata_write_outputs@
#end if
]]></configfile>
</configfiles>
<inputs>
Expand All @@ -173,6 +177,7 @@ sa.pl.regions(
<param argument="nolambda" type="boolean" checked="false" truevalue="True" falsevalue="False" label="If True, macs3 will use the background lambda as local lambda"/>
<param argument="shift" type="integer" value="-100" label="The shift size in MACS"/>
<param argument="extsize" type="integer" value="200" label="The extension size in MACS"/>
<param argument="min_len" type="integer" optional="true" value="" label="The minimum length of a called peak" help="If not set, it is set to the extension size."/>
<param argument="blacklist" type="data" format="bed" optional="true" label="Blacklist file in BED format"
help="If provided, regions in the blacklist will be removed."/>
<param argument="key_added" type="text" value="macs3" label="`.uns` key under which to add peak information"/>
Expand All @@ -192,8 +197,7 @@ sa.pl.regions(
<expand macro="param_chunk_size" size="500"/>
<param argument="use_x" type="boolean" truevalue="True" falsevalue="False" checked="false" label="If True, use the matrix stored in .X as raw counts"/>
<expand macro="min_max_frag_size"/>
<!--expand macro="param_counting_strategy"/-->
<param argument="count_frag_as_reads" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Whether to count fragments as reads"/>
<expand macro="param_counting_strategy"/>
</when>
<when value="tl.marker_regions">
<expand macro="inputs_anndata"/>
Expand Down Expand Up @@ -264,6 +268,7 @@ sa.pl.regions(
<param name="qvalue" value="0.1"/>
<param name="shift" value="-100"/>
<param name="extsize" value="200"/>
<param name="min_len" value="50"/>
<param name="key_added" value="macs3"/>
</conditional>
<section name="advanced_common">
Expand All @@ -276,6 +281,7 @@ sa.pl.regions(
<has_text_matching expression="qvalue = 0.1"/>
<has_text_matching expression="shift = -100"/>
<has_text_matching expression="extsize = 200"/>
<has_text_matching expression="min_len = 50"/>
<has_text_matching expression="key_added = 'macs3'"/>
</assert_contents>
</output>
Expand Down Expand Up @@ -317,7 +323,7 @@ sa.pl.regions(
<param name="merged_peaks" location="https://zenodo.org/records/11260316/files/merged_peaks.tabular"/>
<param name="chunk_size" value="500"/>
<param name="use_x" value="False"/>
<param name="count_frag_as_reads" value="True"/>
<param name="counting_strategy" value="insertion"/>
</conditional>
<section name="advanced_common">
<param name="show_log" value="true" />
Expand All @@ -327,10 +333,10 @@ sa.pl.regions(
<has_text_matching expression="sa.pp.make_peak_matrix"/>
<has_text_matching expression="chunk_size = 500"/>
<has_text_matching expression="use_x = False"/>
<has_text_matching expression="count_frag_as_reads = True"/>
<has_text_matching expression="counting_strategy = 'insertion'"/>
</assert_contents>
</output>
<output name="anndata_out" location="https://zenodo.org/records/11260316/files/pp.make_peak_matrix.pbmc_500_chr21.h5ad" ftype="h5ad" compare="sim_size" delta_frac="0.1" />
<output name="anndata_out" location="https://zenodo.org/records/12751925/files/pp.make_peak_matrix.pbmc_500_chr21.h5ad" ftype="h5ad" compare="sim_size" delta_frac="0.1" />
</test>
<test expect_num_outputs="3">
<!-- tl.marker_regions -->
Expand Down
44 changes: 32 additions & 12 deletions tools/snapatac2/preprocessing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ sa.pp.add_tile_matrix(
#if $method.max_frag_size
max_frag_size = $method.max_frag_size,
#end if
##counting_strategy = '$method.counting_strategy',
count_frag_as_reads = $method.count_frag_as_reads,
counting_strategy = '$method.counting_strategy',
n_jobs = int(os.getenv("GALAXY_SLOTS", 4))
)
Expand All @@ -107,8 +106,7 @@ adata = sa.pp.make_gene_matrix(
#if $method.max_frag_size
max_frag_size = $method.max_frag_size,
#end if
##counting_strategy = '$method.counting_strategy'
count_frag_as_reads = $method.count_frag_as_reads
counting_strategy = '$method.counting_strategy'
)
#else if $method.method == 'pp.filter_cells'
Expand Down Expand Up @@ -285,8 +283,7 @@ sa.metrics.tsse(
<expand macro="sanitize_query"/>
</param>
<expand macro="min_max_frag_size"/>
<!--expand macro="param_counting_strategy"/-->
<param argument="count_frag_as_reads" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Whether to count fragments as reads"/>
<expand macro="param_counting_strategy"/>
</when>
<when value="pp.make_gene_matrix">
<expand macro="inputs_anndata"/>
Expand All @@ -302,8 +299,7 @@ sa.metrics.tsse(
<param argument="gene_name_key" type="text" value="gene_name" label="The key of the gene name in the gene annotation file"/>
<param argument="gene_id_key" type="text" value="gene_id" label="The key of the gene id in the gene annotation file"/>
<expand macro="min_max_frag_size"/>
<!--expand macro="param_counting_strategy"/-->
<param argument="count_frag_as_reads" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Whether to count fragments as reads"/>
<expand macro="param_counting_strategy"/>
</when>
<when value="pp.filter_cells">
<expand macro="inputs_anndata"/>
Expand Down Expand Up @@ -446,7 +442,7 @@ sa.metrics.tsse(
<param name="transcript_id_key" value="transcript_id"/>
<param name="gene_name_key" value="gene_name"/>
<param name="gene_id_key" value="gene_id"/>
<param name="count_frag_as_reads" value="True"/>
<param name="counting_strategy" value="insertion"/>
</conditional>
<section name="advanced_common">
<param name="show_log" value="true" />
Expand All @@ -461,7 +457,7 @@ sa.metrics.tsse(
<has_text_matching expression="transcript_id_key = 'transcript_id'"/>
<has_text_matching expression="gene_name_key = 'gene_name'"/>
<has_text_matching expression="gene_id_key = 'gene_id'"/>
<has_text_matching expression="count_frag_as_reads = True"/>
<has_text_matching expression="counting_strategy = 'insertion'"/>
</assert_contents>
</output>
<output name="anndata_out" location="https://zenodo.org/records/12548681/files/pp.make_gene_matrix.pbmc_500_chr21.h5ad" ftype="h5ad" compare="sim_size" delta_frac="0.1" />
Expand Down Expand Up @@ -513,7 +509,7 @@ sa.metrics.tsse(
<param name="bin_size" value="5000"/>
<param name="chunk_size" value="500"/>
<param name="exclude_chroms" value="chr1, chr2, chr3, chr4, chr5, chr6, chr7, chr8, chr9, chr10, chr11, chr12, chr13, chr14, chr15, chr16, chr17, chr18, chr19, chr20, chr22, chrX, chrY"/>
<param name="count_frag_as_reads" value="True"/>
<param name="counting_strategy" value="insertion"/>
</conditional>
<section name="advanced_common">
<param name="show_log" value="true" />
Expand All @@ -524,7 +520,31 @@ sa.metrics.tsse(
<has_text_matching expression="bin_size = 5000"/>
<has_text_matching expression="chunk_size = 500"/>
<has_text_matching expression="exclude_chroms = \['chr1', 'chr2', 'chr3', 'chr4', 'chr5', 'chr6', 'chr7', 'chr8', 'chr9', 'chr10', 'chr11', 'chr12', 'chr13', 'chr14', 'chr15', 'chr16', 'chr17', 'chr18', 'chr19', 'chr20', 'chr22', 'chrX', 'chrY'\]"/>
<has_text_matching expression="count_frag_as_reads = True"/>
<has_text_matching expression="counting_strategy = 'insertion'"/>
</assert_contents>
</output>
<output name="anndata_out" ftype="h5ad" compare="sim_size" delta_frac="0.1" location="https://zenodo.org/records/11260316/files/pp.add_tile_matrix.pbmc_500_chr21.h5ad"/>
</test>
<test expect_num_outputs="2">
<!-- pp.add_tile_matrix counting_strategy fragment -->
<conditional name="method">
<param name="method" value="pp.add_tile_matrix"/>
<param name="adata" location="https://zenodo.org/records/11260316/files/pp.filter_cells.pbmc_500_chr21.h5ad"/>
<param name="bin_size" value="5000"/>
<param name="chunk_size" value="500"/>
<param name="exclude_chroms" value="chr1, chr2, chr3, chr4, chr5, chr6, chr7, chr8, chr9, chr10, chr11, chr12, chr13, chr14, chr15, chr16, chr17, chr18, chr19, chr20, chr22, chrX, chrY"/>
<param name="counting_strategy" value="fragment"/>
</conditional>
<section name="advanced_common">
<param name="show_log" value="true" />
</section>
<output name="hidden_output">
<assert_contents>
<has_text_matching expression="sa.pp.add_tile_matrix"/>
<has_text_matching expression="bin_size = 5000"/>
<has_text_matching expression="chunk_size = 500"/>
<has_text_matching expression="exclude_chroms = \['chr1', 'chr2', 'chr3', 'chr4', 'chr5', 'chr6', 'chr7', 'chr8', 'chr9', 'chr10', 'chr11', 'chr12', 'chr13', 'chr14', 'chr15', 'chr16', 'chr17', 'chr18', 'chr19', 'chr20', 'chr22', 'chrX', 'chrY'\]"/>
<has_text_matching expression="counting_strategy = 'fragment'"/>
</assert_contents>
</output>
<output name="anndata_out" ftype="h5ad" compare="sim_size" delta_frac="0.1" location="https://zenodo.org/records/11260316/files/pp.add_tile_matrix.pbmc_500_chr21.h5ad"/>
Expand Down

0 comments on commit b37248e

Please sign in to comment.