Mercurial > repos > jay > gaiac_violin_plot
annotate gaiac_precision_calculation/gaiac_precision_calculation.py @ 3:9de2b10ed246 draft default tip
planemo upload for repository https://github.com/jaidevjoshi83/gaiac commit e9587f93346c7b55e1be00bad5844bf2db3ed03d-dirty
author | jay |
---|---|
date | Thu, 10 Jul 2025 19:40:38 +0000 |
parents | abfc2c9779d6 |
children |
rev | line source |
---|---|
0
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
1 import scipy |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
2 import argparse |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
3 from scipy.stats.distributions import chi2 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
4 import pandas as pd |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
5 import numpy as np |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
6 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
7 def Precision(infile, clm1, clm2, Out): |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
8 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
9 df = pd.read_csv(infile, sep="\t") |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
10 lOc = int(df.shape[0]) |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
11 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
12 cl = df.columns.tolist() |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
13 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
14 df['PM10_OPC_DIFF']=(((df[cl[int(clm1)-1]])-(df[cl[int(clm2)-1]]))/(((df[cl[int(clm1)-1]])+(df[cl[int(clm2)-1]]))/2)*100) |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
15 df['PM10_OPC_DIFFs']=(df['PM10_OPC_DIFF'])*(df['PM10_OPC_DIFF']) |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
16 d10=df.PM10_OPC_DIFF.sum() |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
17 d10_2=df.PM10_OPC_DIFFs.sum() |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
18 CV_10= (np.sqrt((lOc*(d10_2)-(d10)**2)/(2*lOc*(lOc-1))))*(np.sqrt((lOc-1)/(chi2.ppf(0.1, df=lOc)))) |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
19 df1 = pd.DataFrame([CV_10], columns=['Percent Precision']) |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
20 df1.round(4).to_csv(Out,sep='\t') |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
21 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
22 if __name__=="__main__": |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
23 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
24 parser = argparse.ArgumentParser() |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
25 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
26 parser.add_argument("-I", "--infile", required=True, default=None, help="Input file") |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
27 parser.add_argument("-c1", "--column_1", required=True, default=None, help="First column") |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
28 parser.add_argument("-c2", "--column_2", required=True, default=None, help="Second column") |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
29 parser.add_argument("-o", "--out", required=True, default=None, help="OutFile") |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
30 args = parser.parse_args() |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
31 |
abfc2c9779d6
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
32 Precision(args.infile, args.column_1, args.column_2, args.out) |