comparison viz_graphs.py @ 27:a6f94856a282 draft

Uploaded
author glogobyte
date Sun, 05 Dec 2021 13:29:56 +0000
parents
children
comparison
equal deleted inserted replaced
26:6528239cedf0 27:a6f94856a282
1 # Import FPDF class
2 from fpdf import FPDF
3
4 # Import glob module to find all the files matching a pattern
5 import glob
6
7 #############################################################################################################################################################3
8
9 def pdf_after_DE(analysis,top,font_path,iso_star_fl,non_star_fl):
10
11 # Image extensions
12 if analysis=="2":
13 image_extensions = ("tem.png","a2.png","non.png")
14 else:
15 image_extensions = ("tem.png","a2.png")
16
17 # This list will hold the images file names
18 images = []
19
20 # Build the image list by merging the glob results (a list of files)
21 # for each extension. We are taking images from current folder.
22 for extension in image_extensions:
23 images.extend(glob.glob(extension))
24
25 # Create instance of FPDF class
26 pdf = FPDF('P', 'in', 'letter')
27 pdf.add_font('uni-arial', '', font_path+"/arial-unicode-ms.ttf", uni=True)
28 # Add new page. Without this you cannot create the document.
29 pdf.add_page()
30 # Set font to Arial, 'B'old, 16 pts
31 pdf.set_font('Arial', 'B', 16.0)
32
33 # Page header
34 pdf.cell(pdf.w-0.5, 0.5, 'Differential expression of miRNAs and isomiRs',align='C')
35 #pdf.ln(0.25)
36
37 pdf.ln(0.7)
38 pdf.set_font('Arial','B', 12.0)
39 if "tem.png" in images:
40 pdf.cell(pdf.w-0.5, 0.5, 'Top '+top+' differentially expressed miRNA and templated isoforms',align='C')
41 # Smaller font for image captions
42 pdf.set_font('Arial', '', 10.0)
43 # Image caption
44 pdf.ln(0.4)
45 pdf.image(images[images.index("tem.png")],x=0.8, w=7, h=8)
46 pdf.ln(0.3)
47 if iso_star_fl==1:
48 pdf.set_font('uni-arial', '', 9.0)
49 pdf.cell(0.2)
50 pdf.cell(3.0, 0.0, " ★ IsomiRs potentially generated from multiple loci")
51 #pdf.set_font('Arial','B', 12.0)
52 else:
53 print("WARNING: There aren't miRNAs which fullfiled these criteria" )
54 pdf.set_font('Arial','B', 12.0)
55 if "non.png" in images and analysis=="2":
56 if "tem.png" in images: pdf.add_page()
57 pdf.ln(0.7)
58 pdf.cell(pdf.w-0.5, 0.5, 'Top '+top+' differentially expressed non-templated isomiRs',align='C')
59 pdf.ln(0.4)
60 pdf.image(images[images.index("non.png")],x=0.8, w=7, h=8)
61 pdf.ln(0.3)
62 if non_star_fl==1:
63 pdf.set_font('uni-arial', '', 9.0)
64 pdf.cell(0.2)
65 pdf.cell(3.0, 0.0, " ★ IsomiRs potentially generated from multiple loci")
66
67 #pdf.image(images[images.index("non.png")],x=0.5, w=7.5, h=6.5)
68 else:
69 print("WARNING: There aren't non-template miRNAs which fullfiled these criteria" )
70
71 pdf.set_font('Arial','B', 12.0)
72 if "a2.png" in images:
73 if len(images)>=2: pdf.add_page()
74 pdf.ln(0.5)
75 pdf.cell(pdf.w-0.5, 0.5, 'Top differentially expressed miRNAs and isomiRs grouped by arm',align='C')
76 pdf.ln(0.4)
77 pdf.image(images[images.index("a2.png")],x=0.8, w=7, h=8)
78 pdf.ln(0.3)
79 else:
80 print("WARNING: There aren't non-template miRNAs which fullfiled these criteria" )
81
82
83 pdf.output('report2.pdf', 'F')
84
85
86