Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/anndata/export.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<configfiles>
<configfile name="script_file"><![CDATA[
@CMD_imports@
adata = ad.read_h5ad('$input')
adata = ad.read_h5ad('$input', backed='r')
adata.write_csvs('.', sep="\t", skip_data = False)
]]></configfile>
</configfiles>
Expand Down
2 changes: 1 addition & 1 deletion tools/anndata/import.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="anndata_import" name="Import Anndata" version="@TOOL_VERSION@+galaxy2" profile="@PROFILE@">
<tool id="anndata_import" name="Import Anndata" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
Comment thread
SaimMomin12 marked this conversation as resolved.
<description>from different formats</description>
<macros>
<import>macros.xml</import>
Expand Down
10 changes: 8 additions & 2 deletions tools/anndata/inspect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from scipy import io
pd.options.display.precision = 15
adata = ad.read_h5ad('$input')
adata = ad.read_h5ad('$input', backed='r')
#if $inspect.info == 'general'
with open('$general', 'w', encoding="utf-8") as f:
Expand Down Expand Up @@ -202,7 +202,13 @@ pd.DataFrame(adata.varm['PCs']).to_csv("$varm_PCs", sep="\t", index = False)
<conditional name="inspect">
<param name="info" value="general"/>
</conditional>
<output name="general" value="inspect.general.txt"/>
<output name="general">
<assert_contents>
<has_text_matching expression="AnnData object with n_obs .* n_vars = 500 .* 11" />
<has_text_matching expression="obs: 'cell_type'" />
<has_text_matching expression="uns: 'highlights', 'iroot'" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="1">
<!-- test 2: X -->
Expand Down
4 changes: 2 additions & 2 deletions tools/anndata/macros.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<macros>
<token name="@TOOL_VERSION@">0.11.4</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@VERSION_SUFFIX@">3</token>
Comment thread
SaimMomin12 marked this conversation as resolved.
<token name="@PROFILE@">21.09</token>
<xml name="requirements">
<requirements>
Expand Down Expand Up @@ -39,7 +39,7 @@ AnnData stores a data matrix `X` together with annotations of observations `obs`


AnnData stores observations (samples) of variables (features) in the rows of a matrix. This is the convention of the modern classics
of statistics (`Hastie et al., 2009 <https://web.stanford.edu/~hastie/ElemStatLearn/>`__) and machine learning (Murphy, 2012), the convention of dataframes both in R and Python and the established statistics
of statistics (Hastie et al., 2009) and machine learning (Murphy, 2012), the convention of dataframes both in R and Python and the established statistics
and machine learning packages in Python (statsmodels, scikit-learn).

More details on the `AnnData documentation
Expand Down
22 changes: 13 additions & 9 deletions tools/anndata/manipulate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
<configfile name="script_file"><![CDATA[
@CMD_imports@

adata = ad.read_h5ad('$input')
adata = ad.read_h5ad('$input', backed='r')

#if $manipulate.function == 'concatenate'
adata = adata.to_memory()
#for i, filepath in enumerate($manipulate.other_adatas)
adata_$i = ad.read_h5ad('$filepath')
adata_$i = ad.read_h5ad('$filepath', backed='r').to_memory()
#end for
adata = adata.concatenate(
#for i, filepath in enumerate($manipulate.other_adatas)
Expand Down Expand Up @@ -118,6 +119,7 @@ del adata.var['${from_var}']
adata.strings_to_categoricals()

#else if $manipulate.function == 'transpose'
adata = adata.to_memory()
adata = adata.transpose()

#else if $manipulate.function == 'add_annotation'
Expand All @@ -137,14 +139,15 @@ adata.obs = obs

#else if $manipulate.function == 'split_on_obs'
import os
adata = adata.to_memory()
res_dir = "output_split"
os.makedirs(res_dir, exist_ok=True)
for s,field_value in enumerate(adata.obs["${manipulate.key}"].unique()):
ad_s = adata[adata.obs.${manipulate.key} == field_value]
ad_s = adata[adata.obs.${manipulate.key} == field_value].copy()
ad_s.write(f"{res_dir}/${manipulate.key}_{s}.h5ad", compression='gzip')

#else if $manipulate.function == 'copy_obs'
source_adata = ad.read_h5ad('$source_adata')
source_adata = ad.read_h5ad('$source_adata', backed='r')
#for $key in $manipulate.keys
if '$key.source_key' in source_adata.obs:
#if str($key.target_key) == '':
Expand All @@ -157,7 +160,7 @@ else:
#end for

#else if $manipulate.function == 'copy_uns'
source_adata = ad.read_h5ad('$source_adata')
source_adata = ad.read_h5ad('$source_adata', backed='r')
#for $key in $manipulate.keys
if '$key.source_key' in source_adata.uns:
#if str($key.target_key) == '':
Expand All @@ -170,7 +173,7 @@ else:
#end for

#else if $manipulate.function == 'copy_embed'
source_adata = ad.read_h5ad('$source_adata')
source_adata = ad.read_h5ad('$source_adata', backed='r')
#for $key in $manipulate.keys
if '$key.source_key' in source_adata.obsm:
#if $key.target_key is None
Expand All @@ -183,7 +186,7 @@ else:
#end for

#else if $manipulate.function == 'copy_layers'
source_adata = ad.read_h5ad('$source_adata')
source_adata = ad.read_h5ad('$source_adata', backed='r')
#for $key in $manipulate.keys
if '$key.source_key' in source_adata.layers:
#if $key.target_key is None
Expand All @@ -196,14 +199,15 @@ else:
#end for

#else if $manipulate.function == 'copy_X'
source_adata = ad.read_h5ad('$source_adata')
source_adata = ad.read_h5ad('$source_adata', backed='r')
#if $target_key is None
adata.X = source_adata.X
#else
adata.layers['$target_key'] = source_adata.X
#end if

#else if $manipulate.function == 'save_raw'
adata = adata.to_memory()
adata.raw = adata

#end if
Expand Down Expand Up @@ -924,7 +928,7 @@ This tool takes an AnnData dataset, manipulates it and returns it.

The possible manipulations are:

- Concatenate along the observations axis (`concatenate method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.concatenate.html>`__)
- Concatenate along the observations axis (`concatenate method <https://anndata.readthedocs.io/en/stable/generated/anndata.AnnData.concatenate.html>`__)

The `uns`, `varm` and `obsm` attributes are ignored.

Expand Down
Loading