plot_profile.sh 1.52 KB
Newer Older
1
#!/bin/bash
Venkat Malladi's avatar
Venkat Malladi committed
2
#plot_profile.sh
3

Venkat Malladi's avatar
Venkat Malladi committed
4
5
6
7
8
9
10
11
12
13
14
script_name="plot_profile.sh"

#Help function
usage() {
  echo "-h  --Help documentation for $script_name"
  echo "-g  --File path to gtf/bed files"
  echo "Example: $script_name -g 'genome.gtf'"
  exit 1
}


Venkat Malladi's avatar
Venkat Malladi committed
15
16
17
18
19
20
raise()
{
  echo "${1}" >&2
}

check_tools() {
21
  raise "
Venkat Malladi's avatar
Venkat Malladi committed
22
23
   Checking for required libraries and components on this system
   "
24
25
26
27
28
29
   deeptools --version &> version_deeptools.txt
   if [ $? -gt 0 ]
     then
      raise "Missing deeptools"
      return 1
    fi
Venkat Malladi's avatar
Venkat Malladi committed
30
31
32
33
34
35
36
}

compute_matrix() {
  raise "
  Computing matrix on ${1} using ${2}
  "

37
38
39
40
41
42
43
  computeMatrix reference-point \
    --referencePoint TSS \
    -S ${1} \
    -R ${2} \
    --skipZeros \
    -o computeMatrix.gz \
    -p max/2
Venkat Malladi's avatar
Venkat Malladi committed
44
45
46
47
48
49
50
51
52
53
54
55
56

  if [ $? -gt 0 ]
  then
    raise "Problem building matrix"
    return 1
  fi
}

plot_profile() {
  raise "
  Plotting profile
  "

57
58
  plotProfile -m computeMatrix.gz \
    -out plotProfile.png
Venkat Malladi's avatar
Venkat Malladi committed
59
60
61
62
63
64
65
66
67
68

  if [ $? -gt 0 ]
  then
    raise "Problem plotting"
    return 1
  fi
}


run_main() {
Venkat Malladi's avatar
Venkat Malladi committed
69
70
71

  # Parsing options
  OPTIND=1 # Reset OPTIND
72
  while getopts :g:h opt
Venkat Malladi's avatar
Venkat Malladi committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
      do
          case $opt in
              g) gtf=$OPTARG;;
              h) usage;;
          esac
      done

  shift $(($OPTIND -1))

  # Check for mandatory options
  if [[ -z $gtf ]]; then
      usage
  fi

Venkat Malladi's avatar
Venkat Malladi committed
87
  bws=$(ls *pooled.fc_signal.bw)
Venkat Malladi's avatar
Venkat Malladi committed
88
89
90

  check_tools || exit 1

91
  compute_matrix "${bws}" "${gtf}" || return 1
Venkat Malladi's avatar
Venkat Malladi committed
92

93
  plot_profile || return 1
Venkat Malladi's avatar
Venkat Malladi committed
94
95
96
97
98
99

  raise "ALL COMPLETE"
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]
then
100
  run_main "$@"
Venkat Malladi's avatar
Venkat Malladi committed
101
102
103
104
105
  if [ $? -gt 0 ]
  then
    exit 1
  fi
fi