Skip to content

Commit 7616783

Browse files
authored
Merge pull request #199 from databio/dev
Dev
2 parents 124df2f + a0e5ef6 commit 7616783

33 files changed

+1910
-650
lines changed

PEPATACr/R/PEPATACr.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ plotFRiF <- function(sample_name, num_reads, genome_size,
836836
group=feature, color=feature)) +
837837
#geom_line(aes(linetype=feature), size=2, alpha=0.5) +
838838
geom_line(size=2, alpha=0.5) +
839-
guides(linetype = FALSE) +
839+
guides(linetype = "none") +
840840
labs(x=expression(log[10]("number of bases")),
841841
y="FRiF") +
842842
theme_PEPATAC()
@@ -885,7 +885,7 @@ plotFRiF <- function(sample_name, num_reads, genome_size,
885885
p <- ggplot(covDF, aes(x=log10(cumSize), y=frip,
886886
group=feature, color=feature)) +
887887
geom_line(size=2, alpha=0.5) +
888-
guides(linetype = FALSE) +
888+
guides(linetype = "none") +
889889
labs(x=expression(log[10]("number of bases")), y="FRiF") +
890890
theme_PEPATAC()
891891

@@ -919,7 +919,7 @@ plotFRiF <- function(sample_name, num_reads, genome_size,
919919
aes(x=log10(cumSize), y=frip,
920920
group=feature, color=feature)) +
921921
geom_line(aes(linetype=feature), size=2, alpha=0.5) +
922-
guides(linetype = FALSE) +
922+
guides(linetype = "none") +
923923
labs(x=expression(log[10]("number of bases")),
924924
y="FRiF") +
925925
theme_PEPATAC()
@@ -1640,12 +1640,13 @@ narrowPeakToBigBed <- function(input=input, chr_sizes=chr_sizes,
16401640
#' peaks. It also trims peaks extending beyond the bounds of the chromosome.
16411641
#'
16421642
#' @param input Path to narrowPeak file
1643+
#' @param sample_name Sample name character string
16431644
#' @param chr_sizes Genome chromosome sizes file. <Chr> <Size>
16441645
#' @param output Output file name.
16451646
#' @param normalize Remove overlaps and normalize the score.
16461647
#' @keywords reduce fixed peaks
16471648
#' @export
1648-
reducePeaks <- function(input, chr_sizes, output=NA, normalize=FALSE) {
1649+
reducePeaks <- function(input, sample_name, chr_sizes, output=NA, normalize=FALSE) {
16491650
info <- file.info(file.path(input))
16501651
if (file.exists(file.path(input)) && info$size != 0) {
16511652
peaks <- fread(file.path(input))
@@ -1719,8 +1720,8 @@ reducePeaks <- function(input, chr_sizes, output=NA, normalize=FALSE) {
17191720
final[score < 0, score := 0]
17201721
# save final peak set
17211722
if (is.na(output)) {
1722-
fwrite(final, paste0(sampleName(input),
1723-
"_peaks_normalized.narrowPeak"),
1723+
file_path <- file.path(dirname(input), sample_name)
1724+
fwrite(final, paste0(file_path, "_peaks_normalized.narrowPeak"),
17241725
sep="\t", col.names=FALSE)
17251726
} else {
17261727
fwrite(final, output, sep="\t", col.names=FALSE)

checkinstall

Lines changed: 108 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# PEPATAC pipeline installation check
44
#
55

6-
if [[ $# -gt 0 ]] ; then
6+
if [ $# -gt 0 ] ; then
77
echo "Usage: checkinstall"
88
exit 1
99
fi
1010

1111
set -o pipefail
12+
# set -e
1213

1314
echo -e "-----------------------------------------------------------"
1415
echo -e " "
@@ -49,28 +50,28 @@ GREEN='\033[0;32m'
4950
YELLOW='\033[0;33m'
5051
NC='\033[0m' # No Color
5152

52-
function fail {
53+
fail() {
5354
printf "${RED}\u2716 $@${NC}\n"
5455
}
5556

56-
function success {
57+
success() {
5758
printf "${GREEN}\xE2\x9C\x94 $@${NC}\n"
5859
}
5960

60-
function warn {
61-
printf "${YELLOW}$@${NC}\n"
61+
warn() {
62+
printf "${YELLOW}\u26A0 $@${NC}\n"
6263
}
6364

6465
################################################################################
6566
echo -e "Checking base requirements... "
66-
echo -e " "
67+
6768
BASE_REQS=0
6869

69-
declare -a requiredPkgs=("refgenie" "looper")
70+
declare -a requiredPkgs=("looper")
7071

7172
for package in ${requiredPkgs[@]}; do
7273
if ! pip_show $package; then
73-
echo $(fail "ERROR: PEPATAC requires the Python package, $package. Try pip install $package and checkinstall again.")
74+
echo $(fail "ERROR: PEPATAC requires the Python package, $package. Try pip install $package.")
7475
printf "\n"
7576
exit 1
7677
fi
@@ -84,7 +85,6 @@ fi
8485
################################################################################
8586
echo -e "-----------------------------------------------------------"
8687
echo -e "Checking native installation... "
87-
echo -e " "
8888
NATIVE_INSTALL=0
8989

9090
# Check Python
@@ -111,6 +111,12 @@ if ! is_executable "pip"; then
111111
BULKER_INSTALL=1
112112
fi
113113

114+
if [ -f "requirements.txt" ]; then
115+
REQS="requirements.txt"
116+
else
117+
REQS=$(curl https://raw.githubusercontent.com/databio/pepatac/master/requirements.txt)
118+
fi
119+
114120
while IFS= read -r line; do
115121
[ "${line:0:1}" = "#" ] && continue
116122
IFS='>=' read -r -a array <<< "$line"
@@ -164,15 +170,15 @@ while IFS= read -r line; do
164170
echo -e $(success "SUCCESS: Python package ${package}\trequired: any\tinstalled: ${installed_version}")
165171
fi
166172
fi
167-
done < "requirements.txt"
173+
done < $REQS
168174

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

172178
for cmd in ${requiredCommands[@]}; do
173179
if ! is_executable $cmd; then
174180
echo $(warn "WARNING: Install $cmd and checkinstall again.")
175-
printf "\n"
181+
# printf "\n"
176182
NATIVE_INSTALL=1
177183
else
178184
echo -e $(success "SUCCESS: ${cmd}")
@@ -210,7 +216,6 @@ done
210216
################################################################################
211217
echo -e "-----------------------------------------------------------"
212218
echo -e "Checking conda installation... "
213-
echo -e " "
214219
CONDA_INSTALL=0
215220

216221
if ! is_executable "conda"; then
@@ -246,6 +251,12 @@ else
246251
CONDA_INSTALL=1
247252
fi
248253

254+
if [ -f "requirements.txt" ]; then
255+
REQS="requirements.txt"
256+
else
257+
REQS=$(curl https://raw.githubusercontent.com/databio/pepatac/master/requirements.txt)
258+
fi
259+
249260
while IFS= read -r line; do
250261
[ "${line:0:1}" = "#" ] && continue
251262
IFS='>=' read -r -a array <<< "$line"
@@ -298,7 +309,7 @@ else
298309
echo -e $(success "SUCCESS: Python package ${package}\trequired: any\tinstalled: ${installed_version}")
299310
fi
300311
fi
301-
done < "requirements.txt"
312+
done < $REQS
302313

303314
# Check tool installation
304315
declare -a requiredCommands=("perl" "awk" "grep" "sed" "bedtools" "bowtie2" "fseq" "macs2" "preseq" "samblaster" "samtools" "skewer" "bedToBigBed" "bigWigCat" "wigToBigWig" "Rscript")
@@ -347,62 +358,115 @@ fi
347358
################################################################################
348359
echo -e "-----------------------------------------------------------"
349360
echo -e "Checking bulker installation... "
350-
echo -e " "
351361
BULKER_INSTALL=0
352362

353-
if ! is_executable "bulker"; then
354-
echo $(warn "WARNING: To use bulker, pip install bulker and checkinstall again.")
355-
printf "\n"
356-
BULKER_INSTALL=1
363+
if ! is_executable "docker"; then
364+
DOCKER=1
357365
else
358-
BULKER_INSTALL=0
359-
echo -e $(success "SUCCESS: bulker")
366+
DOCKER=0
360367
fi
361368

362-
CWD=$(pwd)
363-
crate=$(grep 'bulker_crate' $CWD/sample_pipeline_interface.yaml | awk '{print $2}')
364-
echo "crate: ${crate}"
369+
if ! is_executable "singularity"; then
370+
SINGULARITY=1
371+
else
372+
SINGULARITY=0
373+
fi
365374

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

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

374-
isActivatable=$(bulker run ${crate} $CWD/pipelines/pepatac.py --help)
375-
#echo "isActivatable: ${isActivatable}"
376-
if [ -v "$isActivatable" ]; then
377-
echo $(warn "WARNING: Could not activate the bulker crate, ${crate}. Check out https://bulker.databio.org/en/latest/install/.")
378-
printf "\n"
389+
if [ "$DOCKER" -eq 1 ] && [ "$SINGULARITY" -eq 1 ]; then
390+
echo -e $(fail "ERROR: bulker")
379391
BULKER_INSTALL=1
380392
else
381-
BULKER_INSTALL=0
382-
echo -e $(success "SUCCESS: bulker run ${crate}")
393+
if ! is_executable "bulker"; then
394+
echo $(warn "WARNING: To use bulker, pip install bulker and checkinstall again.")
395+
printf "\n"
396+
BULKER_INSTALL=1
397+
else
398+
BULKER_INSTALL=0
399+
echo -e $(success "SUCCESS: bulker")
400+
fi
401+
402+
CWD=$(pwd)
403+
404+
if [ -f "sample_pipeline_interface.yaml" ]; then
405+
IFACE="sample_pipeline_interface.yaml"
406+
CRATE=$(cat $IFACE | grep 'bulker_crate' | tr " " "\n" | tail -n 1)
407+
else
408+
IFACE=$(curl https://raw.githubusercontent.com/databio/pepatac/master/sample_pipeline_interface.yaml)
409+
CRATE=$(echo $IFACE | tr " " "\n" | grep -A1 'bulker_crate' | tail -n 1)
410+
fi
411+
412+
yes n | bulker load $CRATE
413+
if [ $? -eq 0 ]; then
414+
echo $(warn "WARNING: Could not bulker load ${CRATE}. Check out https://bulker.databio.org/en/latest/install/.")
415+
printf "\n"
416+
BULKER_INSTALL=1
417+
fi
418+
419+
if [ -f "$CWD/pipelines/pepatac.py" ]; then
420+
PIPELINE="$CWD/pipelines/pepatac.py"
421+
else
422+
PIPELINE=$(curl https://raw.githubusercontent.com/databio/pepatac/master/pipelines/pepatac.py)
423+
fi
424+
425+
CMD_CHECK=$(bulker run ${CRATE} $PIPELINE --help)
426+
EXIT_CODE=$(echo $?)
427+
isActivatable=$(echo "${EXIT_CODE}" | awk '{ print $1+0; exit }')
428+
if [ "$isActivatable" -eq 0 ]; then
429+
BULKER_INSTALL=0
430+
echo -e $(success "SUCCESS: bulker run ${CRATE}")
431+
else
432+
echo $(warn "WARNING: Could not activate the bulker crate, ${CRATE}. Check out https://bulker.databio.org/en/latest/install/.")
433+
printf "\n"
434+
BULKER_INSTALL=1
435+
fi
383436
fi
384437

385438
################################################################################
386439
echo -e "-----------------------------------------------------------"
387440
echo -e " PEPATAC checkinstall results "
388-
echo -e " "
389441

390442
if [ "$NATIVE_INSTALL" -eq 0 ]; then
391-
echo -e $(success "SUCCESS: PEPATAC can be run utilizing native installations!")
443+
echo -e $(success "SUCCESS: PEPATAC can be run using native installations!")
444+
else
445+
echo -e $(fail "ERROR: PEPATAC cannot be run using native installations.")
446+
fi
447+
448+
if [ "$CONDA_INSTALL" -eq 0 ]; then
449+
echo -e $(success "SUCCESS: PEPATAC can be run using conda installation!")
450+
else
451+
echo -e $(fail "ERROR: PEPATAC cannot be run via conda.")
452+
fi
453+
454+
if [ "$DOCKER" -eq 0 ]; then
455+
echo -e $(success "SUCCESS: PEPATAC can be run using docker!")
392456
else
393-
echo -e $(fail "WARNING: PEPATAC cannot be run utilizing native installations!")
457+
echo -e $(fail "ERROR: PEPATAC cannot be run using docker.")
394458
fi
395459

396-
if [ "$CONDA_INSTALL" -eq 0 ]; then
397-
echo -e $(success "SUCCESS: PEPATAC can be run utilizing conda installation!")
460+
if [ "$SINGULARITY" -eq 0 ]; then
461+
echo -e $(success "SUCCESS: PEPATAC can be run using singularity!")
398462
else
399-
echo -e $(fail "WARNING: PEPATAC cannot be run via conda!")
463+
echo -e $(fail "ERROR: PEPATAC cannot be run using singularity.")
400464
fi
401465

402-
if [ "$BULKER_INSTALL" -eq 0 ]; then
403-
echo -e $(success "SUCCESS: PEPATAC can be run utilizing bulker!")
466+
if [ "$BULKER_INSTALL" -eq 0 ]; then
467+
echo -e $(success "SUCCESS: PEPATAC can be run using bulker!")
404468
else
405-
echo -e $(fail "WARNING: PEPATAC cannot be run utilizing bulker!")
469+
echo -e $(fail "ERROR: PEPATAC cannot be run using bulker.")
406470
fi
407471

408472
if [ "$NATIVE_INSTALL" -eq 1 ] && [ "$CONDA_INSTALL" -eq 1 ] && [ "$BULKER_INSTALL" -eq 1 ]; then

containers/pepatac.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM phusion/baseimage:master
55
LABEL maintainer Jason Smith "[email protected]"
66

77
# Version info
8-
LABEL version 0.9.16
8+
LABEL version 0.10.0
99

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

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

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

0 commit comments

Comments
 (0)