This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extracting individual chromosomes from a .gfa graph

Hello,

I recently downloaded the pangenome graph produced by the Human Pangenome Reference Consortium (hprc-v2.0-mc-grch38.gfa.gz) and, to make my future workflows easier and faster, I would like to extract specific chromosomes from the graph and produce one .gfa file per chromosome. I saw that vg chunk could potentially do that. The issue is that I currently have a .gfa file and apparently, if I understood well, that command requires to use a .vg or .xg file. I have therefore several questions, for example if I want to extract chromosome 2:

  1. Is it possible to use directly the .gfa file and give it to vg chunk ?

  2. If not, this would mean that I should convert the .gfa into a .vg file or even a .xg file, but I'm not sure which way to go. Apparently, while the .xg file format should allow for the command to run faster than with a .vg file, an .xg file does not contain the actual DNA sequences but only the graph structure and paths, which would not be ideal as I want a .gfa file that contains all the information as an output. What would be the optimal option for my situation ?

As I am new in the pangenomics field, my questions may be trivial but thank you anyway for taking the time to read it! Also, if you know any other way to extract chromsomes from a graph, please let me know.

xg vg gfa chunk

1 answer

You can use vg chunk directly with a GFA file, but it will be slow and use a lot of memory due to the large number of haplotypes in HPRC release 2 graphs. (The same will also be true with .vg and .xg graphs.)

GBZ is the only supported format that can handle haplotype paths efficiently. If you have vg 1.73.0, you can chunk GBZ graphs into components with:

vg chunk -x graph.gbz --gbz

The output will consist of a set of graphs with names of the form <prefix>_<num>_<contig>.gbz (e.g. chunk_11_chr2.gbz), one per graph component. You can change the prefix from the default chunk with option --prefix <prefix>. The chunks are numbered according to the order they are stored in the graph. vg will try to guess an appropriate contig name for each chunk from reference paths.

If you only want the chunk for a specific chromosome, you can try using option --contig <contig>. It will work with HPRC graphs. The heuristic may fail with other graphs, if the path naming convention is not what vg expects or if there are multiple components for a single chromosome or multiple chromosomes in a single component.

Log in to answer this question.