I have a contigs file that I generated using Minia and then I have used Minimap2 to map these contigs again to the reference genome. Now I want to plot the gap distribution i.e. gap distance of the set of contigs with respect to the positions in the reference genome. For example: something like , if there are m contigs obtained from the Minia, then X axis will show 0 to m-1 gap points (in an ideal case where there is no overlap between the contigs and the contigs are aligned back to back without space).
The file from minimap2 looks like this:
0 17679 0 17679 + NZ_BCML01000091.1 39426 18736 36415 17679 17679 60 NM:i:0 ms:i:35358 AS:i:35358 nn:i:0 tp:A:P cm:i:3274 s1:i:17675 s2:i:49 de:f:0 rl:i:75 cg:Z:17679M
1 16011 0 16011 + NZ_BCML01000021.1 105137 86 16097 16011 16011 60 NM:i:0 ms:i:32022 AS:i:32022 nn:i:0 tp:A:P cm:i:3008 s1:i:15996 s2:i:0 de:f:0 rl:i:15 cg:Z:16011M
2 2779 0 2779 - NZ_BCML01000048.1 72397 14902 17681 2779 2779 60 NM:i:0 ms:i:5558 AS:i:5558 nn:i:0 tp:A:P cm:i:519 s1:i:2751 s2:i:0 de:f:0 rl:i:45 cg:Z:2779M
4 177 0 177 + NZ_BCML01000150.1 16425 15710 15887 177 177 60 NM:i:0 ms:i:354 AS:i:354 nn:i:0 tp:A:P cm:i:30 s1:i:160 s2:i:0 de:f:0 rl:i:15 cg:Z:177M
where the 1st column is the contig ID and 8th and 9th column show the start and end position of the contig on the reference genome.
I have used the samtools for obtaining a length distribution plot, but not understanding how to do a gap distribution plot. I can use awk on linux or python or R. Anything that is going to work. Thank you for all the help.