Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New features, bug fixes, and new test case framework for 4.16.0 #30

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
7c84ace
Avoid truncation from double to integer
welchr Jun 8, 2018
ae64014
Add more logging statements, primarily for filtered variants
welchr Jun 8, 2018
da15bdf
Latest savvy version
welchr May 23, 2019
a83b362
Raise exception if savvy fails while reading file
welchr May 23, 2019
665ef93
Disable unsupported argument
welchr Mar 23, 2020
25be279
Missed imports; remove debug prints
welchr Mar 30, 2020
5d41c6c
Implement support for heterogeneity statistics
welchr Apr 12, 2020
0270608
Allow skipping burden tests
welchr Apr 16, 2020
fdab910
Fix heterogeneity stats
welchr Apr 19, 2020
cc6edc2
Switch to Catch2 test framework
welchr Apr 23, 2020
0afad3d
Refactor Meta to remove global state
welchr Apr 24, 2020
08f234c
Allow skipping output when testing
welchr Apr 24, 2020
56ab521
Fix test case for heterogeneity chisq values
welchr Apr 24, 2020
35e090d
Refactor parsing score/cov file listing
welchr Apr 24, 2020
e9e658a
Refactor single variant p-value calc; added -log10(p)
welchr Apr 24, 2020
ac76eac
Fix test cases; add test for -log10(p) on extreme small p-value
welchr Apr 24, 2020
fca15d2
Remove global state on GroupFromAnnotation
welchr Apr 24, 2020
ed2ab88
Additional comments on het stats
welchr Apr 24, 2020
ca6fa07
Write out -log10 single variant p-values
welchr Apr 25, 2020
69bd5dc
Write het p-values in -log10 scale
welchr Apr 25, 2020
81e1305
Refactor file output, log file creation
welchr Apr 26, 2020
0097971
Don't need to skipOutput on tests after refactor
welchr Apr 26, 2020
8882ee2
Refactor meta prep
welchr Apr 27, 2020
6627cfc
Supporting code and initial test case for file I/O
welchr Apr 27, 2020
26b8c27
Fix precision of p-value (even without --logPvalue) + test cases
welchr Apr 27, 2020
e35212e
Fix single variant meta-analysis reader to use column header instead …
welchr May 1, 2020
2516048
Rename variable (it isn't maf, it's alt freq)
welchr May 7, 2020
c708e4f
Extra AF stats: mean, SE, min, max
welchr May 7, 2020
f2b223e
Update reader for new AF stats in meta-analysis results file
welchr May 7, 2020
a05128d
Test case for new AF stats
welchr May 7, 2020
4d970b4
Additional comments
welchr May 7, 2020
7d2994e
Allow testing only within a given chrom:start-end
welchr May 9, 2020
5af74fb
Test case for --range
welchr May 9, 2020
c736e43
Data files for range test
welchr May 9, 2020
219b308
Additional data files for tests
welchr May 9, 2020
72a4f42
Fix regression from new tabix usage
welchr May 12, 2020
bc976dd
Update libStatGen to fix linux compile error and pin to commit
welchr May 12, 2020
d6a0f0b
Update savvy version
welchr May 12, 2020
ff5e1dc
Dockerfile and .dockerignore
welchr May 12, 2020
0738f31
Travis CI
welchr May 12, 2020
6548fd6
Fix pooled alt AF parsing
welchr May 14, 2020
a5f973d
Support for comparing two single variant result sets read in from a f…
welchr May 14, 2020
3cc2852
Fix logP getting switched on without command line arg given
welchr May 14, 2020
814724c
Check equality of metadata from single variant reader
welchr May 14, 2020
89033a9
Update tutorial expected results after patches
welchr May 14, 2020
8e53291
Add first tutorial dataset to test suite
welchr May 14, 2020
549d956
Compare equality of group test datasets
welchr May 14, 2020
85947a9
Check group p-val, effect
welchr May 14, 2020
03c7f6d
Check SKAT, burden, VT in tutorial dataset
welchr May 14, 2020
b07ff72
Cleanup logs, test output
welchr May 14, 2020
142f9c5
Fix another linux compile error
welchr May 15, 2020
bbcad0f
Move file exists
welchr May 15, 2020
8f08cd7
Modify all readers to check for file existence and successful record …
welchr May 15, 2020
0d7eda3
Add other tutorial test case for rvtest input
welchr May 15, 2020
1e01930
Fix regression in reading rvtest formatted files
welchr May 15, 2020
4ef3eb4
Load heterogeneity p-value in SV reader
welchr May 21, 2020
fccc37c
Patch heterogeneity code to obey --range
welchr May 21, 2020
839011c
Test case for heterogeneity and --range option
welchr May 21, 2020
bad5271
Allow skipping PDF generation
welchr May 21, 2020
741e5fc
Fix PDF heisenbug
welchr May 21, 2020
e601640
Tests for burden, SKAT, VT under the alternative
welchr May 22, 2020
4b72083
Test with a monomorphic variant
welchr May 22, 2020
1c64639
Travis build for OSX
welchr May 26, 2020
d075432
Remove old raremetal tests
welchr May 27, 2020
860aeea
Fix raremetalworker binary path in cmake tests
welchr May 27, 2020
ec97e96
Update README
welchr May 28, 2020
a38be53
Support both MacOS 10.14 and 10.15 in travis
welchr May 27, 2020
d2dec1b
Run RMW tests on OSX
welchr May 28, 2020
0e88083
Fix missed columns in SKAT result header when --condition used
welchr Oct 17, 2020
a25912e
Fix COND_PVALUE repeated twice in header
welchr Oct 17, 2020
aa9cc1e
Expose headers in group test and single variant readers
welchr Oct 17, 2020
6798dd4
Read in conditional effect size, p-value for single variants
welchr Oct 17, 2020
384fcce
Add test case for --condition
welchr Oct 17, 2020
214237b
Fix incorrect dimension for temporary X^T * X matrix
welchr Jan 5, 2022
a23cab3
Disable --useCovariates as projection matrix is never used
welchr Jan 5, 2022
5b0fda0
Fix issue with zlib
welchr Feb 24, 2023
6d87a91
Protect against seg fault caused by ifeof() bug
welchr Mar 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cget
venv
.git
private
build
clion-build-debug
clion-build-release
docker-compose.override.yml
55 changes: 55 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
language: cpp

