Skip to content

Commit

Permalink
better error messages when problems with barcode_runs (#101)
Browse files Browse the repository at this point in the history
* better error messages when problems with `barcode_runs`

* `black` formatting w newer version of `black`
  • Loading branch information
jbloom authored Feb 2, 2024
1 parent 016e7af commit 12299f2
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

#### version 3.6.1
- Better error messages with problems with `barcode_runs`

### version 3.6.0
- Add `func_effect_diffs` option to compare differences among functional effects.
- Update environment:
Expand Down
10 changes: 7 additions & 3 deletions Snakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Top-level ``snakemake`` file that runs analysis."""


import collections
import itertools
import os
Expand All @@ -27,8 +26,13 @@ else:
)
if not set(barcode_run_req_cols).issubset(barcode_runs.columns):
raise ValueError(f"{barcode_runs.columns=} missing {barcode_run_req_cols=}")
assert len(barcode_runs) == barcode_runs["sample"].nunique()
assert barcode_runs[barcode_run_req_cols].notnull().all().all()
if len(barcode_runs) != barcode_runs["sample"].nunique():
raise ValueError(
"`barcode_runs` contains duplicated (non-unique) samples:\n"
+ str(barcode_runs.groupby("sample").size().sort_values(ascending=False))
)
if not barcode_runs[barcode_run_req_cols].notnull().all().all():
raise ValueError(f"{barcode_run_req_cols=} not all non-null")

# check no FASTQ assigned to multiple samples
dup_fastq_R1 = (
Expand Down
1 change: 0 additions & 1 deletion antibody_escape.smk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Note that these rules can analyze arbitrary assays. Throughout the workflow, the
"""


# read the config for antibody escape
with open(config["antibody_escape_config"]) as f:
antibody_escape_config = yaml.safe_load(f)
Expand Down
1 change: 0 additions & 1 deletion build_variants.smk
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""``snakemake`` files with rules for building variants."""


build_variants_docs = {}


Expand Down
1 change: 0 additions & 1 deletion count_variants.smk
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""``snakemake`` files with rules for counting variants from barcode sequencing."""


# Names and values of files to add to docs
count_variants_docs = {
"Analysis notebooks": collections.defaultdict(dict),
Expand Down
1 change: 0 additions & 1 deletion func_effects.smk
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""``snakemake`` files with rules for calculating functional effects."""


# read the config for func effects
with open(config["func_effects_config"]) as f:
func_effects_config = yaml.safe_load(f)
Expand Down
8 changes: 5 additions & 3 deletions notebooks/build_codon_variants.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,11 @@
" ),\n",
" y=alt.Y(\"percent\", title=\"% variants with mutation\"),\n",
" tooltip=[\n",
" alt.Tooltip(c, format=\".3g\")\n",
" if c in {\"percent\", \"count\", \"n_variants\"}\n",
" else c\n",
" (\n",
" alt.Tooltip(c, format=\".3g\")\n",
" if c in {\"percent\", \"count\", \"n_variants\"}\n",
" else c\n",
" )\n",
" for c in site_freqs.columns\n",
" ],\n",
" )\n",
Expand Down
8 changes: 5 additions & 3 deletions notebooks/summary.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,11 @@
" ),\n",
" color=alt.Color(\n",
" f\"{antibody_set} escape_floored:Q\",\n",
" title=f\"{antibody_set} escape\"\n",
" if len(antibody_set) < 14\n",
" else [antibody_set, \"escape\"],\n",
" title=(\n",
" f\"{antibody_set} escape\"\n",
" if len(antibody_set) < 14\n",
" else [antibody_set, \"escape\"]\n",
" ),\n",
" legend=legend,\n",
" scale=alt.Scale(\n",
" zero=True,\n",
Expand Down
1 change: 0 additions & 1 deletion scripts/build_docs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Implements ``snakemake`` rule to translate gene sequence."""


import os
import sys

Expand Down
1 change: 0 additions & 1 deletion scripts/count_barcodes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Count variants from Illumina barcodes."""


import os
import sys

Expand Down
1 change: 0 additions & 1 deletion scripts/format_altair_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""


import argparse

from bs4 import BeautifulSoup as bs
Expand Down
1 change: 0 additions & 1 deletion scripts/func_scores.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Get functional scores from barcode counts."""


import sys

import alignparse.utils
Expand Down
1 change: 0 additions & 1 deletion scripts/gene_sequence.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Implements ``snakemake`` rule to get gene sequence."""


import sys

import Bio.SeqIO
Expand Down
1 change: 0 additions & 1 deletion scripts/prob_escape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Get probabilities (fraction) of antibody escape from variant counts."""


import sys

import Bio.SeqIO
Expand Down
1 change: 0 additions & 1 deletion scripts/translate_geneseq.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Implements ``snakemake`` rule to translate gene sequence."""


import sys

import Bio.SeqIO
Expand Down
1 change: 0 additions & 1 deletion test_example/scripts/spatial_distances.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Implements ``snakemake`` rule `spatial_distances`"""


import sys
import urllib

Expand Down

0 comments on commit 12299f2

Please sign in to comment.