1
$\begingroup$

HG38 human reference is the collection of reference from all 22 chromosomes,x,y chromosomes, and some others. I was targeting to split the reference file into 22 chromosomes fasta files. I am following this link https://crashcourse.housegordon.org/split-fasta-files.html to split the fasta files.More specifically I want to split the fasta file into all possible (placed,unlocalized and unplaced) sequence and the merge placed and localized sequences. However, I am unsure where to put the HLA part of the reference. Should I put it in Chromosome 6? Also, should I dump the unknown chromosomes as I am specifically interested in chromosomes 1-22?

Any suggestion on splitting the fasta file into 22 chromosomes would be nice.

$\endgroup$
4
  • 1
    $\begingroup$ "should I dump the unknown chromosomes as I am specifically interested in chromosomes 1-22". That's up to you. We cannot tell you what your data preservation strategy should be. $\endgroup$
    – Ram RS
    Dec 16, 2022 at 17:10
  • 1
    $\begingroup$ Is the question about the computing/parsing side (how do I make one file per sequence from a multi-fasta file?) or is it more about the biology of what the different chromosomes in hg38 actually are? You seem to be asking about both sides but I can't quite understand. $\endgroup$
    – terdon
    Dec 16, 2022 at 17:49
  • $\begingroup$ It is more about biology $\endgroup$ Dec 16, 2022 at 17:55
  • 3
    $\begingroup$ Then please edit your question and make that clear. As it stands, I read this as asking about how to split a multi-fasta file. One thing though: if the people who generated the genome couldn't put the extra sequences in a specific chromosome, what makes you think you will be able to? This feels like an XY problem. Why do you think you need to end up with exactly 22 chromosomes? Can you explain what the final objective is here? $\endgroup$
    – terdon
    Dec 16, 2022 at 18:11

1 Answer 1

2
$\begingroup$

The HLA region is already a part of chromosome 6. When you split the file, it will just be included with the rest of the chromosome. Whether or not you include the remaining contigs depends on your specific objectives. Inclusion of the unplaced and unlocalized scaffolds usually helps to reduce mapping errors, for example. To split/extract only chr1-22 from the UCSC hg38.fa.gz, we can just use . With the following in a file called script.awk:

BEGIN {
    for(i=1;i<=22;i++) {
        arr["chr" i]
    }
}

/^>/ {
    f=substr($0,2)
}

f in arr {
    print > f ".fa"
}

Run using:

awk -f script.awk <(zcat hg38.fa.gz)
$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.