def main(args): ''' args - parsed arguments that include pos_sequences, neg_sequences, arch_file, and weights_file ''' # encode fasta print('Loading sequence data...') pos_seq = encode_fasta_sequences(args.pos_sequences) print('{} positive test sequences'.format(len(pos_seq))) neg_seq = encode_fasta_sequences(args.neg_sequences) print('{} negative test sequences\n'.format(len(neg_seq))) # load model prefix = args.arch_file.replace('.arch.json', '') print('Loading {} model...'.format(prefix)) model = SequenceDNN.load(args.arch_file, args.weights_file) # predict binding probability on test sequences print('Getting predictions...') pos_predictions = model.predict(pos_seq) for index, pred in enumerate(pos_predictions): print('positive_test_{}\tP(bound)={}'.format(index, pred[0])) print('') neg_predictions = model.predict(neg_seq) for index, pred in enumerate(neg_predictions): print('negative_test_{}\tP(bound)={}'.format(index, pred[0])) print('') # visualize trained model and motifs print('Plotting deeplift scores on positive sequences...') model.plot_deeplift(pos_seq, '{}_deeplift_positive'.format(prefix)) print('Plotting true motifs...') motif_names = ['IRF_known1', 'NFKB_known1'] for index, motif in enumerate(motif_names): fig = plot_motif(motif, figsize=(10, 4), ylab=motif) fig.savefig('motif{}.png'.format(index + 1), bbox_inches='tight') print('Plotting architecture...') model.plot_architecture('{}_architecture.png'.format(prefix)) print('Plotting convolutional filters...') plot_sequence_filters(model, prefix)
def plot_motifs(simulation_data): for motif_name in simulation_data.motif_names: plot_motif(motif_name, figsize=(10, 4), ylab=motif_name)