Skip to content

Commit

Permalink
bivariate: clean code; yaml: change defaults: spearman
Browse files Browse the repository at this point in the history
  • Loading branch information
johaGL committed Mar 21, 2024
1 parent 764c65f commit ab9722a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/dimet/config/analysis/method/bivariate_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ name: Computation of the correlation of MDV profiles, or the metabolite time cou
# (**) : automatically will run

conditions_MDV_comparison: # (**) if >= 2 conditions and >=1 timepoint (timepoints run separately)
isotopologue_proportions: pearson
isotopologue_proportions: spearman

timepoints_MDV_comparison: # (**) if >= 1 condition and >=2 timepoints
isotopologue_proportions: pearson
isotopologue_proportions: spearman

conditions_metabolite_time_profiles: # (**) if >= 2 conditions AND >=2 time points in data
abundances: pearson
mean_enrichment: pearson
abundances: spearman
mean_enrichment: spearman

# test modification doable with external config 'statistical_test'
# test modification accessible through external config 'statistical_test'

correction_method: fdr_bh

Expand Down
10 changes: 9 additions & 1 deletion src/dimet/method/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
import sys
from typing import Union
from typing import Dict, Union

import hydra
from omegaconf import DictConfig, ListConfig, OmegaConf, open_dict
Expand Down Expand Up @@ -191,6 +191,14 @@ class BivariateAnalysisConfig(MethodConfig):
"""
correction_method: str = "fdr_bh"
output_include_gmean_arr_columns: bool = True
conditions_MDV_comparison: Dict[str, str] = {
'isotopologue_proportions': 'spearman'}
timepoints_MDV_comparison: Dict[str, str] = {
'isotopologue_proportions': 'spearman'}
conditions_metabolite_time_profiles: Dict[str, str] = {
'abundances': 'spearman',
'mean_enrichment': 'spearman'
}

def build(self) -> "BivariateAnalysis":
return BivariateAnalysis(config=self)
Expand Down
4 changes: 2 additions & 2 deletions src/dimet/processing/bivariate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def compute_statistical_correlation(df: pd.DataFrame,
stat_list = []
pvalue_list = []
for i, metabolite in enumerate(list(df['metabolite'])):
# array of n-(timepoints or m+x) geometrical means values
# array of n (timepoints or m+x) geometrical means values
array_1 = df.loc[metabolite, "gmean_arr_1"]
array_2 = df.loc[metabolite, "gmean_arr_2"]
if test == "pearson":
Expand Down Expand Up @@ -79,7 +79,7 @@ def compute_bivariate_by_behavior(
"""
performs two steps:
1. calls functions to compute geometric means, obtaining df's inside dict
2. computes the bivariate statistical test (pearson by default)
2. computes the bivariate statistical test
"""
if behavior == "conditions_MDV_comparison":
df_dict = conditions_MDV_gmean_df_dict(df, metadata_df, comparison)
Expand Down

0 comments on commit ab9722a

Please sign in to comment.