jobs:
include:
- os: linux
dist: bionic
compiler: gcc
env: LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
before_install:
- |
sudo apt update
sudo apt install build-essential cmake gfortran locales zlib1g-dev liblzma-dev
sudo apt install python3 python3-setuptools python3-pip python3-virtualenv
sudo locale-gen en_US.UTF-8
sudo pip3 install cget
cget install -f requirements.txt

- os: osx
osx_image: xcode11.3
compiler: clang
before_install:
- |
brew install cmake zlib xz python3
brew cask install gfortran
sudo python3 -m pip install cget
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
cget install -f requirements.txt

- os: osx
osx_image: xcode11.4
compiler: clang
before_install:
- |
brew install cmake zlib xz python3
brew cask install gfortran
sudo python3 -m pip install cget
export CPATH=$(xcrun --show-sdk-path)/usr/include
export CFLAGS="${CFLAGS} -Wno-nullability-completeness -Wno-expansion-to-defined -Wno-undef"
cget install -f requirements.txt

cache: pip

install:
- rm -rf build && mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cget/cget/cget.cmake -DBUILD_TESTS=1 ..
- make
- cd ..

script:
- build/raremetal/tests/bin/tests-raremetal
- cd build

# The raremetalworker tests only work on OSX. If we're on OSX, then run the tests and return the result.
# Otherwise, this statement should return true, to avoid completely failing the entire build/job.
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then ctest --verbose; else true; fi
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ find_library(LIB_HTS hts)
find_library(LIB_Z z)
find_library(LIB_RMATH Rmath)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)

