Mercurial > repos > iuc > preprocess_muon
comparison preprocess_muon.xml @ 0:f86862ab76fb draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/muon commit fef10e0d450018d1e6ba4cbbda76c7686edc8aae
| author | iuc |
|---|---|
| date | Sat, 25 Oct 2025 21:00:39 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f86862ab76fb |
|---|---|
| 1 <tool id="preprocess_muon" name="muon filter and normalize" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@"> | |
| 2 <macros> | |
| 3 <import>macros.xml</import> | |
| 4 </macros> | |
| 5 <expand macro="requirements"/> | |
| 6 <expand macro="version_command"/> | |
| 7 <command detect_errors="exit_code"><![CDATA[ | |
| 8 @COPY_MUDATA@ | |
| 9 @CMD@ | |
| 10 ]]></command> | |
| 11 <configfiles> | |
| 12 <configfile name="script_file"><![CDATA[ | |
| 13 @CMD_imports@ | |
| 14 @CMD_read_inputs@ | |
| 15 | |
| 16 #if $method.method == 'pp.intersect_obs' | |
| 17 mu.pp.intersect_obs( | |
| 18 mdata | |
| 19 ) | |
| 20 ## Update the features. Only union features of the modalities are considered | |
| 21 mdata.update_var() | |
| 22 | |
| 23 | |
| 24 #else if $method.method == 'pp.l2norm' | |
| 25 mu.pp.l2norm( | |
| 26 mdata, | |
| 27 #if $method.mod | |
| 28 mod='$method.mod', | |
| 29 #end if | |
| 30 #if $method.rep | |
| 31 rep='$method.rep', | |
| 32 #end if | |
| 33 n_pcs=$method.n_pcs, | |
| 34 copy=False | |
| 35 ) | |
| 36 | |
| 37 #else if $method.method == 'pp.neighbors' | |
| 38 mu.pp.neighbors( | |
| 39 mdata, | |
| 40 #if str($method.n_neighbors) | |
| 41 n_neighbors=$method.n_neighbors, | |
| 42 #end if | |
| 43 n_bandwidth_neighbors=$method.n_bandwidth_neighbors, | |
| 44 n_multineighbors=$method.n_multineighbors, | |
| 45 @CMD_neighbor_keys@ | |
| 46 metric='$method.metric', | |
| 47 #if $method.key_added | |
| 48 key_added='$method.key_added', | |
| 49 #end if | |
| 50 weight_key='$method.weight_key', | |
| 51 add_weights_to_modalities=$method.add_weights_to_modalities, | |
| 52 eps=$method.eps, | |
| 53 random_state=$method.random_state, | |
| 54 copy=False | |
| 55 ) | |
| 56 | |
| 57 #else if $method.method == 'pp.sample_obs' | |
| 58 mu.pp.sample_obs( | |
| 59 mdata, | |
| 60 frac=$method.frac, | |
| 61 #if $method.groupby | |
| 62 groupby='$method.groupby', | |
| 63 #end if | |
| 64 #if str($method.min_n) | |
| 65 min_n=$method.min_n | |
| 66 #end if | |
| 67 ) | |
| 68 #end if | |
| 69 | |
| 70 @CMD_mudata_write_outputs@ | |
| 71 ]]></configfile> | |
| 72 </configfiles> | |
| 73 <inputs> | |
| 74 <expand macro="inputs_mudata"/> | |
| 75 <conditional name="method"> | |
| 76 <param name="method" type="select" label="Method used for plotting"> | |
| 77 <option value="pp.intersect_obs">Subset: Subset observations present only in all modalities, using 'muon.pp.intersect_obs'</option> | |
| 78 <option value="pp.l2norm">Normalize: Normalize observations to unit L2 norm, using 'muon.pp.l2norm'</option> | |
| 79 <option value="pp.neighbors">Search: Multimodal nearest neighbor search, using 'muon.pp.neighbors'</option> | |
| 80 <option value="pp.sample_obs">Return an object with some of the observations (subsampling). 'muon.pp.sample_obs'</option> | |
| 81 </param> | |
| 82 <when value="pp.intersect_obs"/> | |
| 83 <when value="pp.l2norm"> | |
| 84 <param argument="mod" type="text" optional="true" label="Names of the modalities to normalize" help="Leave empty to use all modalities"> | |
| 85 <expand macro="sanitize_string" /> | |
| 86 </param> | |
| 87 <param argument="rep" type="text" optional="true" label="The representation to normalize." help="X or any key for .obsm is valid, for all modalities"> | |
| 88 <expand macro="sanitize_query" /> | |
| 89 </param> | |
| 90 <param argument="n_pcs" type="integer" min="0" value="0" label="The number of principal components to use." help="This affects the result only if a PCA representation is being normalized"/> | |
| 91 </when> | |
| 92 <when value="pp.neighbors"> | |
| 93 <param argument="n_neighbors" type="integer" optional="true" label="Number of nearest neighbors to find" | |
| 94 help="If not set, arithmetic mean of per-modality neighbors will be used"/> | |
| 95 <param argument="n_bandwidth_neighbors" type="integer" value="20" label="Number of nearest neighbors to use for bandwidth selection"/> | |
| 96 <param argument="n_multineighbors" type="integer" value="200" label="Number of nearest neighbors in each modality to consider as candidates for multimodal nearest neighbors" | |
| 97 help="Only points in the union of per-modality nearest neighbors are candidates for multimodal nearest neighbors. | |
| 98 This will use the same metric that was used for the nearest neighbor search in the respective modality."/> | |
| 99 <expand macro="param_neighbor_keys"/> | |
| 100 <param argument="metric" type="select" label="Distance measure to use" help="This will only be used in the final step to search for nearest neighbors in the set of candidates."> | |
| 101 <option value="euclidean" selected="true">euclidean</option> | |
| 102 <option value="braycurtis">braycurtis</option> | |
| 103 <option value="canberra">canberra</option> | |
| 104 <option value="chebyshev">chebyshev</option> | |
| 105 <option value="cityblock">cityblock</option> | |
| 106 <option value="correlation">correlation</option> | |
| 107 <option value="cosine">cosine</option> | |
| 108 <option value="dice">dice</option> | |
| 109 <option value="hamming">hamming</option> | |
| 110 <option value="jaccard">jaccard</option> | |
| 111 <option value="jensenshannon">jensenshannon</option> | |
| 112 <option value="kulsinski">kulsinski</option> | |
| 113 <option value="mahalanobis">mahalanobis</option> | |
| 114 <option value="matching">matching</option> | |
| 115 <option value="minkowski">minkowski</option> | |
| 116 <option value="rogerstanimoto">rogerstanimoto</option> | |
| 117 <option value="russellrao">russellrao</option> | |
| 118 <option value="seuclidean">seuclidean</option> | |
| 119 <option value="sokalmichener">sokalmichener</option> | |
| 120 <option value="sokalsneath">sokalsneath</option> | |
| 121 <option value="sqeuclidean">sqeuclidean</option> | |
| 122 <option value="wminkowski">wminkowski</option> | |
| 123 <option value="yule">yule</option> | |
| 124 </param> | |
| 125 <expand macro="param_key_added_common"/> | |
| 126 <param argument="weight_key" type="text" value="mod_weight" label="Weight key to add to each modality’s .obs or to mdata.obs"> | |
| 127 <expand macro="sanitize_query" /> | |
| 128 </param> | |
| 129 <param argument="add_weights_to_modalities" type="boolean" truevalue="True" falsevalue="False" checked="false" label="If to add weights to individual modalities" help="By default, the weights will be added to mdata.obs"/> | |
| 130 <expand macro="param_eps" eps_value="0.0001"/> | |
| 131 <expand macro="param_random_state" seed="42"/> | |
| 132 </when> | |
| 133 <when value="pp.sample_obs"> | |
| 134 <param argument="frac" type="float" min="0" max="1" value="0.1" label="A fraction of observations to return"/> | |
| 135 <param argument="groupby" type="text" optional="true" label="Categorical column in .obs that is used for prior grouping before sampling observations"> | |
| 136 <expand macro="sanitize_query"/> | |
| 137 </param> | |
| 138 <param argument="min_n" type="integer" min="0" optional="true" label="Return min_n observations if fraction frac of observations is below min_n" | |
| 139 help="When groupby is not None, min_n is applied per group."/> | |
| 140 </when> | |
| 141 </conditional> | |
| 142 <expand macro="inputs_common_advanced" /> | |
| 143 </inputs> | |
| 144 <outputs> | |
| 145 <expand macro="muon_outputs"/> | |
| 146 </outputs> | |
| 147 <tests> | |
| 148 <test expect_num_outputs="2"> | |
| 149 <!-- test1: intersect_obs --> | |
| 150 <param name="mdata" ftype="h5ad" location="https://zenodo.org/records/12570984/files/pbmc3k_chr21.h5mu"/> | |
| 151 <param name="method" value="pp.intersect_obs"/> | |
| 152 <section name="advanced_common"> | |
| 153 <param name="show_log" value="true" /> | |
| 154 </section> | |
| 155 <output name="hidden_output"> | |
| 156 <assert_contents> | |
| 157 <has_text_matching expression="mu.pp.intersect_obs"/> | |
| 158 </assert_contents> | |
| 159 </output> | |
| 160 <assert_stdout> | |
| 161 <has_text_matching expression="179 × 490"/> | |
| 162 <has_text_matching expression="179 x 178"/> | |
| 163 <has_text_matching expression="179 x 312"/> | |
| 164 </assert_stdout> | |
| 165 <output name="mudata_out" ftype="h5ad"> | |
| 166 <assert_contents> | |
| 167 <has_h5_keys keys="mod/rna"/> | |
| 168 <has_h5_keys keys="mod/atac"/> | |
| 169 </assert_contents> | |
| 170 </output> | |
| 171 </test> | |
| 172 <test expect_num_outputs="2"> | |
| 173 <!-- test2: l2norm --> | |
| 174 <param name="mdata" ftype="h5ad" location="https://zenodo.org/records/12570984/files/pbmc3k_chr21.h5mu"/> | |
| 175 <param name="method" value="pp.l2norm"/> | |
| 176 <param name="n_pcs" value="5"/> | |
| 177 <section name="advanced_common"> | |
| 178 <param name="show_log" value="true" /> | |
| 179 </section> | |
| 180 <output name="hidden_output"> | |
| 181 <assert_contents> | |
| 182 <has_text_matching expression="mu.pp.l2norm"/> | |
| 183 <has_text_matching expression="copy=False"/> | |
| 184 <has_text_matching expression="n_pcs=5"/> | |
| 185 </assert_contents> | |
| 186 </output> | |
| 187 <assert_stdout> | |
| 188 <has_text_matching expression="179 × 490"/> | |
| 189 <has_text_matching expression="179 x 178"/> | |
| 190 <has_text_matching expression="179 x 312"/> | |
| 191 </assert_stdout> | |
| 192 <output name="mudata_out" ftype="h5ad"> | |
| 193 <assert_contents> | |
| 194 <has_h5_keys keys="mod/rna"/> | |
| 195 <has_h5_keys keys="mod/atac"/> | |
| 196 </assert_contents> | |
| 197 </output> | |
| 198 </test> | |
| 199 <test expect_num_outputs="2"> | |
| 200 <!-- test3: neighbors --> | |
| 201 <param name="mdata" ftype="h5ad" location="https://zenodo.org/records/12570984/files/pbmc3k_chr21_pp.neighbors_in.h5mu"/> | |
| 202 <param name="method" value="pp.neighbors"/> | |
| 203 <param name="n_neighbors" value="2"/> | |
| 204 <param name="n_bandwidth_neighbors" value="3"/> | |
| 205 <param name="n_multineighbors" value="5"/> | |
| 206 <conditional name="n_keys"> | |
| 207 <param name="type" value="separate"/> | |
| 208 <repeat name="modalities"> | |
| 209 <param name="mod_name" value="rna"/> | |
| 210 <param name="neighbor_keys" value="neighbors"/> | |
| 211 </repeat> | |
| 212 <repeat name="modalities"> | |
| 213 <param name="mod_name" value="atac"/> | |
| 214 <param name="neighbor_keys" value="neighbors"/> | |
| 215 </repeat> | |
| 216 </conditional> | |
| 217 <section name="advanced_common"> | |
| 218 <param name="show_log" value="true" /> | |
| 219 </section> | |
| 220 <output name="hidden_output"> | |
| 221 <assert_contents> | |
| 222 <has_text_matching expression="mu.pp.neighbors"/> | |
| 223 <has_text_matching expression="copy=False"/> | |
| 224 <has_text_matching expression="n_neighbors=2"/> | |
| 225 <has_text_matching expression="n_bandwidth_neighbors=3"/> | |
| 226 <has_text_matching expression="n_multineighbors=5"/> | |
| 227 <has_text_matching expression="metric='euclidean'"/> | |
| 228 <has_text_matching expression="weight_key='mod_weight'"/> | |
| 229 <has_text_matching expression="add_weights_to_modalities=False"/> | |
| 230 <has_text_matching expression="eps=0.0001"/> | |
| 231 <has_text_matching expression="random_state=42"/> | |
| 232 </assert_contents> | |
| 233 </output> | |
| 234 <assert_stdout> | |
| 235 <has_text_matching expression="2711 × 1781"/> | |
| 236 <has_text_matching expression="2711 x 555"/> | |
| 237 <has_text_matching expression="2711 x 1226"/> | |
| 238 </assert_stdout> | |
| 239 <output name="mudata_out" ftype="h5ad"> | |
| 240 <assert_contents> | |
| 241 <has_h5_keys keys="mod/rna"/> | |
| 242 <has_h5_keys keys="mod/atac"/> | |
| 243 </assert_contents> | |
| 244 </output> | |
| 245 </test> | |
| 246 <test expect_num_outputs="2"> | |
| 247 <!-- test4: sample_obs --> | |
| 248 <param name="mdata" ftype="h5ad" location="https://zenodo.org/records/12570984/files/pbmc3k_chr21.h5mu"/> | |
| 249 <param name="method" value="pp.sample_obs"/> | |
| 250 <param name="frac" value="0.5"/> | |
| 251 <param name="min_n" value="10"/> | |
| 252 <section name="advanced_common"> | |
| 253 <param name="show_log" value="true" /> | |
| 254 </section> | |
| 255 <output name="hidden_output"> | |
| 256 <assert_contents> | |
| 257 <has_text_matching expression="mu.pp.sample_obs"/> | |
| 258 <has_text_matching expression="frac=0.5"/> | |
| 259 <has_text_matching expression="min_n=10"/> | |
| 260 </assert_contents> | |
| 261 </output> | |
| 262 <assert_stdout> | |
| 263 <has_text_matching expression="179 × 490"/> | |
| 264 <has_text_matching expression="179 x 178"/> | |
| 265 <has_text_matching expression="179 x 312"/> | |
| 266 </assert_stdout> | |
| 267 <output name="mudata_out" ftype="h5ad"> | |
| 268 <assert_contents> | |
| 269 <has_h5_keys keys="mod/rna"/> | |
| 270 <has_h5_keys keys="mod/atac"/> | |
| 271 </assert_contents> | |
| 272 </output> | |
| 273 </test> | |
| 274 </tests> | |
| 275 <help><![CDATA[ | |
| 276 Filter: Filter observations (samples or cells) in-place using any column in .obs or in .X ('muon.pp.filter_obs') | |
| 277 ================================================================================================================ | |
| 278 | |
| 279 Filter observations (samples or cells) in-place using any column in .obs or in .X. | |
| 280 | |
| 281 More details on the `muon documentation | |
| 282 <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.filter_obs.html#muon.pp.filter_obs>`__ | |
| 283 | |
| 284 Filter: Filter variables (features) ('muon.pp.filter_var') | |
| 285 ========================================================== | |
| 286 | |
| 287 Filter variables (features, e.g. genes) in-place using any column in .var or row in .X. | |
| 288 | |
| 289 More details on the `muon documentation | |
| 290 <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.filter_var.html#muon.pp.filter_var>`__ | |
| 291 | |
| 292 Subset: Subset observations (samples or cells) in-place taking observations present only in all modalities ('muon.pp.intersect_obs') | |
| 293 ==================================================================================================================================== | |
| 294 | |
| 295 Subset observations (samples or cells) in-place taking observations present only in all modalities. | |
| 296 | |
| 297 More details on the `muon documentation | |
| 298 <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.intersect_obs.html#muon.pp.intersect_obs>`__ | |
| 299 | |
| 300 Normalize: Normalize observations to unit L2 norm ('muon.pp.l2norm') | |
| 301 ==================================================================== | |
| 302 | |
| 303 Normalize observations to unit L2 norm. | |
| 304 | |
| 305 More details on the `muon documentation | |
| 306 <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.l2norm.html#muon.pp.l2norm>`__ | |
| 307 | |
| 308 Search: Multimodal nearest neighbor search ('muon.pp.neighbors') | |
| 309 ================================================================ | |
| 310 | |
| 311 Multimodal nearest neighbor search by implementing the multimodal nearest neighbor method of Hao et al. and Swanson et al. | |
| 312 The neighbor search efficiency on this heavily relies on UMAP. In particular, you may want to decrease | |
| 313 n_multineighbors for large data set to avoid excessive peak memory use. To achieve results as close as possible | |
| 314 to the Seurat implementation, observations must be normalized to unit L2 norm prior to running per-modality | |
| 315 nearest-neighbor search. | |
| 316 | |
| 317 More details on the `muon documentation | |
| 318 <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.neighbors.html#muon.pp.neighbors>`__ | |
| 319 | |
| 320 ]]></help> | |
| 321 <expand macro="citations"/> | |
| 322 </tool> |
