-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcellranger-atac.sh
executable file
·199 lines (162 loc) · 6.8 KB
/
cellranger-atac.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/bash
# initial commit FA200323
# version 1
if [ "$1" = "help" ] || [ -z "$1" ]
then
echo ""
echo "--------------------------------------------------------------------------------------"
echo " To run this script, use the following syntax:"
echo " bash" $0 "<auto> , <no-dups> or <idoi> "
echo " auto - autodetects duplicate sampleIDs "
echo " no-dups - autodetects all sampleIDs"
echo " idoi - expects user to provide a sample ID list named idoi"
echo "--------------------------------------------------------------------------------------"
echo ""
echo ""
echo ""
exit 1
elif [[ "$1" = "auto" ]]; then
#statements
#----------------------------------------------------------------------------------------
# get sample names and sample ids
for i in */
do
cd $i/outs
DIR=`pwd`
cat input_samplesheet.csv | cut -d "," -f3 | cut -d "-" -f2 | cut -d "_" -f3 | sed 1,2d >> ../../.ids
cat input_samplesheet.csv | cut -d "," -f3 | sed 1,2d >> ../../.names
cd ../../
done
#----------------------------------------------------------------------------------------
# samples with multiple run folders;
sort .ids | uniq -d > idoi
#----------------------------------------------------------------------------------------
# get fastqs path info
for i in */
do
cd $i/outs
cat input_samplesheet.csv | cut -d "," -f3 | sed 1,2d | awk '{print "'$i'" "outs/fastq_path/ :" $0}' >> ../../.paths.info
cd ../../
done
#----------------------------------------------------------------------------------------
# cellranger count
readarray sampleIDs < idoi
for i in "${sampleIDs[@]}"
do
ID=$i
GREP_PATH=$(grep `echo $i`$ .paths.info | cut -d ":" -f1 | xargs | sed -e 's/ /,/g')
GREP_NAME=$(grep `echo $i`$ .names | xargs | sed -e 's/ /,/g')
echo "SAMPLE_ID = $ID"
echo "FASTQ_PATH = $GREP_PATH"
echo "SAMPLE_NAME = $GREP_NAME"
echo "-----------------------------------"
echo ""
/programs/cellranger-atac-1.2.0/cellranger-atac count --id=$ID \
--reference=/workdir/singleCellData/10x_reference_files/refdata-cellranger-atac-GRCh38-1.2.0 \
--fastqs=$GREP_PATH \
--sample=$GREP_NAME \
--localcores 48 --localmem 250
done
DATE=`date +"%m_%d_%H-%M"`
mkdir CellRangerATAC-Output_${DATE}
readarray sampleIDs < idoi
for i in "${sampleIDs[@]}"
do
mv $i CellRangerATAC-Output_${DATE}
done
elif [[ "$1" = "no-dups" ]]; then
#statements
#----------------------------------------------------------------------------------------
# get sample names and sample ids
for i in */
do
cd $i/outs
DIR=`pwd`
cat input_samplesheet.csv | cut -d "," -f3 | cut -d "-" -f2 | cut -d "_" -f3 | sed 1,2d >> ../../.ids
cat input_samplesheet.csv | cut -d "," -f3 | sed 1,2d >> ../../.names
cd ../../
done
# get sample ids
cat .ids > idoi
#----------------------------------------------------------------------------------------
# get fastqs path info
for i in */
do
cd $i/outs
cat input_samplesheet.csv | cut -d "," -f3 | sed 1,2d | awk '{print "'$i'" "outs/fastq_path/ :" $0}' >> ../../.paths.info
cd ../../
done
#----------------------------------------------------------------------------------------
# cellranger count
readarray sampleIDs < idoi
for i in "${sampleIDs[@]}"
do
ID=$i
GREP_PATH=$(grep `echo $i`$ .paths.info | cut -d ":" -f1 | xargs | sed -e 's/ /,/g')
GREP_NAME=$(grep `echo $i`$ .names | xargs | sed -e 's/ /,/g')
echo "SAMPLE_ID = $ID"
echo "FASTQ_PATH = $GREP_PATH"
echo "SAMPLE_NAME = $GREP_NAME"
echo "-----------------------------------"
echo ""
/programs/cellranger-atac-1.2.0/cellranger-atac count --id=$ID \
--reference=/workdir/singleCellData/10x_reference_files/refdata-cellranger-atac-GRCh38-1.2.0 \
--fastqs=$GREP_PATH \
--sample=$GREP_NAME \
--localcores 48 --localmem 250
done
DATE=`date +"%m_%d_%H-%M"`
mkdir CellRangerATAC-Output_${DATE}
readarray sampleIDs < idoi
for i in "${sampleIDs[@]}"
do
mv $i CellRangerATAC-Output_${DATE}
done
else [[ "$1" = "idoi" ]]
#----------------------------------------------------------------------------------------
# get sample names and sample ids
for i in */
do
cd $i/outs
DIR=`pwd`
cat input_samplesheet.csv | cut -d "," -f3 | cut -d "-" -f2 | cut -d "_" -f3 | sed 1,2d >> ../../.ids
cat input_samplesheet.csv | cut -d "," -f3 | sed 1,2d >> ../../.names
cd ../../
done
#----------------------------------------------------------------------------------------
# get fastqs path info
for i in */
do
cd $i/outs
cat input_samplesheet.csv | cut -d "," -f3 | sed 1,2d | awk '{print "'$i'" "outs/fastq_path/ :" $0}' >> ../../.paths.info
cd ../../
done
#----------------------------------------------------------------------------------------
# cellranger count
cat idoi | while read i
do
ID=$i
G="$ID$|A$ID$"
GREP_PATH=$(egrep -h $G .paths.info | cut -d ":" -f1 | xargs | sed -e 's/ /,/g')
GREP_NAME=`egrep -h $G .names | xargs | sed -e 's/ /,/g'`
echo "SAMPLE_ID = $ID"
echo "FASTQ_PATH = $GREP_PATH"
echo "SAMPLE_NAME = $GREP_NAME"
echo "-----------------------------------"
echo ""
/programs/cellranger-atac-1.2.0/cellranger-atac count --id=$ID \
--reference=/workdir/fa286/rsync-ref/refdata-cellranger-atac-GRCh38-1.2.0 \
--fastqs=$GREP_PATH \
--sample=$GREP_NAME \
--localcores 48 --localmem 500
done
DATE=`date +"%m_%d_%H-%M"`
mkdir CellRangerATAC-Output_${DATE}
readarray sampleIDs < idoi
for i in "${sampleIDs[@]}"
do
mv $i CellRangerATAC-Output_${DATE}
done
mv .paths.info .ids .names idoi CellRangerATAC-Output_${DATE}
chmod -R 777 CellRangerATAC-Output_${DATE}
fi