# \dontshow{
options(gmax.processes = 2)
# }
gdb.init_examples()
# Create TSS intervals with strand information
tss <- data.frame(
chrom = c("chr1", "chr1", "chr1"),
start = c(1000, 2000, 3000),
end = c(1001, 2001, 3001),
strand = c(1, -1, 1), # +, -, +
gene = c("GeneA", "GeneB", "GeneC")
)
# Create regulatory features
features <- data.frame(
chrom = "chr1",
start = c(500, 800, 1200, 1800, 2200, 2800, 3200),
end = c(600, 900, 1300, 1900, 2300, 2900, 3300),
feature_id = paste0("F", 1:7)
)
# Find upstream neighbors (promoter analysis)
upstream <- gintervals.neighbors.upstream(tss, features,
maxneighbors = 2, maxdist = 1000
)
print(upstream)
# Find downstream neighbors (gene body analysis)
downstream <- gintervals.neighbors.downstream(tss, features,
maxneighbors = 2, maxdist = 5000
)
print(downstream)
# Find both directions in one call
both <- gintervals.neighbors.directional(tss, features,
maxneighbors_upstream = 1,
maxneighbors_downstream = 1,
maxdist = 1000
)
print(both$upstream)
print(both$downstream)
Run the code above in your browser using DataLab