about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2025-09-06 14:20:18 +0100
committerArun Isaac2025-09-06 14:20:18 +0100
commit3ac9f93122a1987da82b1d1a730715768eaf386e (patch)
tree81eb2f47b383894403591387f6f12ba6d4f055c5
parente4b2baaac813757585e5027b26f23b39c1b24070 (diff)
downloadpyhegp-3ac9f93122a1987da82b1d1a730715768eaf386e.tar.gz
pyhegp-3ac9f93122a1987da82b1d1a730715768eaf386e.tar.lz
pyhegp-3ac9f93122a1987da82b1d1a730715768eaf386e.zip
Roll cat_data_frames into cat_genotype.
cat_data_frames is no longer a special function used by both
cat_genotype and cat_phenotype. Specialize it and roll it into
cat_genotype.
-rw-r--r--pyhegp/pyhegp.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/pyhegp/pyhegp.py b/pyhegp/pyhegp.py
index e93c62f..3598931 100644
--- a/pyhegp/pyhegp.py
+++ b/pyhegp/pyhegp.py
@@ -124,12 +124,12 @@ def encrypt_phenotype(phenotype, key):
                                    columns=sample_names)),
                      axis="columns")
 
-def cat_data_frames(frames, metadata_columns):
-    def cat2(df1, df2):
-        return pd.merge(df1, df2, how="inner", on=metadata_columns)
-    return reduce(cat2, frames)
-
 def cat_genotype(genotypes):
+    def cat2(df1, df2):
+        return pd.merge(df1, df2,
+                        how="inner",
+                        on=list(filter(is_genotype_metadata_column,
+                                       df1.columns)))
     match genotypes:
         # If there are no input data frames, return an empty data
         # frame with the chromosome and position columns.
@@ -140,9 +140,7 @@ def cat_genotype(genotypes):
             genotype.position = genotype.position.astype("int")
             return genotype
         case _:
-            return cat_data_frames(genotypes,
-                                   list(filter(is_genotype_metadata_column,
-                                               genotypes[0].columns)))
+            return reduce(cat2, genotypes)
 
 def cat_phenotype(phenotypes):
     match phenotypes: