def main(): """ Performs NMF decomposition with provided matrix """ args = parse_arguments() sig.sigProfilerExtractor(input_type = 'matrix', \ output = args.output, \ input_data = args.input_data, \ reference_genome = args.ref, \ opportunity_genome = args.ref, \ context_type = args.context_type, \ exome = args.exome, \ minimum_signatures = args.minimum_signatures, \ maximum_signatures = args.maximum_signatures, \ nmf_replicates = args.nmf_replicates, \ matrix_normalization = args.matrix_normalization, \ nmf_init = args.nmf_init, \ cpu = args.cpu, \ make_decomposition_plots = False, \ resample = args.resample, \ precision = args.precision, \ min_nmf_iterations = args.min_nmf_iterations, \ max_nmf_iterations = args.max_nmf_iterations, \ nmf_test_conv = args.nmf_test_conv, \ nmf_tolerance = args.nmf_tolerance, \ stability = args.stability, \ min_stability = args.min_stability, \ combined_stability = args.combined_stability, \ cosmic_version = args.cosmic_version, \ de_novo_fit_penalty = args.de_novo_fit_penalty, \ nnls_add_penalty = args.nnls_add_penalty, \ nnls_remove_penalty = args.nnls_remove_penalty, \ initial_remove_penalty = args.initial_remove_penalty, \ refit_denovo_signatures = args.refit_denovo_signatures ) return ()
def test_cpu(data): sig.sigProfilerExtractor("text", "example_output", data, startProcess=1, endProcess=2, totalIterations=3)
def main(argv): input = '' output = '' try: opts, args = getopt.getopt(argv, "hi:o:", ["ifile=", "ofile="]) except getopt.GetoptError: print('denovoSig.py -i <inputfile> -o <outputdir>') sys.exit(2) if len(sys.argv) <= 1: print('denovoSig.py -i <inputfile> -o <outputdir>') sys.exit(2) for opt, arg in opts: if opt == '-h': print('denovoSig.py -i <inputfile> -o <outputdir>') sys.exit() elif opt in ("-i", "--ifile"): inputfile = arg elif opt in ("-o", "--ofile"): outputdir = arg else: print('Unknown option', opt) print('denovoSig.py -i <inputfile> -o <outputdir>') sys.exit(2) print('Generating De Novo signatures for input file: ', inputfile) print('Output directory is: ', outputdir) #Run De Novo sig extraction sig.sigProfilerExtractor("table", outputdir, inputfile)
def main(): data = sig.importdata("text") sig.sigProfilerExtractor("text", "example_output", data, minimum_signatures=1, maximum_signatures=2, nmf_replicates=3)
def main(): data = sig.importdata("text") sig.sigProfilerExtractor("text", "example_output", data, startProcess=1, endProcess=2, totalIterations=3)
def test_gpu(data): if torch.cuda.device_count() > 0: sig.sigProfilerExtractor("text", "example_output", data, startProcess=1, endProcess=2, totalIterations=3, gpu=True)
def extractSignatures(output, vcfpath, genome, project, sigClass='SBS', sigContext='96', exome=False, threads=-1): """Extracts signatures from a matrix generated by SigProfilerMatrixGenerator""" sigType = sigClass + sigContext if exome: input_data = vcfpath + "/output/" + sigClass + "/" + project + "." + sigType + ".exome" else: input_data = vcfpath + "/output/" + sigClass + "/" + project + "." + sigType + ".all" sig.sigProfilerExtractor("matrix", output, input_data, reference_genome=genome, opportunity_genome=genome, context_type=sigType, minimum_signatures=1, maximum_signatures=10, cpu=threads) from SigProfilerExtractor import decomposition as decomp signatures = output + "/" + sigType + "/Suggested_Solution/" + sigType + "_De-Novo_Solution/Signatures/" + sigType + "_De-Novo_Signatures.txt" activities = output + "/" + sigType + "/Suggested_Solution/" + sigType + "_De-Novo_Solution/Activities/" + sigType + "_De-Novo_Activities_refit.txt" samples = output + "/" + sigType + "/Samples.txt" #to get all cosmic signatures without filtering decomp.decompose(signatures, activities, samples, output, genome_build=genome, verbose=False, nnls_add_penalty=0.0, nnls_remove_penalty=0.0, initial_remove_penalty=0.0, de_novo_fit_penalty=0.02)
if os.path.isdir(mk_dir_path) is False: os.mkdir(mk_dir_path) sp.call(rf'cp {vcf_file} {mk_dir_path}', shell=True) # exit(0) os.chdir(root_dir) # os.getcwd() # input_vcf_dir = '/home/jun9485/data/utuc/somatic_call/filtered/snp/' # path_to_example_table = sig.importdata("vcf") # path_to_example_table = sig.importdata("vcf") # print(path_to_example_table) input_dir_lst = glob(root_dir + vcf_dir_format) # print(input_dir_lst) for i in range(len(input_dir_lst)): input_vcf_dir = input_dir_lst[i] input_vcf_dir_name = input_vcf_dir.split(r'/')[-1] out_dir_name = rf'sig_analysis_{input_vcf_dir_name}/' sig.sigProfilerExtractor('vcf', out_dir_name, input_vcf_dir)
if __name__ == "__main__": args = parse_args() if args.directory is None: current = getcwd() args.directory = current + "/" + "sigprofiler_sigs" try: if not isdir(args.directory): mkdir(args.directory) except: print("ERROR: creation of directory", args.directory, "failed. Please use the -d option to create a valid directory.") try: shutil.copyfile(args.table, args.directory + "/" + args.table) except: print("File copy failed.", args.table, args.directory + "/" + args.table) sig.sigProfilerExtractor("table", args.directory, args.table, startProcess=args.start, endProcess=args.end, totalIterations=args.iters, cpu=args.cpu, mtype=args.mtype, gpu=args.gpu)