I would like to ask a question. I have BAM files for each hg19 chromosome, but I need to create a fastq.gz file, so I can realign the reads to hg38 again. The SRA for the dataset I am interested in doesn't exist, but only already aligned ones. I wanted to ask if anyone has done it before and how to create one pair of paired-end fastq.gz files out of 23 BAM files. Do I need to convert first to Fastq eahc BAM file separately and then combine corresponding fastq1 and fast2 for PE reads?
If reads have been aligned to each chromosome separately then you may have the entire dataset in just one BAM file, assuming unaligned reads are included. Then you may need to convert just one file.
If unaligend reads are not included then you will need to do the conversion for each BAM file and then merge the reads. Make sure there are no duplicates. Passing the end result through repair.sh from BBMap suite will ensure that reads in R1/R2 files will be in sync.
This tutorial shows how to easily convert a BAM file into FASTA https://onestopdataanalysis.com/convert-bam-to-fasta/