Previous changeset 8:d868221262d5 (2020-06-05) Next changeset 10:54f1212d26ac (2020-06-11) |
Commit message:
"planemo upload for repository https://github.com/ebi-gene-expression-group/container-galaxy-sc-tertiary/tree/develop/tools/tertiary-analysis/scanpy commit bcab272f6785d5967b1ec68acf5390ec3ace49fd" |
modified:
anndata_operations.xml |
b |
diff -r d868221262d5 -r b8eb50bd397c anndata_operations.xml --- a/anndata_operations.xml Fri Jun 05 09:11:44 2020 -0400 +++ b/anndata_operations.xml Mon Jun 08 05:08:44 2020 -0400 |
[ |
@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<tool id="anndata_ops" name="AnnData Operations" version="0.0.1+galaxy2" profile="@PROFILE@"> +<tool id="anndata_ops" name="AnnData Operations" version="0.0.2+galaxy0" profile="@PROFILE@"> <description>modifies metadata and flags genes</description> <macros> <import>scanpy_macros2.xml</import> @@ -7,11 +7,25 @@ <expand macro="requirements"/> <command detect_errors="exit_code"><![CDATA[ ln -s '${input_obj_file}' input.h5 && + +#if $copy_o.default: +#for $i, $os in enumerate($copy_o.obs_sources): + ln -s '${os}' obs_source_${i}.h5 && +#end for +#end if + +#if $copy_e.default: +#for $i, $es in enumerate($copy_e.embedding_sources): + ln -s '${es}' embedding_source_${i}.h5 && +#end for +#end if python $operations ]]></command> <configfiles> <configfile name="operations"> import scanpy as sc +import anndata +from numpy import all import logging adata = sc.read('input.h5') @@ -34,6 +48,42 @@ logging.warning('No genes starting with {} found, skip calculating expression of {} genes'.format('${flag.startswith}', '${flag.flag}')) #end for +#if $copy_o.default and len($copy_o.obs_keys) > 0: +#for $i, $obs_s in enumerate($copy_o.obs_sources): +ad_s = sc.read('obs_source_${i}.h5') +if adata.n_obs == ad_s.n_obs and all(adata.obs_names == ad_s.obs_names): + #for $j, $o_key in enumerate($copy_o.obs_keys): + keys_to_copy = (k for k in ad_s.obs.keys() if "${o_key.contains}" in k) + for k_to_copy in keys_to_copy: + adata.obs[[k_to_copy+"_${i}"]] = ad_s.obs[[k_to_copy]] + if k_to_copy in ad_s.uns.keys(): + adata.uns[k_to_copy+"_${i}"] = ad_s.uns[k_to_copy] + #end for +else: + logging.warning("Observation source ${i} AnnData file is not compatible to be merged to main AnnData file, different cell names.") +#end for +#end if + + +#if $copy_e.default and len($copy_e.embedding_keys) > 0: +#for $i, $obs_s in enumerate($copy_e.embedding_sources): +ad_s = sc.read('embedding_source_${i}.h5') +if adata.n_obs == ad_s.n_obs and all(adata.obs_names == ad_s.obs_names): + #for $j, $e_key in enumerate($copy_e.embedding_keys): + keys_to_copy = (k for k in ad_s.obsm.keys() if "${e_key.contains}" in k) + for k_to_copy in keys_to_copy: + adata.obsm[k_to_copy+"_${i}"] = ad_s.obsm[k_to_copy] + #end for +else: + logging.warning("Embedding source ${i} AnnData file is not compatible to be merged to main AnnData file, different cell names.") +#end for +#end if + +#if $sanitize_varm: +if hasattr(adata, 'raw') and hasattr(adata.raw, 'X') and hasattr(adata.raw, 'var'): + new_ad = anndata.AnnData(X=adata.raw.X, obs=adata.obs, var=adata.raw.var) + adata.raw = new_ad +#end if if len(qc_vars) > 0: pct_top = [${top_genes}] @@ -69,6 +119,29 @@ <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."/> </repeat> <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"/> + <conditional name="copy_o"> + <param name="default" type="boolean" checked="false" label="Copy observations (such as clusters)"/> + <when value="true"> + <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"> + <param name="contains" type="text" label="Key contains" help="Keys to be copied need to contain the text set here."/> + </repeat> + <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"/> + <!-- <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"/> --> + </when> + <when value="false"/> + </conditional> + <conditional name="copy_e"> + <param name="default" type="boolean" checked="false" label="Copy embeddings (such as UMAP, tSNE)"/> + <when value="true"> + <repeat name="embedding_keys" title="Keys from embeddings to copy" help="will copy all embedding 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 tSNE, UMAP, etc." min="1"> + <param name="contains" type="text" label="Key contains" help="Keys to be copied need to contain the text set here."/> + </repeat> + <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"/> + <!-- <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"/> --> + </when> + <when value="false"/> + </conditional> + <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."/> </inputs> <outputs> |