Skip to content

Commit

Permalink
Deploying to gh-pages from @ 218e35b 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ielis committed Nov 21, 2024
1 parent 7818fb6 commit 88c988f
Show file tree
Hide file tree
Showing 19 changed files with 272 additions and 101 deletions.
106 changes: 87 additions & 19 deletions latest/_modules/gpsea/analysis/_base.html

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions latest/_modules/gpsea/analysis/pcats/_impl.html

Large diffs are not rendered by default.

28 changes: 18 additions & 10 deletions latest/_modules/gpsea/analysis/pcats/stats/_stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ <h1>Source code for gpsea.analysis.pcats.stats._stats</h1><div class="highlight"
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>

<span class="kn">import</span> <span class="nn">scipy</span>
<span class="kn">from</span> <span class="nn">scipy.stats</span> <span class="kn">import</span> <span class="n">fisher_exact</span>

<span class="kn">from</span> <span class="nn">..._base</span> <span class="kn">import</span> <span class="n">Statistic</span>
<span class="kn">from</span> <span class="nn">..._base</span> <span class="kn">import</span> <span class="n">Statistic</span><span class="p">,</span> <span class="n">StatisticResult</span>


<div class="viewcode-block" id="CountStatistic">
Expand Down Expand Up @@ -150,7 +150,7 @@ <h1>Source code for gpsea.analysis.pcats.stats._stats</h1><div class="highlight"
<span class="k">def</span> <span class="nf">compute_pval</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">counts</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span><span class="p">:</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">StatisticResult</span><span class="p">:</span>
<span class="k">pass</span></div>


Expand Down Expand Up @@ -190,12 +190,19 @@ <h1>Source code for gpsea.analysis.pcats.stats._stats</h1><div class="highlight"
<span class="k">def</span> <span class="nf">compute_pval</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">counts</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span><span class="p">:</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">StatisticResult</span><span class="p">:</span>
<span class="k">if</span> <span class="n">counts</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">):</span>
<span class="n">_</span><span class="p">,</span> <span class="n">pval</span> <span class="o">=</span> <span class="n">scipy</span><span class="o">.</span><span class="n">stats</span><span class="o">.</span><span class="n">fisher_exact</span><span class="p">(</span><span class="n">counts</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="n">alternative</span><span class="o">=</span><span class="s2">&quot;two-sided&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">pval</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">fisher_exact</span><span class="p">(</span><span class="n">counts</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="n">alternative</span><span class="o">=</span><span class="s2">&quot;two-sided&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">StatisticResult</span><span class="p">(</span>
<span class="n">statistic</span><span class="o">=</span><span class="n">result</span><span class="o">.</span><span class="n">statistic</span><span class="p">,</span>
<span class="n">pval</span><span class="o">=</span><span class="n">result</span><span class="o">.</span><span class="n">pvalue</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">elif</span> <span class="n">counts</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fisher_exact</span><span class="p">(</span><span class="n">counts</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
<span class="n">pval</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fisher_exact</span><span class="p">(</span><span class="n">counts</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
<span class="k">return</span> <span class="n">StatisticResult</span><span class="p">(</span>
<span class="n">statistic</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">pval</span><span class="o">=</span><span class="n">pval</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;Unsupported counts shape </span><span class="si">{</span><span class="n">counts</span><span class="o">.</span><span class="n">shape</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span></div>

Expand Down Expand Up @@ -239,11 +246,12 @@ <h1>Source code for gpsea.analysis.pcats.stats._stats</h1><div class="highlight"
<span class="n">p_0</span> <span class="o">/=</span> <span class="n">Decimal</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">factorial</span><span class="p">(</span><span class="n">table</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]))</span>

<span class="n">p</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_dfs</span><span class="p">(</span><span class="n">mat</span><span class="p">,</span> <span class="n">pos</span><span class="p">,</span> <span class="n">row_sum</span><span class="p">,</span> <span class="n">col_sum</span><span class="p">,</span> <span class="n">p_0</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
<span class="n">FisherExactTest</span><span class="o">.</span><span class="n">_dfs</span><span class="p">(</span><span class="n">mat</span><span class="p">,</span> <span class="n">pos</span><span class="p">,</span> <span class="n">row_sum</span><span class="p">,</span> <span class="n">col_sum</span><span class="p">,</span> <span class="n">p_0</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>

<span class="k">return</span> <span class="nb">float</span><span class="p">(</span><span class="n">p</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>

<span class="k">def</span> <span class="nf">_dfs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mat</span><span class="p">,</span> <span class="n">pos</span><span class="p">,</span> <span class="n">r_sum</span><span class="p">,</span> <span class="n">c_sum</span><span class="p">,</span> <span class="n">p_0</span><span class="p">,</span> <span class="n">p</span><span class="p">):</span>
<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">_dfs</span><span class="p">(</span><span class="n">mat</span><span class="p">,</span> <span class="n">pos</span><span class="p">,</span> <span class="n">r_sum</span><span class="p">,</span> <span class="n">c_sum</span><span class="p">,</span> <span class="n">p_0</span><span class="p">,</span> <span class="n">p</span><span class="p">):</span>

<span class="p">(</span><span class="n">xx</span><span class="p">,</span> <span class="n">yy</span><span class="p">)</span> <span class="o">=</span> <span class="n">pos</span>
<span class="p">(</span><span class="n">r</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span> <span class="o">=</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">r_sum</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">c_sum</span><span class="p">))</span>
Expand Down Expand Up @@ -307,7 +315,7 @@ <h1>Source code for gpsea.analysis.pcats.stats._stats</h1><div class="highlight"
<span class="n">pos_new</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">yy</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">pos_new</span> <span class="o">=</span> <span class="p">(</span><span class="n">xx</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">yy</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_dfs</span><span class="p">(</span><span class="n">mat_new</span><span class="p">,</span> <span class="n">pos_new</span><span class="p">,</span> <span class="n">r_sum</span><span class="p">,</span> <span class="n">c_sum</span><span class="p">,</span> <span class="n">p_0</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
<span class="n">FisherExactTest</span><span class="o">.</span><span class="n">_dfs</span><span class="p">(</span><span class="n">mat_new</span><span class="p">,</span> <span class="n">pos_new</span><span class="p">,</span> <span class="n">r_sum</span><span class="p">,</span> <span class="n">c_sum</span><span class="p">,</span> <span class="n">p_0</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>

<span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="nb">object</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">FisherExactTest</span><span class="p">)</span>
Expand Down
12 changes: 6 additions & 6 deletions latest/_modules/gpsea/analysis/pscore/_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h1>Source code for gpsea.analysis.pscore._api</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">..predicate.genotype</span> <span class="kn">import</span> <span class="n">GenotypePolyPredicate</span>
<span class="kn">from</span> <span class="nn">.stats</span> <span class="kn">import</span> <span class="n">PhenotypeScoreStatistic</span>

<span class="kn">from</span> <span class="nn">.._base</span> <span class="kn">import</span> <span class="n">MonoPhenotypeAnalysisResult</span><span class="p">,</span> <span class="n">Statistic</span>
<span class="kn">from</span> <span class="nn">.._base</span> <span class="kn">import</span> <span class="n">MonoPhenotypeAnalysisResult</span><span class="p">,</span> <span class="n">Statistic</span><span class="p">,</span> <span class="n">StatisticResult</span>
<span class="kn">from</span> <span class="nn">.._partition</span> <span class="kn">import</span> <span class="n">ContinuousPartitioning</span>


Expand Down Expand Up @@ -215,9 +215,9 @@ <h1>Source code for gpsea.analysis.pscore._api</h1><div class="highlight"><pre>
<span class="n">phenotype</span><span class="p">:</span> <span class="n">PhenotypeScorer</span><span class="p">,</span>
<span class="n">statistic</span><span class="p">:</span> <span class="n">Statistic</span><span class="p">,</span>
<span class="n">data</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span>
<span class="n">pval</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
<span class="n">statistic_result</span><span class="p">:</span> <span class="n">StatisticResult</span><span class="p">,</span>
<span class="p">):</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">gt_predicate</span><span class="p">,</span> <span class="n">phenotype</span><span class="p">,</span> <span class="n">statistic</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">pval</span><span class="p">)</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">gt_predicate</span><span class="p">,</span> <span class="n">phenotype</span><span class="p">,</span> <span class="n">statistic</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">statistic_result</span><span class="p">)</span>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">phenotype</span><span class="p">,</span> <span class="n">PhenotypeScorer</span><span class="p">)</span>

<div class="viewcode-block" id="PhenotypeScoreAnalysisResult.phenotype_scorer">
Expand Down Expand Up @@ -291,7 +291,7 @@ <h1>Source code for gpsea.analysis.pscore._api</h1><div class="highlight"><pre>
<span class="sa">f</span><span class="s2">&quot;phenotype_scorer=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_phenotype</span><span class="si">}</span><span class="s2">, &quot;</span>
<span class="sa">f</span><span class="s2">&quot;statistic=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_statistic</span><span class="si">}</span><span class="s2">, &quot;</span>
<span class="sa">f</span><span class="s2">&quot;data=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="si">}</span><span class="s2">, &quot;</span>
<span class="sa">f</span><span class="s2">&quot;pval=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_pval</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="sa">f</span><span class="s2">&quot;statistic_result=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_statistic_result</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="p">)</span>

