visualize_5_26.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. def geneplot_mhat(df, markeridcol, chr, pv, gwasp, markernames, gfont, gstyle, ax):
  2. if markeridcol is not None:
  3. if markernames is not None and markernames is True:
  4. for i in df[markeridcol].unique():
  5. if df.loc[df[markeridcol] == i, pv].iloc[0] <= gwasp:
  6. if gstyle == 1:
  7. plt.text(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0],
  8. str(i), fontsize=gfont)
  9. elif gstyle == 2:
  10. plt.annotate(i, xy=(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0]),
  11. xycoords='data', xytext=(5, -15), textcoords='offset points', size=6,
  12. bbox=dict(boxstyle="round", alpha=0.2),
  13. arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.2, relpos=(0, 0)))
  14. elif markernames is not None and isinstance(markernames, (tuple, list)):
  15. for i in df[markeridcol].unique():
  16. if i in markernames:
  17. if gstyle == 1:
  18. plt.text(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0],
  19. str(i), fontsize=gfont)
  20. elif gstyle == 2:
  21. plt.annotate(i, xy=(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0]),
  22. xycoords='data', xytext=(5, -15), textcoords='offset points', size=6,
  23. bbox=dict(boxstyle="round", alpha=0.2),
  24. arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.2, relpos=(0, 0)))
  25. elif markernames is not None and isinstance(markernames, dict):
  26. for i in df[markeridcol].unique():
  27. if i in markernames:
  28. if gstyle == 1:
  29. plt.text(df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0],
  30. markernames[i], fontsize=gfont)
  31. elif gstyle == 2:
  32. plt.annotate(markernames[i], xy=(
  33. df.loc[df[markeridcol] == i, 'ind'].iloc[0], df.loc[df[markeridcol] == i, 'tpval'].iloc[0]),
  34. xycoords='data', xytext=(5, -15), textcoords='offset points', size=6,
  35. bbox=dict(boxstyle="round", alpha=0.2),
  36. arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.2, relpos=(0, 0)))
  37. else:
  38. raise Exception("provide 'markeridcol' parameter")