diff --git a/plot_lfclfc_scatter.py b/plot_lfclfc_scatter.py index 9c17183ea5ff18c3bbc5ca27d30e4a6e377c4aab..b872063f59fa974f904245403ca76e2ba45a5c42 100755 --- a/plot_lfclfc_scatter.py +++ b/plot_lfclfc_scatter.py @@ -150,9 +150,21 @@ class Scatterplot: line_style = { "linewidth": 0.5, "color": "lightblue", "linestyle": "dashed"} axis.axhline(y=1, **line_style) + axis.annotate( + f"y = 1", xy=(min(self.data.x)-1, 1), xycoords="data", + verticalalignment='bottom', size="x-small", color="lightblue") axis.axhline(y=-1, **line_style) + axis.annotate( + f"y = -1", xy=(min(self.data.x)-1, -1), xycoords="data", + verticalalignment='top', size="x-small", color="lightblue") axis.axvline(x=1, **line_style) + axis.annotate( + f"x = -1", xy=(-1, min(self.data.y)-1), xycoords="data", + horizontalalignment='right', rotation=90, size="x-small", color="lightblue") axis.axvline(x=-1, **line_style) + axis.annotate( + f"x = 1", xy=(1, min(self.data.y)-1), xycoords="data", + horizontalalignment='left', rotation=90, size="x-small", color="lightblue") # Number of genes beyond lfc thresholds, in each quadrant # up_up = 100 * len(self.data.query( # f"x > 1 & y > 1")) / len(self.data) @@ -163,34 +175,34 @@ class Scatterplot: # down_down = 100 * len(self.data.query( # f"x < 1 & y < 1")) / len(self.data) up_up = len(self.data.query( - f"x > 1 & y > 1")) + "x > 1 & y > 1")) up_down = len(self.data.query( - f"x > 1 & y < 1")) + "x > 1 & y < -1")) down_up = len(self.data.query( - f"x < 1 & y > 1")) + "x < -1 & y > 1")) down_down = len(self.data.query( - f"x < 1 & y < 1")) + "x < -1 & y < -1")) # axis.text(0.9, 0.9, f"{up_up}", transform = axis.transAxes) # axis.text(0.9, 0.1, f"{up_down}", transform = axis.transAxes) # axis.text(0.1, 0.9, f"{down_up}", transform = axis.transAxes) # axis.text(0.1, 0.1, f"{down_down}", transform = axis.transAxes) axis.annotate( - f"{up_up}", xy=(0.95, 0.95), xycoords='axes fraction', + f"{up_up}", xy=(0.95, 0.95), xycoords="axes fraction", size="x-small", color="lightblue", horizontalalignment="right", verticalalignment="top") axis.annotate( - f"{up_down}", xy=(0.95, 0.05), xycoords='axes fraction', + f"{up_down}", xy=(0.95, 0.05), xycoords="axes fraction", size="x-small", color="lightblue", horizontalalignment="right", verticalalignment="bottom") axis.annotate( - f"{down_up}", xy=(0.05, 0.95), xycoords='axes fraction', + f"{down_up}", xy=(0.05, 0.95), xycoords="axes fraction", size="x-small", color="lightblue", horizontalalignment="left", verticalalignment="top") axis.annotate( - f"{down_down}", xy=(0.05, 0.05), xycoords='axes fraction', + f"{down_down}", xy=(0.05, 0.05), xycoords="axes fraction", size="x-small", color="lightblue", horizontalalignment="left", verticalalignment="bottom") @@ -224,16 +236,6 @@ class Scatterplot: equal_axes=True, tight=True) -######################################################### -# For better traceability, options and global variables # -# should be stored as class attributes # -######################################################### -# class Globals(object): -# """This object holds global variables.""" -# plot_diagonal = False -# max_logfold = None - - def main(): """Main function of the program.""" print(" ".join(sys.argv)) @@ -304,39 +306,6 @@ def main(): help="Colour to use for the elements in the list given by option " "--gene_list or --selector.") # parser.add_argument( - # "--label_size", - # type=int, - # help="Font size for axis labels", - # default=24) - # parser.add_argument( - # "--hm_label_size", - # type=int, - # help="Font size for fold heatmap labels", - # default=9) - # parser.add_argument( - # "--legend_size", - # type=int, - # help="Font size for legend labels", - # default=9) - # parser.add_argument( - # "--marker_size", - # type=int, - # help="Size for markers on the plot", - # default=4) - # parser.add_argument( - # "--tick_size", - # type=int, - # help="Font size for ticks", - # default=18) - # parser.add_argument( - # "-x", "--x_axis", - # help="Label for the x axis of the plot.", - # required=True) - # parser.add_argument( - # "-y", "--y_axis", - # help="Label for the y axis of the plot.", - # required=True) - # parser.add_argument( # "-t", "--transform", # help="log2, log10, or a linear scale to apply.", # default=0) @@ -347,8 +316,6 @@ def main(): args = parser.parse_args() # if args.plot_diagonal: # Globals.plot_diagonal = True - # if args.max_logfold: - # Globals.max_logfold = args.max_logfold plot_data = Scatterplot( args.x_input_data, args.y_input_data, @@ -365,10 +332,6 @@ def main(): # transform = int(args.transform) if args.gene_list: (list_name, base_gene_list) = get_gene_list(args.gene_list) - # with open(args.gene_list, "r") as infile: - # base_gene_list = [ - # strip_split(line)[0] for line in infile.readlines() - # if line[0] != "#"] else: base_gene_list = [] if args.selector: