Skip to content

Commit c5a2e72

Browse files
committed
v2.15
1 parent 1f232fe commit c5a2e72

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

Scripts/AlignReads.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ def MapAndCount(sample):
360360
for k in range(L):
361361
GuideCounts.write(str(sgIDs[k]) + '\t'+ str(geneIDs[k]) + '\t' + str(ReadsPerGuide[k]) + '\n')
362362
GuideCounts.close()
363+
# No-mapping warning
364+
if sum(ReadsPerGuide) == 0:
365+
print('!! ERROR: Zero total read counts! Check library file and index !!')
363366
# Read counts per gene in library
364367
print('Counting reads per gene ...')
365368
global GeneList

Scripts/FindHits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ def PrepareHitList(sample):
157157
'control stdev [norm.]': [numpy.sqrt(sigma2[k]) for k in range(L)],
158158
'fold change': [fc[k] for k in range(L)],
159159
'p-value': ['%.2E' % Decimal(NBpval[k]) for k in range(L)],
160-
'adj. p-value': ['%.2E' % Decimal(NBpval_0[k]) for k in range(L)],
160+
'FDR': ['%.2E' % Decimal(NBpval_0[k]) for k in range(L)],
161161
'significant': [str(significant[k]) for k in range(L)]},
162162
columns = ['sgRNA','gene','counts [norm.]','control mean [norm.]',\
163-
'control stdev [norm.]','fold change','p-value','adj. p-value','significant'])
163+
'control stdev [norm.]','fold change','p-value','FDR','significant'])
164164
if ScreenType == 'enrichment':
165165
Results_df_0 = Results_df.sort_values(['significant','fold change'],ascending=[0,0])
166166
elif ScreenType == 'depletion':

Scripts/PinAPL.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,10 @@
170170
StatMsg = 'Time elapsed [hours]: ' + '%.3f' % time_elapsed +'\n'
171171
os.system('python -u PrintStatus.py TimeStamp "'+StatMsg+'" 2>&1 | tee -a PinAPL-Py.log')
172172

173-
# Move Log File
173+
# Move Log Files
174174
if not os.path.exists(LogFileDir):
175175
os.makedirs(LogFileDir)
176176
os.system('cp configuration.yaml '+LogFileDir)
177-
os.system('cp PinAPL-Py.log '+LogFileDir)
177+
os.system('cp PinAPL-Py.log '+LogFileDir)
178+
os.chdir(WorkingDir)
179+
os.system('cp DataSheet.xlsx '+LogFileDir)

Scripts/PlotCounts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ def GOI_Scatterplot(sample,GOI='None'):
120120
if svg:
121121
plt.savefig(sample+' '+GOI+' counts.svg')
122122
else:
123-
plt.savefig(sample+' '+' counts.png', dpi=res)
123+
plt.savefig(sample+' counts.png', dpi=res)
124124
if svg:
125-
plt.savefig(sample+' '+' counts.svg')
125+
plt.savefig(sample+' counts.svg')
126126
plt.close()
127127

128128
# ------------------------------------------------

Scripts/RankGenes.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def compute_aRRA(g):
8585
GOI = geneList[g]
8686
GOI_ranks_sig = list()
8787
for i in range(L):
88-
if GOI == genes[i] and (NB_pval[i] < alpha):
88+
if GOI == genes[i] and (NB_pval[i] < P_0):
8989
GOI_ranks_sig.append(ranks[i])
9090
j = len(GOI_ranks_sig)
9191
if j>0:
@@ -103,7 +103,7 @@ def compute_aRRA(g):
103103
def compute_aRRA_null(I):
104104
I_ranks_sig = list()
105105
for i in range(L):
106-
if (i in I) and (NB_pval[i] < alpha):
106+
if (i in I) and (NB_pval[i] < P_0):
107107
I_ranks_sig.append(ranks[i])
108108
j = len(I_ranks_sig)
109109
if j>0:
@@ -152,7 +152,7 @@ def GeneRankingAnalysis(sample):
152152
ListDir = config['HitDir']
153153
EffDir = config['EffDir']
154154
GeneDir = config['GeneDir']
155-
global alpha; alpha = config['alpha']
155+
alpha = config['alpha']
156156
padj = config['padj']
157157
num_cores = multiprocessing.cpu_count()
158158
global r; r = config['sgRNAsPerGene']
@@ -162,6 +162,7 @@ def GeneRankingAnalysis(sample):
162162
pvalDir = config['pvalDir']
163163
res = config['dpi']
164164
svg = config['svg']
165+
global P_0; P_0 = 0.05 # p-value Threshold for aRRA analysis
165166

