예제 #1
0
def run_r_script_logged(branch: "CellBranch", r_script_filepath: str,
                        arg_list: list, logfile_prefix: str):
    """
    Runs an R script for a process, which additionally entails outputting log
    files
    """
    command_string = f"Rscript {r_script_filepath} {' '.join(map(str, arg_list))}"
    process_run = branch[branch.current_process]
    logs_dir = str(process_run.logs_path)
    process_shell_command(command_string, logs_dir, logfile_prefix)
예제 #2
0
def run_process_r_script(forest: "CellForest", r_script_filepath: str,
                         arg_list: list, process_name: str):
    """
    Runs an R script for a process, which additionally entails outputting log
    files
    """
    command_string = f"Rscript {r_script_filepath} {' '.join(map(str, arg_list))}"
    working_dir = str(forest[process_name].path)
    process_shell_command(
        command_string=command_string,
        working_dir=working_dir,
        process_name=process_name,
    )
예제 #3
0
def old_rds_to_pickle(rds_path, output_dir):
    output_dir = Path(output_dir)
    if not os.path.isfile(rds_path):
        raise ValueError(f"rds file does not exists: {rds_path}")
    output_mtx_path = output_dir / "matrix.mtx"
    output_pickle_path = output_dir / "matrix.pickle"
    output_cell_ids_path = output_dir / "cell_ids.tsv"
    output_genes_path = output_dir / "genes.tsv"
    output_metadata_path = output_dir / "cell_metadata.tsv"
    cmd_str = f"Rscript {RDS_CONVERTER_SCRIPT} {rds_path} {output_mtx_path} {output_cell_ids_path} {output_genes_path} {output_metadata_path}"
    process_shell_command(cmd_str, output_dir, "matrix_rds_to_sparse_pickle")
    sparse_matrix = mmread(str(output_mtx_path)).T.tocsr()
    with open(str(output_pickle_path), "wb") as f:
        pickle.dump(sparse_matrix, f, protocol=pickle.HIGHEST_PROTOCOL)
    paths_to_zip = [output_mtx_path, output_cell_ids_path, output_genes_path]
    for filepath in paths_to_zip:
        gzip_replace(filepath)
예제 #4
0
 def _run_r_script(script_path: str, working_dir: Union[str, Path],
                   arg_list: list, process_name: str):
     command_string = f"Rscript {str(script_path)} {' '.join(map(str, arg_list))}"
     process_shell_command(command_string=command_string,
                           logs_dir=working_dir,
                           logfile_prefix=process_name)