code: def _run_bubbletree(vcf_csv, cnv_csv, data, wide_lrr=False, do_plots=True,
                      handle_failures=True):
      
      lrr_scale = 10.0 if wide_lrr else 1.0
      local_sitelib = utils.R_sitelib()
      base = utils.splitext_plus(vcf_csv)[0]
      r_file = "%s-run.R" % base
      bubbleplot_out = "%s-bubbleplot.pdf" % base
      trackplot_out = "%s-trackplot.pdf" % base
      calls_out = "%s-calls.rds" % base
      freqs_out = "%s-bubbletree_prevalence.txt" % base
      sample = dd.get_sample_name(data)
      do_plots = "yes" if do_plots else "no"
      with open(r_file, "w") as out_handle:
          out_handle.write(_script.format(**locals()))
      if not utils.file_exists(freqs_out):
          cmd = "%s && %s --no-environ %s" % (utils.get_R_exports(), utils.Rscript_cmd(), r_file)
          try:
              do.run(cmd, "Assess heterogeneity with BubbleTree")
          except subprocess.CalledProcessError as msg:
              if handle_failures and _allowed_bubbletree_errorstates(str(msg)):
                  with open(freqs_out, "w") as out_handle:
                      out_handle.write('bubbletree failed:\n %s"\n' % (str(msg)))
              else:
                  logger.exception()
                  raise
      return {"caller": "bubbletree",
              "report": freqs_out,
              "plot": {"bubble": bubbleplot_out, "track": trackplot_out}}
docs: Create R script and run on input data
  
      BubbleTree has some internal hardcoded paramters that assume a smaller
      distribution of log2 scores. This is not true for tumor-only calls, so if
      we specify wide_lrr we scale the calculations to actually get calls. Need a
      better long term solution with flexible parameters.