Skip to content

Commit

Permalink
PR changed for annotate_bed.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jethror1 committed Sep 27, 2020
1 parent 0209537 commit 8f15c75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# eggd_coverage_report

This is a tool to generate coverage statistics for NGS data, and combine these into an interactive HTML report. This gives both summary level and in depth information as to the coverage of the data, including various tables and plots to visualise the data. Examples of the output statistics files and report may be found in `data/example`.<br>
This is a tool to generate coverage statistics for NGS data, and combine these into an interactive HTML report. This gives both summary level and in depth information as to the coverage of the data, including various tables and plots to visualise the data. Examples of the output statistics files and report may be found in `data/example`.<br>

It is written to take in per base coverage data (as output from tools such as mosdepth and samtools mpileup) as input to calculate coverage for target regions defined in a bed file. <br></br>

Expand Down
21 changes: 10 additions & 11 deletions bin/annotate_bed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ Help()
{
# Display Help
echo "
This script may be used to perform bedtools intersect commands to generate the required tsv file
This script may be used to perform bedtools intersect commands to generate the required annotated bed file
for generating single sample coverage statistics."
echo ""
echo "Usage:"
echo ""
echo "-i Input bed file; must have columns chromosome, start position, end position, transcript."
echo "-g Exons nirvana file, contains required gene and exon information."
echo "-b Per base coverage file (output from mosdepth or similar)."
echo "-o Output file name prefix, will have the .tsv suffix."
echo "-o Output file name prefix, will have the .bed suffix."
echo "-h Print this Help."
echo ""

Expand All @@ -43,26 +43,25 @@ while getopts ":i:g:b:o:h" option; do
exit
;;
\*) # incorrect option

;;
esac
done

# check for no and incorrect args given
if [ -z $input_bed ] ||
[ -z $gene_file ] ||
[ -z $bp_coverage ] ||
# check for no and incorrect args given a
if [ -z $input_bed ] ||
[ -z $gene_file ] ||
[ -z $bp_coverage ] ||
[ -z $outfile ]; then

echo "Error: Missing arguments, please see usage below."
Help
exit 0
fi

# add gene and exon annotation to bed file from exons nirvana tsv
bedtools intersect -a $input_bed -b $gene_file -wa -wb | awk 'OFS="\t" {if ($4 == $9) print}' | cut -f 1,2,3,8,9,10 > $(tmp).txt
bedtools intersect -a $input_bed -b $gene_file -wa -wb | awk 'OFS="\t" {if ($4 == $9) print}' | cut -f 1,2,3,8,9,10 > ${tmp}.txt

# add coverage annotation from per base coverage bed file
bedtools intersect -wa -wb -a $tmp.txt -b $bp_coverage | cut -f 1,2,3,4,5,6,8,9,10 > $outfile.tsv
bedtools intersect -wa -wb -a $tmp.txt -b $bp_coverage | cut -f 1,2,3,4,5,6,8,9,10 > $outfile.bed

echo "Done. Output file: " $outfile.tsv
echo "Done. Output file: " $outfile.bed

0 comments on commit 8f15c75

Please sign in to comment.