Question: Can I get AddOrReplaceReadGroups working for multiple files?
gravatar for James Reeve
10 months ago by
James Reeve90
James Reeve90 wrote:

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
  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 \
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.

bash picard tools • 433 views
ADD COMMENTlink modified 10 months ago by b.d237160 • written 10 months ago by James Reeve90
grep -n $FileName.bam

will not produce anything. You're grepping stdin

ADD REPLYlink written 10 months ago by Pierre Lindenbaum122k
gravatar for b.d237
10 months ago by
National University of Ireland, Galway
b.d237160 wrote:
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 COMMENTlink modified 10 months ago • written 10 months ago by b.d237160

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

ADD REPLYlink written 9 months ago by James Reeve90
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 836 users visited in the last hour