Entering edit mode
9 months ago
kabir.deb
▴
90
Hi,
I was wondering how can I use AddOrReplaceReadGroups
for assinging Read Group (RG) tags for multiple bam
files. I've 20 BAM files with names cfR_1....20_valAligned_star_mrdup_sort.bam
generated using STAR
aligner. Here, I'm expecting the added RG name should be only cfR_1
, not the additional portion of the name.
cd /path to BAM/rnaBAM
file1=$(ls *_valAligned_star_mrdup_sort.bam | sed -n ${SLURM_ARRAY_TASK_ID}p)
picard AddOrReplaceReadGroups VALIDATION_STRINGENCY=LENIENT I=$file1 O=${file1%%.*}_rg.bam RGID=${file1%%.*} RGLB=${file1%%.*}
RGPL=illumina RGPU=run RGSM=${file1%%.*}
samtools view -H cfR_1_valAligned_star_mrdup_sort_rg.bam | grep "@RG"
[W::bam_hdr_read] EOF marker is absent. The input is probably truncated.
@RG ID:cfR_1_valAligned_star_mrdup_sort LB:cfR_1_valAligned_star_mrdup_sort PL:illumina SM:cfR_1_valAligned_star_mrdup_sort PU:run
I ended up with ID:cfR_1_valAligned_star_mrdup_sort
, while I just want cfR_1
to be mentioned only.