@@ -104,10 +104,11 @@ def VolcanoPlot(fc,NBpval2,significant,pvalDir,ScreenType,sample,res,svg,alpha):
104104 plt .figure (figsize = (5 ,4 ))
105105 plt .scatter (logfc ,neglogp2 ,s = 3 ,facecolor = 'grey' ,lw = 0 ,alpha = 0.35 )
106106 plt .scatter (logfc_sig ,neglogp2_sig ,s = 3 ,facecolor = 'green' ,lw = 0 ,alpha = 0.35 ,label = 'FDR<' + str (alpha ))
107- xmin = min (min (logfc_sig ),min (logfc ))
108- xmax = max (max (logfc_sig ),max (logfc ))
109- ymax = max (max (neglogp2_sig ),max (neglogp2 ))
110- plt .xlim ([0.95 * xmin ,1.05 * xmax ]); plt .ylim ([0 ,1.05 * ymax ])
107+ if len (logfc_sig )> 0 and len (neglogp2_sig )> 0 :
108+ xmin = min (min (logfc_sig ),min (logfc ))
109+ xmax = max (max (logfc_sig ),max (logfc ))
110+ ymax = max (max (neglogp2_sig ),max (neglogp2 ))
111+ plt .xlim ([0.95 * xmin ,1.05 * xmax ]); plt .ylim ([0 ,1.05 * ymax ])
111112 plt .xlabel ('log2 fold change' , fontsize = 12 )
112113 plt .ylabel ('-log10 p-value (two-sided)' , fontsize = 12 )
113114 plt .title (sample + ' sgRNA Volcano Plot' , fontsize = 14 )
@@ -129,7 +130,10 @@ def QQPlot(NBpval,significant,pvalDir,sample,res,svg,alpha):
129130 neglogpExp .sort ()
130131 sig = [significant [k ] for k in range (L )]
131132 sig .sort ()
132- S = list (sig ).index (True )
133+ if True in sig :
134+ S = list (sig ).index (True )
135+ else :
136+ S = L
133137 plt .figure (figsize = (5 ,4 ))
134138 plt .scatter (neglogpExp [0 :S ],neglogp [0 :S ],s = 8 ,facecolor = 'grey' ,lw = 0 ,alpha = 0.35 )
135139 plt .scatter (neglogpExp [S :],neglogp [S :],s = 8 ,facecolor = 'green' ,lw = 0 ,alpha = 0.35 ,label = 'FDR<' + str (alpha ))
@@ -156,7 +160,10 @@ def zScorePlot(fc,significant,pvalDir,ScreenType,sample,res,svg,alpha):
156160 zScores = [(logfc [k ]- m )/ std for k in range (L )]
157161 sig = [significant [k ] for k in range (L )]
158162 sig .sort ()
159- S = list (sig ).index (True )
163+ if True in sig :
164+ S = list (sig ).index (True )
165+ else :
166+ S = L
160167 if ScreenType == 'enrichment' :
161168 zScores .sort ();
162169 elif ScreenType == 'depletion' :
@@ -172,6 +179,9 @@ def zScorePlot(fc,significant,pvalDir,ScreenType,sample,res,svg,alpha):
172179 plt .xlabel ('ranked sgRNAs' , fontsize = 12 )
173180 plt .ylabel ('z-Score' , fontsize = 12 )
174181 plt .title (sample + ' sgRNA ' + ScreenType ,fontsize = 14 )
175- plt .legend (loc = 'upper left' , prop = {'size' :10 })
182+ if ScreenType == 'enrichment' :
183+ plt .legend (loc = 'upper left' , prop = {'size' :10 })
184+ elif ScreenType == 'depletion' :
185+ plt .legend (loc = 'upper right' , prop = {'size' :10 })
176186 plt .tight_layout ()
177187 plt .savefig (sample + '_' + 'sgRNA_zScores.png' , dpi = res )
0 commit comments