Commit 3ddac00d authored by Blaise Li's avatar Blaise Li
Browse files

Made lfc-lfc plotting specificities optional.

parent 34c5af35
...@@ -152,9 +152,11 @@ class Scatterplot: ...@@ -152,9 +152,11 @@ class Scatterplot:
if gene_id in chose_from] if gene_id in chose_from]
return [gene_id for gene_id in self.data.query(selector).index] return [gene_id for gene_id in self.data.query(selector).index]
def plot_maker(self, grouping=None, group2colour=None, **kwargs): def plot_maker(self, annotate_folds=True, grouping=None, group2colour=None, **kwargs):
"""Builds a plotting function that can colour dots based on them """Builds a plotting function that can colour dots based on them
belonging to a group defined by *grouping*.""" belonging to a group defined by *grouping*.
If *annotate_folds* is True, lines indicating 2-fold thresholds
will be added to the plot, as well as counts in each quadrants."""
def plotting_function(): def plotting_function():
"""Generates the scatterplot, returns its legend so that """Generates the scatterplot, returns its legend so that
*save_plot* can include it in the bounding box.""" *save_plot* can include it in the bounding box."""
...@@ -173,6 +175,7 @@ class Scatterplot: ...@@ -173,6 +175,7 @@ class Scatterplot:
return None return None
else: else:
raise raise
if annotate_folds:
# Lines indicating 2-fold threshold. # Lines indicating 2-fold threshold.
# Assumes the data are in log2 fold changes # Assumes the data are in log2 fold changes
line_style = { line_style = {
...@@ -307,7 +310,7 @@ class Scatterplot: ...@@ -307,7 +310,7 @@ class Scatterplot:
return plotting_function return plotting_function
def save_plot(self, outfile, def save_plot(self, outfile,
grouping=None, group2colour=None, annotate_folds=True, grouping=None, group2colour=None,
**kwargs): **kwargs):
"""Creates the plotting function and transmits it for execution """Creates the plotting function and transmits it for execution
to the function that really does the saving.""" to the function that really does the saving."""
...@@ -318,10 +321,14 @@ class Scatterplot: ...@@ -318,10 +321,14 @@ class Scatterplot:
# equal_axes = False # equal_axes = False
# else: # else:
# equal_axes = True # equal_axes = True
if annotate_folds:
equal_axes = True equal_axes = True
else:
equal_axes = False
save_plot( save_plot(
outfile, outfile,
self.plot_maker( self.plot_maker(
annotate_folds,
grouping=grouping, group2colour=group2colour, **kwargs), grouping=grouping, group2colour=group2colour, **kwargs),
equal_axes=equal_axes, equal_axes=equal_axes,
tight=True) tight=True)
...@@ -407,6 +414,12 @@ def main(): ...@@ -407,6 +414,12 @@ def main():
# "-t", "--transform", # "-t", "--transform",
# help="log2, log10, or a linear scale to apply.", # help="log2, log10, or a linear scale to apply.",
# default=0) # default=0)
parser.add_argument(
"--not_foldchanges",
help="Use this option to inactivate plotting options for "
"log2FoldChange.",
default=False,
action="store_true")
parser.add_argument( parser.add_argument(
"--plot_regression", "--plot_regression",
help="Use this option to plot the regression line.", help="Use this option to plot the regression line.",
...@@ -476,6 +489,7 @@ def main(): ...@@ -476,6 +489,7 @@ def main():
plot_data.save_plot( plot_data.save_plot(
# args.x_axis, args.y_axis, # args.x_axis, args.y_axis,
out_pdf, out_pdf,
annotate_folds=not args.not_foldchanges,
grouping=gene_list, group2colour=(list_name, args.colour), grouping=gene_list, group2colour=(list_name, args.colour),
x_range=args.data_range, x_range=args.data_range,
y_range=args.data_range, y_range=args.data_range,
...@@ -489,6 +503,7 @@ def main(): ...@@ -489,6 +503,7 @@ def main():
plot_data.save_plot( plot_data.save_plot(
# args.x_axis, args.y_axis, # args.x_axis, args.y_axis,
out_pdf, out_pdf,
annotate_folds=not args.not_foldchanges,
x_range=args.data_range, x_range=args.data_range,
y_range=args.data_range, y_range=args.data_range,
regression=args.plot_regression) regression=args.plot_regression)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment