def main(args=None): args = parse_arguments().parse_args(args) corr = Correlation(args.corData, labels=args.labels,) args.plotFile.close() corr.rowCenter = args.rowCenter corr.plot_pca(args.plotFile.name, plot_title=args.plotTitle, image_format=args.plotFileFormat) if args.outFileNameData is not None: import matplotlib mlab_pca = matplotlib.mlab.PCA(corr.matrix) n = len(corr.labels) of = args.outFileNameData of.write("Component\t{}\tEigenvalue\n".format("\t".join(corr.labels))) for i in range(n): of.write("{}".format(i + 1)) for v in mlab_pca.Wt[i, :]: of.write("\t{}".format(v)) of.write("\t{}\n".format(mlab_pca.s[i])) args.outFileNameData.close()
def main(args=None): args = parse_arguments().parse_args(args) corr = Correlation( args.corData, labels=args.labels, ) args.plotFile.close() corr.rowCenter = args.rowCenter corr.plot_pca(args.plotFile.name, plot_title=args.plotTitle, image_format=args.plotFileFormat) if args.outFileNameData is not None: import matplotlib mlab_pca = matplotlib.mlab.PCA(corr.matrix) n = len(corr.labels) of = args.outFileNameData of.write("Component\t{}\tEigenvalue\n".format("\t".join(corr.labels))) for i in range(n): of.write("{}".format(i + 1)) for v in mlab_pca.Wt[i, :]: of.write("\t{}".format(v)) of.write("\t{}\n".format(mlab_pca.s[i])) args.outFileNameData.close()
def main(args=None): args = parse_arguments().parse_args(args) if args.plotFile is None and args.outFileNameData is None: sys.exit( "At least one of --plotFile and --outFileNameData must be specified!\n" ) if args.ntop < 0: sys.exit("The value specified for --ntop must be >= 0!\n") if args.PCs[0] == args.PCs[1]: sys.exit("You must specify different principal components!\n") if args.PCs[0] <= 0 or args.PCs[1] <= 0: sys.exit("The specified principal components must be at least 1!\n") corr = Correlation( args.corData, labels=args.labels, ) corr.rowCenter = args.rowCenter corr.transpose = args.transpose corr.ntop = args.ntop corr.log2 = args.log2 Wt, eigenvalues = corr.plot_pca(args.plotFile, PCs=args.PCs, plot_title=args.plotTitle, image_format=args.plotFileFormat, plotWidth=args.plotWidth, plotHeight=args.plotHeight, cols=args.colors, marks=args.markers) if args.outFileNameData is not None: of = open(args.outFileNameData, "w") of.write("#plotPCA --outFileNameData\n") of.write("Component\t{}\tEigenvalue\n".format("\t".join(corr.labels))) n = eigenvalues.shape[0] for i in range(n): of.write("{}\t{}\t{}\n".format( i + 1, "\t".join(["{}".format(x) for x in Wt[i, :]]), eigenvalues[i])) of.close()
def main(args=None): args = parse_arguments().parse_args(args) if args.plotFile is None and args.outFileNameData is None: sys.exit("At least one of --plotFile and --outFileNameData must be specified!\n") if args.ntop < 0: sys.exit("The value specified for --ntop must be >= 0!\n") if args.PCs[0] == args.PCs[1]: sys.exit("You must specify different principal components!\n") if args.PCs[0] <= 0 or args.PCs[1] <= 0: sys.exit("The specified principal components must be at least 1!\n") corr = Correlation(args.corData, labels=args.labels,) corr.rowCenter = args.rowCenter corr.transpose = args.transpose corr.ntop = args.ntop corr.log2 = args.log2 Wt, eigenvalues = corr.plot_pca(args.plotFile, PCs=args.PCs, plot_title=args.plotTitle, image_format=args.plotFileFormat, plotWidth=args.plotWidth, plotHeight=args.plotHeight, cols=args.colors, marks=args.markers) if args.outFileNameData is not None: of = open(args.outFileNameData, "w") of.write("#plotPCA --outFileNameData\n") of.write("Component\t{}\tEigenvalue\n".format("\t".join(corr.labels))) n = eigenvalues.shape[0] for i in range(n): of.write("{}\t{}\t{}\n".format(i + 1, "\t".join(["{}".format(x) for x in Wt[i, :]]), eigenvalues[i])) of.close()