Skip to content

Commit

Permalink
Push to 0.0.10:
Browse files Browse the repository at this point in the history
- improve app UI
- update packages
  • Loading branch information
MrTomRod committed Mar 14, 2023
1 parent 9227d14 commit be62501
Show file tree
Hide file tree
Showing 13 changed files with 700 additions and 505 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ RUN pip install -U /tmp/scoary/scoary_2-$SCOARY_VERSION-py3-none-any.whl && \
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR
ENV CONFINT_DB=/tmp/CONFINT_DB
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR

WORKDIR /data
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ association per trait. The results can be explored interactively with a simple,
- [Understanding the p values](https://github.com/MrTomRod/scoary-2/wiki/Understanding-the-p-values)
- [Usage as Python library](https://github.com/MrTomRod/scoary-2/wiki/Usage-as-Python-library)

# Todo:

- [X] Binarize traits during multiprocessing
- [X] Idea: min_qval * min_empirical_p as new score
- [X] Improve messaging and logging
- [X] Remove multiple_testing_picking, more like Scoary 1 syntax?
- [X] Log runtime?
- [X] Refactoring
- [X] `overview.html`: go to function, popover always left
- [X] `overview.html` & `trait.html`: ~~set proper title~~, add logo/favicon
- [ ] `overview.html` & `trait.html`: link to `summary.tsv` / `coverage-matrix.tsv` / `result.tsv` download
- [X] Create wiki


[orthofinder]: https://github.com/davidemms/OrthoFinder/
[roary]: https://sanger-pathogens.github.io/Roary/
873 changes: 493 additions & 380 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scoary-2"
version = "0.0.9"
version = "0.0.10"
description = "Scoary 2: Associate genes with traits!"
authors = ["MrTomRod <[email protected]>"]
license = "GPL3"
Expand Down
4 changes: 2 additions & 2 deletions scoary/load_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def apply_kmeans(kmeans: KMeans, data: pd.Series) -> (pd.Series, dict):
# insert_positions = [v - i for i, v in enumerate(np.where(nan_vector)[0])]
label_to_class = dict(zip(nan_free_data.index, labels_))
return pd.array([label_to_class.get(l, pd.NA) for l in data.index], dtype="boolean"), \
{'method': 'kmeans', 'cutoff': np.mean(fit.cluster_centers_)}
{'method': 'kmeans', 'cutoff': np.mean(fit.cluster_centers_)}


def classify_gm(val: [float, float], certainty_cutoff: float):
Expand Down Expand Up @@ -290,7 +290,7 @@ def worker(
new_ns = grasp_namespace(BinarizeTraitNamespace, ns)
del ns

kmeans = KMeans(n_clusters=2, random_state=new_ns.random_state)
kmeans = KMeans(n_init='auto', n_clusters=2, random_state=new_ns.random_state)
gm = GaussianMixture(n_components=2, random_state=new_ns.random_state, covariance_type=new_ns.covariance_type)

if new_ns.method == 'kmeans':
Expand Down
8 changes: 4 additions & 4 deletions scoary/scoary.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def scoary(
:param traits: Path to trait presence/absence table: columns=traits, rows=isolates
:param outdir: Directory to place output files
:param multiple_testing: "method:cutoff" for filtering genes after Fisher's test, where cutoff is a number that
specifies the FWER and method is one of [bonferroni, sidak, holm-sidak, holm, simes-hochberg, hommel, fdr_bh,
fdr_by, fdr_tsbh, fdr_tsbky]. Alternatively, the method can be 'native': then, the cutoff targets the uncorrected
pvalue from Fisher's test.
:param worst_cutoff: Drop traits if no gene with "worst" pvalue lower than threshold. Recommended if
specifies the FWER and method is one of [native, bonferroni, sidak, holm-sidak, holm, simes-hochberg, hommel,
fdr_bh, fdr_by, fdr_tsbh, fdr_tsbky]. Alternatively, the method can be 'native': then, the cutoff targets the
uncorrected p-value from Fisher's test.
:param worst_cutoff: Drop traits if no gene with "worst" p-value lower than threshold. Recommended if
dataset contains multiple species
:param max_genes: Keep only n highest-scoring genes in Fisher's test. Recommended if dataset is big and contains
multiple species; avoids waisting computational resources on traits that simply correlate with phylogeny
Expand Down
102 changes: 61 additions & 41 deletions scoary/templates/overview.css
Original file line number Diff line number Diff line change
@@ -1,71 +1,91 @@
/*#popoverTable, th , td{*/
/* width: 100%;*/
/* border: 1px solid;*/
/*}*/
#grid {
display: grid;
width: 100%;
height: 100vh;
grid-template-columns: 4fr 5fr;
}

.left {
/*float: left;*/
height: 100vh;
min-width: 610px;
max-width: 770px;
overflow: scroll;
}

.right {
float: right
height: 100vh;
min-width: 400px;
display: flex;
flex-direction: column;
justify-content: space-between;
overflow-y: auto;
}

.right-container {
position: fixed;
display: grid;
right: 0;
transform: translateY(-50%);
top: 50%;
.btn {
margin-top: 5px;
}

#trait-select {
padding: 1rem;
margin-bottom: 1rem;
}

.popover {
max-width: 550px;
max-height: 100%;
overflow: auto;
#trait-info {
margin-bottom: 1rem;
overflow-y: scroll;
}

.popover-header a {
color: unset
#trait-info h2 a {
color: unset;
text-decoration: unset;
display: flex;
justify-content: space-between;
margin: 0;
padding: 0;
}

#highlighter {
width: 12rem;
#trait-info h2 button {
margin: 0;
}

#svg-container {
overflow-y: scroll;
overflow-x: hidden;
}

.placeholder {
opacity: unset;
background-color: unset;
}

/* imitate bootstrap container shrinking */
@media (min-width: 576px) {
.right-container {
max-width: 540px;
}
#legend {
margin-bottom: 0.7rem;
}

@media (min-width: 768px) {
.right-container {
max-width: 720px;
}
#legend td, #legend th {
text-align: center;
padding: 0 3px 0 3px;
}

@media (min-width: 992px) {
.right-container {
max-width: 960px;
}
#legend th {
font-weight: bold;
}

#legend-link {
color: unset;
text-decoration: unset;
}