add_library(libraremetal
libRareMetal/mvtnorm/randomF77.c
libRareMetal/pdf/PDF.cpp
Expand Down Expand Up @@ -136,8 +138,8 @@ target_include_directories(raremetalworker PRIVATE otherLib/eigen-3.2.0)
target_link_libraries(raremetalworker libraremetal ${LIB_SAVVY} ${LIB_ZSTD})
target_compile_definitions(raremetalworker PRIVATE VERSION="${PROJECT_VERSION}")


if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
add_subdirectory(raremetal/tests)
endif()
70 changes: 70 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM ubuntu:18.04

ARG BUILD_DATE
ARG GIT_SHA
ARG RAREMETAL_VERSION

LABEL org.label-schema.name="RAREMETAL"
LABEL org.label-schema.description="Meta-analysis of rare genetic variant aggregation tests"
LABEL org.label-schema.vendor="University of Michigan, Center for Statistical Genetics"
LABEL org.label-schema.url="https://github.com/statgen/RAREMETAL"
LABEL org.label-schema.vcs-url="https://github.com/statgen/RAREMETAL"
LABEL org.label-schema.schema-version="1.0"

# Install required packages for swiss to install. Many of swiss' dependencies
# require compiling C/C++ code.
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
gfortran \
python3 \
python3-pip \
zlib1g-dev \
liblzma-dev \
locales \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8

# Install necessary python packages (backports.lzma needed for cget to extract .xz archives)
RUN pip3 install cget

# Create a group and user to execute as, then drop root
ARG UID
ARG GID
RUN \
if [ -n "$GID" ]; then \
addgroup --gid $GID raremetal; \
else \
addgroup raremetal; \
fi && \
if [ -n "$UID" ]; then \
adduser --gecos "User for running raremetal as non-root" --shell /bin/bash --disabled-password --uid $UID --ingroup raremetal raremetal; \
else \
adduser --gecos "User for running raremetal as non-root" --shell /bin/bash --disabled-password --ingroup raremetal raremetal; \
fi

WORKDIR /home/raremetal
USER raremetal

# Copy source
COPY --chown=raremetal:raremetal . /home/raremetal/

# Compile & run tests
# We want the docker build to fail if the tests fail
RUN cget install -f requirements.txt
RUN mkdir build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cget/cget/cget.cmake -DBUILD_TESTS=1 .. && \
make && \
cd .. && \
build/raremetal/tests/bin/tests-raremetal

ENTRYPOINT ["build/bin/raremetal"]

# Frequently changing metadata here to avoid cache misses
LABEL org.label-schema.version=$RAREMETAL_VERSION
LABEL org.label-schema.vcs-ref=$GIT_SHA
LABEL org.label-schema.build-date=$BUILD_DATE
101 changes: 82 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,106 @@
Raremetal: A tool for rare variants meta-analysis
RAREMETAL: A tool for rare variants meta-analysis

(c) 2012-2018 Shuang Feng, Dajiang Liu, Sai Chen, Gonçalo Abecasis

For more information, please see the [RAREMETAL wiki](http://genome.sph.umich.edu/wiki/RAREMETAL).

## Installation
1. Clone this repository
2. Open a terminal and change to the directory containing this README file.
3. Enter the following sequence of commands to download dependencies and build the code (with tests run automatically during build):


### Requirements

RAREMETAL requires the following libraries to build. These should already be installed on most scientific
computing clusters.

#### Linux

On Linux, the following packages are needed:

- zlib
- liblzma
- cmake
- gcc/g++
- gfortran
- python3
- cget

As an example in Ubuntu specifically, you can install with the following commands:

```bash
sudo apt update
sudo apt install build-essential cmake gfortran locales zlib1g-dev liblzma-dev
sudo apt install python3 python3-setuptools python3-pip python3-virtualenv
sudo python3 -m pip install cget
```

#### MacOS

Use Homebrew to install the necessary packages:

```bash
brew install cmake zlib xz python3
brew cask install gfortran
sudo python3 -m pip install cget
```

You may need to manually install the C++ headers on MacOS 10.4 (Mojave) by running the following command:

```bash
cget install -f requirements.txt
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cget/cget/cget.cmake -DBUILD_TESTS=1 ..
make
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
```

To run unit tests, ensure that you have run cmake with `-DBUILD_TESTS=1` and built at least once,
then run `make` or `ctest --verbose`.
For Mac OS 10.5 (Catalina), C++ headers may be missing and you may receive excessive compiler warnings. The following settings may help:

```bash
# Specify path to MacOS C++ SDK header files
export CPATH=$(xcrun --show-sdk-path)/usr/include

# Disable compiler warnings introduced in Catalina
export CFLAGS="${CFLAGS} -Wno-nullability-completeness -Wno-expansion-to-defined -Wno-undef"
```

#### Windows

Windows is currently unsupported. You may have some luck with Windows Subsystem for Linux, or a VM.

### Installing

1. Clone this repository: `git clone https://github.com/statgen/raremetal.git`
2. Open a terminal and change to the directory containing this README file.
3. Enter the following sequence of commands to download dependencies and build the code:

```bash
cget install -f requirements.txt
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cget/cget/cget.cmake -DBUILD_TESTS=1 ..
make
```

If you encounter problems while building, see the [wiki instructions](https://genome.sph.umich.edu/wiki/RAREMETAL_DOWNLOAD_%26_BUILD)
and [FAQ](https://genome.sph.umich.edu/wiki/RAREMETAL_FAQ) for more information.

### Requirements
Raremetal requires the following libraries to build. These should already be installed on most scientific
computing clusters.
### Running tests

- libRMath (The R math library. If not installed, use `apt-get install r-mathlib` on ubuntu or `brew install r`
on Mac OS)
- zlib (`apt-get install zlib1g-dev` on Ubuntu)
To run unit tests, ensure that you have run cmake with `-DBUILD_TESTS=1` and built at least once, then run:

On Mac OS, installing R as a standalone package is not sufficient to use libRMath in other executables.
Consider `brew install r` or [r-devel](https://r.research.att.com/) in that case.
```bash
# To test RAREMETAL, run the following:
build/raremetal/tests/bin/tests-raremetal

# To test RAREMETALWORKER, run the following:
cd build
make test
```

Both sets of tests are automatically run by Travis CI as well, see `.travis.yml` for details.

## Changes

Newest version: v.4.14.1 released at 07/10/2017

View change log at: http://genome.sph.umich.edu/wiki/RAREMETAL_Change_Log

### RAREMETAL2

We are also working on a beta version that provides new features and options- RAREMETAL2.

This code is still in the experimental stages, but a full release is planned in the future. See:
Expand Down
21 changes: 3 additions & 18 deletions raremetal/src/Calculate_mvt_pvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <stdio.h>
#include "MathMatrix.h"
#include "StringHash.h"
#include "IntArray.h"
#include "MathSVD.h"

#define MATHLIB_STANDALONE

Expand Down Expand Up @@ -112,15 +114,9 @@ double CalculateMVTPvalue(Vector &score, Matrix &cov, double t_max)
//A new combination has been generated!
comb.Push(alpha[indx[owk]]);
}
/*
printf("New combination:\n");
for(int i=0;i<comb.Length();i++)
printf("%g ",comb[i]);
printf("\n");
*/

//Calculate P(A|BC)
GetConditionalDist(score, cov, comb, par);
// printf("pars are:%g %g\n",par[0],par[1]);
double chisq, condProb, prob;
if (par[1] == 0.0)
{
Expand All @@ -134,7 +130,6 @@ double CalculateMVTPvalue(Vector &score, Matrix &cov, double t_max)
}
condProb = pchisq(chisq, 1, 0, 0);
}
// printf("conditional prob is:%g\n",condProb);
String hashKey;

if (r == 2)
Expand All @@ -143,10 +138,7 @@ double CalculateMVTPvalue(Vector &score, Matrix &cov, double t_max)
hashKey += tmp;
tmp = comb[1];
hashKey += tmp;
// printf("hashKey is: %s\n",hashKey.c_str());
prob = condProb * uni;
//prob = exp(log(condProb) + log(uni));
//printf("joint prob is:%g\n",prob);
jointProbHash.SetDouble(hashKey, prob);
hashKey.Clear();
} else
Expand All @@ -156,13 +148,7 @@ double CalculateMVTPvalue(Vector &score, Matrix &cov, double t_max)
int tmp = comb[i];
hashKey += tmp;
}
// printf("hashKey is: %s\n",hashKey.c_str());
prob = jointProbHash.Double(hashKey);
// printf("joint prob is:%g\n",prob);
//if(prob == _NAN_)
//{
// printf("Error! Joint probability %s is not hashed in properly.\n",hashKey);
// }
prob *= condProb; //This is the new joint prob.
String newKey;
int tmp = comb[0];
Expand All @@ -174,7 +160,6 @@ double CalculateMVTPvalue(Vector &score, Matrix &cov, double t_max)
}

pvalue -= prob;
// printf("pvalue so far is:%g\n",pvalue);
comb.Clear();
for (int iwk = r - 1; iwk >= 0; iwk--)
{
Expand Down
13 changes: 6 additions & 7 deletions raremetal/src/GroupFromAnnotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
#include "InputFile.h"
#include "QuickIndex.h"

String GroupFromAnnotation::groupFile = "";
String GroupFromAnnotation::vcfInput = "";
String GroupFromAnnotation::function = "";
String GroupFromAnnotation::mapFile = "../data/refFlat_hg19.txt";
bool GroupFromAnnotation::labelHits = false;

GroupFromAnnotation::GroupFromAnnotation()
{
geneCount = 0;
geneCount = 0;
groupFile = "";
vcfInput = "";
function = "";
mapFile = "../data/refFlat_hg19.txt";
labelHits = false;
}

GroupFromAnnotation::~GroupFromAnnotation()
Expand Down
Loading