Rsamtools: scan all optional tags that exists in my bam file
1
0
Entering edit mode
Guest User ★ 13k
@guest-user-4897
Last seen 9.6 years ago
Hi, Using Rsamtools to read a bam file, is there a way to scan all the optional tag fields that exists in the bam file without having to explicitly specify them a priory in the ScanBamParam argument? -- output of sessionInfo(): R version 3.0.2 (2013-09-25) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] parallel stats graphics grDevices utils datasets methods base other attached packages: [1] doParallel_1.0.3 iterators_1.0.6 foreach_1.4.1 data.table_1.8.10 Rsamtools_1.13.44 Biostrings_2.29.19 GenomicRanges_1.13.45 XVector_0.1.4 [9] IRanges_1.19.38 BiocGenerics_0.7.5 loaded via a namespace (and not attached): [1] bitops_1.0-6 codetools_0.2-8 stats4_3.0.2 tools_3.0.2 zlibbioc_1.7.0 -- Sent via the guest posting facility at bioconductor.org.
Rsamtools Rsamtools • 1.6k views
ADD COMMENT
0
Entering edit mode

You could take a peek at the first line of the bam file using:

> samtools view pbmc_granulocyte_sorted_3k_gex_possorted_bam.bam | head -1
A00984:207:HGWCKDSXY:3:2164:11369:30076 0       chr1    10014   1       90M     *       0       0       AACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAAACCCT      F:FFFFFFFFFFFFFFFFFFFF:FFFFFFFFFFFFFFFFFFFFF,,F:FFFFFFFFFFFFFFFFF,FFFF,,FF:F:,FF,FF,FFF:F,   NH:i:4  HI:i:1  AS:i:86 nM:i:1  RG:Z:pbmc_granulocyte_sorted_3k:0:1:HGWCKDSXY:3 RE:A:I  xf:i:0  CR:Z:AGCATAAGTTAATACT   CY:Z:FFFF:::FF,F:FFF:   UR:Z:TACGATAAATTA       UY:Z:FFFFFF:FF:FF       UB:Z:TACGATAAATTA

which will give you the tags in the file after the 11th position, i.e., NH, HI, AS, RG, RE, etc. in this example.

You could then do

scanBam(bam, param = ScanBamParam(tag = "RE", tagFilter = list(RE = "I")))

but there is no 'get all tags from BAM file' function AFAIK.

ADD REPLY
0
Entering edit mode
@martin-morgan-1513
Last seen 4 days ago
United States
On 09/28/2013 11:30 AM, rubi [guest] wrote: > > Hi, > > Using Rsamtools to read a bam file, is there a way to scan all the optional > tag fields that exists in the bam file without having to explicitly specify > them a priory in the ScanBamParam argument? No, you've got to specify explicitly the tags you want; there's nothing in the BAM header specification that indicates the tags present in the file (otherwise scanBamHeader() might have helped) and there's no way to say 'give me each tag as it's encountered' in Rsamtools. Martin > > > -- output of sessionInfo(): > > R version 3.0.2 (2013-09-25) Platform: x86_64-w64-mingw32/x64 (64-bit) > > locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United > States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] > LC_TIME=English_United States.1252 > > attached base packages: [1] parallel stats graphics grDevices utils > datasets methods base > > other attached packages: [1] doParallel_1.0.3 iterators_1.0.6 > foreach_1.4.1 data.table_1.8.10 Rsamtools_1.13.44 > Biostrings_2.29.19 GenomicRanges_1.13.45 XVector_0.1.4 [9] IRanges_1.19.38 > BiocGenerics_0.7.5 > > loaded via a namespace (and not attached): [1] bitops_1.0-6 > codetools_0.2-8 stats4_3.0.2 tools_3.0.2 zlibbioc_1.7.0 > > -- Sent via the guest posting facility at bioconductor.org. > > _______________________________________________ Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793
ADD COMMENT

Login before adding your answer.

Traffic: 946 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6