# singlePermutation: Count Feature Overlap Under a Permutation In shiftR: Fast Enrichment Analysis via Circular Permutations

## Description

This function performs fast feature overlap count under a circular permutation. The input data sets must be preprocessed with `shiftrPrepareLeft` and `shiftrPrepareRight` functions.

## Usage

 `1` ```singlePermutation(left, right, offset) ```

## Arguments

 `left` Feature set prepared with `shiftrPrepareLeft` function. `right` Feature set prepared with `shiftrPrepareRight` function. `offset` Offset of one feature set relative to another. See the example below for clarity. Zero indicate no offset, i.e. simply count feature overlap.

## Value

Returns count of feature overlap under a circular permutation.

## Author(s)

Andrey A Shabalin andrey.shabalin@gmail.com

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34``` ```### Number of features nf = 1e6 ### Generate left and right sets lset = sample(c(0L,1L), size = nf, replace = TRUE) rset = sample(c(0L,1L), size = nf, replace = TRUE) | lset # Prepare binary sets: lbin = shiftrPrepareLeft(lset) rbin = shiftrPrepareRight(rset) ### count feature overlap # R calculations overlapS = sum(lset & rset) # Binary calculations overlapF = singlePermutation(lbin, rbin, 0) message("Feature overlap: ", overlapS, " / ", overlapF, " (slow/fast count)") stopifnot( overlapS == overlapF ) ### Count overlap with offset offset = 2017 # R calculations overlapOS = sum(lset[ c((offset+1):nf, 1:offset)] & rset) # Binary calculations overlapOF = singlePermutation(lbin, rbin, offset) message("Feature overlap at offset: ", overlapOS, " / ", overlapOF, " (slow/fast count)") stopifnot( overlapOS == overlapOF ) ```

shiftR documentation built on May 2, 2019, 3:41 a.m.