Skip to main content

Converting 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)

In addition to a filepath, 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

Descriptions of command line arguments

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

This file is available for download here. Each row is a PCR reaction curve for a given covid test and each column is a cycle in the PCR reaction.

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.4.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

ct2vl-1.0.4-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ct2vl-1.0.4.tar.gz
  • Upload date:
  • Size: 10.3 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.4.tar.gz
Algorithm Hash digest
SHA256 797c624181efe849fd3145c3a7f68c15dac0ebbf19ff4d5bf9d5848a7f72f599
MD5 6b627fd9563a580f8935d8722013c0b0
BLAKE2b-256 befdf4b8302692d683292c119aa7a9d01d3377f04e1f41aa9d2d35683f93ee6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ct2vl-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f5eacf477545e2bec30a435ff9b40391cea919654353b8fd7b8d0498f83faed0
MD5 825d19541a3345ff99ec665df9472188
BLAKE2b-256 26acb602ebc58f3bd7d2038cb87d8f92aae0f070ba0ca0210e8186dc63afcb4e

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