Mercurial > repos > iuc > anndata_manipulate
changeset 1:19592ec717ef draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/anndata/ commit 8ef5f7c6f8728608a3f05bb51e11b642b84a05f5"
line wrap: on
line diff
--- a/macros.xml Wed Apr 10 03:25:05 2019 -0400 +++ b/macros.xml Wed Oct 16 06:26:45 2019 -0400 @@ -1,11 +1,11 @@ <macros> - <token name="@VERSION@">0.6.19</token> + <token name="@VERSION@">0.6.22.post1</token> <token name="@GALAXY_VERSION@">galaxy0</token> <xml name="requirements"> <requirements> <requirement type="package" version="@VERSION@">anndata</requirement> - <requirement type="package" version="1.4">scanpy</requirement> <requirement type="package" version="2.0.17">loompy</requirement> + <requirement type="package" version="2.9.0">h5py</requirement> <yield /> </requirements> </xml>
--- a/manipulate.xml Wed Apr 10 03:25:05 2019 -0400 +++ b/manipulate.xml Wed Oct 16 06:26:45 2019 -0400 @@ -50,11 +50,76 @@ key='$manipulate.key', categories=$categories) -#else if $manipulate.function == 'transpose' -adata.transpose() - #else if $manipulate.function == 'strings_to_categoricals' adata.strings_to_categoricals() + +#else if $manipulate.function == 'transpose' +adata = adata.transpose() + +#else if $manipulate.function == 'add_annotation' +import pandas as pd +extra_annot_t = pd.read_csv('$manipulate.new_annot', sep='\t').reset_index(drop=True) + #if $manipulate.var_obs == 'var' +var_index = adata.var_names +var = pd.concat([adata.var.reset_index(drop=True), extra_annot_t], axis=1) +var.index = var_index +adata.var = var + #else if $manipulate.var_obs == 'obs' +obs_index = adata.obs.index +obs = pd.concat([adata.obs.reset_index(drop=True), extra_annot_t], axis=1) +obs.index = obs_index +adata.obs = obs + #end if + +#else if $manipulate.function == 'filter' + #if $manipulate.filter.filter == 'key' + #if $manipulate.var_obs == 'var' +filtered = adata.var['$manipulate.filter.key'] + #else if $manipulate.var_obs == 'obs' +filtered = adata.obs['$manipulate.filter.key'] + #end if + + #if $manipulate.filter.filter_key.type == 'number' + #if $manipulate.filter.filter_key.filter == 'equal' +filtered = filtered == $manipulate.filter.filter_key.value + #else if $manipulate.filter.filter_key.filter == 'equal' +filtered = filtered != $manipulate.filter.filter_key.value + #else if $manipulate.filter.filter_key.filter == 'less' +filtered = filtered < $manipulate.filter.filter_key.value + #else if $manipulate.filter.filter_key.filter == 'less_or_equal' +filtered = filtered <= $manipulate.filter.filter_key.value + #else if $manipulate.filter.filter_key.filter == 'greater' +filtered = filtered > $manipulate.filter.filter_key.value + #else if $manipulate.filter.filter_key.filter == 'greater_or_equal' +filtered = filtered >= $manipulate.filter.filter_key.value + #end if + #else if $manipulate.filter.filter_key.type == 'text' + #if $manipulate.filter.filter_key.filter == 'equal' +filtered = filtered == '$manipulate.filter.filter_key.value' + #else +filtered = filtered != '$manipulate.filter.filter_key.value' + #end if + #else if $manipulate.filter.filter_key.type == 'boolean' +filtered = filtered == $manipulate.filter.filter_key.value + #end if + + #else if $manipulate.filter.filter == 'index' + #if str($manipulate.filter.index.format) == 'file' +with open('$manipulate.filter.index.file', 'r') as filter_f: + filters = [str(x.strip()) for x in filter_f.readlines()] +filtered = filters + #else + #set $filters = [str(x.strip()) for x in $manipulate.filter.index.text.split(',')] +filtered = $filters + #end if + #end if +print(filtered) + + #if $manipulate.var_obs == 'var' +adata = adata[:,filtered] + #else if $manipulate.var_obs == 'obs' +adata = adata[filtered, :] + #end if #end if adata.write('anndata.h5ad') @@ -70,6 +135,8 @@ <option value="rename_categories">Rename categories of annotation</option> <option value="strings_to_categoricals">Transform string annotations to categoricals</option> <option value="transpose">Transpose the data matrix, leaving observations and variables interchanged</option> + <option value="add_annotation">Add new annotation(s) for observations or variables</option> + <option value="filter">Filter observations or variables</option> </param> <when value="concatenate"> <param name="other_adatas" type="data" format="h5ad" multiple="true" label="Annotated data matrix to add"/> @@ -97,13 +164,78 @@ </when> <when value="strings_to_categoricals"/> <when value="transpose"/> + <when value="add_annotation"> + <param name="var_obs" type="select" label="What to annotate?"> + <option value="var">Variables (var)</option> + <option value="obs">Observations (obs)</option> + </param> + <param name="new_annot" type="data" format="tabular" label="Table with new annotations" + help="The new table should have the same number of rows and same order than obs or var. The key names should be in the header (1st line)"/> + </when> + <when value="filter"> + <param name="var_obs" type="select" label="What to annotate?"> + <option value="var">Variables (var)</option> + <option value="obs">Observations (obs)</option> + </param> + <conditional name="filter"> + <param name="filter" type="select" label="Type of filtering?"> + <option value="key">By key (column) values</option> + <option value="index">By index (row)</option> + </param> + <when value="key"> + <param name="key" type="text" value="n_genes" label="Key to filter"/> + <conditional name="filter_key"> + <param name="type" type="select" label="Type of value to filter"> + <option value="number">Number</option> + <option value="text">Text</option> + <option value="boolean">Boolean</option> + </param> + <when value="number"> + <param name="filter" type="select" label="Filter"> + <option value="equal">equal to</option> + <option value="not_equal">not equal to</option> + <option value="less">less than</option> + <option value="less_or_equal">less than or equal to</option> + <option value="greater">greater than</option> + <option value="greater_or_equal">greater than or equal to</option> + </param> + <param name="value" type="float" value="2500" label="Value"/> + </when> + <when value="text"> + <param name="filter" type="select" label="Filter"> + <option value="equal">equal to</option> + <option value="not_equal">not equal to</option></param> + <param name="value" type="text" value="2500" label="Value"/> + </when> + <when value="boolean"> + <param name="value" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Value to keep"/> + </when> + </conditional> + </when> + <when value="index"> + <conditional name="index"> + <param name="format" type="select" label="Format for the filter by index"> + <option value="file">File</option> + <option value="text" selected="true">Text</option> + </param> + <when value="text"> + <param name="text" type="text" value="" label="List of index to keep" help="Indexes separated by a comma"/> + </when> + <when value="file"> + <param name="file" type="data" format="txt" label="File with the list of index to keep" help="One index per line"/> + </when> + </conditional> + </when> + </conditional> + </when> </conditional> </inputs> <outputs> - <data name="anndata" format="h5ad" from_work_dir="anndata.h5ad" label="${tool.name} on ${on_string}"/> + <data name="anndata" format="h5ad" from_work_dir="anndata.h5ad" label="${tool.name} (${manipulate.function}) on ${on_string}"/> </outputs> <tests> <test> + <!-- test 1 --> <param name="input" value="krumsiek11.h5ad"/> <conditional name="manipulate"> <param name="function" value="concatenate"/> @@ -122,6 +254,7 @@ <output name="anndata" value="manipulate.concatenate.h5ad" ftype="h5ad" compare="sim_size"/> </test> <test> + <!-- test 2 --> <param name="input" value="krumsiek11.h5ad"/> <conditional name="manipulate"> <param name="function" value="obs_names_make_unique"/> @@ -133,6 +266,7 @@ <output name="anndata" value="manipulate.obs_names_make_unique.h5ad" ftype="h5ad" compare="sim_size"/> </test> <test> + <!-- test 3 --> <param name="input" value="krumsiek11.h5ad"/> <conditional name="manipulate"> <param name="function" value="var_names_make_unique"/> @@ -144,6 +278,7 @@ <output name="anndata" value="manipulate.var_names_make_unique.h5ad" ftype="h5ad" compare="sim_size"/> </test> <test> + <!-- test 4 --> <param name="input" value="krumsiek11.h5ad"/> <conditional name="manipulate"> <param name="function" value="rename_categories"/> @@ -158,6 +293,7 @@ <output name="anndata" value="manipulate.rename_categories.h5ad" ftype="h5ad" compare="sim_size"/> </test> <test> + <!-- test 5 --> <param name="input" value="krumsiek11.h5ad"/> <conditional name="manipulate"> <param name="function" value="strings_to_categoricals"/> @@ -168,6 +304,7 @@ <output name="anndata" value="manipulate.strings_to_categoricals.h5ad" ftype="h5ad" compare="sim_size"/> </test> <test> + <!-- test 6 --> <param name="input" value="krumsiek11.h5ad"/> <conditional name="manipulate"> <param name="function" value="transpose"/> @@ -177,6 +314,60 @@ </assert_stdout> <output name="anndata" value="manipulate.transpose.h5ad" ftype="h5ad" compare="sim_size"/> </test> + <test> + <!-- test 7 --> + <param name="input" value="krumsiek11.h5ad"/> + <conditional name="manipulate"> + <param name="function" value="add_annotation"/> + <param name="var_obs" value="var"/> + <param name="new_annot" value="var_add_annotation.tabular"/> + </conditional> + <output name="anndata" value="manipulate.add_annotation_var.h5ad" ftype="h5ad" compare="sim_size"/> + </test> + <test> + <!-- test 8 --> + <param name="input" value="krumsiek11.h5ad"/> + <conditional name="manipulate"> + <param name="function" value="add_annotation"/> + <param name="var_obs" value="obs"/> + <param name="new_annot" value="obs_add_annotation.tabular"/> + </conditional> + <output name="anndata" value="manipulate.add_annotation_obs.h5ad" ftype="h5ad" compare="sim_size"/> + </test> + <test> + <!-- test 9 --> + <param name="input" value="krumsiek11.h5ad"/> + <conditional name="manipulate"> + <param name="function" value="filter"/> + <param name="var_obs" value="var"/> + <conditional name="filter"> + <param name="filter" value="index"/> + <conditional name="index"> + <param name="format" value="text"/> + <param name="text" value="Gata2,EKLF"/> + </conditional> + </conditional> + </conditional> + <output name="anndata" value="manipulate.filter_var_index.h5ad" ftype="h5ad" compare="sim_size"/> + </test> + <test> + <!-- test 10 --> + <param name="input" value="krumsiek11.h5ad"/> + <conditional name="manipulate"> + <param name="function" value="filter"/> + <param name="var_obs" value="obs"/> + <conditional name="filter"> + <param name="filter" value="key"/> + <param name="key" value="cell_type"/> + <conditional name="filter_key"> + <param name="type" value="text"/> + <param name="filter" value="equal"/> + <param name="value" value="progenitor"/> + </conditional> + </conditional> + </conditional> + <output name="anndata" value="manipulate.filter_obs_key.h5ad" ftype="h5ad" compare="sim_size"/> + </test> </tests> <help><![CDATA[ **What it does** @@ -211,6 +402,10 @@ Data matrix is transposed, observations and variables are interchanged. +- Add annotation for variables or observations + +- Filter data variables or observations, by index or key + @HELP@ ]]></help> <expand macro="citations"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/obs_add_annotation.tabular Wed Oct 16 06:26:45 2019 -0400 @@ -0,0 +1,641 @@ +annot1 annot2 +0 progenitor +1 progenitor +2 progenitor +3 progenitor +4 progenitor +5 progenitor +6 progenitor +7 progenitor +8 progenitor +9 progenitor +10 progenitor +11 progenitor +12 progenitor +13 progenitor +14 progenitor +15 progenitor +16 progenitor +17 progenitor +18 progenitor +19 progenitor +20 progenitor +21 progenitor +22 progenitor +23 progenitor +24 progenitor +25 progenitor +26 progenitor +27 progenitor +28 progenitor +29 progenitor +30 progenitor +31 progenitor +32 progenitor +33 progenitor +34 progenitor +35 progenitor +36 progenitor +37 progenitor +38 progenitor +39 progenitor +40 progenitor +41 progenitor +42 progenitor +43 progenitor +44 progenitor +45 progenitor +46 progenitor +47 progenitor +48 progenitor +49 progenitor +50 progenitor +51 progenitor +52 progenitor +53 progenitor +54 progenitor +55 progenitor +56 progenitor +57 progenitor +58 progenitor +59 progenitor +60 progenitor +61 progenitor +62 progenitor +63 progenitor +64 progenitor +65 progenitor +66 progenitor +67 progenitor +68 progenitor +69 progenitor +70 progenitor +71 progenitor +72 progenitor +73 progenitor +74 progenitor +75 progenitor +76 progenitor +77 progenitor +78 progenitor +79 progenitor +80 Mo +81 Mo +82 Mo +83 Mo +84 Mo +85 Mo +86 Mo +87 Mo +88 Mo +89 Mo +90 Mo +91 Mo +92 Mo +93 Mo +94 Mo +95 Mo +96 Mo +97 Mo +98 Mo +99 Mo +100 Mo +101 Mo +102 Mo +103 Mo +104 Mo +105 Mo +106 Mo +107 Mo +108 Mo +109 Mo +110 Mo +111 Mo +112 Mo +113 Mo +114 Mo +115 Mo +116 Mo +117 Mo +118 Mo +119 Mo +120 Mo +121 Mo +122 Mo +123 Mo +124 Mo +125 Mo +126 Mo +127 Mo +128 Mo +129 Mo +130 Mo +131 Mo +132 Mo +133 Mo +134 Mo +135 Mo +136 Mo +137 Mo +138 Mo +139 Mo +140 Mo +141 Mo +142 Mo +143 Mo +144 Mo +145 Mo +146 Mo +147 Mo +148 Mo +149 Mo +150 Mo +151 Mo +152 Mo +153 Mo +154 Mo +155 Mo +156 Mo +157 Mo +158 Mo +159 Mo +0 progenitor +1 progenitor +2 progenitor +3 progenitor +4 progenitor +5 progenitor +6 progenitor +7 progenitor +8 progenitor +9 progenitor +10 progenitor +11 progenitor +12 progenitor +13 progenitor +14 progenitor +15 progenitor +16 progenitor +17 progenitor +18 progenitor +19 progenitor +20 progenitor +21 progenitor +22 progenitor +23 progenitor +24 progenitor +25 progenitor +26 progenitor +27 progenitor +28 progenitor +29 progenitor +30 progenitor +31 progenitor +32 progenitor +33 progenitor +34 progenitor +35 progenitor +36 progenitor +37 progenitor +38 progenitor +39 progenitor +40 progenitor +41 progenitor +42 progenitor +43 progenitor +44 progenitor +45 progenitor +46 progenitor +47 progenitor +48 progenitor +49 progenitor +50 progenitor +51 progenitor +52 progenitor +53 progenitor +54 progenitor +55 progenitor +56 progenitor +57 progenitor +58 progenitor +59 progenitor +60 progenitor +61 progenitor +62 progenitor +63 progenitor +64 progenitor +65 progenitor +66 progenitor +67 progenitor +68 progenitor +69 progenitor +70 progenitor +71 progenitor +72 progenitor +73 progenitor +74 progenitor +75 progenitor +76 progenitor +77 progenitor +78 progenitor +79 progenitor +80 Ery +81 Ery +82 Ery +83 Ery +84 Ery +85 Ery +86 Ery +87 Ery +88 Ery +89 Ery +90 Ery +91 Ery +92 Ery +93 Ery +94 Ery +95 Ery +96 Ery +97 Ery +98 Ery +99 Ery +100 Ery +101 Ery +102 Ery +103 Ery +104 Ery +105 Ery +106 Ery +107 Ery +108 Ery +109 Ery +110 Ery +111 Ery +112 Ery +113 Ery +114 Ery +115 Ery +116 Ery +117 Ery +118 Ery +119 Ery +120 Ery +121 Ery +122 Ery +123 Ery +124 Ery +125 Ery +126 Ery +127 Ery +128 Ery +129 Ery +130 Ery +131 Ery +132 Ery +133 Ery +134 Ery +135 Ery +136 Ery +137 Ery +138 Ery +139 Ery +140 Ery +141 Ery +142 Ery +143 Ery +144 Ery +145 Ery +146 Ery +147 Ery +148 Ery +149 Ery +150 Ery +151 Ery +152 Ery +153 Ery +154 Ery +155 Ery +156 Ery +157 Ery +158 Ery +159 Ery +0 progenitor +1 progenitor +2 progenitor +3 progenitor +4 progenitor +5 progenitor +6 progenitor +7 progenitor +8 progenitor +9 progenitor +10 progenitor +11 progenitor +12 progenitor +13 progenitor +14 progenitor +15 progenitor +16 progenitor +17 progenitor +18 progenitor +19 progenitor +20 progenitor +21 progenitor +22 progenitor +23 progenitor +24 progenitor +25 progenitor +26 progenitor +27 progenitor +28 progenitor +29 progenitor +30 progenitor +31 progenitor +32 progenitor +33 progenitor +34 progenitor +35 progenitor +36 progenitor +37 progenitor +38 progenitor +39 progenitor +40 progenitor +41 progenitor +42 progenitor +43 progenitor +44 progenitor +45 progenitor +46 progenitor +47 progenitor +48 progenitor +49 progenitor +50 progenitor +51 progenitor +52 progenitor +53 progenitor +54 progenitor +55 progenitor +56 progenitor +57 progenitor +58 progenitor +59 progenitor +60 progenitor +61 progenitor +62 progenitor +63 progenitor +64 progenitor +65 progenitor +66 progenitor +67 progenitor +68 progenitor +69 progenitor +70 progenitor +71 progenitor +72 progenitor +73 progenitor +74 progenitor +75 progenitor +76 progenitor +77 progenitor +78 progenitor +79 progenitor +80 Mk +81 Mk +82 Mk +83 Mk +84 Mk +85 Mk +86 Mk +87 Mk +88 Mk +89 Mk +90 Mk +91 Mk +92 Mk +93 Mk +94 Mk +95 Mk +96 Mk +97 Mk +98 Mk +99 Mk +100 Mk +101 Mk +102 Mk +103 Mk +104 Mk +105 Mk +106 Mk +107 Mk +108 Mk +109 Mk +110 Mk +111 Mk +112 Mk +113 Mk +114 Mk +115 Mk +116 Mk +117 Mk +118 Mk +119 Mk +120 Mk +121 Mk +122 Mk +123 Mk +124 Mk +125 Mk +126 Mk +127 Mk +128 Mk +129 Mk +130 Mk +131 Mk +132 Mk +133 Mk +134 Mk +135 Mk +136 Mk +137 Mk +138 Mk +139 Mk +140 Mk +141 Mk +142 Mk +143 Mk +144 Mk +145 Mk +146 Mk +147 Mk +148 Mk +149 Mk +150 Mk +151 Mk +152 Mk +153 Mk +154 Mk +155 Mk +156 Mk +157 Mk +158 Mk +159 Mk +0 progenitor +1 progenitor +2 progenitor +3 progenitor +4 progenitor +5 progenitor +6 progenitor +7 progenitor +8 progenitor +9 progenitor +10 progenitor +11 progenitor +12 progenitor +13 progenitor +14 progenitor +15 progenitor +16 progenitor +17 progenitor +18 progenitor +19 progenitor +20 progenitor +21 progenitor +22 progenitor +23 progenitor +24 progenitor +25 progenitor +26 progenitor +27 progenitor +28 progenitor +29 progenitor +30 progenitor +31 progenitor +32 progenitor +33 progenitor +34 progenitor +35 progenitor +36 progenitor +37 progenitor +38 progenitor +39 progenitor +40 progenitor +41 progenitor +42 progenitor +43 progenitor +44 progenitor +45 progenitor +46 progenitor +47 progenitor +48 progenitor +49 progenitor +50 progenitor +51 progenitor +52 progenitor +53 progenitor +54 progenitor +55 progenitor +56 progenitor +57 progenitor +58 progenitor +59 progenitor +60 progenitor +61 progenitor +62 progenitor +63 progenitor +64 progenitor +65 progenitor +66 progenitor +67 progenitor +68 progenitor +69 progenitor +70 progenitor +71 progenitor +72 progenitor +73 progenitor +74 progenitor +75 progenitor +76 progenitor +77 progenitor +78 progenitor +79 progenitor +80 Neu +81 Neu +82 Neu +83 Neu +84 Neu +85 Neu +86 Neu +87 Neu +88 Neu +89 Neu +90 Neu +91 Neu +92 Neu +93 Neu +94 Neu +95 Neu +96 Neu +97 Neu +98 Neu +99 Neu +100 Neu +101 Neu +102 Neu +103 Neu +104 Neu +105 Neu +106 Neu +107 Neu +108 Neu +109 Neu +110 Neu +111 Neu +112 Neu +113 Neu +114 Neu +115 Neu +116 Neu +117 Neu +118 Neu +119 Neu +120 Neu +121 Neu +122 Neu +123 Neu +124 Neu +125 Neu +126 Neu +127 Neu +128 Neu +129 Neu +130 Neu +131 Neu +132 Neu +133 Neu +134 Neu +135 Neu +136 Neu +137 Neu +138 Neu +139 Neu +140 Neu +141 Neu +142 Neu +143 Neu +144 Neu +145 Neu +146 Neu +147 Neu +148 Neu +149 Neu +150 Neu +151 Neu +152 Neu +153 Neu +154 Neu +155 Neu +156 Neu +157 Neu +158 Neu +159 Neu
Binary file test-data/pp.neighbors_umap_euclidean.recipe_weinreb17.paul15_subsample.h5ad has changed