This is an automated email from the git hooks/post-receive script. bob.dybian-guest pushed a commit to branch master in repository plink1.9.
commit ae340cc2bfb39d6e618f37634f3c8db92929e716 Author: Dylan Aïssi <bob.dyb...@gmail.com> Date: Tue Sep 12 10:17:16 2017 +0200 New upstream version 1.90~b4.7-170906 --- Makefile | 63 +++++++++++++++++++++---------- plink.c | 69 ++++++++++++++++++++++++---------- plink_calc.c | 6 +-- plink_common.c | 2 +- plink_data.c | 27 +++++++++----- plink_data.h | 2 + plink_help.c | 8 ++-- plink_lasso.c | 115 ++++++++++++++++++++++++++++----------------------------- plink_lasso.h | 4 +- plink_rserve.c | 7 +++- plink_rserve.h | 2 +- 11 files changed, 184 insertions(+), 121 deletions(-) diff --git a/Makefile b/Makefile index 7b45e20..7e1c335 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,10 @@ NO_LAPACK = # Variable that allows additional linker flags (e.g., "-L/path/to/libs") to be -# passed into the linker; to use this, invoke 'make LINKFLAGS_EXTRA="<opts>"'. -LINKFLAGS_EXTRA = +# passed into the linker; to use this, invoke 'make LDFLAGS_EXTRA="<opts>"'. +LDFLAGS_EXTRA = -.PHONY: clean +.PHONY: clean install # should autodetect system SYS = UNIX @@ -24,19 +24,30 @@ else endif endif -CFLAGS=-Wall -O2 -BLASFLAGS=-L/usr/lib64/atlas -llapack -lcblas -latlas -LINKFLAGS=-lm -lpthread -ldl -ZLIB=../zlib-1.2.11/libz.so.1.2.11 +# Allow these to be overridden by make arguments or env variables, so people +# don't have to edit the Makefile to build in a different environment. +BIN ?= plink +CC ?= gcc +CXX ?= g++ +CFLAGS ?= -Wall -O2 +CXXFLAGS ?= -Wall -O2 +BLASFLAGS ?= -L/usr/lib64/atlas -llapack -lcblas -latlas +LDFLAGS ?= -lm -lpthread -ldl +ZLIB ?= ../zlib-1.2.11/libz.so.1.2.11 + +PREFIX ?= /usr/local +DESTDIR ?= . +INSTALL ?= install +STRIP ?= strip ifeq ($(SYS), MAC) GCC_GTEQ_43 := $(shell expr `g++ -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 40300) ifeq "$(GCC_GTEQ_43)" "1" - CFLAGS=-Wall -O2 -flax-vector-conversions + CFLAGS ?= -Wall -O2 -flax-vector-conversions endif - BLASFLAGS=-framework Accelerate - LINKFLAGS=-ldl - ZLIB=../zlib-1.2.11/libz.1.2.11.dylib + BLASFLAGS ?= -framework Accelerate + LDFLAGS ?= -ldl + ZLIB ?= ../zlib-1.2.11/libz.1.2.11.dylib endif ifeq ($(SYS), WIN) @@ -45,9 +56,9 @@ ifeq ($(SYS), WIN) # on Windows. # If you don't already have LAPACK built, you'll probably want to turn on # NO_LAPACK. - BLASFLAGS=-L. lapack/liblapack.a -L. lapack/librefblas.a - LINKFLAGS=-lm -static-libgcc - ZLIB=../zlib-1.2.11/libz.a + BLASFLAGS ?= -L. lapack/liblapack.a -L. lapack/librefblas.a + LDFLAGS ?= -lm -static-libgcc + ZLIB ?= ../zlib-1.2.11/libz.a endif ifdef NO_LAPACK @@ -57,23 +68,35 @@ endif OBJS = plink.o plink_assoc.o plink_calc.o plink_cluster.o plink_cnv.o plink_common.o plink_data.o plink_dosage.o plink_family.o plink_filter.o plink_glm.o plink_help.o plink_homozyg.o plink_lasso.o plink_ld.o plink_matrix.o plink_misc.o plink_perm.o plink_rserve.o plink_set.o plink_stats.o SFMT.o dcdflib.o pigz.o yarn.o Rconnection.o hfile.o bgzf.o # In the event that you are still concurrently using PLINK 1.07, we suggest -# renaming that binary to "plink107", and this one to "plink1". +# renaming that binary to "plink107", and this one to "plink" or "plink1". + +all: $(BIN) plink: $(OBJS) - g++ $^ $(LINKFLAGS_EXTRA) $(BLASFLAGS) $(LINKFLAGS) -L. $(ZLIB) -o $@ + $(CXX) $(OBJS) $(LDFLAGS_EXTRA) $(BLASFLAGS) $(LDFLAGS) -L. $(ZLIB) -o $@ plinkw: $(OBJS) - gfortran -O2 $^ $(LINKFLAGS_EXTRA) -Wl,-Bstatic $(BLASFLAGS) $(LINKFLAGS) -L. $(ZLIB) -o $@ + gfortran -O2 $(OBJS) $(LDFLAGS_EXTRA) -Wl,-Bstatic $(BLASFLAGS) $(LDFLAGS) -L. $(ZLIB) -o $@ + +install: + $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin + $(INSTALL) -c $(BIN) $(DESTDIR)$(PREFIX)/bin + +install-strip: install + $(STRIP) $(DESTDIR)$(PREFIX)/bin/$(BIN) clean: rm -f $(OBJS) plink plinkw - # Pattern-based rules for compiling object (.o) files; basically identical to # GNU make's built-in rules, except we explicitly use "g++" instead of $(CC). +# Compiling C files with a C++ compiler is deprecated, but the code needs +# to be cleaned up before we can switch to cc. E.g. plink_rserve.c +# includes a C++ header and exposed functions will need to be declared with +# extern "C". %.o: %.c - g++ -c $(CFLAGS) $< -o $@ + $(CXX) -c $(CFLAGS) $< -o $@ %.o: %.cc - g++ -x c++ -c $(CFLAGS) $< -o $@ + $(CXX) -x c++ -c $(CXXFLAGS) $< -o $@ diff --git a/plink.c b/plink.c index 4e3d37c..3f707ed 100644 --- a/plink.c +++ b/plink.c @@ -93,7 +93,7 @@ static const char ver_str[] = #ifdef STABLE_BUILD - "PLINK v1.90b4.4" + "PLINK v1.90b4.7" #else "PLINK v1.90p" #endif @@ -105,10 +105,10 @@ static const char ver_str[] = #else " 32-bit" #endif - " (31 May 2017)"; + " (6 Sep 2017)"; static const char ver_str2[] = // include leading space if day < 10, so character length stays the same - "" + " " #ifdef STABLE_BUILD "" // (don't want this when version number has a trailing letter) #else @@ -319,7 +319,7 @@ static inline int32_t relationship_or_ibc_req(uint64_t calculation_type) { return (relationship_req(calculation_type) || (calculation_type & CALC_IBC)); } -int32_t plink(char* outname, char* outname_end, char* bedname, char* bimname, char* famname, char* cm_map_fname, char* cm_map_chrname, char* phenoname, char* extractname, char* excludename, char* keepname, char* removename, char* keepfamname, char* removefamname, char* filtername, char* freqname, char* distance_wts_fname, char* read_dists_fname, char* read_dists_id_fname, char* evecname, char* mergename1, char* mergename2, char* mergename3, char* missing_mid_template, char* missing_marke [...] +int32_t plink(char* outname, char* outname_end, char* bedname, char* bimname, char* famname, char* cm_map_fname, char* cm_map_chrname, char* phenoname, char* extractname, char* excludename, char* keepname, char* removename, char* keepfamname, char* removefamname, char* filtername, char* freqname, char* distance_wts_fname, char* read_dists_fname, char* read_dists_id_fname, char* evecname, char* mergename1, char* mergename2, char* mergename3, char* missing_mid_template, char* missing_marke [...] FILE* bedfile = nullptr; FILE* phenofile = nullptr; uintptr_t unfiltered_marker_ct = 0; @@ -479,16 +479,7 @@ int32_t plink(char* outname, char* outname_end, char* bedname, char* bimname, ch goto plink_ret_OPEN_FAIL; } memcpy(outname_end, ".bed", 5); - // if file doesn't exist, realpath returns nullptr on Linux instead of what - // the path would be. -#ifdef _WIN32 - uii = GetFullPathName(outname, FNAMESIZE, &(g_textbuf[FNAMESIZE + 64]), nullptr); - if (uii && (uii <= FNAMESIZE) && (!strcmp(g_textbuf, &(g_textbuf[FNAMESIZE + 64])))) -#else - cptr = realpath(outname, &(g_textbuf[FNAMESIZE + 64])); - if (cptr && (!strcmp(g_textbuf, &(g_textbuf[FNAMESIZE + 64])))) -#endif - { + if (realpath_identical(outname, g_textbuf, &(g_textbuf[FNAMESIZE + 64]))) { logprint("Note: --make-bed input and output filenames match. Appending '~' to input\nfilenames.\n"); uii = strlen(bedname); memcpy(g_textbuf, bedname, uii + 1); @@ -1919,7 +1910,7 @@ int32_t plink(char* outname, char* outname_end, char* bedname, char* bimname, ch #if defined __cplusplus && !defined _WIN32 if (calculation_type & CALC_RPLUGIN) { - retval = rserve_call(rplugin_fname, rplugin_port, (misc_flags / MISC_RPLUGIN_DEBUG) & 1, bedfile, bed_offset, marker_ct, unfiltered_marker_ct, marker_exclude, marker_reverse, marker_ids, max_marker_id_len, marker_allele_ptrs, marker_pos, plink_maxsnp, chrom_info_ptr, unfiltered_sample_ct, pheno_nm, pheno_nm_ct, pheno_c, pheno_d, cluster_ct, cluster_map, cluster_starts, covar_ct, covar_d, outname, outname_end); + retval = rserve_call(rplugin_fname, rplugin_host_or_socket, rplugin_port, (misc_flags / MISC_RPLUGIN_DEBUG) & 1, bedfile, bed_offset, marker_ct, unfiltered_marker_ct, marker_exclude, marker_reverse, marker_ids, max_marker_id_len, marker_allele_ptrs, marker_pos, plink_maxsnp, chrom_info_ptr, unfiltered_sample_ct, pheno_nm, pheno_nm_ct, pheno_c, pheno_d, cluster_ct, cluster_map, cluster_starts, covar_ct, covar_d, outname, outname_end); if (retval) { goto plink_ret_1; } @@ -1927,7 +1918,7 @@ int32_t plink(char* outname, char* outname_end, char* bedname, char* bimname, ch #endif if (calculation_type & CALC_LASSO_LAMBDA) { - retval = lasso_lambda(marker_exclude, marker_reverse, chrom_info_ptr, sex_male, pheno_nm, covar_nm, bed_offset, unfiltered_marker_ct, marker_ct, unfiltered_sample_ct, pheno_nm_ct, hh_exists, lasso_lambda_iters, lasso_h2, bedfile, outname, outname_end, &lasso_minlambda); + retval = lasso_lambda(marker_exclude, marker_reverse, chrom_info_ptr, sample_exclude, sex_male, pheno_nm, covar_nm, bed_offset, unfiltered_marker_ct, marker_ct, unfiltered_sample_ct, sample_ct, pheno_nm_ct, hh_exists, lasso_lambda_iters, lasso_h2, bedfile, outname, outname_end, &lasso_minlambda); if (retval) { goto plink_ret_1; } @@ -2086,7 +2077,7 @@ int32_t plink(char* outname, char* outname_end, char* bedname, char* bimname, ch } } if (calculation_type & CALC_LASSO) { - retval = lasso(threads, bedfile, bed_offset, outname, outname_end2, unfiltered_marker_ct, marker_exclude, marker_ct, marker_ids, max_marker_id_len, marker_allele_ptrs, marker_reverse, chrom_info_ptr, unfiltered_sample_ct, pheno_nm_ct, lasso_h2, lasso_minlambda, lasso_select_covars_range_list_ptr, misc_flags, pheno_nm, pheno_c, pheno_d, covar_ct, covar_names, max_covar_name_len, covar_nm, covar_d, sex_male, hh_exists); + retval = lasso(threads, bedfile, bed_offset, outname, outname_end2, unfiltered_marker_ct, marker_exclude, marker_ct, marker_ids, max_marker_id_len, marker_allele_ptrs, marker_reverse, chrom_info_ptr, unfiltered_sample_ct, sample_ct, pheno_nm_ct, lasso_h2, lasso_minlambda, lasso_select_covars_range_list_ptr, misc_flags, sample_exclude, pheno_nm, pheno_c, pheno_d, covar_ct, covar_names, max_covar_name_len, covar_nm, covar_d, sex_male, hh_exists); if (retval) { goto plink_ret_1; } @@ -3181,9 +3172,10 @@ int32_t main(int32_t argc, char** argv) { char* metaanal_pfield_search_order = nullptr; char* metaanal_essfield_search_order = nullptr; char* rplugin_fname = nullptr; + char* rplugin_host_or_socket = nullptr; uint32_t gene_report_border = 0; uint32_t metaanal_flags = 0; - uint32_t rplugin_port = 6311; + int32_t rplugin_port = -2; // now interpreted by rserve_call() as default double vcf_min_qual = -1; double vcf_min_gq = -1; double vcf_min_gp = -1; @@ -4177,7 +4169,7 @@ int32_t main(int32_t argc, char** argv) { if (enforce_param_ct_range(param_ct, argv[cur_arg], 1, 1)) { goto main_ret_INVALID_CMDLINE_2A; } - if (scan_posint_capped(argv[cur_arg + 1], 65535, &rplugin_port)) { + if (scan_posint_capped(argv[cur_arg + 1], 65535, (uint32_t*)(&rplugin_port))) { sprintf(g_logbuf, "Error: Invalid --R-port parameter '%s'.\n", argv[cur_arg + 1]); goto main_ret_INVALID_CMDLINE_WWA; } @@ -4189,6 +4181,39 @@ int32_t main(int32_t argc, char** argv) { logprint("Note: --R-debug flag deprecated. Use e.g. '--R [filename] debug'.\n"); misc_flags |= MISC_RPLUGIN_DEBUG; goto main_param_zero; + } else if (!memcmp(argptr2, "-host", 6)) { + if (!rplugin_fname) { + logerrprint("Error: --R-host must be used with --R.\n"); + goto main_ret_INVALID_CMDLINE; + } + if (enforce_param_ct_range(param_ct, argv[cur_arg], 1, 1)) { + goto main_ret_INVALID_CMDLINE_2A; + } + retval = alloc_string(&rplugin_host_or_socket, argv[cur_arg + 1]); + if (retval) { + goto main_ret_INVALID_CMDLINE_WWA; + } + } else if (!memcmp(argptr2, "-socket", 8)) { + if (!rplugin_fname) { + logerrprint("Error: --R-socket must be used with --R.\n"); + goto main_ret_INVALID_CMDLINE; + } + if (rplugin_port != -2) { + logerrprint("Error: --R-socket cannot be used with --R-port.\n"); + goto main_ret_INVALID_CMDLINE; + } + if (rplugin_host_or_socket) { + logerrprint("Error: --R-socket cannot be used with --R-host.\n"); + goto main_ret_INVALID_CMDLINE; + } + if (enforce_param_ct_range(param_ct, argv[cur_arg], 1, 1)) { + goto main_ret_INVALID_CMDLINE_2A; + } + retval = alloc_string(&rplugin_host_or_socket, argv[cur_arg + 1]); + if (retval) { + goto main_ret_INVALID_CMDLINE_WWA; + } + rplugin_port = -1; } else { goto main_ret_INVALID_CMDLINE_UNRECOGNIZED; } @@ -7530,6 +7555,9 @@ int32_t main(int32_t argc, char** argv) { sprintf(g_logbuf, "Error: Invalid increment '%s' for --%s.\n", argv[cur_arg + param_ct - 1], argptr); goto main_ret_INVALID_CMDLINE_WWA; } + if ((ld_info.modifier & LD_PRUNE_KB_WINDOW) && (ld_info.prune_window_incr > 1)) { + LOGERRPRINTFWW("Warning: --%s step size should be 1 when window size is in kb units.\n", argptr); + } if (scan_double(argv[cur_arg + param_ct], &ld_info.prune_last_param) || (ld_info.prune_last_param < 0.0) || (ld_info.prune_last_param >= 1.0)) { sprintf(g_logbuf, "Error: Invalid --%s r^2 threshold '%s'.\n", argptr, argv[cur_arg + param_ct]); goto main_ret_INVALID_CMDLINE_WWA; @@ -13546,7 +13574,7 @@ int32_t main(int32_t argc, char** argv) { } else if (!rel_info.ibc_type) { rel_info.ibc_type = 1; } - retval = plink(outname, outname_end, pedname, mapname, famname, cm_map_fname, cm_map_chrname, phenoname, extractname, excludename, keepname, removename, keepfamname, removefamname, filtername, freqname, distance_wts_fname, read_dists_fname, read_dists_id_fname, evecname, mergename1, mergename2, mergename3, missing_mid_template, missing_marker_id_match, makepheno_str, phenoname_str, a1alleles, a2alleles, recode_allele_name, covar_fname, update_alleles_fname, read_genome_fname, qual_fi [...] + retval = plink(outname, outname_end, pedname, mapname, famname, cm_map_fname, cm_map_chrname, phenoname, extractname, excludename, keepname, removename, keepfamname, removefamname, filtername, freqname, distance_wts_fname, read_dists_fname, read_dists_id_fname, evecname, mergename1, mergename2, mergename3, missing_mid_template, missing_marker_id_match, makepheno_str, phenoname_str, a1alleles, a2alleles, recode_allele_name, covar_fname, update_alleles_fname, read_genome_fname, qual_fi [...] } while (0) { main_ret_NOMEM: @@ -13709,6 +13737,7 @@ int32_t main(int32_t argc, char** argv) { free_cond(metaanal_pfield_search_order); free_cond(metaanal_essfield_search_order); free_cond(rplugin_fname); + free_cond(rplugin_host_or_socket); oblig_missing_cleanup(&oblig_missing_info); cluster_cleanup(&cluster); diff --git a/plink_calc.c b/plink_calc.c index 63f76b5..868617a 100644 --- a/plink_calc.c +++ b/plink_calc.c @@ -6861,7 +6861,6 @@ int32_t calc_rel(pthread_t* threads, uint32_t parallel_idx, uint32_t parallel_to double* main_weights_ptr = nullptr; double* dptr2; double set_allele_freq_buf[MULTIPLEX_DIST]; - char wbuf[96]; uint64_t start_offset; uint64_t hundredth; unsigned char* overflow_buf; @@ -7125,19 +7124,20 @@ int32_t calc_rel(pthread_t* threads, uint32_t parallel_idx, uint32_t parallel_to if (fputs_checked("FID\tIID\tNOMISS\tFhat1\tFhat2\tFhat3\n", outfile)) { goto calc_rel_ret_WRITE_FAIL; } + char* textbuf = g_textbuf; sample_uidx = 0; for (sample_idx = 0; sample_idx < sample_ct; sample_uidx++, sample_idx++) { next_unset_ul_unsafe_ck(sample_exclude, &sample_uidx); fam_id = &(sample_ids[sample_uidx * max_sample_id_len]); sample_id = (char*)memchr(fam_id, '\t', max_sample_id_len); - wptr = memcpyax(wbuf, fam_id, (uintptr_t)(sample_id - fam_id), '\t'); + wptr = memcpyax(textbuf, fam_id, (uintptr_t)(sample_id - fam_id), '\t'); wptr = strcpyax(wptr, &(sample_id[1]), '\t'); wptr = uint32toa_x(marker_ct - sample_missing_unwt[sample_idx], '\t', wptr); wptr = dtoa_gx(*dptr3++ - 1.0, '\t', wptr); wptr = dtoa_gx(*dptr4++ - 1.0, '\t', wptr); wptr = dtoa_gx(*dptr2++ - 1.0, '\n', wptr); - if (fwrite_checked(wbuf, wptr - wbuf, outfile)) { + if (fwrite_checked(textbuf, wptr - textbuf, outfile)) { goto calc_rel_ret_WRITE_FAIL; } } diff --git a/plink_common.c b/plink_common.c index e6b8021..47fa921 100644 --- a/plink_common.c +++ b/plink_common.c @@ -4763,7 +4763,7 @@ void chrom_error(const char* chrom_name, const char* file_descrip, const Chrom_i if ((raw_code > ((int32_t)chrom_info_ptr->max_code)) && ((raw_code <= MAX_CHROM_TEXTNUM + XYMT_OFFSET_CT) || (raw_code >= MAX_POSSIBLE_CHROM))) { if (chrom_info_ptr->species != SPECIES_UNKNOWN) { if (chrom_info_ptr->species == SPECIES_HUMAN) { - logerrprint("(This is disallowed for humans. Check if the problem is with your data, or if\nyou forgot to define a different chromosome set with e.g. --chr-set.).\n"); + logerrprint("(This is disallowed for humans. Check if the problem is with your data, or if\nyou forgot to define a different chromosome set with e.g. --chr-set.)\n"); } else { logerrprint("(This is disallowed by the PLINK 1.07 species flag you used. You can\ntemporarily work around this restriction with --chr-set; contact the developers\nif you want the flag to be permanently redefined.)\n"); } diff --git a/plink_data.c b/plink_data.c index 972aa21..50baef0 100644 --- a/plink_data.c +++ b/plink_data.c @@ -246,10 +246,13 @@ int32_t load_map(FILE** mapfile_ptr, char* mapname, uint32_t* map_cols_ptr, uint max_marker_id_blen = ulii; } if (!unfiltered_marker_ct) { - textbuf_iter = next_token_mult(textbuf_iter, 2); + // bugfix (24 Jul 2017): this was inappropriately erroring out on + // 3-column .map files + textbuf_iter = next_token(textbuf_iter); if (!textbuf_iter) { goto load_map_ret_MISSING_TOKENS; } + textbuf_iter = skip_initial_spaces(token_endnn(textbuf_iter)); if (*textbuf_iter > ' ') { *map_cols_ptr = 4; } @@ -3636,7 +3639,8 @@ int32_t make_bed(FILE* bedfile, uintptr_t bed_offset, char* bimname, char* outna goto make_bed_ret_NOMEM; } writebuf = (uintptr_t*)g_bigstack_base; - pass_ct = 1 + ((sample_ctv2 * marker_ct * sizeof(intptr_t) - 1) / cur_bigstack_left); + // 32-bit bugfix (6 Sep 2017): necessary to cast numerator to 64-bit + pass_ct = 1 + ((sample_ctv2 * ((uint64_t)marker_ct) * sizeof(intptr_t) - 1) / cur_bigstack_left); pass_size = 1 + ((marker_ct - 1) / pass_ct); *outname_end = '\0'; LOGPRINTFWW5("--make-bed to %s.bed + %s.bim + %s.fam ... ", outname, outname, outname); @@ -6623,6 +6627,15 @@ int32_t ped_to_bed(char* pedname, char* mapname, char* outname, char* outname_en return retval; } +uint32_t realpath_identical(const char* outname, const char* read_realpath, char* write_realpath_buf) { +#ifdef _WIN32 + const uint32_t fname_slen = GetFullPathName(outname, FNAMESIZE, write_realpath_buf, nullptr); + return (fname_slen && (fname_slen <= FNAMESIZE) && (!strcmp(read_realpath, write_realpath_buf))); +#else + return (realpath(outname, write_realpath_buf) && (!strcmp(read_realpath, write_realpath_buf))); +#endif +} + int32_t lgen_to_bed(char* lgenname, char* mapname, char* famname, char* outname, char* outname_end, int32_t missing_pheno, uint64_t misc_flags, uint32_t lgen_modifier, char* lgen_reference_fname, Chrom_info* chrom_info_ptr) { // This code has not been carefully optimized, and also does not support // multipass writes. @@ -7143,14 +7156,8 @@ int32_t lgen_to_bed(char* lgenname, char* mapname, char* famname, char* outname, LOGERRPRINTFWW("Error: Failed to open %s.\n", outname); goto lgen_to_bed_ret_OPEN_FAIL; } -#ifdef _WIN32 - uii = GetFullPathName(outname, FNAMESIZE, &(g_textbuf[FNAMESIZE + 64]), nullptr); - if (!(uii && (uii <= FNAMESIZE) && (!strcmp(g_textbuf, &(g_textbuf[FNAMESIZE + 64]))))) -#else - cptr = realpath(outname, &(g_textbuf[FNAMESIZE + 64])); - if (!(cptr && (!strcmp(g_textbuf, &(g_textbuf[FNAMESIZE + 64]))))) -#endif - { + // bugfix (25 Jul 2017): forgot the not + if (!realpath_identical(outname, g_textbuf, &(g_textbuf[FNAMESIZE + 64]))) { if (fopen_checked(famname, "r", &infile)) { goto lgen_to_bed_ret_OPEN_FAIL; } diff --git a/plink_data.h b/plink_data.h index e18e977..4a76e01 100644 --- a/plink_data.h +++ b/plink_data.h @@ -34,6 +34,8 @@ int32_t oxford_to_bed(char* genname, char* samplename, char* outname, char* outn int32_t ped_to_bed(char* pedname, char* mapname, char* outname, char* outname_end, uint32_t fam_cols, uint64_t misc_flags, int32_t missing_pheno, Chrom_info* chrom_info_ptr); +uint32_t realpath_identical(const char* outname, const char* read_realpath, char* write_realpath_buf); + int32_t lgen_to_bed(char* lgenname, char* mapname, char* famname, char* outname, char* outname_end, int32_t missing_pheno, uint64_t misc_flags, uint32_t lgen_modifier, char* lgen_reference_fname, Chrom_info* chrom_info_ptr); int32_t transposed_to_bed(char* tpedname, char* tfamname, char* outname, char* outname_end, uint64_t misc_flags, Chrom_info* chrom_info_ptr); diff --git a/plink_help.c b/plink_help.c index 6192882..6fcd894 100644 --- a/plink_help.c +++ b/plink_help.c @@ -1294,7 +1294,7 @@ int32_t disp_help(uint32_t param_ct, char** argv) { " it. Also, note that scores are multiplied by 0..1 dosages, not 0..2\n" " diploid allele counts, unless the 'double-dosage' modifier is present.\n\n" ); -#if defined __cplusplus && !defined _WIN32 && !defined STABLE_BUILD +#if defined __cplusplus && !defined _WIN32 help_print("R\tR-debug", &help_ctrl, 1, " --R [R script file] <debug>\n" " Connect to a Rserve (preferably version 1.7 or later) background process,\n" @@ -2141,9 +2141,11 @@ int32_t disp_help(uint32_t param_ct, char** argv) { " j defaults to i+1. The 'header' modifier causes the first nonempty line\n" " of this file to be skipped.\n" ); -#if defined __cplusplus && !defined _WIN32 && !defined STABLE_BUILD - help_print("R\tR-port", &help_ctrl, 0, +#if defined __cplusplus && !defined _WIN32 + help_print("R\tR-port\tR-host\tR-socket", &help_ctrl, 0, " --R-port [port #] : Connect to Rserve on a port other than 6311.\n" +" --R-host [host] : Connect to Rserve host.\n" +" --R-socket [sock] : Connect to Rserve socket.\n" ); #endif help_print("parallel\tgenome-lists", &help_ctrl, 0, diff --git a/plink_lasso.c b/plink_lasso.c index ba211d8..8338ca7 100644 --- a/plink_lasso.c +++ b/plink_lasso.c @@ -26,37 +26,37 @@ #define NLAMBDA 100 #define DELTA_THRESHOLD 0.0001 -int32_t transpose_covar(uintptr_t sample_valid_ct, uintptr_t covar_ct, uintptr_t* covar_nm, double* readptr, double* writeptr_start, double sqrt_n_recip, double sample_valid_ct_recip, double sample_valid_ctm1d) { - // this may migrate to plink_common.c... +// covar_nm is already subsetted by sample_include +int32_t transpose_covar(const uintptr_t* sample_exclude, const uintptr_t* pheno_nm, const uintptr_t* covar_nm, const double* readptr, uint32_t sample_ct, uintptr_t sample_valid_ct, uintptr_t covar_ct, double sqrt_n_recip, double sample_valid_ct_recip, double sample_valid_ctm1d, double* writeptr_start) { double sum = 0.0; double ssq = 0.0; double* writeptr = writeptr_start; - uintptr_t sample_uidx; - uintptr_t sample_idx; - double subtract_by; - double multiply_by; - double dxx; - for (sample_uidx = 0, sample_idx = 0; sample_idx < sample_valid_ct; sample_uidx++, sample_idx++) { - next_set_ul_unsafe_ck(covar_nm, &sample_uidx); - dxx = readptr[sample_uidx * covar_ct]; - sum += dxx; - ssq += dxx * dxx; - *writeptr++ = dxx; + uint32_t sample_uidx = 0; + uint32_t uii = 0; + for (uint32_t sample_idx = 0; sample_idx < sample_ct; ++sample_uidx, ++sample_idx) { + next_unset_unsafe_ck(sample_exclude, &sample_uidx); + if (IS_SET(pheno_nm, sample_uidx)) { + const double dxx = readptr[sample_idx * covar_ct]; + sum += dxx; + ssq += dxx * dxx; + *writeptr++ = dxx; + ++uii; + } } if (ssq * ((double)sample_valid_ct) == sum * sum) { return -1; } - subtract_by = sum * sample_valid_ct_recip; - multiply_by = sqrt_n_recip * sqrt(sample_valid_ctm1d / (ssq - sum * subtract_by)); + const double subtract_by = sum * sample_valid_ct_recip; + const double multiply_by = sqrt_n_recip * sqrt(sample_valid_ctm1d / (ssq - sum * subtract_by)); writeptr = writeptr_start; - for (sample_idx = 0; sample_idx < sample_valid_ct; sample_idx++) { + for (uint32_t sample_idx = 0; sample_idx < sample_valid_ct; ++sample_idx) { *writeptr = ((*writeptr) - subtract_by) * multiply_by; writeptr++; } return 0; } -int32_t lasso_bigmem(FILE* bedfile, uintptr_t bed_offset, uintptr_t* marker_exclude, uintptr_t marker_ct, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t* pheno_nm2, double lasso_h2, double lasso_minlambda, uint32_t select_covars, uintptr_t* select_covars_bitfield, double* pheno_d_collapsed, uintptr_t covar_ct, char* covar_names, uintptr_t max_covar_name_len, uintptr_t* covar_nm, double* covar_d, uint32_t hh_or_mt_exists, uintptr_t sample_ [...] +int32_t lasso_bigmem(FILE* bedfile, uintptr_t bed_offset, uintptr_t* marker_exclude, uintptr_t marker_ct, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, const uintptr_t* sample_exclude, uintptr_t* pheno_nm2, double lasso_h2, double lasso_minlambda, uint32_t select_covars, uintptr_t* select_covars_bitfield, double* pheno_d_collapsed, uintptr_t covar_ct, char* covar_names, uintptr_t max_covar_name_len, uintptr_t* covar_nm, double* covar_d, uint32_t h [...] uintptr_t unfiltered_sample_ct4 = (unfiltered_sample_ct + 3) / 4; double* data_arr = (double*)g_bigstack_base; // marker-major double sqrt_n_recip = sqrt(1.0 / ((double)((intptr_t)sample_valid_ct))); @@ -127,7 +127,7 @@ int32_t lasso_bigmem(FILE* bedfile, uintptr_t bed_offset, uintptr_t* marker_excl dyy = (double)((intptr_t)(sample_valid_ct - 1)); if (!select_covars_bitfield) { for (covar_idx = 0; covar_idx < covar_ct; covar_idx++) { - if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(data_arr[covar_idx * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) { + if (transpose_covar(sample_exclude, pheno_nm2, covar_nm, &(covar_d[covar_idx]), sample_ct, sample_valid_ct, covar_ct, sqrt_n_recip, dxx, dyy, &(data_arr[covar_idx * sample_valid_ct]))) { goto lasso_bigmem_ret_CONST_COVAR; } } @@ -140,7 +140,7 @@ int32_t lasso_bigmem(FILE* bedfile, uintptr_t bed_offset, uintptr_t* marker_excl if (IS_SET(select_covars_bitfield, covar_idx)) { continue; } - if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(data_arr[ulii * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) { + if (transpose_covar(sample_exclude, pheno_nm2, covar_nm, &(covar_d[covar_idx]), sample_ct, sample_valid_ct, covar_ct, sqrt_n_recip, dxx, dyy, &(data_arr[ulii * sample_valid_ct]))) { goto lasso_bigmem_ret_CONST_COVAR; } ulii++; @@ -150,7 +150,7 @@ int32_t lasso_bigmem(FILE* bedfile, uintptr_t bed_offset, uintptr_t* marker_excl if (!IS_SET(select_covars_bitfield, covar_idx)) { continue; } - if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(data_arr[ulii * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) { + if (transpose_covar(sample_exclude, pheno_nm2, covar_nm, &(covar_d[covar_idx]), sample_ct, sample_valid_ct, covar_ct, sqrt_n_recip, dxx, dyy, &(data_arr[ulii * sample_valid_ct]))) { goto lasso_bigmem_ret_CONST_COVAR; } ulii++; @@ -429,37 +429,33 @@ uint32_t load_and_normalize(FILE* bedfile, uintptr_t* loadbuf_raw, uintptr_t unf // this needs to work in very-low-memory contexts #define LASSO_LAMBDA_BLOCK_SIZE 64 -int32_t lasso_lambda(const uintptr_t* marker_exclude, const uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t* sex_male, uintptr_t* pheno_nm, const uintptr_t* covar_nm, uintptr_t bed_offset, uintptr_t unfiltered_marker_ct, uintptr_t marker_ct, uintptr_t unfiltered_sample_ct, uintptr_t pheno_nm_ct, uint32_t hh_or_mt_exists, uint32_t lasso_lambda_iters, double lasso_h2, FILE* bedfile, char* outname, char* outname_end, double* lasso_minlambda_ptr) { +int32_t lasso_lambda(const uintptr_t* marker_exclude, const uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, const uintptr_t* sample_exclude, uintptr_t* sex_male, uintptr_t* pheno_nm, const uintptr_t* covar_nm, uintptr_t bed_offset, uintptr_t unfiltered_marker_ct, uintptr_t marker_ct, uintptr_t unfiltered_sample_ct, uint32_t sample_ct, uintptr_t pheno_nm_ct, uint32_t hh_or_mt_exists, uint32_t lasso_lambda_iters, double lasso_h2, FILE* bedfile, char* outname, char* outname_end, doub [...] // standalone memory-efficient lambda calculation, since even 1000 x // sample_ct matrices may be too large. unsigned char* bigstack_mark = g_bigstack_base; FILE* outfile = nullptr; int32_t retval = 0; { + const uintptr_t unfiltered_sample_ctl = BITCT_TO_WORDCT(unfiltered_sample_ct); + uintptr_t* pheno_nm2; uintptr_t sample_valid_ct; if (!covar_nm) { sample_valid_ct = pheno_nm_ct; - } else { - sample_valid_ct = popcount_longs(covar_nm, BITCT_TO_WORDCT(pheno_nm_ct)); - } - const uintptr_t final_mask = get_final_mask(sample_valid_ct); - uintptr_t* pheno_nm2; - if (sample_valid_ct == pheno_nm_ct) { pheno_nm2 = pheno_nm; } else { - const uintptr_t unfiltered_sample_ctl = BITCT_TO_WORDCT(unfiltered_sample_ct); if (bigstack_calloc_ul(unfiltered_sample_ctl, &pheno_nm2)) { goto lasso_lambda_ret_NOMEM; } - uintptr_t sample_uidx; - uintptr_t sample_idx; - for (sample_uidx = 0, sample_idx = 0; sample_idx < pheno_nm_ct; sample_uidx++, sample_idx++) { - next_set_ul_unsafe_ck(pheno_nm, &sample_uidx); - if (IS_SET(covar_nm, sample_idx)) { + uintptr_t sample_uidx = 0; + for (uintptr_t sample_idx = 0; sample_idx < sample_ct; ++sample_uidx, ++sample_idx) { + next_unset_ul_unsafe_ck(sample_exclude, &sample_uidx); + if (IS_SET(pheno_nm, sample_uidx) && IS_SET(covar_nm, sample_idx)) { SET_BIT(sample_uidx, pheno_nm2); } } + sample_valid_ct = popcount_longs(pheno_nm2, unfiltered_sample_ctl); } + const uintptr_t final_mask = get_final_mask(sample_valid_ct); double* rand_matrix; double* max_empirical_lambdas; double* data_window; @@ -636,7 +632,7 @@ int32_t lasso_lambda(const uintptr_t* marker_exclude, const uintptr_t* marker_re } -int32_t lasso_smallmem(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, uintptr_t* marker_exclude, uintptr_t marker_ct, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t* pheno_nm2, double lasso_h2, double lasso_minlambda, uint32_t select_covars, uintptr_t* select_covars_bitfield, double* pheno_d_collapsed, uintptr_t covar_ct, char* covar_names, uintptr_t max_covar_name_len, uintptr_t* covar_nm, double* covar_d, uint32_t hh_or_mt_exi [...] +int32_t lasso_smallmem(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, uintptr_t* marker_exclude, uintptr_t marker_ct, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, const uintptr_t* sample_exclude, uintptr_t* pheno_nm2, double lasso_h2, double lasso_minlambda, uint32_t select_covars, uintptr_t* select_covars_bitfield, double* pheno_d_collapsed, uintptr_t covar_ct, char* covar_names, uintptr_t max_covar_name_len, uintptr_t* covar_nm, doubl [...] // Instead of populating and normalizing data_arr before the coordinate // descent, we reload and renormalize the data every iteration. // Since (i) there's probably a larger number of samples involved, and (ii) @@ -703,7 +699,7 @@ int32_t lasso_smallmem(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, dyy = (double)((intptr_t)(sample_valid_ct - 1)); if (!select_covars_bitfield) { for (covar_idx = 0; covar_idx < covar_ct; covar_idx++) { - if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(covar_data_arr[covar_idx * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) { + if (transpose_covar(sample_exclude, pheno_nm2, covar_nm, &(covar_d[covar_idx]), sample_ct, sample_valid_ct, covar_ct, sqrt_n_recip, dxx, dyy, &(covar_data_arr[covar_idx * sample_valid_ct]))) { goto lasso_smallmem_ret_CONST_COVAR; } } @@ -716,7 +712,7 @@ int32_t lasso_smallmem(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, if (IS_SET(select_covars_bitfield, covar_idx)) { continue; } - if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(covar_data_arr[ulii * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) { + if (transpose_covar(sample_exclude, pheno_nm2, covar_nm, &(covar_d[covar_idx]), sample_ct, sample_valid_ct, covar_ct, sqrt_n_recip, dxx, dyy, &(covar_data_arr[ulii * sample_valid_ct]))) { goto lasso_smallmem_ret_CONST_COVAR; } ulii++; @@ -726,7 +722,7 @@ int32_t lasso_smallmem(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, if (!IS_SET(select_covars_bitfield, covar_idx)) { continue; } - if (transpose_covar(sample_valid_ct, covar_ct, covar_nm, &(covar_d[covar_idx]), &(covar_data_arr[ulii * sample_valid_ct]), sqrt_n_recip, dxx, dyy)) { + if (transpose_covar(sample_exclude, pheno_nm2, covar_nm, &(covar_d[covar_idx]), sample_ct, sample_valid_ct, covar_ct, sqrt_n_recip, dxx, dyy, &(covar_data_arr[ulii * sample_valid_ct]))) { goto lasso_smallmem_ret_CONST_COVAR; } ulii++; @@ -995,16 +991,16 @@ int32_t lasso_smallmem(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, return retval; } -int32_t lasso(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* outname, char* outname_end, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t marker_ct, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t pheno_nm_ct, double lasso_h2, double lasso_minlambda, Range_list* select_covars_range_list_ptr, uint64_t misc_flags, uintptr_t* pheno_nm [...] +int32_t lasso(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* outname, char* outname_end, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t marker_ct, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uint32_t sample_ct, uintptr_t pheno_nm_ct, double lasso_h2, double lasso_minlambda, Range_list* select_covars_range_list_ptr, uint64_t misc_flags, [...] // Coordinate descent LASSO. Based on a MATLAB script by Shashaank // Vattikuti. // Not yet multithreaded. (Main loop is fairly tightly coupled, so getting // a performance benefit will be a bit tricky.) unsigned char* bigstack_mark = g_bigstack_base; FILE* outfile = nullptr; - uintptr_t unfiltered_sample_ctl = BITCT_TO_WORDCT(unfiltered_sample_ct); - uintptr_t unfiltered_sample_ctv2 = QUATERCT_TO_ALIGNED_WORDCT(unfiltered_sample_ct); - uintptr_t unfiltered_marker_ctl = BITCT_TO_WORDCT(unfiltered_marker_ct); + const uintptr_t unfiltered_sample_ctl = BITCT_TO_WORDCT(unfiltered_sample_ct); + const uintptr_t unfiltered_sample_ctv2 = QUATERCT_TO_ALIGNED_WORDCT(unfiltered_sample_ct); + const uintptr_t unfiltered_marker_ctl = BITCT_TO_WORDCT(unfiltered_marker_ct); uintptr_t polymorphic_marker_ct = 0; uint64_t iter_tot = 0; double* xhat = nullptr; @@ -1013,8 +1009,8 @@ int32_t lasso(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* out uintptr_t* sample_male_include2 = nullptr; uintptr_t* select_covars_bitfield = nullptr; char* wptr_start = nullptr; - uint32_t report_zeroes = (misc_flags / MISC_LASSO_REPORT_ZEROES) & 1; - uint32_t select_covars = (misc_flags / MISC_LASSO_SELECT_COVARS) & 1; + const uint32_t report_zeroes = (misc_flags / MISC_LASSO_REPORT_ZEROES) & 1; + const uint32_t select_covars = (misc_flags / MISC_LASSO_SELECT_COVARS) & 1; uint32_t chrom_fo_idx = 0xffffffffU; // exploit overflow uint32_t chrom_end = 0; uint32_t is_x = 0; @@ -1052,8 +1048,22 @@ int32_t lasso(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* out uint32_t uii; if (!covar_ct) { sample_valid_ct = pheno_nm_ct; + pheno_nm2 = pheno_nm; } else { - sample_valid_ct = popcount_longs(covar_nm, BITCT_TO_WORDCT(pheno_nm_ct)); + // bugfix (14 Aug 2017): need to look at intersection of pheno_nm and + // covar_nm, rather than just covar_nm + // also, can't simply use popcount_longs_intersect() and bitvec_and(), + // since covar_nm is already subsetted on sample_include + if (bigstack_calloc_ul(unfiltered_sample_ctl, &pheno_nm2)) { + goto lasso_ret_NOMEM; + } + for (sample_uidx = 0, sample_idx = 0; sample_idx < sample_ct; sample_uidx++, sample_idx++) { + next_unset_ul_unsafe_ck(sample_exclude, &sample_uidx); + if (IS_SET(pheno_nm, sample_uidx) && IS_SET(covar_nm, sample_idx)) { + SET_BIT(sample_uidx, pheno_nm2); + } + } + sample_valid_ct = popcount_longs(pheno_nm2, unfiltered_sample_ctl); } if (sample_valid_ct < 2) { if (pheno_nm_ct < 2) { @@ -1063,19 +1073,6 @@ int32_t lasso(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* out } goto lasso_ret_1; } - if (sample_valid_ct == pheno_nm_ct) { - pheno_nm2 = pheno_nm; - } else { - if (bigstack_calloc_ul(unfiltered_sample_ctl, &pheno_nm2)) { - goto lasso_ret_NOMEM; - } - for (sample_uidx = 0, sample_idx = 0; sample_idx < pheno_nm_ct; sample_uidx++, sample_idx++) { - next_set_ul_unsafe_ck(pheno_nm, &sample_uidx); - if (IS_SET(covar_nm, sample_idx)) { - SET_BIT(sample_uidx, pheno_nm2); - } - } - } sample_valid_ctv2 = QUATERCT_TO_ALIGNED_WORDCT(sample_valid_ct); sqrt_n_recip = sqrt(1.0 / ((double)((intptr_t)sample_valid_ct))); if (bigstack_alloc_ul(sample_valid_ctv2, &sample_include2) || @@ -1179,9 +1176,9 @@ int32_t lasso(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* out } ullii += round_up_pow2(((uint64_t)uii) * sample_valid_ct * sizeof(double), CACHELINE); if (ullii <= bigstack_left()) { - retval = lasso_bigmem(bedfile, bed_offset, marker_exclude, marker_ct, marker_reverse, chrom_info_ptr, unfiltered_sample_ct, pheno_nm2, lasso_h2, lasso_minlambda, select_covars, select_covars_bitfield, pheno_d_collapsed, covar_ct, covar_names, max_covar_name_len, covar_nm, covar_d, hh_or_mt_exists, sample_valid_ct, sample_include2, sample_male_include2, loadbuf_raw, loadbuf_collapsed, rand_matrix, misc_arr, residuals, polymorphic_markers, &polymorphic_marker_ct, &iter_tot, &xhat); + retval = lasso_bigmem(bedfile, bed_offset, marker_exclude, marker_ct, marker_reverse, chrom_info_ptr, unfiltered_sample_ct, sample_exclude, pheno_nm2, lasso_h2, lasso_minlambda, select_covars, select_covars_bitfield, pheno_d_collapsed, covar_ct, covar_names, max_covar_name_len, covar_nm, covar_d, hh_or_mt_exists, sample_ct, sample_valid_ct, sample_include2, sample_male_include2, loadbuf_raw, loadbuf_collapsed, rand_matrix, misc_arr, residuals, polymorphic_markers, &polymorphic_marker [...] } else { - retval = lasso_smallmem(threads, bedfile, bed_offset, marker_exclude, marker_ct, marker_reverse, chrom_info_ptr, unfiltered_sample_ct, pheno_nm2, lasso_h2, lasso_minlambda, select_covars, select_covars_bitfield, pheno_d_collapsed, covar_ct, covar_names, max_covar_name_len, covar_nm, covar_d, hh_or_mt_exists, sample_valid_ct, sample_include2, sample_male_include2, loadbuf_raw, loadbuf_collapsed, rand_matrix, misc_arr, residuals, polymorphic_markers, &polymorphic_marker_ct, &iter_tot, &xhat); + retval = lasso_smallmem(threads, bedfile, bed_offset, marker_exclude, marker_ct, marker_reverse, chrom_info_ptr, unfiltered_sample_ct, sample_exclude, pheno_nm2, lasso_h2, lasso_minlambda, select_covars, select_covars_bitfield, pheno_d_collapsed, covar_ct, covar_names, max_covar_name_len, covar_nm, covar_d, hh_or_mt_exists, sample_ct, sample_valid_ct, sample_include2, sample_male_include2, loadbuf_raw, loadbuf_collapsed, rand_matrix, misc_arr, residuals, polymorphic_markers, &polymor [...] } if (retval || (!polymorphic_marker_ct)) { goto lasso_ret_1; diff --git a/plink_lasso.h b/plink_lasso.h index 3227f03..7c39e9a 100644 --- a/plink_lasso.h +++ b/plink_lasso.h @@ -18,8 +18,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. -int32_t lasso_lambda(const uintptr_t* marker_exclude, const uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t* sex_male, uintptr_t* pheno_nm, const uintptr_t* covar_nm, uintptr_t bed_offset, uintptr_t unfiltered_marker_ct, uintptr_t marker_ct, uintptr_t unfiltered_sample_ct, uintptr_t pheno_nm_ct, uint32_t hh_or_mt_exists, uint32_t lasso_lambda_iters, double lasso_h2, FILE* bedfile, char* outname, char* outname_end, double* lasso_minlambda_ptr); +int32_t lasso_lambda(const uintptr_t* marker_exclude, const uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, const uintptr_t* sample_exclude, uintptr_t* sex_male, uintptr_t* pheno_nm, const uintptr_t* covar_nm, uintptr_t bed_offset, uintptr_t unfiltered_marker_ct, uintptr_t marker_ct, uintptr_t unfiltered_sample_ct, uint32_t sample_ct, uintptr_t pheno_nm_ct, uint32_t hh_or_mt_exists, uint32_t lasso_lambda_iters, double lasso_h2, FILE* bedfile, char* outname, char* outname_end, doub [...] -int32_t lasso(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* outname, char* outname_end, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t marker_ct, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t pheno_nm_ct, double lasso_h2, double lasso_minlambda, Range_list* select_covars_range_list_ptr, uint64_t misc_flags, uintptr_t* pheno_nm [...] +int32_t lasso(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* outname, char* outname_end, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t marker_ct, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uintptr_t* marker_reverse, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uint32_t sample_ct, uintptr_t pheno_nm_ct, double lasso_h2, double lasso_minlambda, Range_list* select_covars_range_list_ptr, uint64_t misc_flags, [...] #endif // __PLINK_LASSO_H__ diff --git a/plink_rserve.c b/plink_rserve.c index 5d1aa6c..7658a50 100644 --- a/plink_rserve.c +++ b/plink_rserve.c @@ -30,7 +30,7 @@ #define RPLUGIN_BLOCK_SIZE 100 -int32_t rserve_call(char* rplugin_fname, uint32_t rplugin_port, uint32_t rplugin_debug, FILE* bedfile, uintptr_t bed_offset, uintptr_t marker_ct, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t* marker_reverse, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uint32_t* marker_pos, uint32_t plink_maxsnp, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t* pheno_nm, uint32_t pheno_nm_ct, uintptr_t* pheno_c, double* pheno_d, u [...] +int32_t rserve_call(char* rplugin_fname, char* rplugin_host_or_socket, int32_t rplugin_port, uint32_t rplugin_debug, FILE* bedfile, uintptr_t bed_offset, uintptr_t marker_ct, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t* marker_reverse, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uint32_t* marker_pos, uint32_t plink_maxsnp, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t* pheno_nm, uint32_t pheno_nm_ct, uintptr_t [...] // See PLINK 1.07 r.cpp. unsigned char* bigstack_mark = g_bigstack_base; FILE* infile = nullptr; @@ -180,7 +180,10 @@ int32_t rserve_call(char* rplugin_fname, uint32_t rplugin_port, uint32_t rplugin if (bigstack_alloc_i(RPLUGIN_BLOCK_SIZE * ((uintptr_t)pheno_nm_ct), &geno_int_buf)) { goto rserve_call_ret_NOMEM; } - rc = new Rconnection("127.0.0.1", rplugin_port); + if (rplugin_port == -2) { + rplugin_port = 6311; + } + rc = new Rconnection(rplugin_host_or_socket, rplugin_port); ii = rc->connect(); if (ii) { sockerrorchecks(g_textbuf, 128, -1); diff --git a/plink_rserve.h b/plink_rserve.h index 7895873..de9bdcc 100644 --- a/plink_rserve.h +++ b/plink_rserve.h @@ -18,6 +18,6 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. -int32_t rserve_call(char* rplugin_fname, uint32_t rplugin_port, uint32_t rplugin_debug, FILE* bedfile, uintptr_t bed_offset, uintptr_t marker_ct, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t* marker_reverse, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uint32_t* marker_pos, uint32_t plink_maxsnp, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t* pheno_nm, uint32_t pheno_nm_ct, uintptr_t* pheno_c, double* pheno_d, u [...] +int32_t rserve_call(char* rplugin_fname, char* rplugin_host_or_socket, int32_t rplugin_port, uint32_t rplugin_debug, FILE* bedfile, uintptr_t bed_offset, uintptr_t marker_ct, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t* marker_reverse, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uint32_t* marker_pos, uint32_t plink_maxsnp, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t* pheno_nm, uint32_t pheno_nm_ct, uintptr_t [...] #endif // __PLINK_RSERVE_H__ -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/plink1.9.git _______________________________________________ debian-med-commit mailing list debian-med-commit@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit