changeset 15:c09d61ede252 draft

"planemo upload for repository https://github.com/ebi-gene-expression-group/container-galaxy-sc-tertiary/tree/develop/tools/tertiary-analysis/scanpy commit 044580b6bfcd36a5c1cb9e70b40045eb8f71b7e2-dirty"
author ebi-gxa
date Wed, 30 Sep 2020 15:34:21 +0000
parents a4ad76e3dc4a
children 004cd2ccf7fc
files anndata_operations.xml
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/anndata_operations.xml	Fri Sep 11 11:04:39 2020 +0000
+++ b/anndata_operations.xml	Wed Sep 30 15:34:21 2020 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<tool id="anndata_ops" name="AnnData Operations" version="@TOOL_VERSION@+galaxy0" profile="@PROFILE@">
+<tool id="anndata_ops" name="AnnData Operations" version="@TOOL_VERSION@+galaxy1" profile="@PROFILE@">
   <description>modifies metadata and flags genes</description>
   <macros>
     <import>scanpy_macros2.xml</import>
@@ -68,9 +68,13 @@
   #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]]
+    suffix=''
+    if k_to_copy in adata.obs:
+        suffix = "_${i}" 
+    
+    adata.obs[[k_to_copy+suffix]] = 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]
+      adata.uns[k_to_copy+suffix] = 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.")
@@ -85,7 +89,10 @@
   #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]
+    suffix = ''
+    if k_to_copy in adata.obsm:
+        suffix = "_${i}"
+    adata.obsm[k_to_copy+suffix] = 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.")
@@ -99,7 +106,10 @@
   #for $j, $u_key in enumerate($copy_u.uns_keys):
   keys_to_copy = (k for k in ad_s.uns.keys() if "${u_key.contains}" in k)
   for k_to_copy in keys_to_copy:
-    adata.uns[k_to_copy+"_${i}"] = ad_s.uns[k_to_copy]
+    suffix=''
+    if k_to_copy in adata.uns:
+        suffix="_${i}"
+    adata.uns[k_to_copy+suffix] = ad_s.uns[k_to_copy]
   #end for
 else:
   logging.warning("Uns source ${i} AnnData file is not compatible to be merged to main AnnData file, different cell names.")