Skip to content

Commit

Permalink
Merge pull request #29 from tillahoffmann/yaml
Browse files Browse the repository at this point in the history
Change from json to yaml for readability.
  • Loading branch information
tillahoffmann authored Jul 31, 2024
2 parents 270fcf8 + 58ad834 commit 60f1cfd
Show file tree
Hide file tree
Showing 32 changed files with 1,021 additions and 1,611 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ figures/
publications/*/*
# ... except the summary and data
!publications/*/*.json
!publications/*/*.yaml
!publications/*/*.rst

shedding/*.c
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Uncertainties surrounding the concentration of viral RNA fragments in the faeces
📊 Datasets
-----------

Datasets can be found in the ``publications`` directory as JSON files following a common schema (see ``schema.json`` for details). All RNA loads are reported as log10 gene copies per mL. The results from individual samples are linked to patients wherever possible to provide longitudional information.
Datasets can be found in the ``publications`` directory as YAML files following a common schema (see ``schema.yaml`` for details). All RNA loads are reported as log10 gene copies per mL. The results from individual samples are linked to patients wherever possible to provide longitudional information.

.. jinja::

Expand Down
10 changes: 7 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from glob import glob
import inspect
from jinja2 import Template
import json
import os
import shedding
import sphinx
import yaml


def _parse_key(argument):
Expand Down Expand Up @@ -74,12 +74,12 @@ def setup(app):


# -- Datasets for jinja templates --------------------------------------------
filenames = glob("publications/*/*.json")
filenames = glob("publications/*/*.yaml")
jinja_context = {}
for filename in sorted(filenames):
with open(filename) as fp:
key, _ = os.path.splitext(os.path.basename(filename))
jinja_context.setdefault("publications", {})[key] = json.load(fp)
jinja_context.setdefault("publications", {})[key] = yaml.safe_load(fp)

# Get all modules for the documentation
modules = set()
Expand Down Expand Up @@ -130,7 +130,11 @@ def setup(app):
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
".eggs",
"build",
"PolyChordLite",
"README.rst",
"venv",
]

# -- Options for HTML output -------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions convert_cycle_threshold.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import argparse
import json
import numpy as np
import yaml


LOOKUP = {
Expand All @@ -27,7 +27,7 @@ def parse_values(values):
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--format", choices=["plain", "json"], default="json", help="output format"
"--format", choices=["plain", "yaml"], default="yaml", help="output format"
)
parser.add_argument(
"--log10",
Expand All @@ -46,9 +46,9 @@ def parse_values(values):
poly = np.polynomial.Polynomial.fit(args.reference, args.target, 1)
results = poly(np.log10(args.values) if args.log10 else args.values)

if args.format == "json":
if args.format == "yaml":
results = [{"reference": x, "target": y} for x, y in zip(args.values, results)]
print(json.dumps(results, indent=4))
print(yaml.dumps(results, indent=4))
elif args.format == "plain":
print("\n".join(map(str, results)))
else:
Expand Down
6 changes: 3 additions & 3 deletions plot_datasets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from glob import glob
import json
from matplotlib import pyplot as plt
import numpy as np
import yaml


def to_float(x):
Expand All @@ -15,15 +15,15 @@ def to_float(x):
"head_width": 0.1,
}
lim_length = 0.25
filenames = glob("publications/*/*.json")
filenames = glob("publications/*/*.yaml")

fig, ax = plt.subplots()
ylabels = []
for i, filename in enumerate(sorted(filenames, reverse=True)):
color = f"C{i}"

with open(filename) as fp:
publication = json.load(fp)
publication = yaml.safe_load(fp)
ylabels.append(publication["key"])

# Plot the level of quantification
Expand Down
19 changes: 0 additions & 19 deletions publications/Cheung2020/Cheung2020.json

This file was deleted.

16 changes: 16 additions & 0 deletions publications/Cheung2020/Cheung2020.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=../../schema.yaml
assay: '?'
doi: 10.1053/j.gastro.2020.03.065
key: Cheung et al. 2020
load_summaries:
max: 7.6
median: 4.7
min: 3.4
loq: null
patients:
n: 59
negative: 50
positive: 9
samples: {}
title: 'Gastrointestinal Manifestations of SARS-CoV-2 Infection and Virus Load in
Fecal Samples From a Hong Kong Cohort: Systematic Review and Meta-analysis'
75 changes: 0 additions & 75 deletions publications/Han2020/Han2020.json

This file was deleted.

48 changes: 48 additions & 0 deletions publications/Han2020/Han2020.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# yaml-language-server: $schema=../../schema.yaml
assay: PowerChek-E
doi: 10.1093/cid/ciaa447
key: Han et al. 2020
loads:
- day: 9
patient: 0
value: 4.616479
- day: 15
patient: 0
value: null
- day: 6
patient: 1
value: 6.792
- day: 8
patient: 1
value: 6.593
- day: 10
patient: 1
value: 7.219
- day: 13
patient: 1
value: 6.383
- day: 15
patient: 1
value: 7.618
- day: 17
patient: 1
value: 6.23
- day: 18
patient: 1
value: 5.855
loq: 3.7558748557
patients:
details:
- description: mother
- age: 0
description: neonate
n: 2
negative: 0
positive: 2
samples:
n: 9
negative: 1
positive: 8
temporal: symptoms
title: Sequential Analysis of Viral Load in a Neonate and Her Mother Infected With
Severe Acute Respiratory Syndrome Coronavirus 2
56 changes: 0 additions & 56 deletions publications/Jeong2020/Jeong2020.json

This file was deleted.

41 changes: 41 additions & 0 deletions publications/Jeong2020/Jeong2020.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# yaml-language-server: $schema=../../schema.yaml
assay: S
doi: 10.1016/j.cmi.2020.07.020
key: Jeong et al. 2020
loads:
- day: 8
err: null
patient: 1
stage: recovery
value: null
- day: 13
err: 0.19
patient: 2
stage: recovery
value: 1.51
- day: 11
err: null
patient: 3
stage: recovery
value: null
- day: 15
err: 0.11
patient: 4
stage: acute
value: 2.18
- day: 30
err: 0.28
patient: 5
stage: recovery
value: 2.01
loq: 0.3
patients:
n: 5
negative: 2
positive: 3
samples:
n: 5
negative: 2
positive: 3
temporal: symptoms
title: Viable SARS-CoV-2 in various specimens from COVID-19 patients
24 changes: 0 additions & 24 deletions publications/Kim2020/Kim2020.json

This file was deleted.

Loading

0 comments on commit 60f1cfd

Please sign in to comment.