Skip to content

v0.2-alpha

Choose a tag to compare

@sr320 sr320 released this 16 Aug 23:44
· 31 commits to main since this release

Addressed following bugs

  1. Context mask uses features, not samples (incorrect sample selection)

    • Problem: In _analyze_context_network_parallel, context is computed from mirna_means (indexed by miRNA features) and then applied to samples via i % len(context_mask). This mismatches axes and yields quasi-random sample subsets.
    • Fix (choose a per-sample context variable):
      a) Sentinel miRNA approach:
      • Pick a biologically relevant miRNA (or set) and compute z-scores per SAMPLE; define high/low based on quantiles or thresholds.
        b) Module score approach:
      • Compute the first PC (eigengene) of a selected miRNA module per SAMPLE; use quantile thresholds (e.g., top/bottom 33%).
        c) Metadata context:
      • If context is time/treatment, use metadata columns directly for stratification.
    • Concrete patch (sentinel miRNA example):
      mi = self.datasets['mirna'].index[0] # or a chosen miRNA
      z = StandardScaler().fit_transform(self.datasets['mirna'].loc[mi].values.reshape(-1,1)).ravel()
      if threshold > 0:
      sample_mask = z > threshold
      else:
      sample_mask = z < threshold
      context_samples = list(self.datasets['gene'].columns[sample_mask])
  2. “High methylation” context not implemented

    • Problem: contexts_to_analyze includes 'high_methylation' but mask is derived only from miRNAs.
    • Fix: Define a methylation-based per-sample score (sentinel CpG, module PC, or mean across a CpG set) and build the mask analogously to the miRNA case.
  3. In-sample R^2 used to declare significance of interaction

    • Problem: Using training R^2 improvements (threshold 0.1) inflates false positives.
    • Fix: Use nested F-tests (statsmodels anova_lm) between models (with vs without interaction) OR K-fold CV to compare out-of-sample R^2 (prefer adjusted R^2 or CV-R^2). Control FDR across all interaction tests.
  4. NaN handling in context direction

    • Problem: 'positive'/'negative' is assigned even when corr_high or corr_low is NaN.
    • Fix: If any is NaN, set context_direction='NA' and context_strength=NaN.
  5. Unused/incorrect precomputations and reporting

    • Problem: Huge sample correlation matrices are computed but unused; MD report labels "samples × features" reversed.
    • Fix: Remove the correlation matrix precompute; in the report print: f"{data.shape[1]} samples × {data.shape[0]} features".

Full Changelog: v0.1...v0.2