-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelta_ct.py
More file actions
33 lines (28 loc) · 1.42 KB
/
Copy pathdelta_ct.py
File metadata and controls
33 lines (28 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pandas as pd
import warnings
warnings.simplefilter(action='ignore') # :(
data = pd.read_csv("qPCR_results_tab.tsv", sep='\t', usecols=["Sample Name", "Target Name", "CT", "Ct Mean"])
tested_gene = data[data['Target Name'] == 'APO837/838']
tested_gene = tested_gene[data["CT"] != "Undetermined"]
reference_gene = data[data['Target Name'] == 'APO851/APO852']
reference_gene = reference_gene[data["CT"] != "Undetermined"]
control_trial = ("S16", "S17", "S18")
tested_trial = ("S4", "S5", "S6")
trials = {"control": [], "tested": []}
for i in range(len(tested_gene)):
r = f'{float(tested_gene.iloc(0)[i]["CT"].replace(",", ".")) - float(reference_gene.iloc(0)[i]["CT"].replace(",", ".")):.6n}'
print(f"{tested_gene.iloc(0)[i]["Sample Name"]}\tΔCT = {r}")
if(tested_gene.iloc(0)[i]["Sample Name"].startswith(control_trial)):
trials["control"].append({tested_gene.iloc(0)[i]["Sample Name"]: r})
elif(tested_gene.iloc(0)[i]["Sample Name"].startswith(tested_trial)):
trials["tested"].append({tested_gene.iloc(0)[i]["Sample Name"]: r})
print("-" * 50)
sum = 0
for i in range(len(trials["control"])):
x = trials["tested"][i]
y = trials["control"][i]
r = float(list(x.values())[0]) - float(list(y.values())[0])
print(f"Subtracting ΔCT value of {list(x.keys())[0]} from ΔCT value of {list(y.keys())[0]}\nΔΔCT = {r}")
sum += r
print("-" * 50)
print(f"Average ΔΔCT: {sum / len(trials["control"])}")