Skip to content

Commit

Permalink
Merge pull request #271 from mcveanlab/lasso
Browse files Browse the repository at this point in the history
Lasso
  • Loading branch information
shajoezhu committed Oct 10, 2018
2 parents 6fcdf31 + 0eead39 commit 8db6899
Show file tree
Hide file tree
Showing 23 changed files with 1,384 additions and 1,024 deletions.
3 changes: 3 additions & 0 deletions .ci/checkedList
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
tests/unittest/test_dEploidIO.cpp
src/dEploid.cpp
src/variantIndex.cpp
src/variantIndex.hpp
src/exceptions.hpp
src/txtReader.cpp
src/txtReader.hpp
src/ibd.hpp
src/ibd.cpp
4 changes: 0 additions & 4 deletions .ci/mycppfileList
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
src/dEploidIO.cpp
src/dEploidIO.hpp
src/exceptions.hpp
src/ibd.cpp
src/ibd.hpp
src/mcmc.cpp
src/mcmc.hpp
src/panel.cpp
Expand All @@ -20,7 +17,6 @@ src/debug/vcfReaderDebug.cpp
src/export/dEploidIOExport.cpp
src/export/dEploidIOExportPosteriorProb.cpp
src/export/writeMcmcRelated.cpp
tests/unittest/test_dEploidIO.cpp
tests/unittest/test_ibd.cpp
tests/unittest/test_mcmc.cpp
tests/unittest/test_panel.cpp
Expand Down
27 changes: 18 additions & 9 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ bin_PROGRAMS = dEploid dEploid_dbg utilities

man1_MANS = docs/_build/man/dEploid.1

TESTS = unit_tests
check_PROGRAMS = unit_tests dEploid_dbg dEploid_prof
TESTS = unit_tests io_unit_tests
check_PROGRAMS = unit_tests dEploid_dbg dEploid_prof io_unit_tests
PROG = DEPLOID

common_flags = -std=c++0x -Isrc/ -Isrc/codeCogs/ -Isrc/random/ -Isrc/gzstream/ -DDEPLOIDVERSION=\"${DEPLOIDVERSION}\" -DCOMPILEDATE=\"${COMPILEDATE}\"
common_flags = -std=c++0x -Isrc/ -Isrc/codeCogs/ -Isrc/random/ -Isrc/gzstream/ -Isrc/lasso/ -DDEPLOIDVERSION=\"${DEPLOIDVERSION}\" -DCOMPILEDATE=\"${COMPILEDATE}\"
common_LDADD = -lz

common_src = src/random/fastfunc.cpp \
Expand All @@ -33,9 +33,12 @@ common_src = src/random/fastfunc.cpp \
src/gzstream/gzstream.cpp \
src/export/dEploidIOExport.cpp \
src/export/dEploidIOExportPosteriorProb.cpp \
src/export/writeMcmcRelated.cpp
src/export/writeMcmcRelated.cpp \
src/lasso/lasso.cpp \
src/lasso/dEploidLasso.cpp

debug_src = src/debug/mcmcDebug.cpp src/debug/vcfReaderDebug.cpp
debug_src = src/debug/mcmcDebug.cpp src/debug/vcfReaderDebug.cpp \
src/lasso/lassoDBG.cpp

dEploid_SOURCES = src/dEploid.cpp $(common_src)
dEploid_dbg_SOURCES = $(debug_src) $(dEploid_SOURCES)
Expand All @@ -51,19 +54,25 @@ dEploid_prof_LDADD = $(common_LDADD)

unit_tests_SOURCES = $(common_src) \
tests/unittest/test_runner.cpp \
tests/unittest/test_dEploidIO.cpp \
tests/unittest/test_ibd.cpp \
tests/unittest/test_updateSingleHap.cpp \
tests/unittest/test_utilities.cpp \
tests/unittest/test_panel.cpp \
tests/unittest/test_txtReader.cpp \
tests/unittest/test_mcmc.cpp \
tests/unittest/test_updatePairHap.cpp \
tests/unittest/test_vcfReader.cpp
tests/unittest/test_updatePairHap.cpp

unit_tests_CXXFLAGS = $(common_flags) -DNDEBUG -DUNITTEST -Wno-write-strings --coverage
unit_tests_LDADD = -lcppunit -ldl $(common_LDADD)

