def geneplot_mhat(df, markeridcol, chr, pv, gwasp, markernames, gfont, gstyle, ax): if markeridcol is not None: if markernames is not None and markernames is True: for i in df[markeridcol].unique(): if df.loc[df[markeridcol] == i, pv].iloc[0] <= gwasp: if gstyle == 1: plt.text(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0], str(i), fontsize=gfont) elif gstyle == 2: plt.annotate(i, xy=(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0]), xycoords='data', xytext=(5, -15), textcoords='offset points', size=6, bbox=dict(boxstyle="round", alpha=0.2), arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.2, relpos=(0, 0))) elif markernames is not None and isinstance(markernames, (tuple, list)): for i in df[markeridcol].unique(): if i in markernames: if gstyle == 1: plt.text(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0], str(i), fontsize=gfont) elif gstyle == 2: plt.annotate(i, xy=(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0]), xycoords='data', xytext=(5, -15), textcoords='offset points', size=6, bbox=dict(boxstyle="round", alpha=0.2), arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.2, relpos=(0, 0))) elif markernames is not None and isinstance(markernames, dict): for i in df[markeridcol].unique(): if i in markernames: if gstyle == 1: plt.text(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0], markernames[i], fontsize=gfont) elif gstyle == 2: plt.annotate(markernames[i], xy=( df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0]), xycoords='data', xytext=(5, -15), textcoords='offset points', size=6, bbox=dict(boxstyle="round", alpha=0.2), arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.2, relpos=(0, 0))) else: raise Exception("provide 'markeridcol' parameter")