comparison anndata_operations.xml @ 10:54f1212d26ac draft

"planemo upload for repository https://github.com/ebi-gene-expression-group/container-galaxy-sc-tertiary/tree/develop/tools/tertiary-analysis/scanpy commit 6806d147bfbb52c61d2a15281b69144fad87250a"
author ebi-gxa
date Thu, 11 Jun 2020 13:07:33 -0400
parents b8eb50bd397c
children f0a29f4b9be9
comparison
equal deleted inserted replaced
9:b8eb50bd397c 10:54f1212d26ac
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <tool id="anndata_ops" name="AnnData Operations" version="0.0.2+galaxy0" profile="@PROFILE@"> 2 <tool id="anndata_ops" name="AnnData Operations" version="0.0.3+galaxy0" profile="@PROFILE@">
3 <description>modifies metadata and flags genes</description> 3 <description>modifies metadata and flags genes</description>
4 <macros> 4 <macros>
5 <import>scanpy_macros2.xml</import> 5 <import>scanpy_macros2.xml</import>
6 </macros> 6 </macros>
7 <expand macro="requirements"/> 7 <expand macro="requirements"/>
15 #end if 15 #end if
16 16
17 #if $copy_e.default: 17 #if $copy_e.default:
18 #for $i, $es in enumerate($copy_e.embedding_sources): 18 #for $i, $es in enumerate($copy_e.embedding_sources):
19 ln -s '${es}' embedding_source_${i}.h5 && 19 ln -s '${es}' embedding_source_${i}.h5 &&
20 #end for
21 #end if
22
23 #if $copy_u.default:
24 #for $i, $us in enumerate($copy_u.uns_sources):
25 ln -s '${us}' uns_source_${i}.h5 &&
20 #end for 26 #end for
21 #end if 27 #end if
22 python $operations 28 python $operations
23 ]]></command> 29 ]]></command>
24 <configfiles> 30 <configfiles>
33 gene_name = '${gene_symbols_field}' 39 gene_name = '${gene_symbols_field}'
34 qc_vars = list() 40 qc_vars = list()
35 41
36 #for $i, $s in enumerate($modifications) 42 #for $i, $s in enumerate($modifications)
37 adata.obs['${s.to_obs}'] = adata.obs['${s.from_obs}'] 43 adata.obs['${s.to_obs}'] = adata.obs['${s.from_obs}']
44 #if not $s.keep_original:
45 del adata.obs['${s.from_obs}']
46 #end if
38 #end for 47 #end for
39 48
40 gene_names = getattr(adata.var, gene_name) 49 gene_names = getattr(adata.var, gene_name)
41 50
42 #for $i, $flag in enumerate($gene_flags) 51 #for $i, $flag in enumerate($gene_flags)
77 else: 86 else:
78 logging.warning("Embedding source ${i} AnnData file is not compatible to be merged to main AnnData file, different cell names.") 87 logging.warning("Embedding source ${i} AnnData file is not compatible to be merged to main AnnData file, different cell names.")
79 #end for 88 #end for
80 #end if 89 #end if
81 90
91 #if $copy_u.default and len($copy_u.uns_keys) > 0:
92 #for $i, $uns_s in enumerate($copy_u.uns_sources):
93 ad_s = sc.read('uns_source_${i}.h5')
94 if adata.n_obs == ad_s.n_obs and all(adata.obs_names == ad_s.obs_names):
95 #for $j, $u_key in enumerate($copy_u.uns_keys):
96 keys_to_copy = (k for k in ad_s.uns.keys() if "${u_key.contains}" in k)
97 for k_to_copy in keys_to_copy:
98 adata.uns[k_to_copy+"_${i}"] = ad_s.uns[k_to_copy]
99 #end for
100 else:
101 logging.warning("Uns source ${i} AnnData file is not compatible to be merged to main AnnData file, different cell names.")
102 #end for
103 #end if
104
82 #if $sanitize_varm: 105 #if $sanitize_varm:
83 if hasattr(adata, 'raw') and hasattr(adata.raw, 'X') and hasattr(adata.raw, 'var'): 106 if hasattr(adata, 'raw') and hasattr(adata.raw, 'X') and hasattr(adata.raw, 'var'):
84 new_ad = anndata.AnnData(X=adata.raw.X, obs=adata.obs, var=adata.raw.var) 107 new_ad = anndata.AnnData(X=adata.raw.X, obs=adata.obs, var=adata.raw.var)
85 adata.raw = new_ad 108 adata.raw = new_ad
86 #end if 109 #end if
110 <sanitizer> 133 <sanitizer>
111 <valid initial="string.printable"/> 134 <valid initial="string.printable"/>
112 </sanitizer> 135 </sanitizer>
113 </param> 136 </param>
114 <param name="to_obs" type="text" label="New name" help="New name in observations that you want to change"/> 137 <param name="to_obs" type="text" label="New name" help="New name in observations that you want to change"/>
138 <param name="keep_original" type="boolean" label="Keep original" help="If activated, it will also keep the original column" checked="false"/>
115 </repeat> 139 </repeat>
116 <param name="gene_symbols_field" value='index' type="text" label="Gene symbols field in AnnData" help="Field inside var.params where the gene symbols are, normally 'index' or 'gene_symbols'"/> 140 <param name="gene_symbols_field" value='index' type="text" label="Gene symbols field in AnnData" help="Field inside var.params where the gene symbols are, normally 'index' or 'gene_symbols'"/>
117 <repeat name="gene_flags" title="Flag genes that start with these names"> 141 <repeat name="gene_flags" title="Flag genes that start with these names">
118 <param name="startswith" type="text" label="Starts with" help="Text that you expect the genes to be flagged to start with, such as 'MT-' for mito genes"/> 142 <param name="startswith" type="text" label="Starts with" help="Text that you expect the genes to be flagged to start with, such as 'MT-' for mito genes"/>
119 <param name="flag" type="text" label="Var name" help="Name of the column in var.names where this boolean flag is stored, for example 'mito' for mitochondrial genes."/> 143 <param name="flag" type="text" label="Var name" help="Name of the column in var.names where this boolean flag is stored, for example 'mito' for mitochondrial genes."/>
120 </repeat> 144 </repeat>
121 <param name="top_genes" label="Number of top genes" value='50' help="to calculate percentage of the flagged genes in that number of top genes. Used by sc.pp.calculate_qc_metrics (integer)." type="integer"/> 145 <param name="top_genes" label="Number of top genes" value='50' help="to calculate percentage of the flagged genes in that number of top genes. Used by sc.pp.calculate_qc_metrics (integer)." type="integer"/>
122 <conditional name="copy_o"> 146 <conditional name="copy_o">
123 <param name="default" type="boolean" checked="false" label="Copy observations (such as clusters)"/> 147 <param name="default" type="boolean" checked="false" label="Copy observations (such as clusters)"/>
124 <when value="true"> 148 <when value="true">
125 <repeat name="obs_keys" title="Keys from obs to copy" help="will copy all obs keys in the given AnnData object to the main AnnData object. Make sure to use AnnData objects that are compatible in terms of genes, cells and expression data. You can use this to copy clusters." min="1"> 149 <repeat name="obs_keys" title="Keys from obs to copy" help="will copy all obs keys in the given AnnData object to the main AnnData object. Make sure to use AnnData objects that are compatible in terms of genes, cells and expression data. You can use this to copy clusters. Uns elements with the same name will be also transferred." min="1">
126 <param name="contains" type="text" label="Key contains" help="Keys to be copied need to contain the text set here."/> 150 <param name="contains" type="text" label="Key contains" help="Keys to be copied need to contain the text set here."/>
127 </repeat> 151 </repeat>
128 <param name="obs_sources" type="data" label="AnnData objects with obs to copy" help="Extracts obs (such as clusters) from these AnnData objects and merges them into the main input. Make sure to use AnnData objects that are compatible in terms of genes, cells and expression data." format="h5,h5ad" multiple="true"/> 152 <param name="obs_sources" type="data" label="AnnData objects with obs to copy" help="Extracts obs (such as clusters) from these AnnData objects and merges them into the main input. Make sure to use AnnData objects that are compatible in terms of genes, cells and expression data." format="h5,h5ad" multiple="true"/>
129 <!-- <param name="check_o" type="boolean" label="Check compatibility" help="checks if the provided AnnData objects are compatible (same genes and cells) for merging." checked="true"/> --> 153 <!-- <param name="check_o" type="boolean" label="Check compatibility" help="checks if the provided AnnData objects are compatible (same genes and cells) for merging." checked="true"/> -->
130 </when> 154 </when>
139 <param name="embedding_sources" type="data" label="AnnData objects with embeddings to copy" help="Extracts embeddings (tSNE, UMAP) from these AnnData objects and merges them into the main input. Make sure to use AnnData objects that are compatible in terms of genes, cells and expression data." format="h5,h5ad" multiple="true"/> 163 <param name="embedding_sources" type="data" label="AnnData objects with embeddings to copy" help="Extracts embeddings (tSNE, UMAP) from these AnnData objects and merges them into the main input. Make sure to use AnnData objects that are compatible in terms of genes, cells and expression data." format="h5,h5ad" multiple="true"/>
140 <!-- <param name="check_e" type="boolean" label="Check compatibility" help="checks if the provided AnnData objects are compatible (same genes and cells) for merging." checked="true"/> --> 164 <!-- <param name="check_e" type="boolean" label="Check compatibility" help="checks if the provided AnnData objects are compatible (same genes and cells) for merging." checked="true"/> -->
141 </when> 165 </when>
142 <when value="false"/> 166 <when value="false"/>
143 </conditional> 167 </conditional>
168 <conditional name="copy_u">
169 <param name="default" type="boolean" checked="false" label="Copy uns"/>
170 <when value="true">
171 <repeat name="uns_keys" title="Keys from uns to copy" help="will copy all uns keys in the given AnnData object to the main AnnData object. Make sure to use AnnData objects that are compatible in terms of genes, cells and expression data. You can use this to copy rank_genes_groups for instance." min="1">
172 <param name="contains" type="text" label="Key contains" help="Keys to be copied need to contain the text set here."/>
173 </repeat>
174 <param name="uns_sources" type="data" label="AnnData objects with uns to copy" help="Extracts uns (such as ranked_genes_groups) from these AnnData objects and merges them into the main input. Make sure to use AnnData objects that are compatible in terms of genes, cells and expression data." format="h5,h5ad" multiple="true"/>
175 </when>
176 </conditional>
144 <param name="sanitize_varm" type="boolean" checked="false" label="Sanitise any null raw.varm objects if any" help="This might be relevant for interfacing with newer versions of AnnData, that might complain if .raw includes a varm null object."/> 177 <param name="sanitize_varm" type="boolean" checked="false" label="Sanitise any null raw.varm objects if any" help="This might be relevant for interfacing with newer versions of AnnData, that might complain if .raw includes a varm null object."/>
145 </inputs> 178 </inputs>
146 179
147 <outputs> 180 <outputs>
148 <expand macro="output_data_obj_no_loom" description="metadata changes on"/> 181 <expand macro="output_data_obj_no_loom" description="metadata changes on"/>
167 * Change observation fields, mostly for downstreaming processes convenience. Multiple fields can be changed as one. 200 * Change observation fields, mostly for downstreaming processes convenience. Multiple fields can be changed as one.
168 * Flag genes that start with a certain text: useful for flagging mitochondrial, spikes or other groups of genes. 201 * Flag genes that start with a certain text: useful for flagging mitochondrial, spikes or other groups of genes.
169 * For the flags created, calculates qc metrics (pct_<flag>_counts). 202 * For the flags created, calculates qc metrics (pct_<flag>_counts).
170 * Calculates `n_genes`, `n_counts` for cells and `n_cells`, `n_counts` for genes. 203 * Calculates `n_genes`, `n_counts` for cells and `n_cells`, `n_counts` for genes.
171 * For top <N> genes specified, calculate qc metrics (pct_counts_in_top_<N>_genes). 204 * For top <N> genes specified, calculate qc metrics (pct_counts_in_top_<N>_genes).
205 * Copy from a set of compatible AnnData objects (same cells and genes):
206 * Observations, such as clustering results.
207 * Embeddings, such as tSNE or UMAPs.
208 * Unstructure annotations, like gene markers.
172 209
173 This functionality will probably be added in the future to a larger package. 210 This functionality will probably be added in the future to a larger package.
174 ]]></help> 211 ]]></help>
175 <expand macro="citations"/> 212 <expand macro="citations"/>
176 </tool> 213 </tool>