Commit 9468f249 authored by Theo Serralta's avatar Theo Serralta

Wrong variable in compute_mean_std

parent 09497ec1
......@@ -445,7 +445,7 @@ def dico_mappabilite(mappability_file):
end_time_3 = time.time()
elapsed_time_3 = end_time_3 - start_time_3
logging.info(f"In dico_mappability : Ending merge intervals with the same score (Time taken: {elapsed_time_2:.4f} seconds)")
logging.info(f"In dico_mappability : Ending merge intervals with the same score (Time taken: {elapsed_time_3:.4f} seconds)")
end_time = time.time()
elapsed_time = end_time - start_time
......@@ -680,8 +680,7 @@ def calcul_med_same_gc(gc_results, depth_correction_results, chr):
"""
Calculate the median depth correction for each unique GC content value.
This function computes the median depth correction values for each unique GC content value in `gc_results`,
filtering out zero values from `depth_correction_results`.
This function computes the median depth correction values for each unique GC content value, filtering out zero values.
Parameters
----------
......@@ -689,8 +688,6 @@ def calcul_med_same_gc(gc_results, depth_correction_results, chr):
A list or array of GC content values.
depth_correction_results : list or numpy.ndarray
A list or array of depth correction values.
chr : str
The chromosome identifier for which the medians are calculated.
Returns
-------
......@@ -735,15 +732,12 @@ def calcul_moy_totale(normalize_depth_results, chr):
"""
Calculate the mean of non-zero normalized depth results.
This function filters out zero values from the normalized depth results and computes the mean
of the remaining non-zero values.
This function filters out zero values from the normalized depth results and computes the mean of the remaining values.
Parameters
----------
normalize_depth_results : list or numpy.ndarray
A list or array of normalized depth values.
chr : str
The chromosome identifier for which the mean is calculated.
Returns
-------
......@@ -757,15 +751,15 @@ def calcul_moy_totale(normalize_depth_results, chr):
# Filter results to remove zero values
non_zero_results = normalize_depth_results[normalize_depth_results != 0]
# Calculate the mean of non-zero results
mean_chr = np.mean(non_zero_results) if non_zero_results.size > 0 else 0
mean_chr_norm = np.mean(non_zero_results) if non_zero_results.size > 0 else 0
sys.stderr.write("Chromosome : %s, mean_chr : %s\n" % (chr, mean_chr))
logging.info(f"Mean chr_norm_no_zero = {mean_chr_norm}")
end_time = time.time()
elapsed_time = end_time - start_time
logging.info(f"Leaving calcul_moy_totale for {chr} (Time taken: {elapsed_time:.4f} seconds)")
return mean_chr
return mean_chr_norm
def calcul_std(normalize_depth_results, chr):
"""
......@@ -805,7 +799,7 @@ def calcul_std(normalize_depth_results, chr):
return std_chr
def compute_mean_std_med(ratio_par_window_results, chr):
def compute_mean_std_med(ratio_par_window_norm_results, chr, normalize_depth_results):
"""
Compute the mean, standard deviation, and median of non-zero ratio results per window.
......@@ -814,7 +808,7 @@ def compute_mean_std_med(ratio_par_window_results, chr):
Parameters
----------
ratio_par_window_results : list or numpy.ndarray
ratio_par_window_norm_results : list or numpy.ndarray
A list or array of ratio values per window.
chr : str
The chromosome identifier for which the statistics are calculated.
......@@ -829,8 +823,9 @@ def compute_mean_std_med(ratio_par_window_results, chr):
start_time = time.time()
# Filter results to remove zero and -1 values
ratio_par_window_results = np.array(ratio_par_window_results)
non_zero_results = ratio_par_window_results[ratio_par_window_results != 0]
ratio_par_window_norm_results = np.array(ratio_par_window_norm_results)
non_zero_results = ratio_par_window_norm_results[ratio_par_window_norm_results != 0]
non_zero_results = non_zero_results[np.isfinite(non_zero_results)]
# Initialize list for stats computation
table = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment