readTests: Read tests

Description Usage Arguments Value Functions Examples

Description

Tests a read to see if its meets some criteria. May return TRUE for only one end of a paired end read. These tests are suitable for use in a samReadFilter but can result in unpaired reads after application; pairedReads should probably be run after running any of these as filters.

Usage

1
2
3
4
5
6
7
8
9
areReadFlagsSet(read, flags)

areReadFlagsUnset(read, flags)

areReadFlags(read, flagVec)

readHasRef(read, ref)

readMateHasRef(read, ref)

Arguments

read

The read to test.

flags

A character vector of one or more flag names to test against the flags set or unset for a read.

flagVec

A logical vector where the names are sam flags and the values indicate if that flag shoud be set (TRUE) or unset (FLAG). If the value of a flag does not matter, it should not be included. NA should not be used.

ref

Regular expression matched against the reference aligned to. Keeps a read if ref matches to the reference this read aligns to (readHasRef(), matching against rname) or the reference the mate of this read aligns to (readMateHasRef(), matching against rnext).

Value

Returns TRUE if a read passes the test, FALSE otherwise. Different ends of the same template will return the same result.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
sam <- Sam("someFile")
aRead <- SamReads(sam)[1]

areReadFlagsUnset( aRead, "NOT_PRIMARY_ALIGNMENT" )
primaryReads <- samReadFilter( sam, "areReadFlagsUnset", "NOT_PRIMARY_ALIGNMENT" )

areReadFlagsSet( aRead, "NOT_PRIMARY_ALIGNMENT" )
secondaryReads <- samReadFilter( sam, "areReadFlagsSet", "NOT_PRIMARY_ALIGNMENT" )

goodAlignmentFlagVec <- c(
	"READ_PAIRED"           =  TRUE, "PROPER_PAIR"             =  TRUE,
   "READ_UNMAPPED"         = FALSE, "MATE_UNMAPPED"           = FALSE,
   "NOT_PRIMARY_ALIGNMENT" = FALSE, "READ_FAILS_VENDOR_QC"    = FALSE,
   "DUPLICATE_READ"        = FALSE, "SUPPLEMENTARY_ALIGNMENT" = FALSE
)
areReadFlags( aRead, goodAlignmentFlagVec )
goodReads <- samReadFilter( sam, "areReadFlags", goodAlignmentFlagVec )

## End(Not run)

jefferys/SamSeq documentation built on Oct. 25, 2019, 8:11 a.m.