def main(): # Get args args = build_parser().parse_args(sys.argv[1:]) setup_logger.setup(verbose=args.verbose) # Read the input gct in_gct = parse.parse(args.in_gct_path) # Read in each of the command line arguments rid = _read_arg(args.rid) cid = _read_arg(args.cid) exclude_rid = _read_arg(args.exclude_rid) exclude_cid = _read_arg(args.exclude_cid) # Slice the gct out_gct = sg.slice_gctoo(in_gct, rid=rid, cid=cid, exclude_rid=exclude_rid, exclude_cid=exclude_cid) assert out_gct.data_df.size > 0, "Slicing yielded an empty gct!" # Write the output gct if args.use_gctx: wgx.write(out_gct, args.out_name) else: wg.write(out_gct, args.out_name, data_null="NaN", metadata_null="NA", filler_null="NA")
def main(): # get args args = build_parser().parse_args(sys.argv[1:]) setup_logger.setup(verbose=args.verbose) logger.debug("args: {}".format(args)) concat_main(args)
def main(): # get args args = build_parser().parse_args(sys.argv[1:]) setup_logger.setup(verbose=args.verbose) logger.debug("args: {}".format(args)) # Get files directly if args.input_filepaths is not None: files = args.input_filepaths # Or find them else: files = get_file_list(args.file_wildcard) # No files found if len(files) == 0: msg = "No files were found. args.file_wildcard: {}".format( args.file_wildcard) logger.error(msg) raise Exception(msg) # Only 1 file found if len(files) == 1: logger.warning( "Only 1 file found. No concatenation needs to be done, exiting") return # More than 1 file found else: # Parse each file and append to a list gctoos = [] for f in files: gctoos.append(parse(f)) # Create concatenated gctoo object if args.concat_direction == "horiz": out_gctoo = hstack(gctoos, args.remove_all_metadata_fields, args.error_report_output_file, args.fields_to_remove, args.reset_ids) elif args.concat_direction == "vert": out_gctoo = vstack(gctoos, args.remove_all_metadata_fields, args.error_report_output_file, args.fields_to_remove, args.reset_ids) # Write out_gctoo to file logger.info("Writing to output file args.out_name: {}".format( args.out_name)) if args.out_type == "gctx": write_gctx.write(out_gctoo, args.out_name) elif args.out_type == "gct": write_gct.write(out_gctoo, args.out_name, filler_null=args.filler_null, metadata_null=args.metadata_null, data_null=args.data_null)
def main(): args = build_parser().parse_args(sys.argv[1:]) setup_logger.setup(verbose=args.verbose) in_gctoo = parse_gctx.parse(args.filename, convert_neg_666=False) if args.output_filepath == None: out_name = str.split(in_gctoo.src, "/")[-1].split(".")[0] else: out_name = args.output_filepath write_gct.write(in_gctoo, out_name)
def main(): args = build_parser().parse_args(sys.argv[1:]) setup_logger.setup(verbose=args.verbose) in_gctoo = parse_gctx.parse(args.filename, convert_neg_666=False) if args.output_filepath == None: basename = os.path.basename(args.filename) out_name = ".".join(basename.split(".")[:-1]) else: out_name = args.output_filepath write_gct.write(in_gctoo, out_name)
x = numpy.random.rand(x_shape[0], x_shape[1]) * numpy.random.randint(1, multiplier_max_functional_tests, size=1) logger.debug("x:\n{}".format(x)) y_other_shape = numpy.random.randint(1, max_dimension_functional_tests, size=1)[0] y_shape = (x_shape[0], y_other_shape) logger.debug("y_shape: {}".format(y_shape)) y = numpy.random.rand(y_shape[0], y_shape[1]) * numpy.random.randint(1, multiplier_max_functional_tests, size=1) logger.debug("y:\n{}".format(y)) combined = numpy.hstack([x, y]) raw_ex = numpy.corrcoef(combined, rowvar=False) logger.debug("raw_ex.shape: {}".format(raw_ex.shape)) ex = raw_ex[:x.shape[1], -y.shape[1]:] logger.debug("ex:\n{}".format(ex)) logger.debug("ex.shape: {}".format(ex.shape)) r = fast_corr.nan_fast_corr(x, y) logger.debug("r:\n{}".format(r)) logger.debug("r.shape: {}".format(r.shape)) self.assertTrue(numpy.allclose(ex, r)) if __name__ == "__main__": setup_logger.setup(verbose=True) unittest.main()
def calculate_total_sample_offsets(offset_mat): abs_total_offset = abs(offset_mat).apply(np.sum) return abs_total_offset def plot_pep(data_df, es, fit_params, pep_name, pep_y_offset, degree=None): plt.figure() plt.scatter(es, data_df.loc[pep_name, :]) plt.ylabel("Quant Value") plt.xlabel("Enrichment Score") if degree is not None: x = np.linspace(np.min(es), 1, 101) plt.plot(x, make_y(x, fit_params.loc[pep_name, degree], pep_y_offset)) plt.title(pep_name) return plt if __name__ == "__main__": args = build_parser().parse_args(sys.argv[1:]) setup_logger.setup(verbose=args.verbose) logger.debug("args: {}".format(args)) continuous_renormalization(args)
def main(): args = build_parser().parse_args(sys.argv[1:]) setup_logger.setup(verbose=args.verbose) gct2gctx_main(args)
(data_df, row_df, col_df) = GCToo.multi_index_df_to_component_dfs(mi_df) self.assertTrue(col_df.equals(e_col_metadata_df)) self.assertTrue(row_df.equals(e_row_metadata_df)) self.assertTrue(data_df.equals(e_data_df)) # edge case: if the index (or column) of the multi-index has only one # level, it becomes a regular index mi_df_index_plain = pd.MultiIndex.from_arrays([["D", "E"]], names=["rid"]) mi_df2 = pd.DataFrame([[1, 3, 5], [7, 11, 13]], index=mi_df_index_plain, columns=mi_df_columns) # row df should be empty e_row_df2 = pd.DataFrame(index=["D", "E"]) (data_df2, row_df2, col_df2) = GCToo.multi_index_df_to_component_dfs(mi_df2) self.assertTrue(row_df2.equals(e_row_df2)) self.assertTrue(col_df2.equals(e_col_metadata_df)) self.assertTrue(data_df2.equals(e_data_df)) if __name__ == "__main__": setup_GCToo_logger.setup(verbose=True) unittest.main()
def main(): # Get args args = build_parser().parse_args(sys.argv[1:]) setup_logger.setup(verbose=args.verbose) subset_main(args)