modified: Makefile
[GalaxyCodeBases.git] / python / salus / dfcorr / diffout.py
blob54000ad0bc11f25ebf69ad498cf932625f77279e
1 #!/usr/bin/env python3
3 import numpy as np
4 import matplotlib as mpl
5 import matplotlib.pyplot as plt
6 from matplotlib.backends.backend_pdf import PdfPages
7 mpl.rcdefaults()
8 mpl.rc('ps', fonttype=42, papersize='figure')
9 mpl.rc('pdf', fonttype=42, compression=9) #pdf.fonttype: 3 # Output Type 3 (Type3) or Type 42 (TrueType)
10 mpl.rc('figure', figsize=(129/25.4, 129/25.4), dpi=600) # autolayout=True
11 mpl.rc('savefig', dpi='figure') # bbox='tight'
13 import pandas as pd
14 import seaborn as sns
16 def qw(s):
17 return tuple(s.split())
19 prefix = '/share/result/spatial/test_huxs/prj/cmpmethod/testicles2/c2ltest/'
21 diffout = pd.read_csv(f'{prefix}diffout.csv.zst', index_col=0)
22 diffcorr=diffout.corr()
24 # micromamba install zstandard
25 factors = qw('Elongating Endothelial InnateLymph Leydig Macrophage Myoid SPG STids Scytes Sertoli Unknown')
27 pdf = PdfPages(f'{prefix}diffout.pdf')
28 for onefactor in factors:
29 colids = []
30 colids.append(f"{onefactor}_1")
31 colids.append(f"{onefactor}_2")
32 onecorr = diffcorr[colids[0]][colids[1]]
33 print(f'{onefactor}: {onecorr}')
34 tmpDF=pd.DataFrame()
35 tmpDF['rank1']=diffout[colids[0]].rank()
36 tmpDF['rank2']=diffout[colids[1]].rank()
37 tmpDF[colids[0]]=diffout[colids[0]]
38 tmpDF[colids[1]]=diffout[colids[1]]
39 plt.figure()
40 sns.jointplot(data=tmpDF, x=colids[0], y=colids[1],kind="scatter",marginal_ticks=True,s=1)
41 plt.suptitle(f'{onefactor}, Corr: {onecorr}')
42 pdf.savefig()
43 plt.close()
44 pdf.close()
45 print(f'.\n[i]Done.', flush=True)