Permalink
Browse files

Flag called no-posteriors to plot dot py to avoid plotting posteriors…

… in case only read densities along gene and junctions are of interest
  • Loading branch information...
1 parent ba50bd8 commit 0e29a04ea3f4923e994d2d5b869efd7c0718550b @yarden committed Feb 3, 2012
@@ -16,7 +16,7 @@ class Sashimi:
"""
def __init__(self, label, output_dir, dimensions=None, png=False,
output_filename=None, settings_filename=None,
- event=None, chrom=None):
+ event=None, chrom=None, no_posteriors=False):
"""
Initialize image settings.
"""
@@ -37,7 +37,8 @@ def __init__(self, label, output_dir, dimensions=None, png=False,
if self.settings_filename != None:
self.settings = plot_settings.parse_plot_settings(settings_filename,
event=event,
- chrom=chrom)
+ chrom=chrom,
+ no_posteriors=no_posteriors)
else:
# Load default settings if no settings filename was given
self.settings = plot_settings.get_default_settings()
@@ -103,7 +103,8 @@ def plot_bf_dist(bf_filename, settings_filename, output_dir,
def plot_event(event_name, pickle_dir, settings_filename,
- output_dir):
+ output_dir,
+ no_posteriors=False):
"""
Visualize read densities across the exons and junctions
of a given MISO alternative RNA processing event.
@@ -128,8 +129,12 @@ def plot_event(event_name, pickle_dir, settings_filename,
pickle_filename = event_to_filenames[event_name]
+ if no_posteriors:
+ print "Asked to not plot MISO posteriors."
+
plot_density_from_file(settings_filename, pickle_filename, event_name,
- output_dir)
+ output_dir,
+ no_posteriors=no_posteriors)
def plot_insert_len(insert_len_filename,
@@ -243,6 +248,8 @@ def main():
"annotation file, (2) directory where MISO output is for that event type (e.g. if event is a "
"skipped exon, provide the directory where the output for all SE events are), "
"(3) path to plotting settings file.")
+ parser.add_option("--no-posteriors", dest="no_posteriors", default=False, action="store_true",
+ help="If given this argument, MISO posterior estimates are not plotted.")
parser.add_option("--output-dir", dest="output_dir", nargs=1, default=None,
help="Output directory.")
(options, args) = parser.parse_args()
@@ -256,6 +263,8 @@ def main():
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
+ no_posteriors = options.no_posteriors
+
if options.plot_insert_len != None:
insert_len_filename = os.path.abspath(os.path.expanduser(options.plot_insert_len[0]))
settings_filename = os.path.abspath(os.path.expanduser(options.plot_insert_len[1]))
@@ -275,7 +284,9 @@ def main():
event_name = options.plot_event[0]
pickle_dir = os.path.abspath(os.path.expanduser(options.plot_event[1]))
settings_filename = os.path.abspath(os.path.expanduser(options.plot_event[2]))
- plot_event(event_name, pickle_dir, settings_filename, output_dir)
+ plot_event(event_name, pickle_dir, settings_filename, output_dir,
+ no_posteriors=no_posteriors)
+
if __name__ == '__main__':
@@ -624,7 +624,8 @@ def cubic_bezier(pts, t):
def plot_density_from_file(settings_f, pickle_filename, event,
- output_dir):
+ output_dir,
+ no_posteriors=False):
"""
Read MISO estimates given an event name.
"""
@@ -633,20 +634,21 @@ def plot_density_from_file(settings_f, pickle_filename, event,
##
tx_start, tx_end, exon_starts, exon_ends, gene_obj, mRNAs, strand, chrom = \
parseGene(pickle_filename, event)
-
+
+ # Override settings flag on whether to show posterior plots
+ # if --no-posteriors was given to plot.py
sashimi_obj = Sashimi(event, output_dir,
event=event,
chrom=chrom,
- settings_filename=settings_f)
+ settings_filename=settings_f,
+ no_posteriors=no_posteriors)
print "Plotting read densities and MISO estimates along event..."
print " - Event: %s" %(event)
- # Parse user given settings
- #settings = plot_settings.parse_plot_settings(settings_f,
- # event=event,
- # chrom=chrom)
settings = sashimi_obj.settings
+ if no_posteriors:
+ settings["show_posteriors"] = False
bam_files = settings['bam_files']
miso_files = settings['miso_files']
@@ -58,7 +58,8 @@ def parse_plot_settings(settings_filename, event=None, chrom=None,
# Parameters to be interpreted as Python lists or
# data structures
DATA_PARAMS=["miso_files", "bam_files", "bf_thresholds",
- "bar_color", "sample_labels"]):
+ "bar_color", "sample_labels"],
+ no_posteriors=False):
"""
Populate a settings dictionary with the plotting parameters, parsed
as the right datatype.
@@ -108,7 +109,11 @@ def parse_plot_settings(settings_filename, event=None, chrom=None,
print "Error: Must provide sample label for each entry in bam_files!"
sys.exit(1)
- if "miso_prefix" in settings and (event != None and chrom != None):
+ if no_posteriors:
+ settings["show_posteriors"] = False
+
+ if ("miso_prefix" in settings) and (event != None and chrom != None) \
+ and settings["show_posteriors"]:
miso_files = miso_utils.get_miso_output_files(event, chrom, settings)
else:
miso_files = settings["miso_files"]

0 comments on commit 0e29a04

Please sign in to comment.