Description Usage Arguments Details Author(s) Examples
View source: R/connect_satalite_vertices.R
Given a list of unique integration site positions (reduced GRanges object) and a directed graph of connected components, this function identifies each node within gap range of clusters and creates an edge to connect the cluster to the 'satalite' node. Edges are drawn from the last node in the cluster to the 'satalite' node, but directionality is determined first by abundance and secondly by an upstream bias.
1 | connect_satalite_vertices(red.sites, graph, gap, bais)
|
red.sites |
GRanges object which has been reduced to single nt positions and contains the revmap from the original GRanges object. The object must also contain a column for cluster membership (clus.id) and a column for abundance (fragLengths). |
graph |
a directed graph built from the red.sites object. Each node corresponds to a row in the red.sites object. |
gap |
integer nucleotide (nt) gap distance to consider joining to clusters. |
bias |
either "upsteam" or "downstream", designating which position to choose if other decision metrics are tied. |
connect_satalite_vertices
returns a graph where nodes within 'gap'
distance from clusters are now connected to the edge of the clusters.
Christopher Nobles, Ph.D.
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 | gr <- gintools:::generate_test_granges(stdev = 3)
red.sites <- reduce(
flank(gr, -1, start = TRUE),
min.gapwidth = 0L,
with.revmap = TRUE)
red.sites$siteID <- seq_along(red.sites)
revmap <- as.list(red.sites$revmap)
red.sites$fragLengths <- lengths(revmap)
red.hits <- GenomicRanges::as.data.frame(
findOverlaps(red.sites, maxgap = 0L, drop.self = TRUE))
red.hits <- red.hits %>%
mutate(q_pos = start(red.sites[queryHits])) %>%
mutate(s_pos = start(red.sites[subjectHits])) %>%
mutate(q_fragLengths = red.sites[queryHits]$fragLengths) %>%
mutate(s_fragLengths = red.sites[subjectHits]$fragLengths) %>%
mutate(strand = unique(strand(
c(red.sites[queryHits], red.sites[subjectHits])))) %>%
mutate(is.upstream = ifelse(
strand == "+",
q_pos < s_pos,
q_pos > s_pos)) %>%
mutate(keep = q_fragLengths > s_fragLengths) %>%
mutate(keep = ifelse(
q_fragLengths == s_fragLengths,
is.upstream,
keep)) %>%
filter(keep)
g <- make_empty_graph(n = length(red.sites), directed = TRUE) %>%
add_edges(unlist(mapply(
c, red.hits$queryHits, red.hits$subjectHits, SIMPLIFY = FALSE)))
red.sites$clus.id <- clusters(g)$membership
connect_satalite_vertices(red.sites, g, gap = 2L, "upstream")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.