Skip to content

Commit

Permalink
Updates for version 1.0 (#5)
Browse files Browse the repository at this point in the history
* setup initial tests

* test: updated testing actions and test structure

* feat: added in some tests for utils

* feat: added in function for reading in population panel files separately

* draft: updated some tests

* test: population panel testing

* feat: new function to add in population handling

* test: added in test for verification of samples

* feat: vcf2frequency table now uses cyvcf2

* draft: small commit - still needs some fixing on docs

* test: some refactoring and some testing

* doc: some additional docstrings

* feat: updated to include data in installation

* feat: finally got cyvcf2 features working

* feat: not supporting windows due to cyvcf2
  • Loading branch information
aabiddanda authored Sep 6, 2022
1 parent c7d0a36 commit f3d0e48
Show file tree
Hide file tree
Showing 29 changed files with 674 additions and 318 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: run tests
run: |
pytest
python -m pytest tests/
- name: run flake8
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: run tests
run: |
pytest
python -m pytest tests/
- name: run flake8
run: |
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/windows.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
sandbox/*
geovar/data/*.csv
docsrc/_build/*
.hypothesis/
*.egg-info/
*.coverage
*.python-version
build/
Binary file added docs/_images/notebooks_getting-started_12_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/notebooks_getting-started_14_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/notebooks_getting-started_18_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/notebooks_getting-started_24_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/_modules/geovar/binning.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ <h1>Source code for geovar.binning</h1><div class="highlight"><pre>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">assert</span> <span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">bins</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="k">assert</span> <span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">bins</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mf">0.0</span><span class="p">)</span>
<span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">bins</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span>
<span class="bp">self</span><span class="o">.</span><span class="n">bins</span> <span class="o">=</span> <span class="n">bins</span>
<span class="bp">self</span><span class="o">.</span><span class="n">freq_mat</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">n_variants</span> <span class="o">=</span> <span class="kc">None</span>
Expand Down
169 changes: 109 additions & 60 deletions docs/_modules/geovar/utils.html

Large diffs are not rendered by default.

86 changes: 56 additions & 30 deletions docs/_sources/notebooks/getting-started.ipynb.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/_sources/stubs/geovar.utils.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

.. autosummary::

flip_alleles
read_pop_panel
sep_freq_mat_pops
vcf_to_freq_table
verify_sample_indices



Expand Down
1 change: 0 additions & 1 deletion docs/_static/pygments.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .nt { color: #004461; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #000000 } /* Name.Variable */
.highlight .ow { color: #004461; font-weight: bold } /* Operator.Word */
.highlight .pm { color: #000000; font-weight: bold } /* Punctuation.Marker */
.highlight .w { color: #f8f8f8; text-decoration: underline } /* Text.Whitespace */
.highlight .mb { color: #990000 } /* Literal.Number.Bin */
.highlight .mf { color: #990000 } /* Literal.Number.Float */
Expand Down
22 changes: 13 additions & 9 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ <h1 id="index">Index</h1>

<div class="genindex-jumpbox">
<a href="#_"><strong>_</strong></a>
| <a href="#F"><strong>F</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#S"><strong>S</strong></a>
| <a href="#V"><strong>V</strong></a>

Expand All @@ -56,14 +56,6 @@ <h2 id="_">_</h2>
</ul></td>
</tr></table>

<h2 id="F">F</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="geovar.html#geovar.utils.flip_alleles">flip_alleles() (in module geovar.utils)</a>
</li>
</ul></td>
</tr></table>

<h2 id="G">G</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand Down Expand Up @@ -96,6 +88,14 @@ <h2 id="M">M</h2>
</ul></td>
</tr></table>

<h2 id="R">R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="geovar.html#geovar.utils.read_pop_panel">read_pop_panel() (in module geovar.utils)</a>
</li>
</ul></td>
</tr></table>

<h2 id="S">S</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand All @@ -108,6 +108,10 @@ <h2 id="V">V</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="geovar.html#geovar.utils.vcf_to_freq_table">vcf_to_freq_table() (in module geovar.utils)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="geovar.html#geovar.utils.verify_sample_indices">verify_sample_indices() (in module geovar.utils)</a>
</li>
</ul></td>
</tr></table>
Expand Down
29 changes: 24 additions & 5 deletions docs/geovar.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ <h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this
</table>
<span class="target" id="module-geovar.utils"></span><p>Utilities for file conversions for GeoVar.</p>
<dl class="py function">
<dt class="sig sig-object py" id="geovar.utils.flip_alleles">
<span class="sig-prename descclassname"><span class="pre">geovar.utils.</span></span><span class="sig-name descname"><span class="pre">flip_alleles</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">acnt</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flip</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/geovar/utils.html#flip_alleles"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#geovar.utils.flip_alleles" title="Permalink to this definition"></a></dt>
<dd><p>Flip alleles if based on being the minor allele.</p>
<dt class="sig sig-object py" id="geovar.utils.read_pop_panel">
<span class="sig-prename descclassname"><span class="pre">geovar.utils.</span></span><span class="sig-name descname"><span class="pre">read_pop_panel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pop_panel_file</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/geovar/utils.html#read_pop_panel"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#geovar.utils.read_pop_panel" title="Permalink to this definition"></a></dt>
<dd><p>Read in a population panel file.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>(</strong> (<em>pop_panel_files</em>) – obj: <cite>string</cite>): list of population</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
Expand All @@ -83,20 +88,34 @@ <h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this

<dl class="py function">
<dt class="sig sig-object py" id="geovar.utils.vcf_to_freq_table">
<span class="sig-prename descclassname"><span class="pre">geovar.utils.</span></span><span class="sig-name descname"><span class="pre">vcf_to_freq_table</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vcf_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pop_panel</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">outfile</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">minor_allele</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/geovar/utils.html#vcf_to_freq_table"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#geovar.utils.vcf_to_freq_table" title="Permalink to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">geovar.utils.</span></span><span class="sig-name descname"><span class="pre">vcf_to_freq_table</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vcf_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pop_df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">outfile</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">minor_allele</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/geovar/utils.html#vcf_to_freq_table"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#geovar.utils.vcf_to_freq_table" title="Permalink to this definition"></a></dt>
<dd><p>Convert a VCF File to a frequency table to be used as input to a GeoVar object.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>vcf_file</strong> (<a class="reference external" href="https://docs.python.org/3/library/string.html#module-string" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">string</span></code></a>) – filepath to VCF file (can be bgzipped).</p></li>
<li><p><strong>pop_panel</strong> (<a class="reference external" href="https://docs.python.org/3/library/string.html#module-string" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">string</span></code></a>) – filepath to population panel file.</p></li>
<li><p><strong>pop_df</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">pandas.DataFrame</span></code>) – population data frame in pandas format.</p></li>
<li><p><strong>outfile</strong> (<a class="reference external" href="https://docs.python.org/3/library/string.html#module-string" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">string</span></code></a>) – file to write output allele frequency table to.</p></li>
<li><p><strong>minor_allele</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bool</span></code></a>) – flag to indicate if we want to polarize to the minor allele.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="geovar.utils.verify_sample_indices">
<span class="sig-prename descclassname"><span class="pre">geovar.utils.</span></span><span class="sig-name descname"><span class="pre">verify_sample_indices</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pop_df</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">samples</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/geovar/utils.html#verify_sample_indices"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#geovar.utils.verify_sample_indices" title="Permalink to this definition"></a></dt>
<dd><p>Generate the sample indices from a list of sample IDs stratified by population.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pop_df</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">pandas.DataFrame</span></code>) – population data frame in pandas format.Must have <cite>pop</cite> and <cite>sample</cite> columns available.</p></li>
<li><p><strong>samples</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">list</span></code></a>) – list of sample IDs (strings) that are ready to be indexed.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</section>
</section>

Expand Down
Loading

0 comments on commit f3d0e48

Please sign in to comment.