def run(self, clean=True):
        template = self.template
        parameters = self.parameters
        # write to a temporary R script
        fw = must_open("tmp", "w")
        path = fw.name

        fw.write(template.safe_substitute(**parameters))
        fw.close()

        sh("Rscript %s" % path)
        if clean:
            os.remove(path)
            # I have no idea why using ggsave, there is one extra image
            # generated, but here I remove it
            rplotspdf = "Rplots.pdf"
            if op.exists(rplotspdf):
                os.remove(rplotspdf)
Create a temporary file and run it
dataset/ETHPy150Open tanghaibao/jcvi/apps/r.py/RTemplate.run