Mercurial > repos > bimib > cobraxy
comparison COBRAxy/flux_to_map.py @ 242:c6d78b0d324d draft
Uploaded
author | francesco_lapi |
---|---|
date | Wed, 15 Jan 2025 10:32:09 +0000 |
parents | 049aa0f4844f |
children | 5aaf15260ca6 |
comparison
equal
deleted
inserted
replaced
241:049aa0f4844f | 242:c6d78b0d324d |
---|---|
696 """ | 696 """ |
697 # Perform Kolmogorov-Smirnov test | 697 # Perform Kolmogorov-Smirnov test |
698 ks_statistic, p_value = st.ks_2samp(dataset1Data, dataset2Data) | 698 ks_statistic, p_value = st.ks_2samp(dataset1Data, dataset2Data) |
699 | 699 |
700 # Calculate means and standard deviations | 700 # Calculate means and standard deviations |
701 mean1 = np.mean(dataset1Data) | 701 mean1 = np.nanmean(dataset1Data) |
702 mean2 = np.mean(dataset2Data) | 702 mean2 = np.nanmean(dataset2Data) |
703 std1 = np.std(dataset1Data, ddof=1) | 703 std1 = np.std(dataset1Data, ddof=1) |
704 std2 = np.std(dataset2Data, ddof=1) | 704 std2 = np.std(dataset2Data, ddof=1) |
705 | 705 |
706 n1 = len(dataset1Data) | 706 n1 = len(dataset1Data) |
707 n2 = len(dataset2Data) | 707 n2 = len(dataset2Data) |
956 # Create copies only if they are needed | 956 # Create copies only if they are needed |
957 metabMap_mean = copy.deepcopy(metabMap) | 957 metabMap_mean = copy.deepcopy(metabMap) |
958 metabMap_median = copy.deepcopy(metabMap) | 958 metabMap_median = copy.deepcopy(metabMap) |
959 | 959 |
960 # Compute medians and means | 960 # Compute medians and means |
961 medians = {key: np.round(np.median(np.array(value), axis=1), 6) for key, value in class_pat.items()} | 961 medians = {key: np.round(np.nanmedian(np.array(value), axis=1), 6) for key, value in class_pat.items()} |
962 means = {key: np.round(np.mean(np.array(value), axis=1),6) for key, value in class_pat.items()} | 962 means = {key: np.round(np.nanmean(np.array(value), axis=1),6) for key, value in class_pat.items()} |
963 | 963 |
964 # Normalize medians and means | 964 # Normalize medians and means |
965 max_flux_medians = max(np.max(np.abs(arr)) for arr in medians.values()) | 965 max_flux_medians = max(np.max(np.abs(arr)) for arr in medians.values()) |
966 max_flux_means = max(np.max(np.abs(arr)) for arr in means.values()) | 966 max_flux_means = max(np.max(np.abs(arr)) for arr in means.values()) |
967 | 967 |