@@ -184,27 +184,26 @@ def compute_fdr(self, countThreshold=2, local_fdr_cutoff=0.05, bins=120):
184
184
self .local_fdr = LocalFdr ()
185
185
self .local_fdr .fit (impDfWithLog , bins )
186
186
pvals = self .local_fdr .get_pvalues ()
187
- fdr , mask = self .local_fdr .get_fdr (local_fdr_cutoff )
187
+ fdr , cutoff_pvalue , mask = self .local_fdr .get_fdr (local_fdr_cutoff )
188
+ self .fdr = fdr
189
+ self .cutoff_pvalue = cutoff_pvalue
188
190
self .pvalsDF = impDfWithLog .reset_index ().assign (
189
191
pvalue = pvals , is_significant = mask
190
192
)
191
193
return (self .pvalsDF , fdr )
192
194
193
- def plot_manhattan_imp (self , fdr = None , gap_size = None ):
195
+ def plot_manhattan_imp (self , gap_size = None ):
194
196
"""Displays manhattan plot of negative log importances for each feature, as well as significance cutoff.
195
197
Categorises features in respective chromosomes, ordered by locus.
196
198
:param gap_size: The size of gap between each chromosome.
197
199
Included as an adjustable parameter as this value scales with the total number of loci
198
200
"""
199
201
pvals = self .pvalsDF
202
+ cutoff_pvalue = self .cutoff_pvalue
200
203
# Estimate appropriate size for gap between chromosomes based on number of loci to plot
201
204
gap_size = (
202
205
gap_size if gap_size is not None else int (np .ceil (pvals .shape [0 ] / 80 ))
203
206
)
204
- if fdr is None :
205
- cutoff = self .local_fdr_cutoff
206
- else :
207
- cutoff = fdr
208
207
209
208
def process_variant_id (variant_id ):
210
209
"""Extracts chromosome, locus, and alleles from the variant_id field using regex
@@ -243,14 +242,15 @@ def process_variant_id(variant_id):
243
242
x = "x" ,
244
243
y = "-logp" ,
245
244
aspect = 3.7 ,
245
+ linewidth = 0 ,
246
246
hue = "chrom" ,
247
247
palette = "bright" ,
248
248
legend = None ,
249
249
)
250
- cutoff_logp = - np .log10 (cutoff )
251
- plot .ax .axhline (y = cutoff_logp , color = "black " , linestyle = "--" )
250
+ cutoff_logp = - np .log10 (cutoff_pvalue )
251
+ plot .ax .axhline (y = cutoff_logp , color = "gray " , linestyle = "--" )
252
252
plot .ax .text (
253
- plot .ax .get_xlim ()[1 ] + 0.1 , cutoff_logp , f"FDR Cutoff = { cutoff :.6f} "
253
+ plot .ax .get_xlim ()[1 ] + 0.1 , cutoff_logp , f"Cutoff = { cutoff_pvalue :.6f} "
254
254
)
255
255
chrom_df = sorted_pvals .groupby ("chrom" )["x" ].median ()
256
256
plot .ax .set_xlabel ("chrom" )
0 commit comments