Beispiel #1
0
def main():
    args = parse_args()
    header, counts = read_counts(args.counts)
    counts = pd.DataFrame(counts, columns=header)
    counts = sort_counts(counts)

    num_genes = int(args.num_genes)-1
    out_dir = args.out_dir

    # plot pca
    print('Generating PCA plot ...')
    plot.plot_pca(out_dir, counts)

    # plot heatmap
    print('Generating Gene Expression Heatmap ...')
    plot.plot_heatmap(out_dir, counts, num_genes)

    # Plot gene expression tragectory
    print('Generating Gene Expression Trajectory ...')
    plot.plot_trajectory(out_dir, counts, num_genes)

    # Save formatted and sorted count file
    counts.to_csv('data/counts_clust.txt', index=False, sep='\t')

    # Call clust to cluster the genes
    print('Clustering Genes (this might take awhile) ...')
    subprocess.call(['mkdir', 'clust_out'])
    if args.kmeans is not None:
        subprocess.call(['clust', 'data/counts_clust.txt',
                         '-o', './clust_out', '-K', args.kmeans])
    else:
        subprocess.call(['clust', 'data/counts_clust.txt',
                        '-o', './clust_out'])

    # Make sure everythin is all set for motif enrichment
    clust_out = args.input_genes
    ref_bed = args.bedfile
    ref_fa = args.genome
    ref_motif = args.motif

    try:
        open(clust_out)
    except FileNotFoundError:
        print('Clustering failed, '
              + 'Clusters_Objects.tsv not found in the output directory')

    print('Motif Enrichment Analysis (this might take awhile) ...')
    try:
        enrichment.run_motif_enrichment(clust_out,
                                        ref_bed,
                                        ref_fa, ref_motif,
                                        args.ame,
                                        100, 100)
    except NameError:
        print('AME is not installed! Please install AME and try again')
        plt.plot(Y_full[(i * nbins):((i + 1) * nbins), 0],
                 Y_full[(i * nbins):((i + 1) * nbins), 1], 'k')
        plt.colorbar(pad=0.1, fraction=0.1)
        plt.xlim(-0.3, 0.5)
        plt.ylim(-0.5, 0.3)
    else:
        ax = fig.add_subplot(3, 2, i + 1, projection='3d')
        ax.scatter(Y_full[(i * nbins):((i + 1) * nbins), 0],
                   Y_full[(i * nbins):((i + 1) * nbins), 1],
                   Y_full[(i * nbins):((i + 1) * nbins), 2],
                   c=color,
                   cmap=cmap)
    plt.title("MDS %s" % s1)
    plt.tight_layout()

fplt.plot_pca()

plt.figure(6)
plt.clf()
fplt.plot_image_array((dist, ),
                      names=['dist_%s' % feat],
                      invert_y=True,
                      nplots=3)
plt.subplot(3, 1, 2)
plt.plot(dat_mean, 'r')
plt.title('%s_%s mean' % (strain, feat))
plt.subplot(3, 1, 3)
plt.plot(dat_var, 'b')
plt.title('%s_%s var' % (strain, feat))

# entropies /cross entropies