Can I get AddOrReplaceReadGroups working for multiple files?
1
0
Entering edit mode
6.1 years ago
James Reeve ▴ 130

I have a dataset of 81 samples that are missing read group information. This leads to problems when trying to use GATK commands. I've found picard tools' AddOrReplaceReadGroups to be a helpful tool for adding read group to a SAM file. But I'm having trouble trying to loop through this command for all my files.

I've been able to come up with this, but there seems to be an issue with my notation in my variables;

while read f1
do 
  FileName=$(echo $f1 | cut -d"," -f1)
  SampleID=$(echo $f1 | cut -d"," -f3)
  RowNum=$(grep -n $FileName.bam)
  java -jar picard.jar AddOrReplaceReadGroups \
     I=$FileName.bam \
     O=$FileName"_sort.bam" \
     SORT_ORDER=coordinate \
     RGID=$SampleID \
     RGLB=WGS \
     RGPL=illumina \
     RGPU=$RowNum \
     RGSM=$FileName
done < file_with_sample_information.csv

Note: the input file file_with_sample_information.csv has 4 columns, the 1st has the sample name and the 3rd has the database (ENA) ascension number.

How can I get this too work? I'd like to avoid manually doing this for 81 files.

picard tools bash • 2.6k views
ADD COMMENT
2
Entering edit mode
grep -n $FileName.bam

will not produce anything. You're grepping stdin

ADD REPLY
2
Entering edit mode
6.1 years ago
Barry Digby ★ 1.3k
while read a b c d; do 
...
...
done < file_with_sample_information.csv

$a is column 1, $b is column 2 and so on.

Just separate a b c d with a space.

Is it trouble assigning variables to filenames? or trouble assigning multiple variables (a, b, c, d)..? Show me the first line of your file

ADD COMMENT
0
Entering edit mode

I was trying to assign multiple variables. I figured it out from your example, thanks.

ADD REPLY

Login before adding your answer.

Traffic: 2172 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6