Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit e408958
Author: Nae-Chyun Chen <s93rm6@gmail.com>
Date:   Sat Jan 7 00:37:46 2023 -0800

    Integrate strobealign in the workflow (#39)

    Support the feature request in #11

commit 797aea4
Author: Nae-Chyun Chen <s93rm6@gmail.com>
Date:   Wed Jan 4 23:40:40 2023 -0800

    Logi minor update (#38)

    Provide the script to do the color inversion

commit 9655767
Author: Nae-Chyun Chen <s93rm6@gmail.com>
Date:   Wed Jan 4 23:30:42 2023 -0800

    Dark logo (#37)

    need improvements though

commit 5c2a714
Author: Nae-Chyun Chen <s93rm6@gmail.com>
Date:   Wed Jan 4 22:48:31 2023 -0800

    Workflow improvement: support unaligned FASTQ inputs (#36)

    * `workflow/leviosam2.sh`: now supports unaligned FASTQ as inputs
    * `workflow/leviosam2.py`: work-in-progress. Plan to use the
    Python-based script as the default in the future
  • Loading branch information
milkschen committed Feb 24, 2023
1 parent 7e278cf commit 80aa373
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

LevioSAM2 lifts over alignments accurately and efficiently using a chain file.

<img src="https://github.com/milkschen/leviosam2/blob/main/figures/levioSAM_S_bw.png" width="300">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./figures/levioSAM_S_bw_dark.png" width="300">
<img alt="Text changing depending on mode. Light: 'So light!' Dark: 'So dark!'" src="./figures/levioSAM_S_bw.png" width="300">
</picture>

## Features

Expand Down
Binary file added figures/levioSAM_S_bw_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed figures/levioSAM_white.pdf
Binary file not shown.
Binary file removed figures/logo_white.png
Binary file not shown.
16 changes: 16 additions & 0 deletions invert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import matplotlib.image as mpimg
import matplotlib.image
import numpy as np


img = mpimg.imread('figures/levioSAM_S_bw.png')
img2 = []
for irow, row in enumerate(img):
img2.append([])
for cell in row:
if sum(cell) != 4:
img2[-1].append([1, 1, 1, 1])
else:
img2[-1].append([1-cell[0], 1-cell[1], 1-cell[2], 1.])
matplotlib.image.imsave('figures/levioSAM_S_bw_dark.png', img2, dpi=300)

37 changes: 32 additions & 5 deletions workflow/leviosam2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function print_usage_and_exit {
echo " -D path Path to the force-defer annotation []"
echo " -B float Bed intersect threshold. See 'leviosam2 lift -h' for details. [0]"
echo " Aligner:"
echo " -a string Aligner to use (bowtie2|bwamem|bwamem2|minimap2|winnowmap2) [bowtie2]"
echo " -a string Aligner to use (bowtie2|bwamem|bwamem2|minimap2|winnowmap2|strobealign) [bowtie2]"
echo " -b path Path to the aligner index (target reference)"
echo " -l string Aligner mode for long read aligner (map-hifi|map-ont) [map-hifi]"
echo " -S Toggle to use single-end mode [off]"
Expand Down Expand Up @@ -130,7 +130,7 @@ do
esac
done

if [[ ${INPUT} == "" ]]; then
if [[ ${INPUT} == "" && ${INPUT_FQ_1} == "" ]]; then
echo "Input is not set"
print_usage_and_exit
fi
Expand All @@ -148,8 +148,8 @@ if [[ ${MEASURE_TIME} > 0 ]]; then
MT="${TIME} -v -ao leviosam2.time_log "
fi

if [[ ! ${ALN} =~ ^(bowtie2|bwamem|bwamem2|minimap2|winnowmap2)$ ]]; then
echo "Invalid ${ALN}. Accepted input: bowtie2, bwamem, bwamem2, minimap2, winnowmap2"
if [[ ! ${ALN} =~ ^(bowtie2|bwamem|bwamem2|minimap2|winnowmap2|strobealign)$ ]]; then
echo "Invalid ${ALN}. Accepted input: bowtie2, bwamem, bwamem2, minimap2, winnowmap2, strobealign"
exit 1
fi

Expand All @@ -163,7 +163,8 @@ fi
set -xp

# Align to the source reference
if [ ! -s ${INPUT} ]; then
if [[ ${INPUT} == "" ]]; then
INPUT=${PFX}.bam
if [[ ${SINGLE_END} == 1 ]]; then
if [[ ${ALN} == "bowtie2" ]]; then
${MT} bowtie2 ${ALN_RG} -p ${THR} -x ${ALN_IDX_SOURCE} \
Expand All @@ -190,6 +191,12 @@ if [ ! -s ${INPUT} ]; then
${MT} ${ALN} -ax ${LR_MODE} --MD -t ${THR} ${ALN_IDX_SOURCE} \
${REF_SOURCE} ${INPUT_FQ_1} | \
${MT} samtools sort -o ${INPUT}
elif [[ ${ALN} == "strobealign" ]]; then
if [[ ${ALN_RG} != "" ]]; then
ALN_RG="--rg ${ALN_RG}"
fi
${MT} ${ALN} ${ALN_RG} -t ${THR} ${REF_SOURCE} ${INPUT_FQ_1} | \
${MT} samtools sort -o ${INPUT}
else
print_usage_and_exit
fi
Expand Down Expand Up @@ -219,6 +226,13 @@ if [ ! -s ${INPUT} ]; then
${MT} ${ALN} -ax ${LR_MODE} --MD -t ${THR} ${ALN_IDX_SOURCE} \
${REF_SOURCE} ${INPUT_FQ_1} ${INPUT_FQ_2} | \
${MT} samtools sort -o ${INPUT}
elif [[ ${ALN} == "strobealign" ]]; then
if [[ ${ALN_RG} != "" ]]; then
ALN_RG="--rg ${ALN_RG}"
fi
${MT} ${ALN} ${ALN_RG} -t ${THR} ${REF_SOURCE} \
${INPUT_FQ_1} ${INPUT_FQ_2} | \
${MT} samtools sort -o ${INPUT}
else
print_usage_and_exit
fi
Expand Down Expand Up @@ -275,6 +289,12 @@ if [[ ${SINGLE_END} == 1 ]]; then
${MT} ${ALN} -ax ${LR_MODE} --MD -t ${THR} ${ALN_RG} \
${REF} ${PFX}-deferred.fq.gz | \
${MT} samtools sort -o ${PFX}-realigned.bam
elif [[ ${ALN} == "strobealign" ]]; then
if [[ ${ALN_RG} != "" ]]; then
ALN_RG="--rg ${ALN_RG}"
fi
${MT} ${ALN} ${ALN_RG} -t ${THR} ${REF} ${PFX}-deferred.fq.gz | \
${MT} samtools sort -o ${PFX}-realigned.bam
else
print_usage_and_exit
fi
Expand Down Expand Up @@ -319,6 +339,13 @@ else
${MT} bwa-mem2 mem -t ${THR} ${ALN_RG} ${ALN_IDX} \
${PFX}-paired-deferred-R1.fq.gz ${PFX}-paired-deferred-R2.fq.gz | \
${MT} samtools view -hb > ${PFX}-paired-realigned.bam
elif [[ ${ALN} == "strobealign" ]]; then
if [[ ${ALN_RG} != "" ]]; then
ALN_RG="--rg ${ALN_RG}"
fi
${MT} ${ALN} ${ALN_RG} -t ${THR} ${REF} \
${PFX}-paired-deferred-R1.fq.gz ${PFX}-paired-deferred-R2.fq.gz | \
${MT} samtools view -hb > ${PFX}-paired-realigned.bam
else
echo "We do not support paired-end mode for aligner ${ALN}"
exit 1
Expand Down

0 comments on commit 80aa373

Please sign in to comment.