Update with alterantive read.bam.tags function#43
Open
fferrari wants to merge 1 commit intohms-dbmi:masterfrom
Open
Update with alterantive read.bam.tags function#43fferrari wants to merge 1 commit intohms-dbmi:masterfrom
fferrari wants to merge 1 commit intohms-dbmi:masterfrom
Conversation
The alternative function will randomly pick only one of the reads in the pair when both are aligned, thus resulting in a taglist object with characteristics similar to a single end BAM file. however, I am not sure this was the intended purpose of the original code handling BAM files with paired end reads.
|
Hey, in version 1.16, when parsing pair-read data, we encountered an error where tag.scc was returning -inf and inf from some max/min functions because all tags were positive. This pull request fixes that, so I'd suggest merging to master. I think the fix presented is also appropriate. Good job! :) For compatibility, I'd rename f_read.bam.tags to read.bam.tags though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @pkharchenko, we came across an issue with BAM files containing paired end reads.
The current read.bam.tags() function has an "if" conditional statement checking for paired end reads in the input BAM
if(any(bitwAnd(bam$flag,0x1))) { # paired-end dataHowever, there are 2 problems with this
the code inside the if statement is taking only reads mapped on the positive strand
posvi <- which(strm==1); rl <- list(tags=tapply(posvi,bam$rname[posvi],function(ii) as.numeric(bam$pos[ii])), flen=tapply(posvi,bam$rname[posvi],function(ii) as.numeric(abs(bam$isize[ii]))))and this will not be compliant with cross-correlation and peak calling algorithms which expect instead reads distributed on both strands
the code handling quality scores is outside the if statement
rl <- c(rl,list(quality=tapply(1:length(bam$pos),bam$rname,function(ii) bam$mapq[ii])))thus resulting in an output taglist object with twice as many quality scores as compared to actual reads positions
I'm proposing an alternative function in a pull request.
The alternative function will randomly pick only one of the reads in the pair when both are aligned, thus resulting in a taglist object with characteristics similar to a single end BAM file. however, I am not sure this was the intended purpose of the original code handling BAM files with paired end reads.