Skip to content

Commit d2048d0

Browse files
FIX: Correct significance line plot to use cutoff p-value (#237)
1 parent 4379b0a commit d2048d0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

python/varspark/lfdrvsnohail.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,27 +184,26 @@ def compute_fdr(self, countThreshold=2, local_fdr_cutoff=0.05, bins=120):
184184
self.local_fdr = LocalFdr()
185185
self.local_fdr.fit(impDfWithLog, bins)
186186
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
188190
self.pvalsDF = impDfWithLog.reset_index().assign(
189191
pvalue=pvals, is_significant=mask
190192
)
191193
return (self.pvalsDF, fdr)
192194

193-
def plot_manhattan_imp(self, fdr=None, gap_size=None):
195+
def plot_manhattan_imp(self, gap_size=None):
194196
"""Displays manhattan plot of negative log importances for each feature, as well as significance cutoff.
195197
Categorises features in respective chromosomes, ordered by locus.
196198
:param gap_size: The size of gap between each chromosome.
197199
Included as an adjustable parameter as this value scales with the total number of loci
198200
"""
199201
pvals = self.pvalsDF
202+
cutoff_pvalue = self.cutoff_pvalue
200203
# Estimate appropriate size for gap between chromosomes based on number of loci to plot
201204
gap_size = (
202205
gap_size if gap_size is not None else int(np.ceil(pvals.shape[0] / 80))
203206
)
204-
if fdr is None:
205-
cutoff = self.local_fdr_cutoff
206-
else:
207-
cutoff = fdr
208207

209208
def process_variant_id(variant_id):
210209
"""Extracts chromosome, locus, and alleles from the variant_id field using regex
@@ -243,14 +242,15 @@ def process_variant_id(variant_id):
243242
x="x",
244243
y="-logp",
245244
aspect=3.7,
245+
linewidth=0,
246246
hue="chrom",
247247
palette="bright",
248248
legend=None,
249249
)
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="--")
252252
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}"
254254
)
255255
chrom_df = sorted_pvals.groupby("chrom")["x"].median()
256256
plot.ax.set_xlabel("chrom")

0 commit comments

Comments
 (0)