Skip to content

Commit

Permalink
refact: Change genome to genome_id
Browse files Browse the repository at this point in the history
  • Loading branch information
jvfe committed Jul 24, 2024
1 parent 1964e89 commit 136ada0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/Build_Upset.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def process_data(samplesheet_df, feature_df, column_name):
Returns:
pd.DataFrame: Transposed presence/absence dataframe with groups column.
"""
merged_df = feature_df.merge(samplesheet_df, on='genome', how='left')
merged_df = feature_df.merge(samplesheet_df, left_on='genome_id', right_on='sample', how='left')

if column_name not in merged_df.columns:
print(f"Warning: Column '{column_name}' not found in samplesheet. Skipping.")
Expand All @@ -56,10 +56,10 @@ def process_data(samplesheet_df, feature_df, column_name):
print(f"Warning: Column '{column_name}' contains only a single unique value. Skipping.")
return None

selected_columns = ['genome', column_name] + list(feature_df.columns[1:])
selected_columns = ['genome_id', column_name] + list(feature_df.columns[1:])
feature_df = merged_df[selected_columns]
presence = feature_df.groupby(column_name).any().astype(int)
presence.drop('genome', axis=1, inplace=True, errors='ignore')
presence.drop('genome_id', axis=1, inplace=True, errors='ignore')
presence_transposed = presence.transpose()
presence_transposed.reset_index(inplace=True)
presence_transposed.rename(columns={'index': 'feature'}, inplace=True)
Expand Down

0 comments on commit 136ada0

Please sign in to comment.