# HG changeset patch # User iuc # Date 1726343880 0 # Node ID 7e8c677a7b719f95ec5e9c9388f48ccf314a5f42 # Parent ed4996a16f7f99fe9e550174e7fc85d291077bbb planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/anndata/ commit 67b3808b56df343798263ff0c905df8cb789edfa diff -r ed4996a16f7f -r 7e8c677a7b71 macros.xml --- a/macros.xml Sun Nov 12 16:42:25 2023 +0000 +++ b/macros.xml Sat Sep 14 19:58:00 2024 +0000 @@ -1,6 +1,7 @@ - 0.10.3 + 0.10.9 0 + 21.09 anndata @@ -21,12 +22,6 @@ python '$script_file' ]]> - - @@ -76,4 +71,11 @@ + + + + + + + diff -r ed4996a16f7f -r 7e8c677a7b71 manipulate.xml --- a/manipulate.xml Sun Nov 12 16:42:25 2023 +0000 +++ b/manipulate.xml Sat Sep 14 19:58:00 2024 +0000 @@ -1,4 +1,4 @@ - + object macros.xml @@ -50,6 +50,27 @@ key='$manipulate.key', categories=$categories) +#else if $manipulate.function == 'remove_keys' + #if $manipulate.obs_keys + #set $keys = [x.strip() for x in str($manipulate.obs_keys).split(',')] +adata.obs = adata.obs.drop(columns=$keys) + #end if + + #if $manipulate.var_keys + #set $keys = [x.strip() for x in str($manipulate.var_keys).split(',')] +adata.var = adata.vars.drop(columns=$keys) + #end if + +#else if $manipulate.function == 'flag_genes' +## adapted from anndata operations + #for $flag in $manipulate.gene_flags +k_cat = adata.var_names.str.startswith('${flag.startswith}') +if k_cat.sum() > 0: + adata.var['${flag.col_name}'] = k_cat +else: + print(f'No genes starting with {'${flag.startswith}'} found.') +#end for + #else if $manipulate.function == 'strings_to_categoricals' adata.strings_to_categoricals() @@ -71,6 +92,14 @@ adata.obs = obs #end if +#else if $manipulate.function == 'split_on_obs' +import os +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.write(f"{res_dir}/${manipulate.key}_{s}.h5ad", compression='gzip') + #else if $manipulate.function == 'filter' #if $manipulate.filter.filter == 'key' #if $manipulate.var_obs == 'var' @@ -126,7 +155,11 @@ #end if -adata.write('anndata.h5ad') +#if $manipulate.function != 'split_on_obs' +adata.write('anndata.h5ad', compression='gzip') +print(adata) +#end if + ]]> @@ -137,9 +170,12 @@ + + + @@ -167,6 +203,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -177,6 +233,15 @@ + + + + + + + + + @@ -237,10 +302,16 @@ - + + manipulate['function'] != 'split_on_obs' + + + + manipulate['function'] == 'split_on_obs' + - + @@ -256,10 +327,15 @@ + - + + + + + - + @@ -268,10 +344,17 @@ + - + + + + + + + - + @@ -280,25 +363,39 @@ + - + + + + + + + - + - + - + + - + + + + + + + - + @@ -306,10 +403,17 @@ + - + + + + + + + - + @@ -317,10 +421,17 @@ + - + + + + + + + - + @@ -328,9 +439,20 @@ - + + + + + + + + + + + + - + @@ -338,9 +460,20 @@ - + + + + + + + + + + + + - + @@ -354,9 +487,18 @@ - + + + + + + + + + + - + @@ -372,23 +514,120 @@ - + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `__) @@ -408,6 +647,14 @@ Besides calling `self.obs[key].cat.categories = categories` - similar for `var` - this also renames categories in unstructured annotation that uses the categorical annotation `key` +- Remove keys from obs or var annotations + + Helps in cleaning up andata with many annotations. For example, helps in removing qc metrics calculated during the preprocesing or already existing cluster annotations. + +- Flag genes start with a pattern + + Useful for flagging the mitochoncdrial or ribosomal protein genes + - Transform string annotations to categoricals (`strings_to_categoricals method `__) Only affects string annotations that lead to less categories than the total number of observations. @@ -416,7 +663,11 @@ Data matrix is transposed, observations and variables are interchanged. -- Add annotation for variables or observations +- Add annotation for variables or + +- Split the AnnData object into multiple AnnData objects based on the values of a given obs key + + For example, helps in splitting an anndata objects based on cluster annotation. This function generates a collection with number of elements equal to the number of categories in the input obs key. - Filter data variables or observations, by index or key diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/addloomout1.loom Binary file test-data/addloomout1.loom has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/addloomout3.loom Binary file test-data/addloomout3.loom has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/converted.loom.test Binary file test-data/converted.loom.test has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/export.krumsiek11.loom Binary file test-data/export.krumsiek11.loom has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/import.csv.h5ad Binary file test-data/import.csv.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/import.loom.krumsiek11.h5ad Binary file test-data/import.loom.krumsiek11.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/import.mtx.legacy_10x.h5ad Binary file test-data/import.mtx.legacy_10x.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/import.mtx.no_10x.h5ad Binary file test-data/import.mtx.no_10x.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/import.mtx.v3_10x.h5ad Binary file test-data/import.mtx.v3_10x.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/import.tsv.h5ad Binary file test-data/import.tsv.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/import.umi_tools.h5ad Binary file test-data/import.umi_tools.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/krumsiek11.h5ad Binary file test-data/krumsiek11.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.add_annotation_obs.h5ad Binary file test-data/manipulate.add_annotation_obs.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.add_annotation_var.h5ad Binary file test-data/manipulate.add_annotation_var.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.concatenate.h5ad Binary file test-data/manipulate.concatenate.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.filter_obs_key.h5ad Binary file test-data/manipulate.filter_obs_key.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.filter_var_index.h5ad Binary file test-data/manipulate.filter_var_index.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.obs_names_make_unique.h5ad Binary file test-data/manipulate.obs_names_make_unique.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.rename_categories.h5ad Binary file test-data/manipulate.rename_categories.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.save_raw.h5ad Binary file test-data/manipulate.save_raw.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.strings_to_categoricals.h5ad Binary file test-data/manipulate.strings_to_categoricals.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.transpose.h5ad Binary file test-data/manipulate.transpose.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/manipulate.var_names_make_unique.h5ad Binary file test-data/manipulate.var_names_make_unique.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/pp.neighbors_umap_euclidean.recipe_weinreb17.paul15_subsample.h5ad Binary file test-data/pp.neighbors_umap_euclidean.recipe_weinreb17.paul15_subsample.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/pp.pca.krumsiek11.h5ad Binary file test-data/pp.pca.krumsiek11.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/tl.diffmap.h5ad Binary file test-data/tl.diffmap.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/tl.draw_graph.h5ad Binary file test-data/tl.draw_graph.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/tl.paga.neighbors_gauss_braycurtis.recipe_weinreb17.paul15_subsample.h5ad Binary file test-data/tl.paga.neighbors_gauss_braycurtis.recipe_weinreb17.paul15_subsample.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/tl.rank_genes_groups.krumsiek11.h5ad Binary file test-data/tl.rank_genes_groups.krumsiek11.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/tl.tsne.h5ad Binary file test-data/tl.tsne.h5ad has changed diff -r ed4996a16f7f -r 7e8c677a7b71 test-data/tl.umap.h5ad Binary file test-data/tl.umap.h5ad has changed