Skip to content

Commit

Permalink
black linting
Browse files Browse the repository at this point in the history
  • Loading branch information
saramonzon committed May 1, 2024
1 parent 5edcc6d commit b47351c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion assets/mash_blast_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def mantel_tester(blast_paths, mash_paths, pval=0.01):
plt.suptitle("") # Elimina el título por defecto
plt.xlabel("Dataset") # Etiqueta para el eje x
plt.ylabel("Mantel correlation value") # Etiqueta para el eje y
ax.set_xticklabels([ticklabel.get_text().capitalize() for ticklabel in ax.get_xticklabels()])
ax.set_xticklabels(
[ticklabel.get_text().capitalize() for ticklabel in ax.get_xticklabels()]
)

# Guarda el boxplot como PNG
plt.savefig(
Expand Down
16 changes: 10 additions & 6 deletions taranis/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ def create_matrix(self, mask_values: list) -> pd.DataFrame:
pd.DataFrame: Hamming distance matrix as panda DataFrame
"""
# Mask unwanted values directly in the DataFrame
regex_pattern = '|'.join([f".*{value}.*" for value in mask_values])
regex_pattern = "|".join([f".*{value}.*" for value in mask_values])
self.allele_matrix.replace(regex_pattern, np.nan, regex=True, inplace=True)

# Get unique values excluding NaN
unique_values = pd.unique(
self.allele_matrix.values.ravel("K")
)
unique_values = unique_values[~pd.isna(unique_values)] # Exclude NaNs from unique values
unique_values = pd.unique(self.allele_matrix.values.ravel("K"))
unique_values = unique_values[
~pd.isna(unique_values)
] # Exclude NaNs from unique values

# Create binary matrix ('1' or '0' ) matching the input matrix vs the unique_values[0]
# astype(int) is used to transform the boolean matrix into integer
Expand All @@ -141,4 +141,8 @@ def create_matrix(self, mask_values: list) -> pd.DataFrame:
pairwise_valid_counts = pairwise_valid.sum(axis=2)
distance_matrix = pairwise_valid_counts - H

return pd.DataFrame(distance_matrix, index=self.allele_matrix.index, columns=self.allele_matrix.index)
return pd.DataFrame(
distance_matrix,
index=self.allele_matrix.index,
columns=self.allele_matrix.index,
)
2 changes: 1 addition & 1 deletion taranis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def filter_df(
row_thr /= 100

# Identify filter values and create a mask for the DataFrame
regex_pattern = '|'.join(filter_values) # This creates 'ASM|LNF|EXC'
regex_pattern = "|".join(filter_values) # This creates 'ASM|LNF|EXC'

# Apply regex across the DataFrame to create a mask
mask = df.applymap(lambda x: bool(re.search(regex_pattern, str(x))))
Expand Down

0 comments on commit b47351c

Please sign in to comment.