<span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
Expand Down Expand Up @@ -366,14 +366,14 @@ <h1>Source code for gpsea.analysis.pscore._api</h1><div class="highlight"><pre>
<span class="n">y</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span>
<span class="n">data</span><span class="p">[</span><span class="n">MonoPhenotypeAnalysisResult</span><span class="o">.</span><span class="n">GT_COL</span><span class="p">]</span> <span class="o">==</span> <span class="n">y_key</span><span class="p">,</span> <span class="n">MonoPhenotypeAnalysisResult</span><span class="o">.</span><span class="n">PH_COL</span>
<span class="p">]</span><span class="o">.</span><span class="n">to_numpy</span><span class="p">(</span><span class="n">dtype</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span> <span class="c1"># type: ignore</span>
<span class="n">pval</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statistic</span><span class="o">.</span><span class="n">compute_pval</span><span class="p">(</span><span class="n">scores</span><span class="o">=</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">))</span>
<span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_statistic</span><span class="o">.</span><span class="n">compute_pval</span><span class="p">(</span><span class="n">scores</span><span class="o">=</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">))</span>

<span class="k">return</span> <span class="n">PhenotypeScoreAnalysisResult</span><span class="p">(</span>
<span class="n">gt_predicate</span><span class="o">=</span><span class="n">gt_predicate</span><span class="p">,</span>
<span class="n">phenotype</span><span class="o">=</span><span class="n">pheno_scorer</span><span class="p">,</span>
<span class="n">statistic</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_statistic</span><span class="p">,</span>
<span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span>
<span class="n">pval</span><span class="o">=</span><span class="n">pval</span><span class="p">,</span>
<span class="n">statistic_result</span><span class="o">=</span><span class="n">result</span><span class="p">,</span>
<span class="p">)</span></div>
</div>

Expand Down
Loading

0 comments on commit 88c988f

Please sign in to comment.