forked from CRG-Beato/utils_beatolab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathucsc_custom_track_upload.sh
executable file
·141 lines (102 loc) · 4.58 KB
/
ucsc_custom_track_upload.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
#==================================================================================================
# Created on: 2017-10-25
# Usage: ./ucsc_custom_track_upload.sh
# Author: Javier Quilez (GitHub: jaquol)
# Goal: (i) copy data to the `file_transfer` directory, which is accessible for the UCSC Genome browser
# (ii) print the sample UCSC Genome Browser custom track definition
#==================================================================================================
#==================================================================================================
# CONFIGURATION VARIABLES AND PATHS
#==================================================================================================
# variables
samples="ag_011_01_03_chipseq ag_011_02_03_chipseq ag_012_01_03_chipseq ag_012_02_03_chipseq ag_013_01_03_chipseq ag_013_02_03_chipseq ag_014_01_03_chipseq ag_014_02_03_chipseq ag_007_01_01_chipseq ag_008_01_01_chipseq ag_009_01_01_chipseq fd_012_01_01_chipseq"
data_type=chipseq
call_peaks_mode=with_control
project=argentina
# paths
python=`which python`
#==================================================================================================
# COMMANDS
#==================================================================================================
echo
for s in $samples; do
echo $s
#==================================================================================================
# Retrieve metadata
#==================================================================================================
echo "... retrieving metadata"
# script to access the metadata
if [[ $project == "4DGenome" ]]; then
io_metadata=/users/project/4DGenome/utils/io_metadata.sh
else
io_metadata=/users/mbeato/projects/utils/io_metadata.sh
fi
# sample name & metadata
sample_name=`$io_metadata -m get_from_metadata -s $s -t input_metadata -a SAMPLE_NAME`
sequencing_type=`$io_metadata -m get_from_metadata -s $s -t input_metadata -a SEQUENCING_TYPE`
if [[ $sequencing_type == 'SE' ]]; then
sequencing_type_long=single_end
elif [[ $sequencing_type == 'PE' ]]; then
sequencing_type_long=paired_end
fi
# species and chromosomes lengths
species=`$io_metadata -m get_from_metadata -s $s -t input_metadata -a SPECIES`
if [[ $species == "Homo_sapiens" ]]; then
version=hg38_mmtv
chrom_sizes=/users/mbeato/projects/assemblies/homo_sapiens/$version/ucsc/${version}_chr1-22XYMUn.chrom.sizes
db=hg38
elif [[ $species == "Mus_musculus" ]]; then
version=mm10
chrom_sizes=/users/mbeato/projects/assemblies/mus_musculus/$version/ucsc/${version}_chr1-19XYMUn.chrom.sizes
db=mm10
fi
#==================================================================================================
# ChIP-seq
#==================================================================================================
if [[ $data_type == "chipseq" ]]; then
# read per per million profiles
echo "... preparing read per million profiles"
# define paths
SHARED_PATH=data/$data_type/samples/$s/profiles/$version/$sequencing_type_long
ifile=/users/mbeato/projects/$SHARED_PATH/${s}*rpm.bw
fname=`basename $ifile`
ODIR=/users/mbeato/projects/file_transfer/open_access/$project
mkdir -p $ODIR
obw=$ODIR/$fname
# copy data to the `file_transfer` directory
cp $ifile $obw
# print custom track definitions
track_type=profiles
composite_track=${data_type}_$track_type
echo -e >> $composite_track.txt
url=https://public-docs.crg.es/mbeato/jquilez/open_access/$project/$fname
echo "track type=bigWig name='${sample_name} profiles' bigDataUrl=$url alwaysZero=on visibility=2 autoScale=off viewLimits=0.0:1.0 maxHeightPixels=50" >> $composite_track.txt
# peaks coordinates
echo "... preparing peaks coordinates"
# define paths
SHARED_PATH=data/$data_type/samples/$s/peaks/macs2/$version/$call_peaks_mode/$sequencing_type_long
ifile=/users/mbeato/projects/$SHARED_PATH/${s}_peaks.narrowPeak
fname=`basename $ifile`
ODIR=/users/mbeato/projects/file_transfer/open_access/$project
mkdir -p $ODIR
obed=$ODIR/$fname
url="http://public-docs.crg.es/mbeato/jquilez/open_access/$project/$fname"
cmd="track type=narrowPeak \
name='${sample_name} peaks (macs2)' \
visibility=1 \
useScore=1 \
db=hg38 \
url=$url \
color=0,102,204"
echo $cmd > $obed
# add file content while skipping calls in the mmtv_luciferase contig
grep -v mmtv_luciferase $ifile >> $obed
# print track hub definitions
track_type=peaks_macs2
composite_track=${data_type}_$track_type
echo -e >> $composite_track.txt
echo $url >> $composite_track.txt
echo
fi
done