@media (min-width: 1200px) {
.right-container {
max-width: 1140px;
}
#legend-link h3 {
text-align: center;
}

@media (min-width: 1400px) {
.right-container {
max-width: 1320px;
}
.legend-title {
display: flex;
}

.legend-title .btn {
padding: 1px 8px 1px 8px;
margin-left: 5px;
margin-top: 2px;
}
71 changes: 51 additions & 20 deletions scoary/templates/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.2/papaparse.min.js"
crossorigin="anonymous"></script>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link href="app/overview.css" rel="stylesheet">

<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
crossorigin="anonymous"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/slim-select/1.27.1/slimselect.min.js"></script>
Expand All @@ -27,21 +26,53 @@

<body>

<section class="container">

<h1>Traits dendrogram</h1>

<div class="right-container">
<object type="image/svg+xml" data="overview_colorbar.svg" id="traits-colorbar" class="right"></object>

<select id="slim-select"></select>
<button id="copy-button" type="button" class="btn btn-info">Copy selected traits</button>
<button id="deselect-button" type="button" class="btn btn btn-warning">Deselect all</button>
</div>


<div id="svg-container">
<!-- <object type="image/svg+xml" data="overview_plot.svg" id="traits-dendrogram" class="left"></object> -->
<section style="height: 100vh">
<div id="grid">
<div class="left">
<h1>Traits dendrogram</h1>
<div id="svg-container" class="col"></div>
</div>
<div class="right container">
<div>
<div id="trait-select">
<select id="slim-select"></select>
<div class="d-flex justify-content-evenly">
<button id="copy-button" type="button" class="btn btn-primary">Copy selected traits</button>
<button id="goto-button" type="button" class="btn btn-success">Scroll to trait</button>
<button id="deselect-button" type="button" class="btn btn btn-warning">Deselect all</button>
</div>
</div>

<div id="trait-info"></div>

</div>

<div class="d-flex flex-column align-items-center" title="Click here to learn more about these values!">

<div class="legend-title">
<h3>Legend</h3>
<a id="legend-link" href="https://github.com/MrTomRod/scoary-2/wiki/Understanding-the-p-values">
<button type="button" class="btn btn-info">?</button>
</a>
</div>

<p>The plot is log<sub>10</sub>-scaled.</p>

<table id="legend">
<tr>
<th style="color:#2ca02c">f</th>
<th style="color:#9467bd">e</th>
<th style="color:#d62728"></th>
</tr>
<tr>
<td>Fisher's <i>q</i>-value</td>
<td>Empirical <i>p</i>-value</td>
<td><i>fq*ep</i> score</td>
</tr>
</table>

</div>
</div>
</div>

</section>
Expand Down
Loading

0 comments on commit be62501

Please sign in to comment.