from ms2lda_molnet_integration import write_output_files write_output_files(vd, pairs_file, output_prefix, metadata, overlap_thresh=args.input_network_overlap, p_thresh=args.input_network_pvalue, X=args.input_network_topx, motif_metadata=motifdb_metadata) # Writing the report - ntoe that you might need to set the 'backend' argument # for this method to work (see the method in lda.py) as it depends what on # your system will render the pdf... from lda import write_topic_report try: write_topic_report(vd, output_prefix + '_topic_report.pdf') except: print("PDF Generation Failed") ### Writing additional output, creates a list of all motifs found in data, one motif per row and MS/MS Scan all_motifs_in_scans = get_motifs_in_scans( vd, metadata, overlap_thresh=args.input_network_overlap, p_thresh=args.input_network_pvalue, X=args.input_network_topx, motif_metadata=motifdb_metadata) # Outputting motif list, one by line fieldnames = [ 'scan', 'precursor.mass', 'retention.time', "motif", "probability",
print "Writing combined edges" with open(input_prefix+'_edges_ms2lda.csv','w') as f: writer = csv.writer(f) for line in all_edges: writer.writerow(line) print "Creating summary file" summary_file = input_prefix + '_lda_summary.csv' write_summary_file(vd,summary_file) print "Creating pdf topic report" report_file = input_prefix + '_lda_report.pdf' write_topic_report(vd,report_file,backend = 'Agg') def check_edge(edge,edges): if check_uni_edge(edge[0],edge[1],edges): return True if check_uni_edge(edge[1],edge[0],edges): return True return False def check_uni_edge(node1,node2,edges): node1edges = filter(lambda x: x[0] == node1) if len(node1edges) > 0: node12edges = filter(lambda x: x[1] == node2) if len(node12edges) > 0: return True return False
vlda.run_vb(initialise=True, n_its=input_iterations) vd = vlda.make_dictionary( features=features, metadata=metadata, filename=output_prefix + '.dict') from ms2lda_molnet_integration import write_output_files write_output_files(vd, pairs_file, output_prefix, metadata, overlap_thresh=args.input_network_overlap, p_thresh=args.input_network_pvalue, X=args.input_network_topx, motif_metadata = motifdb_metadata) # Writing the report - ntoe that you might need to set the 'backend' argument # for this method to work (see the method in lda.py) as it depends what on # your system will render the pdf... from lda import write_topic_report try: write_topic_report(vd,output_prefix+'_topic_report.pdf') except: print("PDF Generation Failed") ### Writing additional output, creates a list of all motifs found in data, one motif per row and MS/MS Scan all_motifs_in_scans = get_motifs_in_scans(vd, metadata, overlap_thresh=args.input_network_overlap, p_thresh=args.input_network_pvalue, X=args.input_network_topx, motif_metadata = motifdb_metadata) with open(output_prefix + "_motifs_in_scans.tsv", 'w') as tsvfile: fieldnames = ['scan', 'precursor.mass', 'retention.time', "motif", "probability", "overlap",