ivanek / Gviz

This is the Gviz development repository. Gviz plots data and annotation information along genomic coordinates.
https://bioconductor.org/packages/Gviz/
Artistic License 2.0
75 stars 10 forks source link

nanopore bam file failed to display using plotTracks #64

Closed yinshiyi closed 2 years ago

yinshiyi commented 2 years ago

samtools view confirm the region of interest has reads, however, I got the example working using illumina bam file.

alTrack2 <- AlignmentsTrack(system.file(package = "Gviz", "extdata", "gapped.bam"), isPaired = TRUE) plotTracks( alTrack2, from = afrom, to = ato, chromosome = "chr12")

However, when i try to use nanopore bam file, it is not working well. it displays in IGV. samtools view -b source.bam 1:13829-33829 > testing.bam

alTrack <- AlignmentsTrack("testing.bam") plotTracks(alTrack, from = 13829, to = 33829, chromosome = "1")

an example read from my bam file aa108537-de21-4d36-b8be-d5adcce2f2ff 2048 1 33318 44 46H24M2D1M1D13M2D5M2D13M1D28M1D20M382H 0 0 AATAAGGCCATGACTACGGGGGCATCAGCAATGCTGTCCAATCCTACTCCAGGCGCTCTTTCCCTACTACGTGTACAACATCATTAGGGACTCGATGAGGAAGG 15-1277<>,&(,(../&$%%/,4??A=<?471)21,,),13B;DB>>?;;2$.'+,7,/)/+-0351550/1/123/%$/77?81+-?<.),=D=7 NM:i:11 ms:i:156 AS:i:154 nn:i:0 tp:A:P cm:i:7 s1:i:68 s2:i:0de:f:0.0727 SA:Z:1,39741,+,258S272M17D2S,60,22;1,38648,+,146S112M7I267S,42,10; rl:i:0

compare with an example read from illumina

HWUSI-EAS1794_0001_FC61KOJ:4:28:19768:1353#0 99 chr12 2966852 255 50M = 2966993 0 CCGCCTTCGCTTTTATTGAGTAGTTAGTGTTCTCAAGCTGGCTCACACCC GEGEGBDD@DEGGGEDDD>FECEEEEECED@FEEFEDFC>CE>ECE>CBD NM:i:1

ivanek commented 2 years ago

Hi @yinshiyi,

Sorry for late reply.

You would need to use options(ucscChromosomeNames=FALSE) and specify chromosome="1". I used your example read to build a fake BAM file. Please note, that I modified the read a bit as there was an issue of shorter quality field compared to the sequence field.

library(Gviz)
library(Rsamtools)

writeLines(text=c("@HD\tVN:1.6\tGO:none\tSO:coordinate", 
  "@SQ\tSN:1\tLN:248956422", 
  "aa108537-de21-4d36-b8be-d5adcce2f2ff\t2048\t1\t33318\t44\t46H24M2D1M1D13M2D5M2D13M1D28M1D20M382H\t*\t0\t0\tAATAAGGCCATGACTACGGGGGCATCAGCAATGCTGTCCAATCCTACTCCAGGCGCTCTTTCCCTACTACGTGTACAACATCATTAGGGACTCGATGAGGAAGG\t15-1277<>,&(,(../&$%%/,4??A=<?471)21,,),13B;DB>>?;;2$.'+,7,/)/+-0351550/1/123/%$/77?8*1+-?<.),=D=7IIIIII\tNM:i:11\tms:i:156\tAS:i:154\tnn:i:0\ttp:A:P\tcm:i:7\ts1:i:68\ts2:i:0de:f:0.0727\tSA:Z:1,39741,+,258S272M17D2S,60,22;1,38648,+,146S112M7I267S,42,10;\trl:i:0"),
  con="test.sam")

asBam("test.sam")

options(ucscChromosomeNames=FALSE)

alTrack <- AlignmentsTrack("test.bam")
plotTracks(alTrack, from = 33e3, to = 33.5e3, chromosome="1", debug=FALSE)

Hope that helps. Best Robert