Skip to main content

A small package that converts SARS-CoV-2 PCR test Ct values to viral loads

Project description

ct2vl: Ct values to viral loads

A python package and command line tool to convert SARS-CoV-2 PCR Ct values to viral loads.

Installation

Assuming python and pip are installed, at the command line, run

pip install ct2vl

Usage

Python package

from ct2vl.conversion import Converter
converter = Converter(traces="traces.csv", LoD=100.0, Ct_at_LoD=37.96)
ct_values = [23.1, 31.8, 28.4, 34.0, 30.2]
viral_loads = converter.ct_to_viral_load(ct_values)

The traces argument of Converter can also accept a pandas DataFrame or numpy ndarray.

Command line tool

To calibrate ct2vl run

python3 -m ct2vl calibrate <traces> <LoD> <Ct_at_LoD>

For example

python3 -m ct2vl calibrate example/path/traces.csv 100.0 37.96

Once ct2vl has been calibrated, Ct values can be converted to viral loads with

python3 -m ct2vl convert <Ct>

One or multiple Ct values can be passed. For example

python3 -m ct2vl convert 23.1

or

python3 -m ct2vl convert 23.1 31.8 28.4 34.0 30.2

Output can be saved to a file by providing a filepath to the optional flag --output

python3 -m ct2vl convert 23.1 --output example/path//viral_loads.tsv

Input

The command line tool has two modes calibrate and convert.

  • mode: calibrate uses positive PCR traces and their corresponding Ct values to calibrate ct2vl for a given machine
    1. traces: Filepath to a csv file containing PCR reaction traces
    2. LoD: Limit of detection (LoD): copies of SARS-CoV-2 viral genomes/mL (copies/mL; viral load at the LoD)
    3. Ct_at_LoD: Ct value at the limit of detection (LoD)
  • mode: convert calculates the viral loads for given Ct values
    1. Ct: A list of Ct values that will be converted to viral loads
    2. --outfile: An optional filepath to save the results to

For calibrate mode, traces is a csv file where each row corresponds to a PCR reaction curve and each column is a cycle in the reaction (example below).

Example traces csv file

0 1 2 3 4 5 6 7 8 ... 29 30 31 32 33 34 35 36 37 38
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.036339 0.105185 0.140072 0.213080 ... 75.820797 103.521744 128.057320 146.543328 158.994255 166.878167 171.755301 174.695708 176.480445 178.004733
1 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.032859 0.106156 0.115075 ... 1.498253 3.242639 6.929736 14.413807 26.735120 42.908856 60.642276 77.436979 90.894471 98.702497
2 0.008563 0.077690 0.112795 0.112795 0.112795 0.112795 0.112795 0.112795 0.250068 ... 239.545742 240.219129 240.706006 241.006463 241.206473 241.304155 241.389261 241.421420 241.421420 241.421420
3 0.000000 0.000000 0.043038 0.061215 0.061215 0.061215 0.061215 0.061215 0.061215 ... 177.787281 185.406029 190.989406 195.223471 198.308876 200.551725 202.243363 203.463125 204.342186 205.015795
4 0.000000 0.000000 0.000000 0.014523 0.038724 0.083699 0.116689 0.131569 0.131569 ... 173.993467 183.424795 190.361277 195.482481 199.194926 201.862966 203.861077 205.329761 206.289263 206.824331
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
16 0.000000 0.000000 0.050974 0.085428 0.085428 0.085428 0.085428 0.085428 0.085428 ... 194.717208 201.251802 206.238474 209.977472 212.850522 214.995915 216.711037 217.980163 218.880729 219.491032
17 0.000000 0.000000 0.000000 0.000000 0.000000 0.080598 0.126204 0.224708 0.254782 ... 187.883601 199.664452 208.208690 214.361070 218.809716 222.239450 224.701419 226.574815 227.972374 229.085984
18 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.092015 0.215467 0.297682 ... 51.416916 80.692981 112.770737 142.339464 165.674804 182.084870 193.083210 200.171681 204.779740 208.237394
19 0.443534 0.443534 0.443534 0.443534 0.443534 0.443534 0.443534 0.443534 0.443534 ... 70.164310 97.490787 122.766640 142.936795 157.475829 167.632976 174.804737 179.870366 183.435423 186.212804
20 0.000000 0.060721 0.060721 0.064403 0.064403 0.064403 0.064403 0.064403 0.064403 ... 225.043424 226.333617 227.403273 228.214905 228.866112 229.370140 229.680560 229.890248 229.967121 229.967121

Example command line output

LoD Ct_at_LoD Ct viral_load log10_viral_load
1 100 37.83 14.73 3.3277e+08 8.52214
2 100 37.83 20.27 7.98283e+06 6.90216
3 100 37.83 18.21 3.13511e+07 7.49625
4 100 37.83 18.05 3.48959e+07 7.54277
5 100 37.83 15.53 1.92109e+08 8.28355

Fine details

If you use conda: This package is currently only available from PyPI; however, using pip with conda is not really recommended, and conda skeleton requires a setup.py (the deprecated way of doing things). This recipe for installing in a conda environment seems to work:

conda install -c conda-forge grayskull
grayskull pypi ct2vl
cd ct2vl
conda build .
cd ..
conda install --use-local ct2vl

That being said, if you have suggestions or feedback on how to support conda installation, let us know.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ct2vl-1.0.3.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

ct2vl-1.0.3-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file ct2vl-1.0.3.tar.gz.

File metadata

  • Download URL: ct2vl-1.0.3.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for ct2vl-1.0.3.tar.gz
Algorithm Hash digest
SHA256 84a516749ab04feacfcbf9672514e9474b2012984bb37e4a3595af62a2919c66
MD5 3c5780fb27ed70f9149a3de270d3c207
BLAKE2b-256 a4552a4256b5c4d8768f600f2b58d455d15180fd2342bb2dcc1a4749771942d8

See more details on using hashes here.

File details

Details for the file ct2vl-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: ct2vl-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for ct2vl-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c269fb907b802c0815b2f3049d23b04b9036fc3b64cbd2c5bd4922f894506a64
MD5 a03dfc1b27d291c320a831ae9f4f77bd
BLAKE2b-256 f29347952a9efc762e9f085dc344fcc73dfe3f32c98445f91fd3a6bb65f36b10

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page