io_unit_tests_SOURCES = $(common_src) \
tests/unittest/test_runner.cpp \
tests/unittest/test_dEploidIO.cpp \
tests/unittest/test_txtReader.cpp \
tests/unittest/test_vcfReader.cpp

io_unit_tests_CXXFLAGS = $(common_flags) -DNDEBUG -DUNITTEST -Wno-write-strings --coverage
io_unit_tests_LDADD = -lcppunit -ldl $(common_LDADD)

clean-local: clean-local-check
.PHONY: clean-local-check utilities
clean-local-check:
Expand Down
2 changes: 1 addition & 1 deletion docs/doxygen/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dist_man_MANS = $(directory)/man_page_1.3 $(directory)/man_page_2.3
$(directory)/man_page_1.3: doxyfile.stamp
$(directory)/man_page_2.3: doxyfile.stamp

doxyfile.stamp:
doxyfile.stamp: ../../src/*pp
$(DOXYGEN) Doxyfile
echo Timestamp > doxyfile.stamp

Expand Down
57 changes: 51 additions & 6 deletions src/dEploid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,72 @@ int main(int argc, char *argv[]) {
return EXIT_SUCCESS;
}

if ( dEploidIO.doComputeLLK() ) {
if (dEploidIO.doComputeLLK()) {
dEploidIO.computeLLKfromInitialHap();
} else if ( dEploidIO.doLsPainting() ) {
} else if (dEploidIO.doLsPainting()) {
dEploidIO.chromPainting();
} else if ( dEploidIO.doIbdPainting() ) {
} else if (dEploidIO.doIbdPainting()) {
dEploidIO.paintIBD();
} else if (dEploidIO.useLasso()) {
dEploidIO.dEploidLasso();
MersenneTwister lassoRg(dEploidIO.randomSeed());
DEploidIO tmpIO(dEploidIO);
vector < vector <double> > hap;
for (size_t chromi = 0;
chromi < dEploidIO.indexOfChromStarts_.size();
chromi++ ) {
tmpIO.position_.clear();
tmpIO.position_.push_back(dEploidIO.position_.at(chromi));
tmpIO.indexOfChromStarts_.clear();
tmpIO.indexOfChromStarts_.push_back(0);
McmcSample * lassoMcmcSample = new McmcSample();
McmcMachinery lassoMcmcMachinery(
&dEploidIO.lassoPlafs.at(chromi),
&dEploidIO.lassoRefCount.at(chromi),
&dEploidIO.lassoAltCount.at(chromi),
dEploidIO.lassoPanels.at(chromi),
&tmpIO,
lassoMcmcSample,
&lassoRg,
false);
lassoMcmcMachinery.runMcmcChain(true, // show progress
false); // use IBD
for (size_t snpi = 0;
snpi < lassoMcmcSample->hap.size(); snpi++) {
hap.push_back(vector <double> (
lassoMcmcSample->hap[snpi].begin(),
lassoMcmcSample->hap[snpi].end()));
}
delete lassoMcmcSample;
}
dEploidIO.writeHap(hap, false);
} else {
if (dEploidIO.useIBD()) { // ibd
McmcSample * ibdMcmcSample = new McmcSample();
MersenneTwister ibdRg(dEploidIO.randomSeed());

McmcMachinery ibdMcmcMachinery(&dEploidIO, ibdMcmcSample,
&ibdRg, true);
McmcMachinery ibdMcmcMachinery(&dEploidIO.plaf_,
&dEploidIO.refCount_,
&dEploidIO.altCount_,
dEploidIO.panel,
&dEploidIO,
ibdMcmcSample,
&ibdRg,
true);
ibdMcmcMachinery.runMcmcChain(true, // show progress
true); // use IBD
delete ibdMcmcSample;
}
McmcSample * mcmcSample = new McmcSample();
MersenneTwister rg(dEploidIO.randomSeed());

McmcMachinery mcmcMachinery(&dEploidIO, mcmcSample, &rg,
McmcMachinery mcmcMachinery(&dEploidIO.plaf_,
&dEploidIO.refCount_,
&dEploidIO.altCount_,
dEploidIO.panel,
&dEploidIO,
mcmcSample,
&rg,
false); // use IBD
mcmcMachinery.runMcmcChain(true, // show progress
false); // use IBD
Expand Down
Loading

0 comments on commit 8db6899

Please sign in to comment.