Package: qqman
qqman for PythonIf you want to check out the source code or have any issues please leave a comment at mygithubrepository.This library is inspired by r-qqman (seehere).It also contains/will contain other methods for python users.ContentsIntroduction1.1.Installation1.2.Requirements1.3.FeaturesManhattan Plot2.1.Parameters2.2.ExamplesQQ Plot3.1.Parameters3.2.Examples1. Introduction1.1. InstallationUsing pip$pipinstallqqman1.2. Requirementsmatplotlibpandasnumpypip$pipinstallnumpy$pipinstallpandas$pipinstallmatplotlibananconda$condainstall-canacondanumpy$condainstall-y-canacondapandas$condainstall-y-cconda-forgematplotlib1.3. FeaturesManhattan PlotQQ Plot2. Manhattan PlotDraws Manhattan plot from PLINK --assoc output or any assoc formatted data that contains [chromosome/basepair/p-value] as columns.2.1. Parametersassoc: string or pandas.DataFrame- Input file path and name of the Plink assoc output.- Pandas DataFrame with columns [chromosome/basepair/p-value]out: string( optional )Output path and file name of the plot. (ie. out="./Manhattan.png")cmap: Colormap( optional : default=Greys_r )A Colormap instance or registered colormap name. matplotlib.cm.get_cmap()cmap_var: int or list( optional : default=2 )int : Number of colors to uselist : Specific colors to use in colormapshow: bool( optional )If true, the plot will be shown on your screen. (This option doesn't work in CUI environment.)gap: float( optional : default=10)A size of gaps between the group of scatter markers of each chromosome in Manhattan plotax: subplot( optional )If given, this subplot is used to plot in instead of a new figure being created.title: string( optional )A title of the plot.title_size: int( optional )A size of the title of the plot.label_size: int( optional )A size of x and y labels of the plot.xtick_size: int( optional )A size of xtick labels.ytick_size: int( optional )A size of ytick labels.xrotation: float( optional )A rotation degree of xtick labels.yrotation: float( optional )A rotation degree of ytick labels.col_chr: string( optional : default="CHR" )A string denoting the column name for the chromosome. Defaults to PLINK’s "CHR" Said column must be numeric.If you have X, Y, or MT chromosomes, be sure to renumber these 23, 24, 25, etc.col_bp: string( optional : default="BP" )A string denoting the column name for the chromosomal position. Defaults to PLINK’s "BP" Said column must be numeric.col_p: string( optional : default="P" )A string denoting the column name for the p-value. Defaults to PLINK’s "P" Said column must be numeric.col_snp: string( optional : default="SNP" )A string denoting the column name for the SNP name (rs number). Defaults to PLINK’s "SNP" Said column should be a charactersuggestiveline: string( optional : default=-log_10(1e-5) )Where to draw a "suggestive" line. Set to False to disable.genomewideline: string( optional : default=-log_10(5e-8) )Where to draw a "genome-wide sigificant" line. Set to False to disable.2.2. Examples2.2.1. Simplefromqqmanimportqqmanif__name__=="__main__":qqman.manhattan("../../temp.assoc",out="./Manhattan.png")2.2.2. Using Subplotfromqqmanimportqqmanimportpandasaspdimportmatplotlib.pyplotaspltif__name__=="__main__":df_assoc=pd.read_csv("../../temp.assoc",header=0,delim_whitespace=True)figure,axes=plt.subplots(nrows=2,ncols=2,figsize=(20,20))qqman.manhattan("../../temp.assoc",ax=axes[0,0],title="Wider gap 100",gap=100)qqman.manhattan("../../temp.assoc",ax=axes[0,1],title="No lines",suggestiveline=False,genomewideline=False)qqman.manhattan("../../temp.assoc",ax=axes[1,0],title="Different colormap",cmap=plt.get_cmap("jet"),cmap_var=10)qqman.manhattan(df_assoc,ax=axes[1,1],title="From DataFrame with xtick rotation",xrotation=45)figure.tight_layout()plt.savefig("./manhattan.png",format="png")plt.clf()plt.close()3. QQ PlotDraws a quantile-quantile plot from p-values of GWAS.3.1. Parametersassoctypes: [string, pandas.DataFrame, numpy.array, list]- Input file path and name of the Plink assoc output.- Pandas DataFrame with columns [chromosome/basepair/p-value]out: string( optional )Output path and file name of the plot. (ie. out="./Manhattan.png")show: bool( optional )If true, the plot will be shown on your screen. (This option doesn't work in CUI environment.)ax: subplot( optional )If given, this subplot is used to plot in instead of a new figure being created.title: string( optional )A title of the plot.title_size: int( optional )A size of the title of the plot.label_size: int( optional )A size of x and y labels of the plot.xtick_size: int( optional )A size of xtick labels.ytick_size: int( optional )A size of ytick labels.xrotation: float( optional )A rotation degree of xtick labels.yrotation: float( optional )A rotation degree of ytick labels.col_p: string( optional : default="P" )A string denoting the column name for the p-value. Defaults to PLINK’s "P" Said column must be numeric.3.2. Examples3.2.1. Simplefromqqmanimportqqmanif__name__=="__main__":qqman.qqplot("../../temp.assoc",out="./QQplot.png")3.2.2. Using Subplotfromqqmanimportqqmanimportpandasaspdimportmatplotlib.pyplotaspltif__name__=="__main__":df_assoc=pd.read_csv("../../temp.assoc",header=0,delim_whitespace=True)p_vals=list(df_assoc['P'])figure,axes=plt.subplots(nrows=2,ncols=2,figsize=(20,20))qqman.qqplot("../../temp.assoc",ax=axes[0,0],title="From file")qqman.qqplot(p_vals,ax=axes[0,1],title="From list")qqman.qqplot(df_assoc.P,ax=axes[1,0],title="From Series")qqman.qqplot(df_assoc,ax=axes[1,1],title="From DataFrame")figure.tight_layout()plt.savefig("./SubQQplot.png",format="png")plt.clf()plt.close()