166167
# ------------------------------------------------
167168
# Read sgRNA enrichment/depletion table
@@ -224,7 +225,7 @@ def GeneRankingAnalysis(sample):
224225
plt.savefig(sample+'_sgRNA_Efficiency.svg')
225226
else: # no control replicates
226227
print('WARNING: No control replicates found! No significant sgRNAs counted.')
227-
sigGuides = ['N/A' for k in range(len(sigGuides))]
228+
sigGuides = ['N/A' for k in range(G)]
228229
# Plot histogram
229230
if not os.path.exists(EffDir):
230231
os.makedirs(EffDir)
@@ -316,6 +317,7 @@ def GeneRankingAnalysis(sample):
316317
SortFlag = True
317318
metric = [-1 for k in range(G)]
318319
metric_pval = [-1 for k in range(G)]
320+
metric_pval0 = [-1 for k in range(G)]
319321
metric_sig = ['N/A' for k in range(G)]
320322
elif GeneMetric == 'STARS':
321323
# -------------------------------------------------
@@ -376,8 +378,9 @@ def GeneRankingAnalysis(sample):
376378
# -------------------------------------------------
377379
# p-value plots
378380
# -------------------------------------------------
379-
print('Plotting p-values ...')
380-
pvalHist_metric(metric_pval,metric_pval0,GeneMetric,pvalDir,sample,res,svg)
381+
if min(NB_pval) > -1:
382+
print('Plotting p-values ...')
383+
pvalHist_metric(metric_pval,metric_pval0,GeneMetric,pvalDir,sample,res,svg)
381384

382385
# -------------------------------------------------
383386
# Output list
@@ -389,15 +392,16 @@ def GeneRankingAnalysis(sample):
389392
Results_df = pandas.DataFrame(data = {'gene': [geneList[g] for g in range(G)],
390393
GeneMetric: [metric[g] for g in range(G)],
391394
GeneMetric+' p_value': ['%.2E' % Decimal(metric_pval[g]) for g in range(G)],
392-
GeneMetric+' adj. p_value': ['%.2E' % Decimal(metric_pval0[g]) for g in range(G)],
393-
'significant': [metric_sig[g] for g in range(G)],
395+
GeneMetric+' FDR': ['%.2E' % Decimal(metric_pval0[g]) for g in range(G)],
396+
'significant': [str(metric_sig[g]) for g in range(G)],
394397
'# signif. sgRNAs': [sigGuides[g] for g in range(G)]},
395-
columns = ['gene',GeneMetric,GeneMetric+' p_value',GeneMetric+' adj. p_value',\
398+
columns = ['gene',GeneMetric,GeneMetric+' p_value',GeneMetric+' FDR',\
396399
'significant','# signif. sgRNAs'])
397400
Results_df_0 = Results_df.sort_values(['significant',GeneMetric],ascending=[False,SortFlag])
398401
GeneListFilename = filename[0:-14]+'_'+GeneMetric+'_'+'P'+str(Np)+'_GeneList.tsv'
399402
Results_df_0.to_csv(GeneListFilename, sep = '\t', index = False)
400403
if SheetFormat == 'xlsx':
404+
print('Converting to xlsx ...')
401405
GeneListFilename = filename[0:-14]+'_'+GeneMetric+'_'+'P'+str(Np)+'_GeneList.xlsx'
402406
Results_df_0.to_excel(GeneListFilename)
403407

configuration.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
ScreenType: 'enrichment' # type of screen ['enrichment'/'depletion']
1010

1111
# LIBRARY PARAMETERS
12-
LibFilename: 'GeCKOv2_library.tsv' # filename of library spreadsheet
12+
LibFilename: 'GeCKOv2_Human.tsv' # filename of library spreadsheet
1313
seq_5_end: 'TCTTGTGGAAAGGACGAAACACCG' # sequence 5' of sgRNA in read
1414
seq_3_end: 'GTTTTAGAGCTAGAAATAGCAAGTT' # sequence 3' of sgRNA in read
1515
NonTargetPrefix: 'NonTargeting' # prefix for non-targeting sgRNAs in library (keep at default if none present)
@@ -22,9 +22,9 @@ keepCutReads: False # keep files containing trimmed reads? ['
2222
Normalization: 'cpm' # Normalization of read counts (counts per mio reads / size-factor) ['cpm'/'size']
2323
Cutoff: 0 # set counts (cpm) below this number to 0
2424
GeneMetric: 'aRRA' # metric for gene ranking ['aRRA'/'STARS'/'ES']
25-
ClusterBy: 'variance' # clustering criterion ['variance'/'counts']
25+
ClusterBy: 'counts' # clustering criterion ['variance'/'counts']
2626
HitListFormat: 'tsv' # Format of results spreadsheets (sgRNA hits and gene ranking) ['tsv'/'xlsx']
27-
alpha: 0.01 # significance level
27+
alpha: 0.10 # false discovery rate
2828
padj: 'fdr_bh' # method for p-value adjustment ['fdr_bh'/'fdr_tsbh']
2929

3030

0 commit comments

Comments
 (0)