fastlmm / FaST-LMM

Python version of Factored Spectrally Transformed Linear Mixed Models
https://fastlmm.github.io/
Apache License 2.0
47 stars 11 forks source link

Added color and ax options to manhattan_plot in util.py #15

Open lucasmiranda42 opened 3 years ago

lucasmiranda42 commented 3 years ago

I modified a bit your version of manhattan_plot to suit my needs. If you think it's appropriate, feel free to merge the slight changes :)

In a nutshell, I added two parameters, "color" and "ax". The first one just gives the user control over the color scheme of the plot, defaulting of course to the same configuration you have on the main branch.

The second adds the possibility to pass a pylab.axes object where to plot the figure, giving the user the possibility to superimpose two or more sets of SNPs to, for example, highlight certain regions. I leave an example below.

pylab.rcParams["figure.figsize"] = (22.0, 10.0)

ax = pylab.axes(label="manplot")    # Define the axes object where to plot
pylab.title("Example Manhattan plot")

chrom_starts = manhattan_plot(
               lmm_gwas_sumstats[["Chr", "ChrPos", "PValue"]].values,
               pvalue_line=5e-8,
               xaxis_unit_bp=True,
               ax=ax,
               )    # Store chrom_starts in a variable, which we'll pass to the second function call
manhattan_plot(
    snps_in_panel[["Chr", "ChrPos", "PValue"]].values,
    xaxis_unit_bp=True,
    color="red",
    chromosome_starts=chrom_starts,    # Pass the chrom_starts defined above
    alpha=1,
    ax=ax,
)

pylab.show()

The result, where two particular regions are highlighted in red: image