diff --git a/assets/mash_blast_correlation.py b/assets/mash_blast_correlation.py index 8663805..a6e7485 100644 --- a/assets/mash_blast_correlation.py +++ b/assets/mash_blast_correlation.py @@ -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( diff --git a/taranis/distance.py b/taranis/distance.py index 87c3b31..b42ee34 100644 --- a/taranis/distance.py +++ b/taranis/distance.py @@ -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 @@ -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, + ) diff --git a/taranis/utils.py b/taranis/utils.py index 0875833..77f6748 100644 --- a/taranis/utils.py +++ b/taranis/utils.py @@ -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))))