Mercurial > repos > bimib > cobraxy
comparison COBRAxy/marea.py @ 293:7b8d9de81a86 draft
Uploaded
| author | francesco_lapi | 
|---|---|
| date | Thu, 15 May 2025 18:23:52 +0000 | 
| parents | 7f3e66dd46fa | 
| children | 1402c2beb8f2 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 292:31bc171a6ba5 | 293:7b8d9de81a86 | 
|---|---|
| 48 parser.add_argument( | 48 parser.add_argument( | 
| 49 '-co', '--comparison', | 49 '-co', '--comparison', | 
| 50 type = str, | 50 type = str, | 
| 51 default = 'manyvsmany', | 51 default = 'manyvsmany', | 
| 52 choices = ['manyvsmany', 'onevsrest', 'onevsmany']) | 52 choices = ['manyvsmany', 'onevsrest', 'onevsmany']) | 
| 53 | |
| 54 parser.add_argument( | |
| 55 '-te' ,'--test', | |
| 56 type = str, | |
| 57 default = 'ks', | |
| 58 choices = ['ks', 'ttest_p', 'ttest_ind', 'wilcoxon', 'mw'], | |
| 59 help = 'Statistical test to use (default: %(default)s)') | |
| 53 | 60 | 
| 54 parser.add_argument( | 61 parser.add_argument( | 
| 55 '-pv' ,'--pValue', | 62 '-pv' ,'--pValue', | 
| 56 type = float, | 63 type = float, | 
| 57 default = 0.1, | 64 default = 0.1, | 
| 501 if abs(foldChange) < (ARGS.fChange - 1) / (abs(ARGS.fChange) + 1): | 508 if abs(foldChange) < (ARGS.fChange - 1) / (abs(ARGS.fChange) + 1): | 
| 502 INVALID_ARROW.styleReactionElements(metabMap, reactionId) | 509 INVALID_ARROW.styleReactionElements(metabMap, reactionId) | 
| 503 continue | 510 continue | 
| 504 | 511 | 
| 505 width = Arrow.MAX_W | 512 width = Arrow.MAX_W | 
| 506 if not math.isinf(foldChange): | 513 if not math.isinf(z_score): | 
| 507 try: width = min( | 514 try: width = min( | 
| 508 max(abs(z_score * Arrow.MAX_W) / maxNumericZScore, Arrow.MIN_W), | 515 max(abs(z_score * Arrow.MAX_W) / maxNumericZScore, Arrow.MIN_W), | 
| 509 Arrow.MAX_W) | 516 Arrow.MAX_W) | 
| 510 | 517 | 
| 511 except ZeroDivisionError: pass | 518 except ZeroDivisionError: pass | 
| 688 dataset1Data : data from the 1st dataset. | 695 dataset1Data : data from the 1st dataset. | 
| 689 dataset2Data : data from the 2nd dataset. | 696 dataset2Data : data from the 2nd dataset. | 
| 690 | 697 | 
| 691 Returns: | 698 Returns: | 
| 692 tuple: (P-value, Z-score) | 699 tuple: (P-value, Z-score) | 
| 693 - P-value from a Kolmogorov-Smirnov test on the provided data. | 700 - P-value from the selected test on the provided data. | 
| 694 - Z-score of the difference between means of the two datasets. | 701 - Z-score of the difference between means of the two datasets. | 
| 695 """ | 702 """ | 
| 696 # Perform Kolmogorov-Smirnov test | 703 match ARGS.test: | 
| 697 ks_statistic, p_value = st.ks_2samp(dataset1Data, dataset2Data) | 704 case "ks": | 
| 705 # Perform Kolmogorov-Smirnov test | |
| 706 _, p_value = st.ks_2samp(dataset1Data, dataset2Data) | |
| 707 case "ttest_p": | |
| 708 # Perform t-test for paired samples | |
| 709 _, p_value = st.ttest_rel(dataset1Data, dataset2Data) | |
| 710 case "ttest_ind": | |
| 711 # Perform t-test for independent samples | |
| 712 _, p_value = st.ttest_ind(dataset1Data, dataset2Data) | |
| 713 case "wilcoxon": | |
| 714 # Perform Wilcoxon signed-rank test | |
| 715 _, p_value = st.wilcoxon(dataset1Data, dataset2Data) | |
| 716 case "mw": | |
| 717 # Perform Mann-Whitney U test | |
| 718 _, p_value = st.mannwhitneyu(dataset1Data, dataset2Data) | |
| 698 | 719 | 
| 699 # Calculate means and standard deviations | 720 # Calculate means and standard deviations | 
| 700 mean1 = np.mean(dataset1Data) | 721 mean1 = np.mean(dataset1Data) | 
| 701 mean2 = np.mean(dataset2Data) | 722 mean2 = np.mean(dataset2Data) | 
| 702 std1 = np.std(dataset1Data, ddof=1) | 723 std1 = np.std(dataset1Data, ddof=1) | 
