Skip to content

Commit

Permalink
Merge pull request #199 from databio/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jpsmith5 committed Jul 21, 2021
2 parents 124df2f + a0e5ef6 commit 7616783
Show file tree
Hide file tree
Showing 33 changed files with 1,910 additions and 650 deletions.
13 changes: 7 additions & 6 deletions PEPATACr/R/PEPATACr.R
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ plotFRiF <- function(sample_name, num_reads, genome_size,
group=feature, color=feature)) +
#geom_line(aes(linetype=feature), size=2, alpha=0.5) +
geom_line(size=2, alpha=0.5) +
guides(linetype = FALSE) +
guides(linetype = "none") +
labs(x=expression(log[10]("number of bases")),
y="FRiF") +
theme_PEPATAC()
Expand Down Expand Up @@ -885,7 +885,7 @@ plotFRiF <- function(sample_name, num_reads, genome_size,
p <- ggplot(covDF, aes(x=log10(cumSize), y=frip,
group=feature, color=feature)) +
geom_line(size=2, alpha=0.5) +
guides(linetype = FALSE) +
guides(linetype = "none") +
labs(x=expression(log[10]("number of bases")), y="FRiF") +
theme_PEPATAC()

Expand Down Expand Up @@ -919,7 +919,7 @@ plotFRiF <- function(sample_name, num_reads, genome_size,
aes(x=log10(cumSize), y=frip,
group=feature, color=feature)) +
geom_line(aes(linetype=feature), size=2, alpha=0.5) +
guides(linetype = FALSE) +
guides(linetype = "none") +
labs(x=expression(log[10]("number of bases")),
y="FRiF") +
theme_PEPATAC()
Expand Down Expand Up @@ -1640,12 +1640,13 @@ narrowPeakToBigBed <- function(input=input, chr_sizes=chr_sizes,
#' peaks. It also trims peaks extending beyond the bounds of the chromosome.
#'
#' @param input Path to narrowPeak file
#' @param sample_name Sample name character string
#' @param chr_sizes Genome chromosome sizes file. <Chr> <Size>
#' @param output Output file name.
#' @param normalize Remove overlaps and normalize the score.
#' @keywords reduce fixed peaks
#' @export
reducePeaks <- function(input, chr_sizes, output=NA, normalize=FALSE) {
reducePeaks <- function(input, sample_name, chr_sizes, output=NA, normalize=FALSE) {
info <- file.info(file.path(input))
if (file.exists(file.path(input)) && info$size != 0) {
peaks <- fread(file.path(input))
Expand Down Expand Up @@ -1719,8 +1720,8 @@ reducePeaks <- function(input, chr_sizes, output=NA, normalize=FALSE) {
final[score < 0, score := 0]
# save final peak set
if (is.na(output)) {
fwrite(final, paste0(sampleName(input),
"_peaks_normalized.narrowPeak"),
file_path <- file.path(dirname(input), sample_name)
fwrite(final, paste0(file_path, "_peaks_normalized.narrowPeak"),
sep="\t", col.names=FALSE)
} else {
fwrite(final, output, sep="\t", col.names=FALSE)
Expand Down
152 changes: 108 additions & 44 deletions checkinstall
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
# PEPATAC pipeline installation check
#

if [[ $# -gt 0 ]] ; then
if [ $# -gt 0 ] ; then
echo "Usage: checkinstall"
exit 1
fi

set -o pipefail
# set -e

echo -e "-----------------------------------------------------------"
echo -e " "
Expand Down Expand Up @@ -49,28 +50,28 @@ GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function fail {
fail() {
printf "${RED}\u2716 $@${NC}\n"
}

function success {
success() {
printf "${GREEN}\xE2\x9C\x94 $@${NC}\n"
}

function warn {
printf "${YELLOW}$@${NC}\n"
warn() {
printf "${YELLOW}\u26A0 $@${NC}\n"
}

################################################################################
echo -e "Checking base requirements... "
echo -e " "

BASE_REQS=0

declare -a requiredPkgs=("refgenie" "looper")
declare -a requiredPkgs=("looper")

for package in ${requiredPkgs[@]}; do
if ! pip_show $package; then
echo $(fail "ERROR: PEPATAC requires the Python package, $package. Try pip install $package and checkinstall again.")
echo $(fail "ERROR: PEPATAC requires the Python package, $package. Try pip install $package.")
printf "\n"
exit 1
fi
Expand All @@ -84,7 +85,6 @@ fi
################################################################################
echo -e "-----------------------------------------------------------"
echo -e "Checking native installation... "
echo -e " "
NATIVE_INSTALL=0

# Check Python
Expand All @@ -111,6 +111,12 @@ if ! is_executable "pip"; then
BULKER_INSTALL=1
fi

if [ -f "requirements.txt" ]; then
REQS="requirements.txt"
else
REQS=$(curl https://raw.githubusercontent.com/databio/pepatac/master/requirements.txt)
fi

while IFS= read -r line; do
[ "${line:0:1}" = "#" ] && continue
IFS='>=' read -r -a array <<< "$line"
Expand Down Expand Up @@ -164,15 +170,15 @@ while IFS= read -r line; do
echo -e $(success "SUCCESS: Python package ${package}\trequired: any\tinstalled: ${installed_version}")
fi
fi
done < "requirements.txt"
done < $REQS

# Check tool installation
declare -a requiredCommands=("perl" "awk" "grep" "sed" "bedtools" "bowtie2" "fseq" "macs2" "preseq" "samblaster" "samtools" "skewer" "bedToBigBed" "bigWigCat" "wigToBigWig" "Rscript")

for cmd in ${requiredCommands[@]}; do
if ! is_executable $cmd; then
echo $(warn "WARNING: Install $cmd and checkinstall again.")
printf "\n"
# printf "\n"
NATIVE_INSTALL=1
else
echo -e $(success "SUCCESS: ${cmd}")
Expand Down Expand Up @@ -210,7 +216,6 @@ done
################################################################################
echo -e "-----------------------------------------------------------"
echo -e "Checking conda installation... "
echo -e " "
CONDA_INSTALL=0

if ! is_executable "conda"; then
Expand Down Expand Up @@ -246,6 +251,12 @@ else
CONDA_INSTALL=1
fi

if [ -f "requirements.txt" ]; then
REQS="requirements.txt"
else
REQS=$(curl https://raw.githubusercontent.com/databio/pepatac/master/requirements.txt)
fi

while IFS= read -r line; do
[ "${line:0:1}" = "#" ] && continue
IFS='>=' read -r -a array <<< "$line"
Expand Down Expand Up @@ -298,7 +309,7 @@ else
echo -e $(success "SUCCESS: Python package ${package}\trequired: any\tinstalled: ${installed_version}")
fi
fi
done < "requirements.txt"
done < $REQS

# Check tool installation
declare -a requiredCommands=("perl" "awk" "grep" "sed" "bedtools" "bowtie2" "fseq" "macs2" "preseq" "samblaster" "samtools" "skewer" "bedToBigBed" "bigWigCat" "wigToBigWig" "Rscript")
Expand Down Expand Up @@ -347,62 +358,115 @@ fi
################################################################################
echo -e "-----------------------------------------------------------"
echo -e "Checking bulker installation... "
echo -e " "
BULKER_INSTALL=0

if ! is_executable "bulker"; then
echo $(warn "WARNING: To use bulker, pip install bulker and checkinstall again.")
printf "\n"
BULKER_INSTALL=1
if ! is_executable "docker"; then
DOCKER=1
else
BULKER_INSTALL=0
echo -e $(success "SUCCESS: bulker")
DOCKER=0
fi

CWD=$(pwd)
crate=$(grep 'bulker_crate' $CWD/sample_pipeline_interface.yaml | awk '{print $2}')
echo "crate: ${crate}"
if ! is_executable "singularity"; then
SINGULARITY=1
else
SINGULARITY=0
fi

yes n | bulker load $crate
if [ "$DOCKER" -eq 0 ]; then
CMD_CHECK=$(docker --help)
if [ $? -eq 0 ]; then
echo -e $(success "SUCCESS: docker.")
else
echo -e $(warn "WARNING: Docker is a recognized command, but does not appear to be active. Please ensure docker is running and checkinstall again.")
DOCKER=1
fi
fi

if [ $? -eq 0 ]; then
echo $(warn "WARNING: Could not bulker load ${crate}. Check out https://bulker.databio.org/en/latest/install/.")
printf "\n"
BULKER_INSTALL=1
if [ "$SINGULARITY" -eq 0 ]; then
echo -e $(success "SUCCESS: singularity.")
fi

isActivatable=$(bulker run ${crate} $CWD/pipelines/pepatac.py --help)
#echo "isActivatable: ${isActivatable}"
if [ -v "$isActivatable" ]; then
echo $(warn "WARNING: Could not activate the bulker crate, ${crate}. Check out https://bulker.databio.org/en/latest/install/.")
printf "\n"
if [ "$DOCKER" -eq 1 ] && [ "$SINGULARITY" -eq 1 ]; then
echo -e $(fail "ERROR: bulker")
BULKER_INSTALL=1
else
BULKER_INSTALL=0
echo -e $(success "SUCCESS: bulker run ${crate}")
if ! is_executable "bulker"; then
echo $(warn "WARNING: To use bulker, pip install bulker and checkinstall again.")
printf "\n"
BULKER_INSTALL=1
else
BULKER_INSTALL=0
echo -e $(success "SUCCESS: bulker")
fi

CWD=$(pwd)

if [ -f "sample_pipeline_interface.yaml" ]; then
IFACE="sample_pipeline_interface.yaml"
CRATE=$(cat $IFACE | grep 'bulker_crate' | tr " " "\n" | tail -n 1)
else
IFACE=$(curl https://raw.githubusercontent.com/databio/pepatac/master/sample_pipeline_interface.yaml)
CRATE=$(echo $IFACE | tr " " "\n" | grep -A1 'bulker_crate' | tail -n 1)
fi

yes n | bulker load $CRATE
if [ $? -eq 0 ]; then
echo $(warn "WARNING: Could not bulker load ${CRATE}. Check out https://bulker.databio.org/en/latest/install/.")
printf "\n"
BULKER_INSTALL=1
fi

if [ -f "$CWD/pipelines/pepatac.py" ]; then
PIPELINE="$CWD/pipelines/pepatac.py"
else
PIPELINE=$(curl https://raw.githubusercontent.com/databio/pepatac/master/pipelines/pepatac.py)
fi

CMD_CHECK=$(bulker run ${CRATE} $PIPELINE --help)
EXIT_CODE=$(echo $?)
isActivatable=$(echo "${EXIT_CODE}" | awk '{ print $1+0; exit }')
if [ "$isActivatable" -eq 0 ]; then
BULKER_INSTALL=0
echo -e $(success "SUCCESS: bulker run ${CRATE}")
else
echo $(warn "WARNING: Could not activate the bulker crate, ${CRATE}. Check out https://bulker.databio.org/en/latest/install/.")
printf "\n"
BULKER_INSTALL=1
fi
fi

################################################################################
echo -e "-----------------------------------------------------------"
echo -e " PEPATAC checkinstall results "
echo -e " "

if [ "$NATIVE_INSTALL" -eq 0 ]; then
echo -e $(success "SUCCESS: PEPATAC can be run utilizing native installations!")
echo -e $(success "SUCCESS: PEPATAC can be run using native installations!")
else
echo -e $(fail "ERROR: PEPATAC cannot be run using native installations.")
fi

if [ "$CONDA_INSTALL" -eq 0 ]; then
echo -e $(success "SUCCESS: PEPATAC can be run using conda installation!")
else
echo -e $(fail "ERROR: PEPATAC cannot be run via conda.")
fi

if [ "$DOCKER" -eq 0 ]; then
echo -e $(success "SUCCESS: PEPATAC can be run using docker!")
else
echo -e $(fail "WARNING: PEPATAC cannot be run utilizing native installations!")
echo -e $(fail "ERROR: PEPATAC cannot be run using docker.")
fi

if [ "$CONDA_INSTALL" -eq 0 ]; then
echo -e $(success "SUCCESS: PEPATAC can be run utilizing conda installation!")
if [ "$SINGULARITY" -eq 0 ]; then
echo -e $(success "SUCCESS: PEPATAC can be run using singularity!")
else
echo -e $(fail "WARNING: PEPATAC cannot be run via conda!")
echo -e $(fail "ERROR: PEPATAC cannot be run using singularity.")
fi

if [ "$BULKER_INSTALL" -eq 0 ]; then
echo -e $(success "SUCCESS: PEPATAC can be run utilizing bulker!")
if [ "$BULKER_INSTALL" -eq 0 ]; then
echo -e $(success "SUCCESS: PEPATAC can be run using bulker!")
else
echo -e $(fail "WARNING: PEPATAC cannot be run utilizing bulker!")
echo -e $(fail "ERROR: PEPATAC cannot be run using bulker.")
fi

if [ "$NATIVE_INSTALL" -eq 1 ] && [ "$CONDA_INSTALL" -eq 1 ] && [ "$BULKER_INSTALL" -eq 1 ]; then
Expand Down
6 changes: 3 additions & 3 deletions containers/pepatac.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM phusion/baseimage:master
LABEL maintainer Jason Smith "jasonsmith@virginia.edu"

# Version info
LABEL version 0.9.16
LABEL version 0.10.0

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
Expand Down Expand Up @@ -87,8 +87,8 @@ RUN pip install virtualenv && \

# Install R
RUN apt update -qq && \
DEBIAN_FRONTEND=noninteractive apt --assume-yes install --no-install-recommends dirmngr && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && \
DEBIAN_FRONTEND=noninteractive apt --assume-yes install --no-install-recommends dirmngr
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && \
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

RUN DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install r-base r-base-dev r-base-core r-recommended && \
Expand Down
Loading

0 comments on commit 7616783

Please sign in to comment.