def test_run_pipline(self): tempdir = exec.stages(self.stages, self.subdirs, keep_data=True) intensities = IntensityTable.load( os.path.join(tempdir, "results", self.spots_file)) self.verify_results(intensities) if os.getenv("TEST_KEEP_DATA") is None: shutil.rmtree(tempdir)
def _cli(cls, args, print_help=False): """Runs the decoder component based on parsed arguments.""" if args.decoder_algorithm_class is None or print_help: cls.decoder_group.print_help() cls.decoder_group.exit(status=2) instance = args.decoder_algorithm_class(**vars(args)) # load intensities and codebook intensities = IntensityTable.load(args.input) codebook = Codebook.from_json(args.codebook) # decode and save output intensities = instance.decode(intensities, codebook) intensities.save(args.output)
def test_run_pipeline(self): tempdir = tempfile.mkdtemp() coverage_enabled = "STARFISH_COVERAGE" in os.environ def callback(interval): print(" ".join(stage[:2]), " ==> {} seconds".format(interval)) try: for subdir in TestWithIssData.SUBDIRS: os.makedirs( "{tempdir}".format(tempdir=os.path.join(tempdir, subdir))) for stage in TestWithIssData.STAGES: cmdline = [ element(tempdir=tempdir) if callable(element) else element for element in stage ] if cmdline[0] == "starfish" and coverage_enabled: coverage_cmdline = [ "coverage", "run", "-p", "--source", "starfish", "-m", "starfish", ] coverage_cmdline.extend(cmdline[1:]) cmdline = coverage_cmdline with clock.timeit(callback): subprocess.check_call(cmdline) intensities = IntensityTable.load( os.path.join(tempdir, "results", "spots.nc")) genes, counts = np.unique( intensities.coords[Codebook.Constants.GENE.value], return_counts=True) gene_counts = pd.Series(counts, genes) assert gene_counts['ACTB_human'] > gene_counts['ACTB_mouse'] finally: if os.getenv("TEST_ISS_KEEP_DATA") is None: shutil.rmtree(tempdir)
def _cli(cls, args, print_help=False): """Runs the gene_assignment component based on parsed arguments.""" from starfish import munge if args.gene_assignment_algorithm_class is None or print_help: cls.gene_assignment_group.print_help() cls.gene_assignment_group.exit(status=2) with open(args.coordinates_geojson, "r") as fh: coordinates = json.load(fh) regions = munge.geojson_to_region(coordinates) print('Assigning genes to cells...') intensity_table = IntensityTable.load(args.intensities) instance = args.gene_assignment_algorithm_class(**vars(args)) result = instance.assign_genes(intensity_table, regions) print("Writing | cell_id | spot_id to: {}".format(args.output)) result.to_json(args.output, orient="records")