Cloufield / gwaslab

A Python package for handling and visualizing GWAS summary statistics. https://cloufield.github.io/gwaslab/
GNU General Public License v3.0
151 stars 25 forks source link

How to use log10P values as input for Manhattan plot? #7

Closed michaelofrancis closed 1 year ago

michaelofrancis commented 1 year ago

Hi, I'm trying to use a table where after importing mysumstats there is a column called "MLOG10P". I thought this should be recognized but I still get this error. I also don't see this in the documentation. The issue as you know is that often P values exceed the float limit around 1e-300 and so log10P should be used. Thanks!

`ValueError Traceback (most recent call last) Cell In[21], line 1 ----> 1 mysumstats.plot_mqq(mode="m",cut=50,colors=["#597FBD","#74BAD3"])

File ~/Library/Python/3.9/lib/python/site-packages/gwaslab/Sumstats.py:405, in Sumstats.plot_mqq(self, args) 402 else: 403 eaf=None --> 405 plot = mqqplot(self.data,snpid=snpid, chrom=chrom, pos=pos, p=p, eaf=eaf,args) 407 return plot

File ~/Library/Python/3.9/lib/python/site-packages/gwaslab/mqqplot.py:194, in mqqplot(insumstats, chrom, pos, p, snpid, eaf, chr_dict, xtick_chr_dict, vcf_path, vcf_chr_dict, gtf_path, gtf_chr_dict, gtf_gene_name, rr_path, rr_header_dict, rr_chr_dict, mlog10p, scaled, mode, scatter_kwargs, region, region_step, region_grid, region_grid_line, region_lead_grid, region_lead_grid_line, region_hspace, region_ld_threshold, region_ld_colors, region_recombination, region_protein_coding, region_flank_factor, region_anno_bbox_args, taf, tabix, mqqratio, bwindowsizekb, density_color, density_range, density_trange, density_threshold, density_tpalette, density_palette, windowsizekb, anno, anno_set, anno_alias, anno_d, anno_args, anno_style, anno_fixed_arm_length, anno_source, anno_adjust, anno_max_iter, arm_offset, arm_scale, arm_scale_d, cut, skip, cutfactor, cut_line_color, sig_line, sig_level, sig_line_color, suggestive_sig_level, highlight, highlight_color, highlight_windowkb, pinpoint, pinpoint_color, stratified, maf_bins, maf_bin_colors, gc, include_chrXYMT, title, mtitle, qtitle, title_pad, title_fontsize, fontsize, anno_fontsize, figargs, colors, marker_size, use_rank, verbose, repel_force, build, dpi, save, saveargs, _invert, log) 192 pass 193 else : --> 194 raise ValueError("Please make sure "+p+" column is in input sumstats.") 196 # CHR and POS ######################################################################## 197 # chrom and pos exists && (m || r mode) 198 if (chrom is not None) and (pos is not None) and (("m" in mode) or ("r" in mode)): 199 # when manhattan plot, chrom and pos is needed.

ValueError: Please make sure P column is in input sumstats.`

Cloufield commented 1 year ago

Hi, Sorry for the error, I just fixed it and please update to pip install gwaslab==3.4.0. You can add "scaled=True" to directly use MLOG10P instead of P.

mysumstats.plot_mqq(skip=2, cut=20, scaled=True)
michaelofrancis commented 1 year ago

This works, thank you! I have a few other problems but I will open a new issue.